1
0
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:
Peter Boyle 2018-09-10 11:20:07 +01:00
parent f27b9347ff
commit b5329d8852

View File

@ -108,6 +108,7 @@ void LambdaApply(uint64_t base, uint64_t Num, lambda Lambda)
#define accelerator_loopN( iterator, num, ... ) \
typedef decltype(num) Iterator; \
if ( num > 0 ) { \
auto lambda = [=] accelerator (Iterator iterator) mutable { \
__VA_ARGS__; \
}; \
@ -119,6 +120,7 @@ void LambdaApply(uint64_t base, uint64_t Num, lambda Lambda)
if ( cudaSuccess != err ) { \
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__ });