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

Generated on Mon Jul 16 01:17:13 2018 for NAMD by  doxygen 1.4.7