summaryrefslogtreecommitdiff
path: root/offload/include
diff options
context:
space:
mode:
authorRoss Brunton <ross@codeplay.com>2025-08-08 10:57:04 +0100
committerGitHub <noreply@github.com>2025-08-08 10:57:04 +0100
commit910d7e90bfc6aef5f974f0cf4b3fc034a2f4849a (patch)
tree771c49ae8baa026efb92881c7d5c2248853e21f6 /offload/include
parent24ea1559d3d0005aefbca2c7a9fad164a8a33632 (diff)
[Offload] Make olLaunchKernel test thread safe (#149497)
This sprinkles a few mutexes around the plugin interface so that the olLaunchKernel CTS test now passes when ran on multiple threads. Part of this also involved changing the interface for device synchronise so that it can optionally not free the underlying queue (which introduced a race condition in liboffload).
Diffstat (limited to 'offload/include')
-rw-r--r--offload/include/Shared/APITypes.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h
index f376c7dc861f..8c150b6bfc2d 100644
--- a/offload/include/Shared/APITypes.h
+++ b/offload/include/Shared/APITypes.h
@@ -21,6 +21,7 @@
#include <cstddef>
#include <cstdint>
+#include <mutex>
extern "C" {
@@ -76,6 +77,9 @@ struct __tgt_async_info {
/// should be freed after finalization.
llvm::SmallVector<void *, 2> AssociatedAllocations;
+ /// Mutex to guard access to AssociatedAllocations and the Queue.
+ std::mutex Mutex;
+
/// The kernel launch environment used to issue a kernel. Stored here to
/// ensure it is a valid location while the transfer to the device is
/// happening.