|
| 1 | +// RUN: %clangxx -fsycl -fsycl-device-only -c -o %t.bc %s |
| 2 | +// RUN: sycl-post-link %t.bc -spec-const=default -o %t-split1.txt |
| 3 | +// RUN: llvm-dis %t-split1_0.bc |
| 4 | +// RUN: cat %t-split1_0.ll | FileCheck %s -check-prefixes=CHECK,CHECK-IR |
| 5 | +// RUN: cat %t-split1_0.prop | FileCheck %s -check-prefixes=CHECK,CHECK-PROP |
| 6 | +// RUN: llvm-spirv -o %t-split1_0.spv -spirv-max-version=1.1 -spirv-ext=+all %t-split1_0.bc |
| 7 | +// |
| 8 | +//==----------- SYCL-2020-spec-const-ids-order.cpp -------------------------==// |
| 9 | +// |
| 10 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 11 | +// See https://llvm.org/LICENSE.txt for license information. |
| 12 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 13 | +// |
| 14 | +//===----------------------------------------------------------------------===// |
| 15 | +// The test checks that the tool chain correctly identifies all specialization |
| 16 | +// constants, emits correct specialization constats map file and can properly |
| 17 | +// translate the resulting bitcode to SPIR-V. |
| 18 | + |
| 19 | +#include <CL/sycl.hpp> |
| 20 | + |
| 21 | +const static sycl::specialization_id<int> SpecConst42{42}; |
| 22 | +const static sycl::specialization_id<int> SecondValue{42}; |
| 23 | +const static sycl::specialization_id<int> ConstantId{42}; |
| 24 | +const static sycl::specialization_id<int> Val23{42}; |
| 25 | + |
| 26 | + |
| 27 | +int main() { |
| 28 | + sycl::queue queue; |
| 29 | + { |
| 30 | + sycl::buffer<int, 1> buf{sycl::range{4}}; |
| 31 | + queue.submit([&](sycl::handler &cgh) { |
| 32 | + cgh.set_specialization_constant<SpecConst42>(1); |
| 33 | + cgh.set_specialization_constant<SecondValue>(2); |
| 34 | + cgh.set_specialization_constant<ConstantId>(3); |
| 35 | + cgh.set_specialization_constant<Val23>(4); |
| 36 | + |
| 37 | + auto acc = buf.get_access<sycl::access::mode::read_write>(cgh); |
| 38 | + cgh.single_task<class Kernel3Name>([=](sycl::kernel_handler kh) { |
| 39 | + acc[0] = kh.get_specialization_constant<SpecConst42>(); |
| 40 | + acc[1] = kh.get_specialization_constant<SecondValue>(); |
| 41 | + acc[2] = kh.get_specialization_constant<ConstantId>(); |
| 42 | + acc[3] = kh.get_specialization_constant<Val23>(); |
| 43 | + }); |
| 44 | + }); |
| 45 | + } |
| 46 | + |
| 47 | + return 0; |
| 48 | +} |
| 49 | + |
| 50 | +// CHECK-PROP: [SYCL/specialization constants] |
| 51 | +// CHECK: _ZTSN2cl4sycl6detail32specialization_id_name_generatorIL_ZL5Val23EEE |
| 52 | +// CHECK-IR-SAME: i32 [[#ID:]] |
| 53 | +// CHECK-NEXT: _ZTSN2cl4sycl6detail32specialization_id_name_generatorIL_ZL10ConstantIdEEE |
| 54 | +// CHECK-IR-SAME: i32 [[#ID+1]] |
| 55 | +// CHECK-NEXT: _ZTSN2cl4sycl6detail32specialization_id_name_generatorIL_ZL11SecondValueEEE |
| 56 | +// CHECK-IR-SAME: i32 [[#ID+2]] |
| 57 | +// CHECK-NEXT: _ZTSN2cl4sycl6detail32specialization_id_name_generatorIL_ZL11SpecConst42EEE |
| 58 | +// CHECK-IR-SAME: i32 [[#ID+3]] |
0 commit comments