@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
387
387
388
388
message ( STATUS " device: ${d} ( ${${d} _aliases} )" )
389
389
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" )
391
395
set ( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
392
396
set ( opt_flags )
393
397
set ( spvflags --spirv-max-version=1.1 )
394
398
set ( MACRO_ARCH SPIRV32 )
395
399
if ( ARCH STREQUAL spirv64 )
396
400
set ( MACRO_ARCH SPIRV64 )
397
401
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" )
399
405
set ( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
400
406
set ( opt_flags -O3 )
401
407
set ( MACRO_ARCH CLSPV32 )
402
408
if ( ARCH STREQUAL clspv64 )
403
409
set ( MACRO_ARCH CLSPV64 )
404
410
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} )
405
423
else ()
406
424
set ( build_flags )
407
425
set ( opt_flags -O3 )
@@ -411,15 +429,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
411
429
set ( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR} /${arch_suffix} " )
412
430
file ( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
413
431
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} )
423
433
424
434
string ( TOUPPER "CLC_${MACRO_ARCH} " CLC_TARGET_DEFINE )
425
435
0 commit comments