Skip to content
Snippets Groups Projects
Commit e2436958 authored by Kurt A. O'Hearn's avatar Kurt A. O'Hearn
Browse files

PG-PuReMD: add better checking for CUDA-capable devices.

parent 05dfc37d
No related branches found
No related tags found
No related merge requests found
#include "cuda_environment.h"
#include "cuda_utils.h"
extern "C" void Setup_Cuda_Environment (int rank, int nprocs, int gpus_per_node)
{
int deviceCount = 0;
cudaGetDeviceCount (&deviceCount);
int deviceCount;
cudaError_t flag;
flag = cudaGetDeviceCount (&deviceCount);
if ( flag != cudaSuccess )
{
fprintf( stderr, "ERROR: no CUDA capable device(s) found. Terminating...\n" );
exit( CANNOT_INITIALIZE );
}
//Calculate the # of GPUs per processor
//and assign the GPU for each process
//hpcc changes
//if (gpus_per_node == 2) {
//TODO: handle condition where # CPU procs > # GPUs
cudaSetDevice ( (rank % (deviceCount)) );
//cudaSetDevice( 1 );
#if defined(__CUDA_DEBUG__)
fprintf( stderr, "p:%d is using GPU: %d \n", rank, (rank % deviceCount));
//} else {
// cudaSetDevice ( 0 );
//}
#endif
///////////////////////////////////////////////
///////////////////////////////////////////////
......@@ -36,9 +39,9 @@ extern "C" void Setup_Cuda_Environment (int rank, int nprocs, int gpus_per_node)
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
}
extern "C" void Cleanup_Cuda_Environment ()
{
cudaDeviceReset ();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment