[llvm] [Offload] `olLaunchHostFunction` (PR #152482)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 08:17:57 PDT 2025
================
@@ -1495,6 +1509,31 @@ struct AMDGPUStreamTy {
OutputSignal->get());
}
+ Error pushHostCallback(void (*Callback)(void *), void *UserData) {
+ // Retrieve an available signal for the operation's output.
+ AMDGPUSignalTy *OutputSignal = nullptr;
+ if (auto Err = SignalManager.getResource(OutputSignal))
+ return Err;
+ OutputSignal->reset();
+ OutputSignal->increaseUseCount();
+
+ AMDGPUSignalTy *InputSignal;
+ {
+ std::lock_guard<std::mutex> Lock(Mutex);
+
+ // Consume stream slot and compute dependencies.
+ InputSignal = consume(OutputSignal).second;
+ }
+
+ // "Leaking" the thread here is consistent with other work added to the
+ // queue. The input and output signals will remain valid until the output is
+ // signaled.
+ std::thread(CallbackWrapper, InputSignal, OutputSignal, Callback, UserData)
----------------
RossBrunton wrote:
schedCallback enqueues tasks to be completed synchronously once the queue has finished all of its tasks (e.g. as part of `synchronise`). They don't participate in the input/output signal dependency resolution, which is what we need for `olLaunchFunction`.
https://github.com/llvm/llvm-project/pull/152482
More information about the llvm-commits
mailing list