1 #ifndef __PROTO_MACROS_H_ 2 #define __PROTO_MACROS_H_ 14 dim3(
size_t a_x,
size_t a_y,
size_t a_z) : x(a_x),y(a_y),z(a_z) {};
18 #define protoStream_t int 19 #define protoGetCurrentStream 0 21 #define protoMalloc(memtype,PTR,NBYTES) protoMallocCPU(PTR,NBYTES) 22 #define protoFree(memtype,PTR) protoFreeCPU(PTR) 24 #define protoMemcpy(memtype,to,from,size,copyType) protoMemcpyCPU((char*)to,(char*)from,size,copyType) 26 #define protoMemcpyAsync(memtype,to,from,size,copyType,stream) protoMemcpyAsyncCPU(to,from,size,copyType,stream) 28 #define protoMemcpyAsync(memtype,to,from,size,copyType,stream) protoMemcpCPU((char*)to,(char*)from,size,copyType) 30 #define protoMemcpyFromSymbol(memtype,a,b,c,d,e) protoMemcpyFromSymbolCPU(a,b,c,d,e) 31 #define protoMemcpyToSymbol(memtype,a,b,c,d,e) protoMemcpyToSymbolCPU(a,b,c,d,e) 33 #define protoDeviceSynchronize(memtype) protoDeviceSynchronizeCPU() 70 #else //If PROTO_ACCEL is defined 73 #define protoMalloc(memtype,PTR,NBYTES) \ 74 if(memtype==Proto::MemType::DEVICE) { protoMallocGPU(PTR,NBYTES); }\ 75 else { protoMallocCPU(PTR,NBYTES);} 77 #define protoFree(memtype,PTR) \ 78 if(memtype==Proto::MemType::DEVICE) { protoFreeGPU(PTR); } \ 79 else { protoFreeCPU(PTR);} 81 #define protoMemcpy(memtype,to,from,size,copyType) \ 82 if(memtype==Proto::MemType::DEVICE) { protoMemcpyGPU(to,from,size,copyType); } \ 83 else { protoMemcpyCPU(to,from,size,copyType);} 86 #define protoMemcpyAsync(memtype,to,from,size,copyType,stream) \ 87 if(memtype==Proto::MemType::DEVICE) { protoMemcpyAsyncGPU(to,from,size,copyType,stream); } \ 88 else { protoMemcpyAsyncCPU(to,from,size,copyType,stream);} 90 #define protoMemcpyAsync(memtype,to,from,size,copyType,stream) \ 91 if(memtype==Proto::MemType::DEVICE) { protoMemcpyGPU(to,from,size,copyType); } \ 92 else { protoMemcpyCPU(to,from,size,copyType);} 95 #define protoMemcpyFromSymbol(memtype,a,b,c,d,e) \ 96 if(memtype==Proto::MemType::DEVICE) { protoMemcpyFromSymbolGPU(a,b,c,d,e); } \ 97 else { protoMemcpyFromSymbolCPU(a,b,c,d,e); } 99 #define protoMemcpyToSymbol(memtype,a,b,c,d,e) \ 100 if(memtype==Proto::MemType::DEVICE) { protoMemcpyToSymbolGPU(a,b,c,d,e);} \ 101 else { protoMemcpyToSymbolCPU(a,b,c,d,e);} 103 #define protoDeviceSynchronize(memtype) \ 104 if(memtype==Proto::MemType::DEVICE) { protoDeviceSynchronizeGPU();} \ 105 else { protoDeviceSynchronizeCPU();} 132 template<
typename Ker,
typename... Args>
133 __global__
void generalLaunch(
const Args... args)
138 #define MAXTHREADS 1024 146 assert(nBlocks.
x> 0 && nBlocks.
y> 0 && nBlocks.
z> 0 && nbThreads > 0);
147 assert(nbThreads<=MAXTHREADS);
148 protoLaunchKernelGPU((generalLaunch<Ker, Args...>), nBlocks, nbThreads,args...);
161 assert(nBlocks.
x> 0 && nBlocks.
y> 0 && nBlocks.
z> 0 && nbThreads > 0);
162 assert(nbThreads<=MAXTHREADS);
164 protoLaunchKernelMemAsyncGPU((generalLaunch<Ker, Args...>), nBlocks, nbThreads, smem, stream, args...);
166 protoLaunchKernelMemGPU((generalLaunch<Ker, Args...>), nBlocks, nbThreads, smem, args...);
size_t y
Definition: Proto_Macros.H:12
dim3(size_t a_x, size_t a_y, size_t a_z)
Definition: Proto_Macros.H:14
Definition: Proto_MemType.H:7
dim3(size_t a_x)
Definition: Proto_Macros.H:15
MemType
Definition: Proto_MemType.H:7
void protoLaunchKernelMemAsyncT(dim3 nBlocks, int nbThreads, int smem, protoStream_t stream, const Args &... args)
Definition: Proto_Macros.H:55
#define GPU_CHECK(in)
Data Types / classes.
Definition: Proto_GPU.H:81
dim3()
Definition: Proto_Macros.H:16
void protoLaunchKernelT(int nBlocks, int nbThreads, const Args &... args)
Definition: Proto_Macros.H:36
#define PRINT_KERNEL_NAME_ARGS(IN, BLOCKS, THREADS)
Functions.
Definition: Proto_GPU.H:220
size_t z
Definition: Proto_Macros.H:13
size_t x
Definition: Proto_Macros.H:11
Definition: Proto_Macros.H:9
#define protoStream_t
Definition: Proto_Macros.H:18