NAMD
Classes | Macros | Functions | Variables
DeviceCUDA.C File Reference
#include "common.h"
#include "charm++.h"
#include "DeviceCUDA.h"
#include "WorkDistrib.h"
#include "CudaUtils.h"
#include <cuda_runtime.h>
#include <cuda.h>

Go to the source code of this file.

Classes

struct  cuda_args_t
 

Macros

#define MAX_NUM_RANKS   2048
 
#define MAX_NUM_DEVICES   256
 
#define REGISTER_DEVICE_EVENTS(DEV)
 

Functions

void cuda_initialize ()
 
void cuda_finalize ()
 
void cuda_getargs (char **argv)
 

Variables

__thread DeviceCUDAdeviceCUDA
 
static __thread cuda_args_t cuda_args
 
int deviceIDList [MAX_NUM_RANKS]
 
int masterPeList [MAX_NUM_DEVICES]
 

Macro Definition Documentation

#define MAX_NUM_DEVICES   256

Definition at line 70 of file DeviceCUDA.C.

Referenced by DeviceCUDA::initialize().

#define MAX_NUM_RANKS   2048

Definition at line 67 of file DeviceCUDA.C.

Referenced by DeviceCUDA::initialize().

#define REGISTER_DEVICE_EVENTS (   DEV)
Value:
traceRegisterUserEvent("CUDA device " #DEV " remote", CUDA_EVENT_ID_BASE + 2 * DEV); \
traceRegisterUserEvent("CUDA device " #DEV " local", CUDA_EVENT_ID_BASE + 2 * DEV + 1);
#define CUDA_EVENT_ID_BASE
Definition: DeviceCUDA.h:22

Function Documentation

void cuda_finalize ( )

Definition at line 26 of file DeviceCUDA.C.

Referenced by BackEnd::exit().

26  {
27  int ndevs = 0;
28  cudaGetDeviceCount(&ndevs);
29  for ( int dev=0; dev < ndevs; ++dev ) {
30  cudaSetDevice(dev);
31  cudaDeviceReset();
32  }
33 }
void cuda_getargs ( char **  argv)

Definition at line 51 of file DeviceCUDA.C.

References cuda_args, cuda_args_t::devicelist, cuda_args_t::devicesperreplica, cuda_args_t::ignoresharing, cuda_args_t::mergegrids, NAMD_die(), cuda_args_t::nomergegrids, cuda_args_t::nostreaming, and cuda_args_t::usedevicelist.

Referenced by all_init().

51  {
53  cuda_args.usedevicelist = CmiGetArgStringDesc(argv, "+devices", &cuda_args.devicelist,
54  "comma-delimited list of CUDA device numbers such as 0,2,1,2");
56  CmiGetArgInt(argv, "+devicesperreplica", &cuda_args.devicesperreplica);
57  if ( cuda_args.devicesperreplica < 0 ) NAMD_die("Devices per replica must be positive\n");
58  cuda_args.ignoresharing = CmiGetArgFlag(argv, "+ignoresharing");
59  cuda_args.mergegrids = CmiGetArgFlag(argv, "+mergegrids");
60  cuda_args.nomergegrids = CmiGetArgFlag(argv, "+nomergegrids");
61  if ( cuda_args.mergegrids && cuda_args.nomergegrids ) NAMD_die("Do not specify both +mergegrids and +nomergegrids");
62  cuda_args.nostreaming = CmiGetArgFlag(argv, "+nostreaming");
63 }
int devicesperreplica
Definition: DeviceCUDA.C:42
int nomergegrids
Definition: DeviceCUDA.C:45
static __thread cuda_args_t cuda_args
Definition: DeviceCUDA.C:49
int usedevicelist
Definition: DeviceCUDA.C:41
int mergegrids
Definition: DeviceCUDA.C:44
int nostreaming
Definition: DeviceCUDA.C:46
void NAMD_die(const char *err_msg)
Definition: common.C:83
int ignoresharing
Definition: DeviceCUDA.C:43
char * devicelist
Definition: DeviceCUDA.C:40
void cuda_initialize ( )

Definition at line 20 of file DeviceCUDA.C.

References deviceCUDA, and DeviceCUDA::initialize().

Referenced by WorkDistrib::peOrderingReady().

20  {
21  deviceCUDA = new DeviceCUDA();
23 }
void initialize()
Definition: DeviceCUDA.C:85
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:18

Variable Documentation

__thread cuda_args_t cuda_args
static

Definition at line 49 of file DeviceCUDA.C.

Referenced by cuda_getargs(), and DeviceCUDA::initialize().

__thread DeviceCUDA* deviceCUDA
int deviceIDList[MAX_NUM_RANKS]

Definition at line 68 of file DeviceCUDA.C.

Referenced by DeviceCUDA::getDeviceIDforPe(), and DeviceCUDA::initialize().

int masterPeList[MAX_NUM_DEVICES]

Definition at line 71 of file DeviceCUDA.C.

Referenced by DeviceCUDA::getMasterPeForDeviceID(), and DeviceCUDA::initialize().