mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-15 00:20:45 +01:00
Protect against zero length loops giving a kernel call failure
This commit is contained in:
parent
f27b9347ff
commit
b5329d8852
@ -108,18 +108,20 @@ void LambdaApply(uint64_t base, uint64_t Num, lambda Lambda)
|
|||||||
|
|
||||||
#define accelerator_loopN( iterator, num, ... ) \
|
#define accelerator_loopN( iterator, num, ... ) \
|
||||||
typedef decltype(num) Iterator; \
|
typedef decltype(num) Iterator; \
|
||||||
auto lambda = [=] accelerator (Iterator iterator) mutable { \
|
if ( num > 0 ) { \
|
||||||
__VA_ARGS__; \
|
auto lambda = [=] accelerator (Iterator iterator) mutable { \
|
||||||
}; \
|
__VA_ARGS__; \
|
||||||
Iterator base = 0; \
|
}; \
|
||||||
Iterator num_block = (num+gpu_threads-1)/gpu_threads; \
|
Iterator base = 0; \
|
||||||
LambdaApply<<<num_block,gpu_threads>>>(base,num,lambda); \
|
Iterator num_block = (num+gpu_threads-1)/gpu_threads; \
|
||||||
cudaDeviceSynchronize(); \
|
LambdaApply<<<num_block,gpu_threads>>>(base,num,lambda); \
|
||||||
cudaError err = cudaGetLastError(); \
|
cudaDeviceSynchronize(); \
|
||||||
if ( cudaSuccess != err ) { \
|
cudaError err = cudaGetLastError(); \
|
||||||
printf("Cuda error %s\n",cudaGetErrorString( err )); \
|
if ( cudaSuccess != err ) { \
|
||||||
exit(0); \
|
printf("Cuda error %s\n",cudaGetErrorString( err )); \
|
||||||
}
|
exit(0); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define cpu_loop( iterator, range, ... ) thread_loop( (auto iterator = range.begin();iterator<range.end();iterator++), { __VA_ARGS__ });
|
#define cpu_loop( iterator, range, ... ) thread_loop( (auto iterator = range.begin();iterator<range.end();iterator++), { __VA_ARGS__ });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user