|
| 1 | +//==---------- unused_load.cpp - DPC++ ESIMD on-device test ---------------==// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// TODO enable on Windows |
| 9 | +// REQUIRES: linux && gpu |
| 10 | +// UNSUPPORTED: cuda |
| 11 | +// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out |
| 12 | +// RUN: %ESIMD_RUN_PLACEHOLDER %t.out |
| 13 | + |
| 14 | +// This test checks that ESIMD JIT compilation does not crash on unused |
| 15 | +// block_load invocation. |
| 16 | + |
| 17 | +#include <CL/sycl.hpp> |
| 18 | +#include <CL/sycl/INTEL/esimd.hpp> |
| 19 | + |
| 20 | +#include <iostream> |
| 21 | + |
| 22 | +using namespace cl::sycl; |
| 23 | + |
| 24 | +constexpr unsigned int VL = 16; |
| 25 | + |
| 26 | +using Ty = float; |
| 27 | + |
| 28 | +int main() { |
| 29 | + Ty data0[VL] = {0}; |
| 30 | + |
| 31 | + try { |
| 32 | + queue q; |
| 33 | + |
| 34 | + buffer<Ty, 1> buf0(data0, range<1>(VL)); |
| 35 | + |
| 36 | + q.submit([&](handler &cgh) { |
| 37 | + std::cout << "Running on " |
| 38 | + << q.get_device().get_info<cl::sycl::info::device::name>() |
| 39 | + << "\n"; |
| 40 | + |
| 41 | + auto acc0 = buf0.get_access<access::mode::read_write>(cgh); |
| 42 | + |
| 43 | + cgh.parallel_for<class Test>( |
| 44 | + range<1>(1), [=](sycl::id<1> i) SYCL_ESIMD_KERNEL { |
| 45 | + using namespace sycl::INTEL::gpu; |
| 46 | + simd<Ty, VL> var = block_load<Ty, VL>(acc0, 0); |
| 47 | + }); |
| 48 | + }); |
| 49 | + q.wait(); |
| 50 | + } catch (cl::sycl::exception const &e) { |
| 51 | + std::cout << "SYCL exception caught: " << e.what() << '\n'; |
| 52 | + return 1; |
| 53 | + } |
| 54 | + std::cout << "Passed\n"; |
| 55 | + return 0; |
| 56 | +} |
0 commit comments