Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 1ca24ce

Browse files
Merge pull request #831 from jlebar/launch-host-only
Mark functions that take the address of a __global__ function as host…
2 parents ea7ac40 + 98b4e16 commit 1ca24ce

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

thrust/system/cuda/detail/bulk/detail/cuda_launcher/triple_chevron_launcher.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ struct triple_chevron_launcher_base<block_size,Function,true>
7474
__host__ __device__
7575
static global_function_pointer_t global_function_pointer()
7676
{
77+
// Don't try to take the address of launch_by_value from the device side if
78+
// we don't support launching kernels from __device__ functions.
79+
#if !defined(__CUDA_ARCH__) || defined(__CUDACC_RDC__)
7780
return launch_by_value<block_size,Function>;
81+
#else
82+
return NULL;
83+
#endif
7884
}
7985
};
8086

@@ -98,7 +104,13 @@ struct triple_chevron_launcher_base<block_size,Function,false>
98104
__host__ __device__
99105
static global_function_pointer_t global_function_pointer()
100106
{
107+
// Don't try to take the address of launch_by_pointer from the device side
108+
// if we don't support launching kernels from __device__ functions.
109+
#if !defined(__CUDA_ARCH__) || defined(__CUDACC_RDC__)
101110
return launch_by_pointer<block_size,Function>;
111+
#else
112+
return NULL;
113+
#endif
102114
}
103115
};
104116

thrust/system/cuda/detail/detail/launch_closure.inl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ template<typename Closure,
7878
__host__ __device__
7979
static launch_function_t get_launch_function()
8080
{
81+
// Don't try to take the address of launch_closure_by_value from the device
82+
// side if we don't support launching kernels from __device__ functions.
83+
#if !defined(__CUDA_ARCH__) || defined(__CUDACC_RDC__)
8184
return launch_closure_by_value<Closure>;
85+
#else
86+
return NULL;
87+
#endif
8288
}
8389

8490
template<typename DerivedPolicy, typename Size1, typename Size2, typename Size3>
@@ -119,7 +125,14 @@ template<typename Closure>
119125
__host__ __device__
120126
static launch_function_t get_launch_function(void)
121127
{
128+
// Don't try to take the address of launch_closure_by_pointer from the
129+
// device side if we don't support launching kernels from __device__
130+
// functions.
131+
#if !defined(__CUDA_ARCH__) || defined(__CUDACC_RDC__)
122132
return launch_closure_by_pointer<Closure>;
133+
#else
134+
return NULL;
135+
#endif
123136
}
124137

125138
template<typename DerivedPolicy, typename Size1, typename Size2, typename Size3>

0 commit comments

Comments
 (0)