| 65 | } |
| 66 | |
| 67 | cublasHandle_t get_handle ( |
| 68 | ) |
| 69 | { |
| 70 | int new_device_id; |
| 71 | CHECK_CUDA(cudaGetDevice(&new_device_id)); |
| 72 | // make room for more devices if needed |
| 73 | if (new_device_id >= (long)handles.size()) |
| 74 | handles.resize(new_device_id+16); |
| 75 | |
| 76 | // If we don't have a handle already for this device then make one |
| 77 | if (!handles[new_device_id]) |
| 78 | CHECK_CUBLAS(cublasCreate(&handles[new_device_id])); |
| 79 | |
| 80 | // Finally, return the handle for the current device |
| 81 | return handles[new_device_id]; |
| 82 | } |
| 83 | |
| 84 | private: |
| 85 | |