|
| 1 | +// UNSUPPORTED: cuda |
| 2 | +// CUDA does not support unnamed lambdas. |
| 3 | +// |
| 4 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-unnamed-lambda %s -o %t.out |
| 5 | +// RUN: %HOST_RUN_PLACEHOLDER %t.out |
| 6 | +// RUN: %ACC_RUN_PLACEHOLDER %t.out |
| 7 | +// RUN: %CPU_RUN_PLACEHOLDER %t.out |
| 8 | +// RUN: %GPU_RUN_PLACEHOLDER %t.out |
| 9 | + |
| 10 | +//==------ oq_event_release.cpp - SYCL ordered queue event release shortcut test --------==// |
| 11 | +// |
| 12 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 13 | +// See https://llvm.org/LICENSE.txt for license information. |
| 14 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 15 | +// |
| 16 | +//===----------------------------------------------------------------------===// |
| 17 | + |
| 18 | +#include <CL/sycl.hpp> |
| 19 | +#include <iostream> |
| 20 | +using namespace cl::sycl; |
| 21 | + |
| 22 | +int main() { |
| 23 | + queue q{property::queue::in_order()}; |
| 24 | + auto dev = q.get_device(); |
| 25 | + auto ctx = q.get_context(); |
| 26 | + const int N = 8; |
| 27 | + |
| 28 | + if (dev.get_info<info::device::usm_shared_allocations>()) { |
| 29 | + auto A = (int *)malloc_shared(N * sizeof(int), dev, ctx); |
| 30 | + |
| 31 | + for (int i = 0; i < N; i++) { |
| 32 | + A[i] = 1; |
| 33 | + } |
| 34 | + |
| 35 | + { |
| 36 | + id<1> offset(0); |
| 37 | + q.parallel_for<class Baz>(range<1>{N}, offset, [=](id<1> ID) { |
| 38 | + auto i = ID[0]; |
| 39 | + A[i]++; |
| 40 | + }); |
| 41 | + |
| 42 | + q.wait(); |
| 43 | + } |
| 44 | + |
| 45 | + { |
| 46 | + nd_range<1> NDR(range<1>{N}, range<1>{2}); |
| 47 | + q.parallel_for<class NDFoo>(NDR, [=](nd_item<1> Item) { |
| 48 | + auto i = Item.get_global_id(0); |
| 49 | + A[i]++; |
| 50 | + }); |
| 51 | + |
| 52 | + q.wait(); |
| 53 | + } |
| 54 | + |
| 55 | + for (int i = 0; i < N; i++) { |
| 56 | + if (A[i] != 3) |
| 57 | + return 1; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + return 0; |
| 62 | +} |
0 commit comments