Skip to content

Commit 56c3914

Browse files
frasercrmcksivan-shani
authored andcommitted
[libclc] Reorganize OpenCL builtins (llvm#140557)
This commits moves all OpenCL builtins under a top-level 'opencl' directory, akin to how the CLC builtins are organized. This new structure aims to better convey the separation of the two layers and that 'CLC' is not a subset of OpenCL or a libclc target. In doing so this commit moves the location of the 'lib' directory to match CLC: libclc/generic/lib/ becomes libclc/opencl/lib/generic/. This allows us to remove some special casing in CMake and ensure a common directory structure. It also tries to better communicate that the OpenCL headers are libclc-specific OpenCL headers and should not be confused with or used as standard OpenCL headers. It does so by ensuring includes are of the form <clc/opencl/*>. It might be that we don't specifically need the libclc OpenCL headers and we simply could use clang's built-in declarations, but we can revisit that later. Aside from the code move, there is some code formatting and updating a couple of OpenCL builtin includes to use the readily available gentype helpers. This allows us to remove some '.inc' files.
1 parent 9b0eed8 commit 56c3914

File tree

488 files changed

+1142
-1188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+1142
-1188
lines changed

libclc/CMakeLists.txt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ include( AddLibclc )
1818

1919
include( GNUInstallDirs )
2020
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
21-
amdgcn-amdhsa/lib/SOURCES;
22-
amdgcn/lib/SOURCES;
23-
clspv/lib/SOURCES;
24-
generic/lib/SOURCES;
25-
ptx-nvidiacl/lib/SOURCES;
26-
r600/lib/SOURCES;
27-
spirv/lib/SOURCES;
21+
# OpenCL libraries
22+
opencl/lib/amdgcn-amdhsa/SOURCES;
23+
opencl/lib/amdgcn/SOURCES;
24+
opencl/lib/clspv/SOURCES;
25+
opencl/lib/generic/SOURCES;
26+
opencl/lib/ptx-nvidiacl/SOURCES;
27+
opencl/lib/r600/SOURCES;
28+
opencl/lib/spirv/SOURCES;
2829
# CLC internal libraries
2930
clc/lib/generic/SOURCES;
3031
clc/lib/amdgcn/SOURCES;
@@ -227,7 +228,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
227228
foreach( file IN ITEMS subnormal_use_default subnormal_disable )
228229
link_bc(
229230
TARGET ${file}
230-
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll
231+
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.ll
231232
)
232233
install(
233234
FILES $<TARGET_PROPERTY:${file},TARGET_FILE>
@@ -237,7 +238,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
237238
endif()
238239

239240
find_package( Python3 REQUIRED COMPONENTS Interpreter )
240-
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/gen_convert.py script_loc )
241+
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/gen_convert.py script_loc )
241242
add_custom_command(
242243
OUTPUT convert.cl
243244
COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
@@ -283,20 +284,20 @@ set_source_files_properties(
283284
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_log10.cl
284285
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/r600/math/clc_native_rsqrt.cl
285286
# OpenCL builtins
286-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
287-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
288-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
289-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
290-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
291-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
292-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
293-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
294-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
295-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
296-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
297-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
298-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
299-
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
287+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_cos.cl
288+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_divide.cl
289+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp.cl
290+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp10.cl
291+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp2.cl
292+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log.cl
293+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log10.cl
294+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log2.cl
295+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_powr.cl
296+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_recip.cl
297+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_rsqrt.cl
298+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl
299+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl
300+
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl
300301
PROPERTIES COMPILE_OPTIONS -fapprox-func
301302
)
302303

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

352353
libclc_configure_lib_source(
353354
clc_lib_files
354-
CLC_INTERNAL
355355
LIB_ROOT_DIR clc
356356
DIRS ${clc_dirs}
357357
)
@@ -365,13 +365,14 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
365365
else()
366366
list( APPEND opencl_gen_files convert.cl )
367367
if ( NOT ENABLE_RUNTIME_SUBNORMAL )
368-
list( APPEND opencl_lib_files generic/lib/subnormal_use_default.ll )
368+
list( APPEND opencl_lib_files opencl/lib/generic/subnormal_use_default.ll )
369369
endif()
370370
endif()
371371
endif()
372372

373373
libclc_configure_lib_source(
374374
opencl_lib_files
375+
LIB_ROOT_DIR opencl
375376
DIRS ${opencl_dirs}
376377
)
377378

@@ -439,7 +440,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
439440
)
440441

441442
list( APPEND build_flags
442-
-I${CMAKE_CURRENT_SOURCE_DIR}/generic/include
443+
-I${CMAKE_CURRENT_SOURCE_DIR}/opencl/include
443444
)
444445

445446
add_libclc_builtin_set(

libclc/clspv/lib/SOURCES

Lines changed: 0 additions & 73 deletions
This file was deleted.

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,6 @@ endfunction(add_libclc_builtin_set)
424424
# LIB_FILE_LIST may be pre-populated and is appended to.
425425
#
426426
# Arguments:
427-
# * CLC_INTERNAL
428-
# Pass if compiling the internal CLC builtin libraries, which have a
429-
# different directory structure.
430427
# * LIB_ROOT_DIR <string>
431428
# Root directory containing target's lib files, relative to libclc root
432429
# directory. If not provided, is set to '.'.
@@ -436,7 +433,7 @@ endfunction(add_libclc_builtin_set)
436433
# subsequent ones.
437434
function(libclc_configure_lib_source LIB_FILE_LIST)
438435
cmake_parse_arguments(ARG
439-
"CLC_INTERNAL"
436+
""
440437
"LIB_ROOT_DIR"
441438
"DIRS"
442439
${ARGN}
@@ -450,11 +447,7 @@ function(libclc_configure_lib_source LIB_FILE_LIST)
450447
set( source_list )
451448
foreach( l IN LISTS ARG_DIRS )
452449
foreach( s "SOURCES" "SOURCES_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" )
453-
if( ARG_CLC_INTERNAL )
454-
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc )
455-
else()
456-
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/${l}/lib/${s} file_loc )
457-
endif()
450+
file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc )
458451
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file_loc} loc )
459452
# Prepend the location to give higher priority to the specialized
460453
# implementation

libclc/generic/include/clc/atomic/atomic_dec.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

libclc/generic/include/clc/atomic/atomic_inc.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)