File indexing completed on 2026-10-17 08:35:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "traccc/examples/hip/tbb_await.hpp"
0011
0012 #include "hip_error_check.hpp"
0013
0014
0015 #include <hip/hip_runtime_api.h>
0016
0017
0018 #include <tbb/task.h>
0019
0020 namespace traccc::hip {
0021
0022 namespace {
0023 void suspend_stream_callback(void* tag) {
0024 tbb::task::resume(*static_cast<tbb::task::suspend_point*>(tag));
0025 }
0026 }
0027
0028 void tbb_await_callback(vecmem::abstract_event& event,
0029 const stream_wrapper& stream) {
0030 event.ignore();
0031 hipError_t err = hipSuccess;
0032 auto suspend_point =
0033 tbb::task::suspend_point{};
0034
0035 tbb::task::suspend([&err, &stream, &suspend_point](auto tag) {
0036 suspend_point = tag;
0037 auto hip_stream = reinterpret_cast<hipStream_t>(stream.hipStream());
0038 err =
0039 hipLaunchHostFunc(hip_stream, suspend_stream_callback, &suspend_point);
0040
0041 if (err != hipSuccess) {
0042 tbb::task::resume(suspend_point);
0043 }
0044 });
0045 HIP_ERROR_CHECK(err);
0046 }
0047 }