Skip to content

Commit 94a61fe

Browse files
committed
PR response
1 parent 8feee57 commit 94a61fe

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Error initPlugins(OffloadContext &Context) {
208208
}
209209

210210
Error olInit_impl() {
211-
std::lock_guard<std::mutex> Lock{OffloadContextValMutex};
211+
std::lock_guard<std::mutex> Lock(OffloadContextValMutex);
212212

213213
if (isOffloadInitialized()) {
214214
OffloadContext::get().RefCount++;
@@ -226,7 +226,7 @@ Error olInit_impl() {
226226
}
227227

228228
Error olShutDown_impl() {
229-
std::lock_guard<std::mutex> Lock{OffloadContextValMutex};
229+
std::lock_guard<std::mutex> Lock(OffloadContextValMutex);
230230

231231
if (--OffloadContext::get().RefCount != 0)
232232
return Error::success();
@@ -487,6 +487,8 @@ Error olSyncQueue_impl(ol_queue_handle_t Queue) {
487487
// Host plugin doesn't have a queue set so it's not safe to call synchronize
488488
// on it, but we have nothing to synchronize in that situation anyway.
489489
if (Queue->AsyncInfo->Queue) {
490+
// We don't need to release the queue and we would like the ability for
491+
// other offload threads to submit work concurrently, so pass "false" here.
490492
if (auto Err = Queue->Device->Device->synchronize(Queue->AsyncInfo, false))
491493
return Err;
492494
}
@@ -735,7 +737,7 @@ Error olGetSymbol_impl(ol_program_handle_t Program, const char *Name,
735737
ol_symbol_kind_t Kind, ol_symbol_handle_t *Symbol) {
736738
auto &Device = Program->Image->getDevice();
737739

738-
std::lock_guard<std::mutex> Lock{Program->SymbolListMutex};
740+
std::lock_guard<std::mutex> Lock(Program->SymbolListMutex);
739741

740742
switch (Kind) {
741743
case OL_SYMBOL_KIND_KERNEL: {

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
22922292

22932293
/// Synchronize current thread with the pending operations on the async info.
22942294
Error synchronizeImpl(__tgt_async_info &AsyncInfo,
2295-
bool RemoveQueue) override {
2295+
bool ReleaseQueue) override {
22962296
AMDGPUStreamTy *Stream =
22972297
reinterpret_cast<AMDGPUStreamTy *>(AsyncInfo.Queue);
22982298
assert(Stream && "Invalid stream");
@@ -2303,7 +2303,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
23032303
// Once the stream is synchronized, return it to stream pool and reset
23042304
// AsyncInfo. This is to make sure the synchronization only works for its
23052305
// own tasks.
2306-
if (RemoveQueue) {
2306+
if (ReleaseQueue) {
23072307
AsyncInfo.Queue = nullptr;
23082308
return AMDGPUStreamManager.returnResource(Stream);
23092309
}

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,12 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
843843
Error setupRPCServer(GenericPluginTy &Plugin, DeviceImageTy &Image);
844844

845845
/// Synchronize the current thread with the pending operations on the
846-
/// __tgt_async_info structure.
847-
Error synchronize(__tgt_async_info *AsyncInfo, bool RemoveQueue = true);
846+
/// __tgt_async_info structure. If ReleaseQueue is false, then the
847+
// underlying queue will not be released. In this case, additional
848+
// work may be submitted to the queue whilst a synchronize is running.
849+
Error synchronize(__tgt_async_info *AsyncInfo, bool ReleaseQueue = true);
848850
virtual Error synchronizeImpl(__tgt_async_info &AsyncInfo,
849-
bool RemoveQueue) = 0;
851+
bool ReleaseQueue) = 0;
850852

851853
/// Invokes any global constructors on the device if present and is required
852854
/// by the target.

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ Error PinnedAllocationMapTy::unlockUnmappedHostBuffer(void *HstPtr) {
13361336
}
13371337

13381338
Error GenericDeviceTy::synchronize(__tgt_async_info *AsyncInfo,
1339-
bool RemoveQueue) {
1339+
bool ReleaseQueue) {
13401340
SmallVector<void *, 2> AllocsToDelete{};
13411341
{
13421342
std::lock_guard<std::mutex> AllocationGuard{AsyncInfo->Mutex};
@@ -1345,7 +1345,7 @@ Error GenericDeviceTy::synchronize(__tgt_async_info *AsyncInfo,
13451345
return Plugin::error(ErrorCode::INVALID_ARGUMENT,
13461346
"invalid async info queue");
13471347

1348-
if (auto Err = synchronizeImpl(*AsyncInfo, RemoveQueue))
1348+
if (auto Err = synchronizeImpl(*AsyncInfo, ReleaseQueue))
13491349
return Err;
13501350

13511351
std::swap(AllocsToDelete, AsyncInfo->AssociatedAllocations);

offload/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,15 @@ struct CUDADeviceTy : public GenericDeviceTy {
638638

639639
/// Synchronize current thread with the pending operations on the async info.
640640
Error synchronizeImpl(__tgt_async_info &AsyncInfo,
641-
bool RemoveQueue) override {
641+
bool ReleaseQueue) override {
642642
CUstream Stream = reinterpret_cast<CUstream>(AsyncInfo.Queue);
643643
CUresult Res;
644644
Res = cuStreamSynchronize(Stream);
645645

646-
// Once the stream is synchronized, return it to stream pool and reset
647-
// AsyncInfo. This is to make sure the synchronization only works for its
648-
// own tasks.
649-
if (RemoveQueue) {
646+
// Once the stream is synchronized and we want to release the queue, return
647+
// it to stream pool and reset AsyncInfo. This is to make sure the
648+
// synchronization only works for its own tasks.
649+
if (ReleaseQueue) {
650650
AsyncInfo.Queue = nullptr;
651651
if (auto Err = CUDAStreamManager.returnResource(Stream))
652652
return Err;

offload/plugins-nextgen/host/src/rtl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ struct GenELF64DeviceTy : public GenericDeviceTy {
298298
/// All functions are already synchronous. No need to do anything on this
299299
/// synchronization function.
300300
Error synchronizeImpl(__tgt_async_info &AsyncInfo,
301-
bool RemoveQueue) override {
301+
bool ReleaseQueue) override {
302302
return Plugin::success();
303303
}
304304

0 commit comments

Comments
 (0)