|
| 1 | +// XFAIL: cuda |
| 2 | +// piextUSM*Alloc functions for CUDA are not behaving as described in |
| 3 | +// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/USM.adoc |
| 4 | +// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/cl_intel_unified_shared_memory.asciidoc |
| 5 | +// |
| 6 | +// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %s -o %t1.out |
| 7 | +// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out |
| 8 | +// RUN: %CPU_RUN_PLACEHOLDER %t1.out |
| 9 | +// RUN: %GPU_RUN_PLACEHOLDER %t1.out |
| 10 | + |
| 11 | +//==------------------- mixed.cpp - Mixed Memory test ---------------------==// |
| 12 | +// |
| 13 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 14 | +// See https://llvm.org/LICENSE.txt for license information. |
| 15 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 16 | +// |
| 17 | +//===----------------------------------------------------------------------===// |
| 18 | + |
| 19 | +#include <CL/sycl.hpp> |
| 20 | + |
| 21 | +using namespace sycl; |
| 22 | + |
| 23 | +int main() { |
| 24 | + const int MAGIC_NUM = 42; |
| 25 | + const int N = 17; |
| 26 | + |
| 27 | + queue q; |
| 28 | + auto dev = q.get_device(); |
| 29 | + auto ctxt = q.get_context(); |
| 30 | + |
| 31 | + auto A = malloc_shared<int>(N, q); |
| 32 | + auto B = malloc_shared<int>(N, q); |
| 33 | + auto C = malloc_shared<int>(std::max(N,64), q); |
| 34 | + |
| 35 | + for (int i = 0; i < N; i++) { |
| 36 | + A[i] = 1; |
| 37 | + B[i] = 2; |
| 38 | + } |
| 39 | + |
| 40 | + q.parallel_for(range<1>(N), [=](id<1> i) { C[i] = A[i] + B[i]; }); |
| 41 | + q.wait(); |
| 42 | + |
| 43 | + for (int i = 0; i < N; i++) { |
| 44 | + assert(C[i] == 3); |
| 45 | + } |
| 46 | + |
| 47 | + for (int i = 0; i < 64; i++) { |
| 48 | + std::cout << C[i] << " "; |
| 49 | + } |
| 50 | + std::cout << std::endl; |
| 51 | + |
| 52 | + free(A, q); |
| 53 | + free(B, q); |
| 54 | + free(C, q); |
| 55 | + |
| 56 | + return 0; |
| 57 | +} |
0 commit comments