[libclc] [libclc] Set OpenCL C version for each target (PR #135733)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 04:31:33 PDT 2025
================
@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
message( STATUS " device: ${d} ( ${${d}_aliases} )" )
- if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+ # 1.2 is Clang's default OpenCL C language standard to compile for.
+ set( opencl_lang_std "CL1.2" )
+
+ if ( ${DARCH} STREQUAL spirv )
+ set( opencl_lang_std "CL3.0" )
set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
set( opt_flags )
set( spvflags --spirv-max-version=1.1 )
set( MACRO_ARCH SPIRV32 )
if( ARCH STREQUAL spirv64 )
set( MACRO_ARCH SPIRV64 )
endif()
- elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+ elseif( ${DARCH} STREQUAL clspv )
+ # Refer to https://github.com/google/clspv for OpenCL version.
+ set( opencl_lang_std "CL3.0" )
set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
set( opt_flags -O3 )
set( MACRO_ARCH CLSPV32 )
if( ARCH STREQUAL clspv64 )
set( MACRO_ARCH CLSPV64 )
endif()
+ elseif( ${DARCH} STREQUAL nvptx )
+ # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV implementation.
+ set( opencl_lang_std "CL3.0" )
+ set( build_flags )
+ set( opt_flags -O3 )
+ set( MACRO_ARCH ${ARCH} )
+ elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa )
+ # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL version.
+ set( opencl_lang_std "CL2.0" )
----------------
arsenm wrote:
I thought we already picked out device compatible default versions in clang?
https://github.com/llvm/llvm-project/pull/135733
More information about the cfe-commits
mailing list