Skip to content

Commit 9922784

Browse files
[rocm-libraries] ROCm/rocm-libraries#1769 (commit c3544e4)
Fix rocThrust 3.0.0 base NVCC job failures This PR contains fixes for libcudacxx/libhipcxx compatibility in rocThrust, forming part of the base for aligning rocThrust with Thrust v3.0.0. It also bumps rocThrust CMake version to 3.16, which is actually needed for the build.
1 parent 24910d2 commit 9922784

25 files changed

+144
-130
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2019-2025 Advanced Micro Devices, Inc.
33
# ########################################################################
44

5-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
5+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
66

77
# --------------------------------------
88
# Update these variables at release time

cmake/DownloadProject.CMakeLists.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Distributed under the OSI-approved MIT License. See accompanying
22
# file LICENSE or https://github.com/Crascit/DownloadProject for details.
33

4-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
4+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
55

66
project(${DL_ARGS_PROJ}-download NONE)
77

extra/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2019-2025 Advanced Micro Devices, Inc.
33
# ########################################################################
44

5-
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
5+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
66

77
# This project includes tests that should be run after
88
# rocThrust is installed from package or using `make install`

testing/cmake/check_namespace.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# manually with:
66
# cmake -D "Thrust_SOURCE_DIR=<thrust project root>" -P check_namespace.cmake
77

8-
cmake_minimum_required(VERSION 3.15)
8+
cmake_minimum_required(VERSION 3.16)
99

1010
set(exclusions
1111
# This defines the macros and must have bare namespace declarations:

thrust/detail/alignment.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@
3333
#include _THRUST_STD_INCLUDE(type_traits) // For `std::alignment_of`.
3434

3535
#if _THRUST_HAS_DEVICE_SYSTEM_STD
36-
# if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
37-
# include <cuda/cmath>
38-
# else
39-
# include <hip/cmath>
40-
# endif
41-
#endif
42-
43-
#if !_THRUST_HAS_DEVICE_SYSTEM_STD
36+
# include _THRUST_LIBCXX_INCLUDE(cmath)
37+
#else
4438
# include <rocprim/detail/various.hpp>
4539
#endif
4640

@@ -87,11 +81,7 @@ THRUST_HOST_DEVICE T aligned_reinterpret_cast(U u)
8781
THRUST_HOST_DEVICE inline _THRUST_STD::size_t aligned_storage_size(_THRUST_STD::size_t n, _THRUST_STD::size_t align)
8882
{
8983
#if _THRUST_HAS_DEVICE_SYSTEM_STD
90-
# if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
91-
return ::cuda::ceil_div(n, align) * align;
92-
# else
93-
return ::hip::ceil_div(n, align) * align;
94-
# endif
84+
return _THRUST_LIBCXX::ceil_div(n, align) * align;
9585
#else
9686
return ::rocprim::detail::ceiling_div(n, align) * align;
9787
#endif

thrust/detail/attributes.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of libcu++, the C++ Standard Library for your entire system,
4+
// under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
8+
//
9+
//===----------------------------------------------------------------------===//
10+
11+
#ifndef DETAIL_ATTRIBUTES_H
12+
#define DETAIL_ATTRIBUTES_H
13+
14+
#include <thrust/detail/config.h>
15+
#if _THRUST_HAS_DEVICE_SYSTEM_STD
16+
17+
// clang-format off
18+
# include _THRUST_STD_INCLUDE(__cccl/attributes.h)
19+
// clang-format on
20+
21+
# define THRUST_DECLSPEC_EMPTY_BASES _CCCL_DECLSPEC_EMPTY_BASES
22+
23+
#else // !_THRUST_HAS_DEVICE_SYSTEM_STD
24+
25+
# ifdef __has_declspec_attribute
26+
# define THRUST_HAS_DECLSPEC_ATTRIBUTE(__x) __has_declspec_attribute(__x)
27+
# else // ^^^ __has_declspec_attribute ^^^ / vvv !__has_declspec_attribute vvv
28+
# define THRUST_HAS_DECLSPEC_ATTRIBUTE(__x) 0
29+
# endif // !__has_declspec_attribute
30+
31+
// MSVC needs extra help with empty base classes
32+
# if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC || THRUST_HAS_DECLSPEC_ATTRIBUTE(empty_bases)
33+
# define THRUST_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
34+
# else // !THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
35+
# define THRUST_DECLSPEC_EMPTY_BASES
36+
# endif // THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC
37+
38+
#endif // _THRUST_HAS_DEVICE_SYSTEM_STD
39+
40+
#endif // DETAIL_ATTRIBUTES_H

thrust/detail/config/compiler.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,15 @@
2121

2222
#pragma once
2323

24-
#if defined(__HIP__)
25-
// Macro enables Device Malloc
26-
# ifndef __HIP_ENABLE_DEVICE_MALLOC__
27-
# define __HIP_ENABLE_DEVICE_MALLOC__ 1
28-
# endif
29-
# include <hip/hip_runtime.h>
30-
#endif
24+
// Internal config header that is only included through thrust/detail/config/config.h
3125

32-
// For _CCCL_IMPLICIT_SYSTEM_HEADER
33-
#if defined(__CUDACC__)
34-
# include <cuda/__cccl_config>
35-
#elif defined(__has_include)
36-
# if __has_include(<cuda/__cccl_config>)
37-
# include <cuda/__cccl_config>
38-
# endif
39-
#endif
26+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
27+
# pragma GCC system_header
28+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
29+
# pragma clang system_header
30+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
31+
# pragma system_header
32+
#endif // no system header
4033

4134
// enumerate host compilers we know about
4235
//! deprecated [Since 2.7]

thrust/detail/config/config.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@
2020

2121
#pragma once
2222

23-
#if defined(__CUDACC__)
23+
#include <thrust/detail/config/libcxx.h> // IWYU pragma: export
24+
2425
// For _CCCL_IMPLICIT_SYSTEM_HEADER
25-
# include <cuda/__cccl_config> // IWYU pragma: export
26+
#if _THRUST_HAS_DEVICE_SYSTEM_STD
27+
# include _THRUST_LIBCXX_INCLUDE(__cccl_config) // IWYU pragma: export
2628
#endif
2729

30+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
31+
# pragma GCC system_header
32+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
33+
# pragma clang system_header
34+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
35+
# pragma system_header
36+
#endif // no system header
37+
2838
// NOTE: The order of these #includes matters.
2939

3040
#include <thrust/detail/config/compiler.h> // IWYU pragma: export
@@ -39,7 +49,6 @@
3949
#include <thrust/detail/config/diagnostic.h> // IWYU pragma: export
4050
#include <thrust/detail/config/execution_space.h> // IWYU pragma: export
4151
#include <thrust/detail/config/global_workarounds.h> // IWYU pragma: export
42-
#include <thrust/detail/config/libcxx.h> // IWYU pragma: export
4352
#include <thrust/detail/config/namespace.h> // IWYU pragma: export
4453
#include <thrust/detail/config/rtti.h> // IWYU pragma: export
4554
#include <thrust/detail/config/visibility.h> // IWYU pragma: export

thrust/detail/config/cpp_compatibility.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
# define THRUST_INCLUDE_DEVICE_CODE 0
7979
# define THRUST_INCLUDE_HOST_CODE 1
8080
# endif
81-
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
81+
#else
8282
// These definitions were intended for internal use only and are now obsolete.
8383
// If you relied on them, consider porting your code to use the functionality
8484
// in libcu++'s <nv/target> header.

thrust/detail/config/libcxx.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#pragma once
2424

25-
#include <thrust/detail/config/config.h>
25+
#include <thrust/detail/config/preprocessor.h>
2626

2727
// This is a utility file that helps managing which
2828
// 'std' implementation we're using. The provided
@@ -33,33 +33,36 @@
3333
// #include _THRUST_STD_INCLUDE(optional)
3434
// using optional_int = _THRUST_STD::optional<int>;
3535

36-
// When targeting CUDA, we want to use 'libcudacxx'. This
37-
// should always be available, since we are also dependent
38-
// on CCCL/thrust, which is a sibling of CCCL/libcudacxx.
39-
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
36+
// If 'libcudacxx' is available
37+
// clang-format off
38+
#if THRUST_HAS_INCLUDE(<cuda/std/cassert>)
39+
// clang-format on
40+
# define _THRUST_LIBCXX_INCLUDE(LIB) <cuda/LIB>
4041
# define _THRUST_STD_INCLUDE(LIB) <cuda/std/LIB>
42+
# define _THRUST_LIBCXX ::cuda
4143
# define _THRUST_STD _CUDA_VSTD
4244
# define _THRUST_HAS_DEVICE_SYSTEM_STD 1
4345
# define _THRUST_STD_NAMESPACE_BEGIN _LIBCUDACXX_BEGIN_NAMESPACE_STD
4446
# define _THRUST_STD_NAMESPACE_END _LIBCUDACXX_END_NAMESPACE_STD
4547

46-
// When targeting HIP, we want to use 'libhipcxx' if
47-
// available. We can do this by checking the existance
48-
// of a known include.
49-
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_HIP
50-
# if defined(__has_include) && __has_include(<hip/std/cassert>)
51-
# define _THRUST_STD_INCLUDE(LIB) <hip/std/LIB>
52-
# define _THRUST_STD ::hip::std
53-
# define _THRUST_HAS_DEVICE_SYSTEM_STD 1
54-
# define _THRUST_STD_NAMESPACE_BEGIN _LIBCUDACXX_BEGIN_NAMESPACE_STD
55-
# define _THRUST_STD_NAMESPACE_END _LIBCUDACXX_END_NAMESPACE_STD
56-
# endif
48+
// If 'libhipcxx' is available
49+
// clang-format off
50+
#elif THRUST_HAS_INCLUDE(<hip/std/cassert>)
51+
// clang-format on
52+
# define _THRUST_LIBCXX_INCLUDE(LIB) <hip/LIB>
53+
# define _THRUST_STD_INCLUDE(LIB) <hip/std/LIB>
54+
# define _THRUST_LIBCXX ::hip
55+
# define _THRUST_STD ::hip::std
56+
# define _THRUST_HAS_DEVICE_SYSTEM_STD 1
57+
# define _THRUST_STD_NAMESPACE_BEGIN _LIBCUDACXX_BEGIN_NAMESPACE_STD
58+
# define _THRUST_STD_NAMESPACE_END _LIBCUDACXX_END_NAMESPACE_STD
5759
#endif
5860

59-
// If not using GPU backend or GPU vendor's STD is not
60-
// found, use fallback.
61+
// If 'libcudacxx' or 'libhipcxx' is not found, use fallback.
6162
#ifndef _THRUST_HAS_DEVICE_SYSTEM_STD
62-
# define _THRUST_STD_INCLUDE(LIB) <LIB>
63+
# define _THRUST_LIBCXX_INCLUDE(LIB)
64+
# define _THRUST_STD_INCLUDE(LIB) <LIB>
65+
# define _THRUST_LIBCXX
6366
# define _THRUST_STD ::std
6467
# define _THRUST_HAS_DEVICE_SYSTEM_STD 0
6568
# define _THRUST_STD_NAMESPACE_BEGIN \

0 commit comments

Comments
 (0)