brintos

brintos / llvm-project-archived public Read only

0
0
Text · 16.1 KiB · e26f168 Raw
386 lines · plain
1// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s2// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s3// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s4// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK205// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 | FileCheck %s6// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++2021 | FileCheck %s7 8// RUN: %clang_cc1 -O0 -triple spirv32-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s9 10 11// Test including the default header as a module.12// The module should be compiled only once and loaded from cache afterwards.13// Change the directory mode to read only to make sure no new modules are created.14// Check time report to make sure module is used.15// Check that some builtins occur in the generated IR when called.16 17// ===18// Clear current directory.19// RUN: rm -rf %t20// RUN: mkdir -p %t21 22// ===23// Compile for OpenCL 1.0 for the first time. A module should be generated.24// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s25// RUN: chmod u-w %t/opencl_c.pcm26 27// ===28// Compile for OpenCL 1.0 for the second time. The module should not be re-created.29// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s30// RUN: chmod u+w %t/opencl_c.pcm31// RUN: mv %t/opencl_c.pcm %t/1_0.pcm32 33// ===34// Compile for OpenCL 2.0 for the first time. The module should change.35// RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s36// RUN: not diff %t/1_0.pcm %t/opencl_c.pcm > /dev/null37// RUN: chmod u-w %t/opencl_c.pcm38 39// ===40// Compile for OpenCL 2.0 for the second time. The module should not change.41// RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s42 43// Check cached module works for different OpenCL versions.44// RUN: rm -rf %t45// RUN: mkdir -p %t46// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s47// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s48// RUN: chmod u-w %t 49// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s50// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s51// RUN: chmod u+w %t52 53// Verify that called builtins occur in the generated IR.54 55// CHECK-NOT: intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty56// CHECK-NOT: ndrange_t57// CHECK20: ndrange_t58// CHECK: _Z16convert_char_rtec59// CHECK-NOT: _Z3ctzc60// CHECK20: _Z3ctzc61// CHECK20: _Z16convert_char_rtec62char f(char x) {63// Check functionality from OpenCL 2.0 onwards64#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)65  ndrange_t t;66  x = ctz(x);67#endif //__OPENCL_C_VERSION__68  return convert_char_rte(x);69}70 71// Verify that a builtin using a write_only image3d_t type is available72// from OpenCL 2.0 onwards.73 74// CHECK20: _Z12write_imagef14ocl_image3d_wo75#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)76void test_image3dwo(write_only image3d_t img) {77  write_imagef(img, (0), (0.0f));78}79#endif //__OPENCL_C_VERSION__80 81#if defined(__OPENCL_CPP_VERSION__)82// Test old atomic overloaded with generic addr space.83void test_atomics(__generic volatile unsigned int* a) {84  atomic_add(a, 1);85}86#endif87 88// Verify that ATOMIC_VAR_INIT is defined.89#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)90global atomic_int z = ATOMIC_VAR_INIT(99);91#endif //__OPENCL_C_VERSION__92// CHECK-MOD: Reading modules93 94// Check that extension macros are defined correctly.95 96// For SPIR all extensions are supported.97#if defined(__SPIR__) || defined(__SPIRV__)98 99// Verify that cl_intel_planar_yuv extension is defined from OpenCL 1.2 onwards.100#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)101// expected-no-diagnostics102#else //__OPENCL_C_VERSION__103// expected-warning@+2{{OpenCL extension 'cl_intel_planar_yuv' unknown or does not require pragma - ignoring}}104#endif //__OPENCL_C_VERSION__105#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable106 107#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)108 109#if cl_khr_subgroup_extended_types != 1110#error "Incorrectly defined cl_khr_subgroup_extended_types"111#endif112#if cl_khr_subgroup_non_uniform_vote != 1113#error "Incorrectly defined cl_khr_subgroup_non_uniform_vote"114#endif115#if cl_khr_subgroup_ballot != 1116#error "Incorrectly defined cl_khr_subgroup_ballot"117#endif118#if cl_khr_subgroup_non_uniform_arithmetic != 1119#error "Incorrectly defined cl_khr_subgroup_non_uniform_arithmetic"120#endif121#if cl_khr_subgroup_shuffle != 1122#error "Incorrectly defined cl_khr_subgroup_shuffle"123#endif124#if cl_khr_subgroup_shuffle_relative != 1125#error "Incorrectly defined cl_khr_subgroup_shuffle_relative"126#endif127#if cl_khr_subgroup_clustered_reduce != 1128#error "Incorrectly defined cl_khr_subgroup_clustered_reduce"129#endif130#if cl_khr_subgroup_rotate != 1131#error "Incorrectly defined cl_khr_subgroup_rotate"132#endif133#if cl_khr_extended_bit_ops != 1134#error "Incorrectly defined cl_khr_extended_bit_ops"135#endif136#if cl_khr_integer_dot_product != 1137#error "Incorrectly defined cl_khr_integer_dot_product"138#endif139#if __opencl_c_integer_dot_product_input_4x8bit != 1140#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit"141#endif142#if __opencl_c_integer_dot_product_input_4x8bit_packed != 1143#error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit_packed"144#endif145#if cl_ext_float_atomics != 1146#error "Incorrectly defined cl_ext_float_atomics"147#endif148#if __opencl_c_ext_fp16_global_atomic_load_store != 1149#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_load_store"150#endif151#if __opencl_c_ext_fp16_local_atomic_load_store != 1152#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_load_store"153#endif154#if __opencl_c_ext_fp16_global_atomic_add != 1155#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_add"156#endif157#if __opencl_c_ext_fp32_global_atomic_add != 1158#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_add"159#endif160#if __opencl_c_ext_fp64_global_atomic_add != 1161#error "Incorrectly defined __opencl_c_ext_fp64_global_atomic_add"162#endif163#if __opencl_c_ext_fp16_local_atomic_add != 1164#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_add"165#endif166#if __opencl_c_ext_fp32_local_atomic_add != 1167#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_add"168#endif169#if __opencl_c_ext_fp64_local_atomic_add != 1170#error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_add"171#endif172#if __opencl_c_ext_fp16_global_atomic_min_max != 1173#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_min_max"174#endif175#if __opencl_c_ext_fp32_global_atomic_min_max != 1176#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_min_max"177#endif178#if __opencl_c_ext_fp64_global_atomic_min_max != 1179#error "Incorrectly defined __opencl_c_ext_fp64_global_atomic_min_max"180#endif181#if __opencl_c_ext_fp16_local_atomic_min_max != 1182#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_min_max"183#endif184#if __opencl_c_ext_fp32_local_atomic_min_max != 1185#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_min_max"186#endif187#if __opencl_c_ext_fp64_local_atomic_min_max != 1188#error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_min_max"189#endif190#if __opencl_c_ext_image_raw10_raw12 != 1191#error "Incorrectly defined __opencl_c_ext_image_raw10_raw12"192#endif193#if __opencl_c_ext_image_unorm_int_2_101010 != 1194#error "Incorrectly defined __opencl_c_ext_image_unorm_int_2_101010"195#endif196#if __opencl_c_ext_image_unsigned_10x6_12x4_14x2 != 1197#error "Incorrectly defined __opencl_c_ext_image_unsigned_10x6_12x4_14x2"198#endif199 200#else201 202#ifdef cl_khr_subgroup_extended_types203#error "Incorrect cl_khr_subgroup_extended_types define"204#endif205#ifdef cl_khr_subgroup_non_uniform_vote206#error "Incorrect cl_khr_subgroup_non_uniform_vote define"207#endif208#ifdef cl_khr_subgroup_ballot209#error "Incorrect cl_khr_subgroup_ballot define"210#endif211#ifdef cl_khr_subgroup_non_uniform_arithmetic212#error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define"213#endif214#ifdef cl_khr_subgroup_shuffle215#error "Incorrect cl_khr_subgroup_shuffle define"216#endif217#ifdef cl_khr_subgroup_shuffle_relative218#error "Incorrect cl_khr_subgroup_shuffle_relative define"219#endif220#ifdef cl_khr_subgroup_clustered_reduce221#error "Incorrect cl_khr_subgroup_clustered_reduce define"222#endif223#ifdef cl_khr_subgroup_rotate224#error "Incorrect cl_khr_subgroup_rotate define"225#endif226#ifdef cl_khr_extended_bit_ops227#error "Incorrect cl_khr_extended_bit_ops define"228#endif229#ifdef cl_khr_integer_dot_product230#error "Incorrect cl_khr_integer_dot_product define"231#endif232#ifdef __opencl_c_integer_dot_product_input_4x8bit233#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit define"234#endif235#ifdef __opencl_c_integer_dot_product_input_4x8bit_packed236#error "Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define"237#endif238#ifdef cl_ext_float_atomics239#error "Incorrect cl_ext_float_atomics define"240#endif241#ifdef __opencl_c_ext_fp16_global_atomic_load_store242#error "Incorrect __opencl_c_ext_fp16_global_atomic_load_store define"243#endif244#ifdef __opencl_c_ext_fp16_local_atomic_load_store245#error "Incorrect __opencl_c_ext_fp16_local_atomic_load_store define"246#endif247#ifdef __opencl_c_ext_fp16_global_atomic_add248#error "Incorrect __opencl_c_ext_fp16_global_atomic_add define"249#endif250#ifdef __opencl_c_ext_fp32_global_atomic_add251#error "Incorrect __opencl_c_ext_fp32_global_atomic_add define"252#endif253#ifdef __opencl_c_ext_fp64_global_atomic_add254#error "Incorrect __opencl_c_ext_fp64_global_atomic_add define"255#endif256#ifdef __opencl_c_ext_fp16_local_atomic_add257#error "Incorrect __opencl_c_ext_fp16_local_atomic_add define"258#endif259#ifdef __opencl_c_ext_fp32_local_atomic_add260#error "Incorrect __opencl_c_ext_fp32_local_atomic_add define"261#endif262#ifdef __opencl_c_ext_fp64_local_atomic_add263#error "Incorrect __opencl_c_ext_fp64_local_atomic_add define"264#endif265#ifdef __opencl_c_ext_fp16_global_atomic_min_max266#error "Incorrect __opencl_c_ext_fp16_global_atomic_min_max define"267#endif268#ifdef __opencl_c_ext_fp32_global_atomic_min_max269#error "Incorrect __opencl_c_ext_fp32_global_atomic_min_max define"270#endif271#ifdef __opencl_c_ext_fp64_global_atomic_min_max272#error "Incorrect __opencl_c_ext_fp64_global_atomic_min_max define"273#endif274#ifdef __opencl_c_ext_fp16_local_atomic_min_max275#error "Incorrect __opencl_c_ext_fp16_local_atomic_min_max define"276#endif277#ifdef __opencl_c_ext_fp32_local_atomic_min_max278#error "Incorrect __opencl_c_ext_fp32_local_atomic_min_max define"279#endif280#ifdef __opencl_c_ext_fp64_local_atomic_min_max281#error "Incorrect __opencl_c_ext_fp64_local_atomic_min_max define"282#endif283#ifdef __opencl_c_ext_image_raw10_raw12284#error "Incorrect __opencl_c_ext_image_raw10_raw12 define"285#endif286#ifdef __opencl_c_ext_image_unorm_int_2_101010287#error "Incorrect __opencl_c_ext_image_unorm_int_2_101010 define"288#endif289#ifdef __opencl_c_ext_image_unsigned_10x6_12x4_14x2290#error "Incorrect __opencl_c_ext_image_unsigned_10x6_12x4_14x2 define"291#endif292 293#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)294 295// OpenCL C features.296#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)297 298#if __opencl_c_atomic_scope_all_devices != 1299#error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"300#endif301 302#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)303 304#ifndef  __opencl_c_pipes305#error "Feature macro __opencl_c_pipes should be defined"306#endif307#ifndef __opencl_c_generic_address_space308#error "Feature macro __opencl_c_generic_address_space should be defined"309#endif310#ifndef __opencl_c_work_group_collective_functions311#error "Feature macro __opencl_c_work_group_collective_functions should be defined"312#endif313#ifndef __opencl_c_atomic_order_acq_rel314#error "Feature macro __opencl_c_atomic_order_acq_rel should be defined"315#endif316#ifndef __opencl_c_atomic_order_seq_cst317#error "Feature macro __opencl_c_atomic_order_seq_cst should be defined"318#endif319#ifndef __opencl_c_atomic_scope_device320#error "Feature macro __opencl_c_atomic_scope_device should be defined"321#endif322#ifndef __opencl_c_atomic_scope_all_devices323#error "Feature macro __opencl_c_atomic_scope_all_devices should be defined"324#endif325#ifndef __opencl_c_device_enqueue326#error "Feature macro __opencl_c_device_enqueue should be defined"327#endif328#ifndef __opencl_c_read_write_images329#error "Feature macro __opencl_c_read_write_images should be defined"330#endif331#ifndef __opencl_c_program_scope_global_variables332#error "Feature macro __opencl_c_program_scope_global_variables should be defined"333#endif334#ifndef __opencl_c_images335#error "Feature macro __opencl_c_images should be defined"336#endif337 338#elif (__OPENCL_C_VERSION__ < 200)339 340#ifdef  __opencl_c_pipes341#error "Incorrect feature macro __opencl_c_pipes define"342#endif343#ifdef __opencl_c_generic_address_space344#error "Incorrect feature macro __opencl_c_generic_address_space define"345#endif346#ifdef __opencl_c_work_group_collective_functions347#error "Incorrect feature macro __opencl_c_work_group_collective_functions define"348#endif349#ifdef __opencl_c_atomic_order_acq_rel350#error "Incorrect feature macro __opencl_c_atomic_order_acq_rel define"351#endif352#ifdef __opencl_c_atomic_order_seq_cst353#error "Incorrect feature macro __opencl_c_atomic_order_seq_cst define"354#endif355#ifdef __opencl_c_atomic_scope_device356#error "Incorrect feature macro __opencl_c_atomic_scope_device define"357#endif358#ifdef __opencl_c_atomic_scope_all_devices359#error "Incorrect feature macro __opencl_c_atomic_scope_all_devices define"360#endif361#ifdef __opencl_c_device_enqueue362#error "Incorrect feature macro __opencl_c_device_enqueue define"363#endif364#ifdef __opencl_c_read_write_images365#error "Incorrect feature macro __opencl_c_read_write_images define"366#endif367#ifdef __opencl_c_program_scope_global_variables368#error "Incorrect feature macro __opencl_c_program_scope_global_variables define"369#endif370#ifdef __opencl_c_images371#error "Incorrect feature macro __opencl_c_images define"372#endif373#ifdef __opencl_c_3d_image_writes374#error "Incorrect feature macro __opencl_c_3d_image_writes define"375#endif376#ifdef __opencl_c_fp64377#error "Incorrect feature macro __opencl_c_fp64 define"378#endif379#ifdef __opencl_c_subgroups380#error "Incorrect feature macro __opencl_c_subgroups define"381#endif382 383#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)384 385#endif // defined(__SPIR__)386