Proto  3.2
Proto_CPU.H
Go to the documentation of this file.
1 #pragma once
2 #include <type_traits>
3 // #include "Proto_MemInfo.H"
4 
5 #define cpuMalloc(ptr,nbBytes) ptr = (decltype(ptr)) malloc(nbBytes)
6 
7 #define protoMallocCPU(PTR,NBYTES) storeMemInfo(Proto::HOST,NBYTES); countMallocHost(cpuMalloc(PTR, NBYTES))
8 #define protoFreeCPU(PTR) free(PTR)
9 
10 #ifndef PROTO_CUDA
11 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(cpuMalloc(a, b))
12 #define protoFreeHost(PTR) free(PTR)
13 #else
14 #ifdef PROTO_HIP
15 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(hipHostMalloc(&a, b))
16 #define protoFreeHost(PTR) hipHostFree(PTR)
17 #else
18 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(cudaMallocHost(&a, b))
19 #define protoFreeHost(PTR) cudaFreeHost(PTR)
20 #endif
21 #endif
22 // trick
23 
24 #ifndef PROTO_ACCEL
25 //static bool isGpu=false;
26 #define protoMemcpyDeviceToDevice false
27 #define protoMemcpyHostToDevice false
28 #define protoMemcpyDeviceToHost false
29 #endif
30 // end trick
31 
32 
33 // COPY
34 
35 
36 #define protoMemcpyCPU(to,from,size,copyType) std::memcpy(to,from,size)
37 #define protoMemcpyAsyncCPU(to,from,size,copyType,stream) std::memcpy(to,from,size)
38 #define protoMemcpyFromSymbolCPU(a,b,c,d,e) std::memcpy(a,b,c)
39 #define protoMemcpyToSymbolCPU(a,b,c,d,e) std::memcpy(a,b,c)
40 
41 #define protoDeviceSynchronizeCPU()