JDFTx  1.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GpuUtil.h File Reference
#include <cstdio>
#include <cuda_runtime.h>
#include <cublas.h>
#include <cufft.h>
#include <vector>

Functions

bool gpuInit (FILE *fpLog=stdout, const std::vector< int > *mpiSiblings=0, double *nGPUs=0)
 
bool isGpuMine ()
 
void gpuErrorCheck ()
 Check for gpu errors, and if any, abort with a useful messsage.
 
bool isGpuEnabled ()
 

Function Documentation

bool gpuInit ( FILE *  fpLog = stdout,
const std::vector< int > *  mpiSiblings = 0,
double *  nGPUs = 0 
)

Must be called before any GPU use (preferably from main(), see isGpuMine) If mpiSiblings (list of processes on the same node) is specified, divide compatible GPUs amongst processes on same node, else select one with max memory nGPUs returns the number of physical GPUs used (fraction if a GPU is shared with other processes) Returns false on failure to find a suitable GPU

bool isGpuMine ( )

Only the thread that called gpuInit() is allowed to use GPU resources This function will return true only on the one thread that rules the gpu.