Author: kpet Date: Fri May 24 07:53:52 2019 New Revision: 361641 URL: http://llvm.org/viewvc/llvm-project?rev=361641&view=rev Log: [OpenCL] Add support for the cl_arm_integer_dot_product extensions
The specification is available in the Khronos OpenCL registry: https://www.khronos.org/registry/OpenCL/extensions/arm/cl_arm_integer_dot_product.txt Signed-off-by: Kevin Petit <kevin.pe...@arm.com> Added: cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def cfe/trunk/lib/Headers/opencl-c.h Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=361641&r1=361640&r2=361641&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original) +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Fri May 24 07:53:52 2019 @@ -81,6 +81,12 @@ OPENCLEXT_INTERNAL(cl_clang_storage_clas OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U) OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U) +// ARM OpenCL extensions +OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_int8, 120, ~0U) +OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int8, 120, ~0U) +OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int16, 120, ~0U) +OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_saturate_int8, 120, ~0U) + // Intel OpenCL extensions OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U) OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U) Modified: cfe/trunk/lib/Headers/opencl-c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=361641&r1=361640&r2=361641&view=diff ============================================================================== --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Fri May 24 07:53:52 2019 @@ -17033,6 +17033,34 @@ uint8 __ovld amd_sadw(uint8 src0, uint8 uint16 __ovld amd_sadw(uint16 src0, uint16 src1, uint16 src2); #endif // cl_amd_media_ops2 +#if defined(cl_arm_integer_dot_product_int8) +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : begin +uint __ovld arm_dot(uchar4 a, uchar4 b); +int __ovld arm_dot(char4 a, char4 b); +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : end +#endif // defined(cl_arm_integer_dot_product_int8) + +#if defined(cl_arm_integer_dot_product_accumulate_int8) +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : begin +uint __ovld arm_dot_acc(uchar4 a, uchar4 b, uint c); +int __ovld arm_dot_acc(char4 a, char4 b, int c); +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : end +#endif // defined(cl_arm_integer_dot_product_accumulate_int8) + +#if defined(cl_arm_integer_dot_product_accumulate_int16) +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : begin +uint __ovld arm_dot_acc(ushort2 a, ushort2 b, uint c); +int __ovld arm_dot_acc(short2 a, short2 b, int c); +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : end +#endif // defined(cl_arm_integer_dot_product_accumulate_int16) + +#if defined(cl_arm_integer_dot_product_accumulate_saturate_int8) +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : begin +uint __ovld arm_dot_acc_sat(uchar4 a, uchar4 b, uint c); +int __ovld arm_dot_acc_sat(char4 a, char4 b, int c); +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : end +#endif // defined(cl_arm_integer_dot_product_accumulate_saturate_int8) + // Disable any extensions we may have enabled previously. #pragma OPENCL EXTENSION all : disable Added: cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl?rev=361641&view=auto ============================================================================== --- cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl (added) +++ cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl Fri May 24 07:53:52 2019 @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s + +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable +void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) { + uint ur = arm_dot(ua, ub); + // CHECK: call spir_func i32 @_Z7arm_dotDv4_hS_ + int sr = arm_dot(sa, sb); + // CHECK: call spir_func i32 @_Z7arm_dotDv4_cS_ +} +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable + +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable +void test_accumulate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) { + uint ur = arm_dot_acc(ua, ub, uc); + // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_hS_j + int sr = arm_dot_acc(sa, sb, c); + // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_cS_i +} +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : disable + +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : enable +void test_accumulate_int16(ushort2 ua, ushort2 ub, uint uc, short2 sa, short2 sb, int c) { + uint ur = arm_dot_acc(ua, ub, uc); + // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_tS_j + int sr = arm_dot_acc(sa, sb, c); + // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_sS_i +} +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : disable + +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : enable +void test_accumulate_saturate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) { + uint ur = arm_dot_acc_sat(ua, ub, uc); + // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_hS_j + int sr = arm_dot_acc_sat(sa, sb, c); + // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_cS_i +} +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : disable + Added: cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl?rev=361641&view=auto ============================================================================== --- cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl (added) +++ cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl Fri May 24 07:53:52 2019 @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -verify -cl-std=CL1.2 -emit-llvm -o - -O0 + +void test_negative() { + uchar4 ua8, ub8; + char4 sa8, sb8; + ushort2 ua16, ub16; + short2 sa16, sb16; + uint ur; + int sr; + ur = arm_dot(ua8, ub8); // expected-error{{no matching function for call to 'arm_dot'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}} + sr = arm_dot(sa8, sb8); // expected-error{{no matching function for call to 'arm_dot'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}} + ur = arm_dot_acc(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}} + sr = arm_dot_acc(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}} + ur = arm_dot_acc(ua16, ub16, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}} + sr = arm_dot_acc(sa16, sb16, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}} + ur = arm_dot_acc_sat(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}} + sr = arm_dot_acc_sat(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}} + // expected-note@opencl-c.h:* {{candidate function not viable}} + // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}} +} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits