JDFTx  1.2.0
GpuUtil.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx. If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_CORE_GPUUTIL_H
21 #define JDFTX_CORE_GPUUTIL_H
22 
23 
24 
25 #ifdef GPU_ENABLED
26 
27 #include <cstdio>
28 #include <cuda_runtime.h>
29 #include <cublas.h>
30 #include <cufft.h>
31 #include <vector>
32 
34 
39 bool gpuInit(FILE* fpLog=stdout, const std::vector<int>* mpiSiblings=0, double* nGPUs=0);
40 
43 bool isGpuMine();
44 
46 extern void gpuErrorCheck();
47 
48 #endif //GPU_ENABLED
49 
50 
51 //A utility function to eliminate ugly #ifdef's when not required
52 inline bool isGpuEnabled()
53 {
54  #ifdef GPU_ENABLED
55  return true;
56  #else
57  return false;
58  #endif
59 }
60 #endif // JDFTX_CORE_GPUUTIL_H
bool isGpuMine()
void gpuErrorCheck()
Check for gpu errors, and if any, abort with a useful messsage.
bool gpuInit(FILE *fpLog=stdout, const std::vector< int > *mpiSiblings=0, double *nGPUs=0)