Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if( DARCH STREQUAL spirv ) which better fits the current style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

set( opencl_lang_std "CL3.0" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look okay to you, @airlied?

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" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look okay, @rjodinchr?

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure who could verify this, or who even uses libclc built for nvptx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @arsenm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we already picked out device compatible default versions in clang?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we already picked out device compatible default versions in clang?

OpenCL C version is 1.2 for all targets by default in clang if the version isn't specified in command line:

return LangStandard::lang_opencl12;

There is TargetInfo api setSupportedOpenCLOpts for target to define its supported extensions and features.

set( build_flags )
set( opt_flags -O3 )
set( MACRO_ARCH ${ARCH} )
else()
set( build_flags )
set( opt_flags -O3 )
Expand All @@ -411,6 +429,8 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )

list( APPEND build_flags -cl-std=${opencl_lang_std} )

string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )

list( APPEND build_flags
Expand Down
Loading