diff --git a/.upstream-tests/test/cuda/bad_atomic_alignment.pass.cpp b/.upstream-tests/test/cuda/bad_atomic_alignment.pass.cpp index c42bd41722..0ad600fde5 100644 --- a/.upstream-tests/test/cuda/bad_atomic_alignment.pass.cpp +++ b/.upstream-tests/test/cuda/bad_atomic_alignment.pass.cpp @@ -17,38 +17,54 @@ // https://github.com/NVIDIA/libcudacxx/issues/160 #include +#include "cuda_space_selector.h" template __host__ __device__ constexpr bool unused(T &&) {return true;} -int main(int argc, char ** argv) -{ - // Test default aligned user type - { - struct key { - int32_t a; - int32_t b; - }; - static_assert(alignof(key) == 4, ""); - cuda::atomic k(key{}); - auto r = k.load(); - k.store(r); - (void)k.exchange(r); - unused(r); - } - // Test forcibly aligned user type - { - struct alignas(8) key { - int32_t a; - int32_t b; - }; - static_assert(alignof(key) == 8, ""); - cuda::atomic k(key{}); - auto r = k.load(); - k.store(r); - (void)k.exchange(r); - unused(r); +template typename Selector> +struct TestFn { + __host__ __device__ + void operator()() const { + { + struct key { + int32_t a; + int32_t b; + }; + typedef cuda::std::atomic A; + Selector sel; + A & t = *sel.construct(); + cuda::std::atomic_init(&t, key{1,2}); + auto r = t.load(); + t.store(r); + (void)t.exchange(r); + } + { + struct alignas(8) key { + int32_t a; + int32_t b; + }; + typedef cuda::std::atomic A; + Selector sel; + A & t = *sel.construct(); + cuda::std::atomic_init(&t, key{1,2}); + auto r = t.load(); + t.store(r); + (void)t.exchange(r); + } } +}; + +int main(int, char**) +{ +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 + TestFn()(); +#endif +#ifdef __CUDA_ARCH__ + TestFn()(); + TestFn()(); +#endif + return 0; } diff --git a/.upstream-tests/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp b/.upstream-tests/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp index 2c6fe9183e..7bd1d81465 100644 --- a/.upstream-tests/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp @@ -18,9 +18,13 @@ #include "test_macros.h" +// NVRTC doesn't include host atomic making this feature test invalid +// TODO: Should we define __cpp_lib_atomic_is_always_lock_free for NVRTC? +#if !defined(__CUDACC_RTC__) #if !defined(__cpp_lib_atomic_is_always_lock_free) # error Feature test macro missing. #endif +#endif template __host__ __device__ void checkAlwaysLockFree() { if (cuda::std::atomic::is_always_lock_free) diff --git a/.upstream-tests/test/std/atomics/atomics.types.generic/atomic_copyable.pass.cpp b/.upstream-tests/test/std/atomics/atomics.types.generic/atomic_copyable.pass.cpp index 954aefb33a..6b78145525 100644 --- a/.upstream-tests/test/std/atomics/atomics.types.generic/atomic_copyable.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.types.generic/atomic_copyable.pass.cpp @@ -22,6 +22,7 @@ // #include // for nanoseconds #include "test_macros.h" +#include "cuda_space_selector.h" template __host__ __device__ @@ -44,7 +45,8 @@ void test_copy_constructible() { template __host__ __device__ void test_atomic_ref_copy_ctor() { - A val = 0; + SHARED A val; + val = 0; T t0(val); T t1(t0); @@ -58,7 +60,8 @@ void test_atomic_ref_copy_ctor() { template __host__ __device__ void test_atomic_ref_move_ctor() { - A val = 0; + SHARED A val; + val = 0; T t0(val); t0++; diff --git a/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref.pass.cpp b/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref.pass.cpp index 15a7316447..0296fbf8cc 100644 --- a/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref.pass.cpp @@ -170,15 +170,15 @@ int main(int, char**) // confidence that this all actually works #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); #endif #ifdef __CUDA_ARCH__ - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); #endif return 0; diff --git a/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref_constness.pass.cpp b/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref_constness.pass.cpp index 7725841083..27089a0b85 100644 --- a/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref_constness.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.types.generic/floating_point_ref_constness.pass.cpp @@ -111,14 +111,14 @@ int main(int, char**) #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 test_for_all_types(); - test_for_all_types(); + test_for_all_types(); #endif #ifdef __CUDA_ARCH__ - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); #endif return 0; diff --git a/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref.pass.cpp b/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref.pass.cpp index 09d678b64f..10e8e4f827 100644 --- a/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref.pass.cpp @@ -202,14 +202,14 @@ int main(int, char**) #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 test_for_all_types(); - test_for_all_types(); + test_for_all_types(); #endif #ifdef __CUDA_ARCH__ - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); #endif return 0; diff --git a/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref_constness.pass.cpp b/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref_constness.pass.cpp index cf0f98312e..b9bbee0095 100644 --- a/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref_constness.pass.cpp +++ b/.upstream-tests/test/std/atomics/atomics.types.generic/integral_ref_constness.pass.cpp @@ -202,14 +202,14 @@ int main(int, char**) #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 test_for_all_types(); - test_for_all_types(); + test_for_all_types(); #endif #ifdef __CUDA_ARCH__ - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); - test_for_all_types(); - test_for_all_types(); + test_for_all_types(); + test_for_all_types(); #endif return 0;