Skip to content

Commit 6bbb236

Browse files
committed
PR response
1 parent c13190e commit 6bbb236

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
@@ -206,7 +206,7 @@ Error initPlugins(OffloadContext &Context) {
206206
}
207207

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

211211
if (isOffloadInitialized()) {
212212
OffloadContext::get().RefCount++;
@@ -224,7 +224,7 @@ Error olInit_impl() {
224224
}
225225

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

229229
if (--OffloadContext::get().RefCount != 0)
230230
return Error::success();
@@ -485,6 +485,8 @@ Error olSyncQueue_impl(ol_queue_handle_t Queue) {
485485
// Host plugin doesn't have a queue set so it's not safe to call synchronize
486486
// on it, but we have nothing to synchronize in that situation anyway.
487487
if (Queue->AsyncInfo->Queue) {
488+
// We don't need to release the queue and we would like the ability for
489+
// other offload threads to submit work concurrently, so pass "false" here.
488490
if (auto Err = Queue->Device->Device->synchronize(Queue->AsyncInfo, false))
489491
return Err;
490492
}
@@ -719,7 +721,7 @@ Error olGetSymbol_impl(ol_program_handle_t Program, const char *Name,
719721
ol_symbol_kind_t Kind, ol_symbol_handle_t *Symbol) {
720722
auto &Device = Program->Image->getDevice();
721723

722-
std::lock_guard<std::mutex> Lock{Program->SymbolListMutex};
724+
std::lock_guard<std::mutex> Lock(Program->SymbolListMutex);
723725

724726
switch (Kind) {
725727
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
@@ -809,10 +809,12 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
809809
Error setupRPCServer(GenericPluginTy &Plugin, DeviceImageTy &Image);
810810

811811
/// Synchronize the current thread with the pending operations on the
812-
/// __tgt_async_info structure.
813-
Error synchronize(__tgt_async_info *AsyncInfo, bool RemoveQueue = true);
812+
/// __tgt_async_info structure. If ReleaseQueue is false, then the
813+
// underlying queue will not be released. In this case, additional
814+
// work may be submitted to the queue whilst a synchronize is running.
815+
Error synchronize(__tgt_async_info *AsyncInfo, bool ReleaseQueue = true);
814816
virtual Error synchronizeImpl(__tgt_async_info &AsyncInfo,
815-
bool RemoveQueue) = 0;
817+
bool ReleaseQueue) = 0;
816818

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

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

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

13351335
Error GenericDeviceTy::synchronize(__tgt_async_info *AsyncInfo,
1336-
bool RemoveQueue) {
1336+
bool ReleaseQueue) {
13371337
SmallVector<void *, 2> AllocsToDelete{};
13381338
{
13391339
std::lock_guard<std::mutex> AllocationGuard{AsyncInfo->Mutex};
@@ -1342,7 +1342,7 @@ Error GenericDeviceTy::synchronize(__tgt_async_info *AsyncInfo,
13421342
return Plugin::error(ErrorCode::INVALID_ARGUMENT,
13431343
"invalid async info queue");
13441344

1345-
if (auto Err = synchronizeImpl(*AsyncInfo, RemoveQueue))
1345+
if (auto Err = synchronizeImpl(*AsyncInfo, ReleaseQueue))
13461346
return Err;
13471347

13481348
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)