diff --git a/lib/threads/Pragmas.h b/lib/threads/Pragmas.h index 2095fbfd..0ef47858 100644 --- a/lib/threads/Pragmas.h +++ b/lib/threads/Pragmas.h @@ -76,15 +76,26 @@ Author: paboyle // Accelerator primitives; fall back to threading ////////////////////////////////////////////////////////////////////////////////// #ifdef GRID_NVCC + +template __global__ +void LambdaApply(int Num, lambda &Lambda) +{ + int ss = blockIdx.x; + if ( ss < Num ) { + Lambda(ss); + } +} + #define accelerator_exec( ... ) \ - auto lambda = [=] accelerator (void) { \ + auto lambda = [=] accelerator (void) mutable { \ __VA_ARGS__; \ }; \ lambda(); #define accelerator __host__ __device__ #define accelerator_inline __host__ __device__ inline -// FIXME ; need to make this a CUDA kernel call + +#if 0 #define accelerator_loop( iterator, range, ... ) \ typedef decltype(range.begin()) Iterator; \ auto lambda = [=] accelerator (Iterator iterator) mutable { \ @@ -93,6 +104,16 @@ Author: paboyle for(auto it=range.begin();it>>(num,lambda); +#endif + #define cpu_loop( iterator, range, ... ) thread_loop( (auto iterator = range.begin();iterator