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 74 of file DeviceCUDA.C.

Referenced by DeviceCUDA::initialize().

#define MAX_NUM_RANKS   2048

Definition at line 71 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:27

Function Documentation

void cuda_finalize ( )

Definition at line 30 of file DeviceCUDA.C.

Referenced by BackEnd::exit().

30  {
31  int ndevs = 0;
32  cudaGetDeviceCount(&ndevs);
33  for ( int dev=0; dev < ndevs; ++dev ) {
34  cudaSetDevice(dev);
35  cudaDeviceReset();
36  }
37 }
void cuda_getargs ( char **  argv)

Definition at line 55 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().

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

Definition at line 24 of file DeviceCUDA.C.

References deviceCUDA, and DeviceCUDA::initialize().

Referenced by WorkDistrib::peOrderingReady().

24  {
25  deviceCUDA = new DeviceCUDA();
27 }
void initialize()
Definition: DeviceCUDA.C:89
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:22

Variable Documentation

__thread cuda_args_t cuda_args
static

Definition at line 53 of file DeviceCUDA.C.

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

__thread DeviceCUDA* deviceCUDA
int deviceIDList[MAX_NUM_RANKS]

Definition at line 72 of file DeviceCUDA.C.

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

int masterPeList[MAX_NUM_DEVICES]

Definition at line 75 of file DeviceCUDA.C.

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