1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Proper offload (accelerator access) will require a mutable copy lambda.

This commit is contained in:
paboyle 2018-02-02 11:38:19 +00:00
parent 51eb2c5dfc
commit b9b5bdfc3a

View File

@ -76,13 +76,19 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
// Accelerator primitives; fall back to threading
//////////////////////////////////////////////////////////////////////////////////
#ifdef GRID_NVCC
#define accelerator_exec( ... ) \
auto lambda = [=] accelerator (void) { \
__VA_ARGS__; \
}; \
lambda();
#define accelerator __host__ __device__
#define accelerator_inline __host__ __device__ inline
// FIXME ; need to make this a CUDA kernel call
#define accelerator_loop( iterator, range, ... ) \
typedef decltype(range.begin()) Iterator; \
auto lambda = [&] (Iterator iterator) { \
__VA_ARGS__; \
auto lambda = [=] accelerator (Iterator iterator) mutable { \
__VA_ARGS__; \
}; \
for(auto it=range.begin();it<range.end();it++){ \
lambda(it); \