| 144 | |
| 145 | public: |
| 146 | Context(int device = 0) |
| 147 | : device_(device) |
| 148 | , stream_(nullptr) |
| 149 | { |
| 150 | #if 0 |
| 151 | //stream creation must be synchronized |
| 152 | //TODO: seems to work without |
| 153 | static std::mutex mutex; |
| 154 | std::lock_guard<std::mutex> lock(mutex); |
| 155 | #endif |
| 156 | |
| 157 | #if CUMAT_SINGLE_THREAD_CONTEXT==0 |
| 158 | //each context has its own stream |
| 159 | CUMAT_SAFE_CALL(cudaStreamCreateWithFlags(&stream_, cudaStreamNonBlocking)); |
| 160 | #endif |
| 161 | //for a global context, use the global stream |
| 162 | |
| 163 | //TODO: init BLAS context and so on |
| 164 | |
| 165 | CUMAT_LOG_DEBUG("Context initialized for thread 0x" << std::hex << std::this_thread::get_id() << ", stream: 0x" << stream_); |
| 166 | } |
| 167 | |
| 168 | ~Context() |
| 169 | { |
nothing calls this directly
no outgoing calls
no test coverage detected