|
| 1 | +// RUN: %{build} -o %t.out |
| 2 | +// RUN: %{run} %t.out |
| 3 | +// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG |
| 4 | +// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} |
| 5 | +// Extra run to check for immediate-command-list in Level Zero |
| 6 | +// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} |
| 7 | + |
| 8 | +// Tests that graph update works for kernel nodes whose parameters are large |
| 9 | +// structs with padding (added by the compiler). |
| 10 | +#include "../graph_common.hpp" |
| 11 | + |
| 12 | +int main() { |
| 13 | + |
| 14 | + constexpr size_t Size = 8; |
| 15 | + |
| 16 | + /* Since val1 is smaller than val2, the compiler should automatically add |
| 17 | + * padding to val1 */ |
| 18 | + struct PaddedStruct { |
| 19 | + uint8_t val1 = 20; |
| 20 | + size_t val2[Size] = {1, 2, 3, 4, 5, 6, 7, 8}; |
| 21 | + } PaddedKernelParam; |
| 22 | + |
| 23 | + static_assert(sizeof(PaddedStruct) == sizeof(size_t) * (Size + 1)); |
| 24 | + |
| 25 | + queue Queue{}; |
| 26 | + exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; |
| 27 | + |
| 28 | + int *PtrA = malloc_device<int>(Size, Queue); |
| 29 | + Queue.memset(PtrA, 0, Size * sizeof(int)).wait(); |
| 30 | + |
| 31 | + auto KernelNode = Graph.add([&](handler &cgh) { |
| 32 | + cgh.parallel_for(Size, [=](item<1> Item) { |
| 33 | + size_t GlobalID = Item.get_id(); |
| 34 | + PtrA[GlobalID] += |
| 35 | + PaddedKernelParam.val1 * PaddedKernelParam.val2[GlobalID]; |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + auto ExecGraph = Graph.finalize(exp_ext::property::graph::updatable{}); |
| 40 | + Queue.ext_oneapi_graph(ExecGraph).wait(); |
| 41 | + |
| 42 | + std::vector<int> HostDataA(Size); |
| 43 | + Queue.copy(PtrA, HostDataA.data(), Size).wait(); |
| 44 | + for (size_t i = 0; i < Size; i++) { |
| 45 | + assert(HostDataA[i] == PaddedKernelParam.val1 * PaddedKernelParam.val2[i]); |
| 46 | + } |
| 47 | + |
| 48 | + return 0; |
| 49 | +} |
0 commit comments