Skip to content

Commit 617a4d1

Browse files
hwinklerbrycelelbach
authored andcommitted
Test that backend is CUDA before using CUDA-specifics in temporary_allocator.
To handle the case that we are using nvcc to compile non-CUDA, e.g. OMP, code, test that the backend THRUST_DEVICE_SYSTEM is THRUST_DEVICE_SYSTEM_CUDA before including and using CUDA-specific code, terminate_with_message().
1 parent 393b542 commit 617a4d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

thrust/detail/allocator/temporary_allocator.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <thrust/system/detail/bad_alloc.h>
2121
#include <cassert>
2222

23-
#ifdef __CUDACC__
23+
#if defined(__CUDA_ARCH__) && THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
2424
#include <thrust/system/cuda/detail/terminate.h>
2525
#endif
2626

@@ -47,7 +47,7 @@ __host__ __device__
4747

4848
#if !defined(__CUDA_ARCH__)
4949
throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");
50-
#else
50+
#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
5151
thrust::system::cuda::detail::terminate_with_message("temporary_buffer::allocate: get_temporary_buffer failed");
5252
#endif
5353
} // end if

0 commit comments

Comments
 (0)