Skip to content

Commit 269bb5b

Browse files
committed
Lock the entire compileKernel function
1 parent 2ad3f93 commit 269bb5b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/cuda/jit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ char linkError[size];
490490

491491
static kc_entry_t compileKernel(const char *ker_name, string jit_ker)
492492
{
493+
std::lock_guard<std::mutex> lock(getDriverApiMutex(getActiveDeviceId()));
494+
493495
size_t ptx_size;
494496
unique_ptr<char[]> ptx(irToPtx(jit_ker, &ptx_size));
495497

@@ -514,7 +516,6 @@ static kc_entry_t compileKernel(const char *ker_name, string jit_ker)
514516
reinterpret_cast<void*>(1)
515517
};
516518

517-
std::lock_guard<std::mutex> lock(getDriverApiMutex(getActiveDeviceId()));
518519
CU_CHECK(cuLinkCreate(5, linkOptions, linkOptionValues, &linkState));
519520
CU_CHECK(cuLinkAddData(linkState, CU_JIT_INPUT_PTX, (void*)ptx.get(),
520521
ptx_size, ker_name, 0, NULL, NULL));

0 commit comments

Comments
 (0)