Skip to content

Commit 7042fbf

Browse files
Use CUDA primary device context instead of creating our own context
1 parent 213f959 commit 7042fbf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cuda_platform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ CudaPlatform::CudaPlatform(Runtime* runtime)
110110
devices_[i].compute_capability = (CUjit_target)(major * 10 + minor);
111111
debug(" (%) %, Compute capability: %.%", i, name, major, minor);
112112

113-
err = cuCtxCreate(&devices_[i].ctx, CU_CTX_MAP_HOST, devices_[i].dev);
114-
CHECK_CUDA(err, "cuCtxCreate()");
113+
err = cuDevicePrimaryCtxRetain(&devices_[i].ctx, devices_[i].dev);
114+
CHECK_CUDA(err, "cuDevicePrimaryCtxRetain()");
115115
}
116116
}
117117

@@ -139,7 +139,7 @@ void CudaPlatform::erase_profiles(bool erase_all) {
139139
CudaPlatform::~CudaPlatform() {
140140
erase_profiles(true);
141141
for (size_t i = 0; i < devices_.size(); i++)
142-
cuCtxDestroy(devices_[i].ctx);
142+
cuDevicePrimaryCtxRelease(devices_[i].dev);
143143
}
144144

145145
void* CudaPlatform::alloc(DeviceId dev, int64_t size) {

0 commit comments

Comments
 (0)