42 #ifndef _CARMA_CONTEXT_H_
43 #define _CARMA_CONTEXT_H_
45 #include <cuda_runtime_api.h>
48 #include <vector_types.h>
97 #define set_active_device(new_device, silent) \
98 _set_active_device(new_device, silent, __FILE__, __LINE__)
99 #define set_active_device_force(new_device, silent) \
100 _set_active_device_force(new_device, silent, __FILE__, __LINE__)
101 #define set_active_deviceForCpy(new_device, silent) \
102 _set_active_device_for_copy(new_device, silent, __FILE__, __LINE__)
107 std::vector<CarmaDevice*> devices;
109 int** can_access_peer;
112 static std::shared_ptr<CarmaContext> s_instance;
120 : ndevice(0), active_device(0), can_access_peer(
nullptr) {}
122 void init_context(
const int nb_devices, int32_t* devices_id);
139 return runtime_version;
145 return driver_version;
153 std::string file,
int line) {
154 if (new_device > ndevice)
return -1;
155 return (can_access_peer[active_device][new_device] != 1)
161 return (this->active_device != new_device)
174 return devices[device]->get_cublas_handle();
177 return devices[device]->get_cusparse_handle();
179 bool can_p2p(
int dev1,
int dev2) {
return can_access_peer[dev1][dev2]; }
194 sSMtoCores nGpuArchCoresPerSM[] = {
214 while (nGpuArchCoresPerSM[index].SM != -1) {
215 if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
216 return nGpuArchCoresPerSM[index].Cores;
225 "MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n",
226 major, minor, nGpuArchCoresPerSM[index - 1].Cores);
227 return nGpuArchCoresPerSM[index - 1].Cores;
229 #endif // _CARMA_CONTEXT_H_