OmniSciDB  04ee39c94c
CudaUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CUDAUTILS_H
18 #define CUDAUTILS_H
19 
20 namespace CudaUtils {
21 
22 template <typename T>
23 void allocGpuMem(T*& devMem,
24  const std::size_t numElems,
25  const std::size_t elemSize,
26  const int gpuNum);
27 
28 template <typename T>
29 void allocPinnedHostMem(T*& hostMem,
30  const std::size_t numElems,
31  const std::size_t elemSize);
32 
33 template <typename T>
34 void copyToGpu(T* devMem,
35  const T* hostMem,
36  const std::size_t numElems,
37  const std::size_t elemSize,
38  const int gpuNum);
39 
40 template <typename T>
41 void copyToHost(T* hostMem,
42  const T* devMem,
43  const std::size_t numElems,
44  const std::size_t elemSize,
45  const int gpuNum);
46 
47 template <typename T>
48 void copyGpuToGpu(T* dstMem,
49  const T* srcMem,
50  const std::size_t numElems,
51  const std::size_t elemSize,
52  const int dstGpuNum);
53 
54 template <typename T>
55 void gpuFree(T*& devMem);
56 
57 template <typename T>
58 void hostFree(T*& hostMem);
59 } // namespace CudaUtils
60 
61 #endif
void copyToHost(T *hostMem, const T *devMem, const std::size_t numElems, const std::size_t elemSize, const int gpuNum)
void copyGpuToGpu(T *dstMem, const T *srcMem, const std::size_t numElems, const std::size_t elemSize, const int dstGpuNum)
void copyToGpu(T *devMem, const T *hostMem, const std::size_t numElems, const std::size_t elemSize, const int gpuNum)
void gpuFree(T *&devMem)
void allocPinnedHostMem(T *&hostMem, const std::size_t numElems, const std::size_t elemSize)
void hostFree(T *&hostMem)
void allocGpuMem(T *&devMem, const std::size_t numElems, const std::size_t elemSize, const int gpuNum)