|
| 1 | +// REQUIRES: gpu, level_zero |
| 2 | + |
| 3 | +// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out |
| 4 | +// RUN: env SYCL_PI_TRACE=2 ZE_DEBUG=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER |
| 5 | + |
| 6 | +// Test that the wait with a barrier is fully batched, i.e. it doesn't cause |
| 7 | +// extra submissions. |
| 8 | + |
| 9 | +#include <CL/sycl.hpp> |
| 10 | +#include <level_zero/ze_api.h> |
| 11 | +#include <vector> |
| 12 | + |
| 13 | +using namespace std; |
| 14 | +using namespace sycl; |
| 15 | + |
| 16 | +void submit_kernel(queue &q) { |
| 17 | + q.submit([&](auto &h) { h.parallel_for(1, [=](size_t id) {}); }); |
| 18 | +} |
| 19 | + |
| 20 | +int main(int argc, char *argv[]) { |
| 21 | + queue q; |
| 22 | + |
| 23 | + submit_kernel(q); // this one will immediatelly execute since q is empty |
| 24 | + // CHECK: ---> piEnqueueKernelLaunch |
| 25 | + // CHECK: ZE ---> zeCommandQueueExecuteCommandLists |
| 26 | + |
| 27 | + submit_kernel(q); // starts a batch |
| 28 | + // CHECK: ---> piEnqueueKernelLaunch |
| 29 | + // CHECK-NOT: ZE ---> zeCommandQueueExecuteCommandLists |
| 30 | + |
| 31 | + // continue the batch |
| 32 | + event barrier = q.ext_oneapi_submit_barrier(); |
| 33 | + // CHECK: ---> piEnqueueEventsWaitWithBarrier |
| 34 | + // CHECK-NOT: ZE ---> zeCommandQueueExecuteCommandLists |
| 35 | + |
| 36 | + submit_kernel(q); |
| 37 | + // CHECK: ---> piEnqueueKernelLaunch |
| 38 | + // CHECK-NOT: ZE ---> zeCommandQueueExecuteCommandLists |
| 39 | + |
| 40 | + // interop should close the batch |
| 41 | + ze_event_handle_t ze_event = |
| 42 | + get_native<backend::ext_oneapi_level_zero>(barrier); |
| 43 | + // CHECK: ---> piextEventGetNativeHandle |
| 44 | + // CHECK: ZE ---> zeCommandQueueExecuteCommandLists |
| 45 | + zeEventHostSynchronize(ze_event, UINT64_MAX); |
| 46 | + |
| 47 | + // CHECK: ---> piQueueFinish |
| 48 | + q.wait_and_throw(); |
| 49 | + return 0; |
| 50 | +} |
0 commit comments