Skip to content

[libclc] Reorganize OpenCL builtins #140557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 27 additions & 26 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ include( AddLibclc )

include( GNUInstallDirs )
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
amdgcn-amdhsa/lib/SOURCES;
amdgcn/lib/SOURCES;
clspv/lib/SOURCES;
generic/lib/SOURCES;
ptx-nvidiacl/lib/SOURCES;
r600/lib/SOURCES;
spirv/lib/SOURCES;
# OpenCL libraries
opencl/lib/amdgcn-amdhsa/SOURCES;
opencl/lib/amdgcn/SOURCES;
opencl/lib/clspv/SOURCES;
opencl/lib/generic/SOURCES;
opencl/lib/ptx-nvidiacl/SOURCES;
opencl/lib/r600/SOURCES;
opencl/lib/spirv/SOURCES;
# CLC internal libraries
clc/lib/generic/SOURCES;
clc/lib/amdgcn/SOURCES;
Expand Down Expand Up @@ -227,7 +228,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
foreach( file IN ITEMS subnormal_use_default subnormal_disable )
link_bc(
TARGET ${file}
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.ll
)
install(
FILES $<TARGET_PROPERTY:${file},TARGET_FILE>
Expand All @@ -237,7 +238,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
endif()

find_package( Python3 REQUIRED COMPONENTS Interpreter )
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/gen_convert.py script_loc )
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/gen_convert.py script_loc )
add_custom_command(
OUTPUT convert.cl
COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
Expand Down Expand Up @@ -283,20 +284,20 @@ set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_log10.cl
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/r600/math/clc_native_rsqrt.cl
# OpenCL builtins
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_cos.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_divide.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp10.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp2.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log10.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log2.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_powr.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_recip.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_rsqrt.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl
PROPERTIES COMPILE_OPTIONS -fapprox-func
)

Expand Down Expand Up @@ -351,7 +352,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )

libclc_configure_lib_source(
clc_lib_files
CLC_INTERNAL
LIB_ROOT_DIR clc
DIRS ${clc_dirs}
)
Expand All @@ -365,13 +365,14 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
else()
list( APPEND opencl_gen_files convert.cl )
if ( NOT ENABLE_RUNTIME_SUBNORMAL )
list( APPEND opencl_lib_files generic/lib/subnormal_use_default.ll )
list( APPEND opencl_lib_files opencl/lib/generic/subnormal_use_default.ll )
endif()
endif()
endif()

libclc_configure_lib_source(
opencl_lib_files
LIB_ROOT_DIR opencl
DIRS ${opencl_dirs}
)

Expand Down Expand Up @@ -439,7 +440,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
)

list( APPEND build_flags
-I${CMAKE_CURRENT_SOURCE_DIR}/generic/include
-I${CMAKE_CURRENT_SOURCE_DIR}/opencl/include
)

add_libclc_builtin_set(
Expand Down
73 changes: 0 additions & 73 deletions libclc/clspv/lib/SOURCES

This file was deleted.

11 changes: 2 additions & 9 deletions libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ endfunction(add_libclc_builtin_set)
# LIB_FILE_LIST may be pre-populated and is appended to.
#
# Arguments:
# * CLC_INTERNAL
# Pass if compiling the internal CLC builtin libraries, which have a
# different directory structure.
# * LIB_ROOT_DIR <string>
# Root directory containing target's lib files, relative to libclc root
# directory. If not provided, is set to '.'.
Expand All @@ -436,7 +433,7 @@ endfunction(add_libclc_builtin_set)
# subsequent ones.
function(libclc_configure_lib_source LIB_FILE_LIST)
cmake_parse_arguments(ARG
"CLC_INTERNAL"
""
"LIB_ROOT_DIR"
"DIRS"
${ARGN}
Expand All @@ -450,11 +447,7 @@ function(libclc_configure_lib_source LIB_FILE_LIST)
set( source_list )
foreach( l IN LISTS ARG_DIRS )
foreach( s "SOURCES" "SOURCES_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" )
if( ARG_CLC_INTERNAL )
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc )
else()
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/${l}/lib/${s} file_loc )
endif()
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc )
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file_loc} loc )
# Prepend the location to give higher priority to the specialized
# implementation
Expand Down
12 changes: 0 additions & 12 deletions libclc/generic/include/clc/atomic/atomic_dec.h

This file was deleted.

12 changes: 0 additions & 12 deletions libclc/generic/include/clc/atomic/atomic_inc.h

This file was deleted.

Loading
Loading