DeviceCUDA.h

Go to the documentation of this file.
00001 #ifndef DEVICECUDA_H
00002 #define DEVICECUDA_H
00003 
00004 #ifdef NAMD_CUDA
00005 #include <cuda_runtime.h>
00006 
00007 #define CUDA_EVENT_ID_POLL_REMOTE 98
00008 #define CUDA_TRACE_POLL_REMOTE \
00009   traceUserEvent(CUDA_EVENT_ID_POLL_REMOTE)
00010 #define CUDA_EVENT_ID_POLL_LOCAL 99
00011 #define CUDA_TRACE_POLL_LOCAL \
00012   traceUserEvent(CUDA_EVENT_ID_POLL_LOCAL)
00013 #define CUDA_EVENT_ID_BASE 100
00014 #define CUDA_TRACE_REMOTE(START,END) \
00015   do { int dev; cudaGetDevice(&dev); traceUserBracketEvent( \
00016        CUDA_EVENT_ID_BASE + 2 * dev, START, END); } while (0)
00017 #define CUDA_TRACE_LOCAL(START,END) \
00018   do { int dev; cudaGetDevice(&dev); traceUserBracketEvent( \
00019        CUDA_EVENT_ID_BASE + 2 * dev + 1, START, END); } while (0)
00020 
00021 //
00022 // Class that handles PE <=> CUDA device mapping
00023 //
00024 class DeviceCUDA {
00025 
00026 private:
00027         // Command line argument settings
00028         char *devicelist;
00029         int usedevicelist;
00030         int devicesperreplica;
00031         int ignoresharing;
00032         int mergegrids;
00033         int nomergegrids;
00034         int nostreaming;
00035 
00036         // Number of devices on this node
00037         int deviceCount;
00038 
00039         // Number of devices on this node that are used for computation
00040         int ndevices;
00041 
00042         // List of device IDs that are used for computation
00043         int *devices;
00044 
00045         // True when GPU is shared between PEs
00046         bool sharedGpu;
00047         // Index of next GPU sharing this GPU
00048         int nextPeSharingGpu;
00049         // Index of the master PE for this GPU
00050         int masterPe;
00051         // Number of PEs that share this GPU
00052         int numPesSharingDevice;
00053         // List of PEs that share this GPU
00054         int *pesSharingDevice;
00055         // True when what???
00056         int gpuIsMine;
00057 
00058         // Device ID for this Pe
00059         int deviceID;
00060 
00061         // Device properties for all devices on this node
00062         cudaDeviceProp* deviceProps;
00063 
00064         void register_user_events();
00065 
00066 public:
00067         DeviceCUDA();
00068         ~DeviceCUDA();
00069         
00070         void initialize();
00071 
00072         int getDeviceCount() {return deviceCount;}
00073         int getNumDevice() {return ndevices;}
00074 
00075         bool device_shared_with_pe(int pe);
00076         bool one_device_per_node();
00077 
00078         int getNoStreaming() {return nostreaming;}
00079         int getNoMergeGrids() {return nomergegrids;}
00080         int getMergeGrids() {return mergegrids;}
00081         void setMergeGrids(const int val) {mergegrids = val;}
00082 
00083         bool getSharedGpu() {return sharedGpu;}
00084         int getNextPeSharingGpu() {return nextPeSharingGpu;}
00085         int getMasterPe() {return masterPe;}
00086         int getNumPesSharingDevice() {return numPesSharingDevice;}
00087         int getPesSharingDevice(const int i) {return pesSharingDevice[i];}
00088 
00089         int getGpuIsMine() {return gpuIsMine;}
00090         void setGpuIsMine(const int val) {gpuIsMine = val;}
00091 
00092         int getDeviceID() {return deviceID;}
00093         int getDeviceIDbyRank(int rank) {return devices[rank];}
00094         int getDeviceIDforPe(int pe);
00095         int getMasterPeForDeviceID(int deviceID);
00096 
00097         int getMaxNumThreads();
00098         int getMaxNumBlocks();
00099 };
00100 #endif //NAMD_CUDA
00101 
00102 #endif // DEVICECUDA_H

Generated on Sat Sep 23 01:17:13 2017 for NAMD by  doxygen 1.4.7