@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
387387
388388 message ( STATUS " device: ${d} ( ${${d} _aliases} )" )
389389
390- if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
390+ # 1.2 is Clang's default OpenCL C language standard to compile for.
391+ set ( opencl_lang_std "CL1.2" )
392+
393+ if ( ${DARCH} STREQUAL spirv )
394+ set ( opencl_lang_std "CL3.0" )
391395 set ( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
392396 set ( opt_flags )
393397 set ( spvflags --spirv-max-version =1.1 )
394398 set ( MACRO_ARCH SPIRV32 )
395399 if ( ARCH STREQUAL spirv64 )
396400 set ( MACRO_ARCH SPIRV64 )
397401 endif ()
398- elseif ( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
402+ elseif ( ${DARCH} STREQUAL clspv )
403+ # Refer to https://github.com/google/clspv for OpenCL version.
404+ set ( opencl_lang_std "CL3.0" )
399405 set ( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
400406 set ( opt_flags -O3 )
401407 set ( MACRO_ARCH CLSPV32 )
402408 if ( ARCH STREQUAL clspv64 )
403409 set ( MACRO_ARCH CLSPV64 )
404410 endif ()
411+ elseif ( ${DARCH} STREQUAL nvptx )
412+ # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV implementation.
413+ set ( opencl_lang_std "CL3.0" )
414+ set ( build_flags )
415+ set ( opt_flags -O3 )
416+ set ( MACRO_ARCH ${ARCH} )
417+ elseif ( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa OR ${DARCH} STREQUAL r600 )
418+ # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL version.
419+ set ( opencl_lang_std "CL2.0" )
420+ set ( build_flags )
421+ set ( opt_flags -O3 )
422+ set ( MACRO_ARCH ${ARCH} )
405423 else ()
406424 set ( build_flags )
407425 set ( opt_flags -O3 )
@@ -411,15 +429,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
411429 set ( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR} /${arch_suffix} " )
412430 file ( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
413431
414- # OpenCL 3.0 extensions
415- string (CONCAT CL_3_0_EXTENSIONS
416- "-cl-ext="
417- "+cl_khr_fp64,"
418- "+cl_khr_fp16,"
419- "+__opencl_c_3d_image_writes,"
420- "+__opencl_c_images,"
421- "+cl_khr_3d_image_writes" )
422- list ( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
432+ list ( APPEND build_flags -cl-std=${opencl_lang_std} )
423433
424434 string ( TOUPPER "CLC_${MACRO_ARCH} " CLC_TARGET_DEFINE )
425435
0 commit comments