Proto
Proto_cpu.H
1 #pragma once
2 #include <type_traits>
3 
4 #define cpuMalloc(ptr,nbBytes) ptr = (decltype(ptr)) malloc(nbBytes)
5 
6 #define protoMallocCPU(PTR,NBYTES) storeMemInfo(Proto::HOST,NBYTES); countMallocHost(cpuMalloc(PTR, NBYTES))
7 #define protoFreeCPU(PTR) free(PTR)
8 
9 #ifndef PROTO_CUDA
10 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(cpuMalloc(a, b))
11 #define protoFreeHost(PTR) free(PTR)
12 #else
13 #ifdef PROTO_HIP
14 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(hipHostMalloc(&a, b))
15 #define protoFreeHost(PTR) hipHostFree(PTR)
16 #else
17 #define protoHostAlloc(a,b) storeMemInfo(Proto::HOST,b); countMallocHost(cudaMallocHost(&a, b))
18 #define protoFreeHost(PTR) cudaFreeHost(PTR)
19 #endif
20 #endif
21 // trick
22 
23 #ifndef PROTO_CUDA
24 //static bool isGpu=false;
25 #define protoMemcpyDeviceToDevice false
26 #define protoMemcpyHostToDevice false
27 #define protoMemcpyDeviceToHost false
28 #endif
29 // end trick
30 
31 
32 // COPY
33 
34 
35 #define protoMemcpyCPU(to,from,size,copyType) std::memcpy(to,from,size)
36 #define protoMemcpyAsyncCPU(to,from,size,copyType,stream) std::memcpy(to,from,size)
37 #define protoMemcpyFromSymbolCPU(a,b,c,d,e) std::memcpy(a,b,c)
38 #define protoMemcpyToSymbolCPU(a,b,c,d,e) std::memcpy(a,b,c)
39 
40 /*
41 #define protoMemcpy(to,from,size,copyType) std::memcpy(to,from,size)
42 #define protoMemcpyAsync(to,from,size,copyType,stream) std::memcpy(to,from,size)
43 #define protoMemcpyFromSymbol(a,b,c,d,e) std::memcpy(a,b,c)
44 #define protoMemcpyToSymbol(a,b,c,d,e) std::memcpy(a,b,c)
45 */
46 
47 
48 #define protoDeviceSynchronizeCPU()
49 
50 
51 //#define protoGetCurrentStream 0
52 
53 /*
54 class dim3 {
55  public:
56  size_t x;
57  size_t y;
58  size_t z;
59  dim3(size_t a_x,size_t a_y, size_t a_z) : x(a_x),y(a_y),z(a_z) {};
60  dim3():x(0),y(0),z(0){};
61 };
62 */
63 
64 
65 // disable commad