|
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out |
| 2 | +// RUN: %ACC_RUN_PLACEHOLDER %t.out |
| 3 | +// RUN: %CPU_RUN_PLACEHOLDER %t.out |
| 4 | +// RUN: %GPU_RUN_PLACEHOLDER %t.out |
| 5 | + |
| 6 | +// Test checks that dependency chain between commands is preserved for in-order |
| 7 | +// queue in the case when usm commands and host tasks are interleaved. |
| 8 | + |
| 9 | +#include <sycl.hpp> |
| 10 | +using namespace sycl; |
| 11 | + |
| 12 | +int main() { |
| 13 | + static constexpr size_t Size = 100; |
| 14 | + queue Q{property::queue::in_order()}; |
| 15 | + |
| 16 | + int *X = malloc_host<int>(Size, Q); |
| 17 | + int *Y = malloc_host<int>(Size, Q); |
| 18 | + int *Z = malloc_host<int>(Size, Q); |
| 19 | + |
| 20 | + Q.memset(X, 0, sizeof(int) * Size); |
| 21 | + Q.submit([&](handler &CGH) { |
| 22 | + auto HostTask = [=] { |
| 23 | + for (int i = 0; i < Size; i++) |
| 24 | + X[i] += 99; |
| 25 | + }; |
| 26 | + CGH.host_task(HostTask); |
| 27 | + }); |
| 28 | + Q.memcpy(Y, X, sizeof(int) * Size); |
| 29 | + Q.submit([&](handler &CGH) { |
| 30 | + auto HostTask = [=] { |
| 31 | + for (int i = 0; i < Size; i++) |
| 32 | + Y[i] *= 2; |
| 33 | + }; |
| 34 | + CGH.host_task(HostTask); |
| 35 | + }); |
| 36 | + Q.fill(Z, 2, Size); |
| 37 | + |
| 38 | + Q.submit([&](handler &CGH) { |
| 39 | + auto HostTask = [=] { Z[99] += Y[99]; }; |
| 40 | + CGH.host_task(HostTask); |
| 41 | + }); |
| 42 | + Q.wait(); |
| 43 | + |
| 44 | + int Error = (Z[99] != 200) ? 1 : 0; |
| 45 | + std::cout << (Error ? "failed\n" : "passed\n"); |
| 46 | + |
| 47 | + free(X, Q); |
| 48 | + free(Y, Q); |
| 49 | + free(Z, Q); |
| 50 | + |
| 51 | + return Error; |
| 52 | +} |
0 commit comments