[INFRA] Import NVIDIA/CCCL upstream as optimization reference library
CCCL (CUDA C++ Core Libraries) provides: - CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk) - Thrust: high-level parallel algorithms (transform_reduce, sort, scan) - libcudacxx: CUDA C++ standard library (atomics, barriers, memory) - cudax: experimental features (memory resources, allocators) - Tuning policies: per-SM hardware-specific algorithm parameters Competition optimization vectors mapped to CCCL: - Output TPS (83% weight): warp_reduce, block_reduce, device_topk - Input TPS (14% weight): device_scan, block_load, prefetch - Cache TPS (3% weight): prefix caching strategy patterns - Memory (0.9 util): pooled/cached/buddy allocators Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only) License: Apache-2.0
This commit is contained in:
2558
cccl_upstream/libcudacxx/cmake/AddLLVM.cmake
Normal file
2558
cccl_upstream/libcudacxx/cmake/AddLLVM.cmake
Normal file
File diff suppressed because it is too large
Load Diff
11
cccl_upstream/libcudacxx/cmake/DetermineGCCCompatible.cmake
Normal file
11
cccl_upstream/libcudacxx/cmake/DetermineGCCCompatible.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# Determine if the compiler has GCC-compatible command-line syntax.
|
||||
|
||||
if (NOT DEFINED LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
|
||||
elseif (MSVC)
|
||||
set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
|
||||
endif()
|
||||
endif()
|
||||
35
cccl_upstream/libcudacxx/cmake/GetHostTriple.cmake
Normal file
35
cccl_upstream/libcudacxx/cmake/GetHostTriple.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# Returns the host triple.
|
||||
# Invokes config.guess
|
||||
|
||||
function(get_host_triple var)
|
||||
if (MSVC)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(value "x86_64-pc-windows-msvc")
|
||||
else()
|
||||
set(value "i686-pc-windows-msvc")
|
||||
endif()
|
||||
elseif (MINGW AND NOT MSYS)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(value "x86_64-w64-windows-gnu")
|
||||
else()
|
||||
set(value "i686-pc-windows-gnu")
|
||||
endif()
|
||||
else(MSVC)
|
||||
if (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
|
||||
message(WARNING "unable to determine host target triple")
|
||||
else()
|
||||
set(config_guess ${LLVM_PATH}/cmake/config.guess)
|
||||
execute_process(
|
||||
COMMAND sh ${config_guess}
|
||||
RESULT_VARIABLE TT_RV
|
||||
OUTPUT_VARIABLE TT_OUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (NOT TT_RV EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to execute ${config_guess}")
|
||||
endif(NOT TT_RV EQUAL 0)
|
||||
set(value ${TT_OUT})
|
||||
endif()
|
||||
endif(MSVC)
|
||||
set(${var} ${value} PARENT_SCOPE)
|
||||
endfunction(get_host_triple var)
|
||||
376
cccl_upstream/libcudacxx/cmake/LLVM-Config.cmake
Normal file
376
cccl_upstream/libcudacxx/cmake/LLVM-Config.cmake
Normal file
@@ -0,0 +1,376 @@
|
||||
function(get_system_libs return_var)
|
||||
message(AUTHOR_WARNING "get_system_libs no longer needed")
|
||||
set(${return_var} "" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(link_system_libs target)
|
||||
message(AUTHOR_WARNING "link_system_libs no longer needed")
|
||||
endfunction()
|
||||
|
||||
# is_llvm_target_library(
|
||||
# library
|
||||
# Name of the LLVM library to check
|
||||
# return_var
|
||||
# Output variable name
|
||||
# ALL_TARGETS;INCLUDED_TARGETS;OMITTED_TARGETS
|
||||
# ALL_TARGETS - default looks at the full list of known targets
|
||||
# INCLUDED_TARGETS - looks only at targets being configured
|
||||
# OMITTED_TARGETS - looks only at targets that are not being configured
|
||||
# )
|
||||
function(is_llvm_target_library library return_var)
|
||||
cmake_parse_arguments(
|
||||
ARG
|
||||
"ALL_TARGETS;INCLUDED_TARGETS;OMITTED_TARGETS"
|
||||
""
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
# Sets variable `return_var' to ON if `library' corresponds to a
|
||||
# LLVM supported target. To OFF if it doesn't.
|
||||
set(${return_var} OFF PARENT_SCOPE)
|
||||
string(TOUPPER "${library}" capitalized_lib)
|
||||
if (ARG_INCLUDED_TARGETS)
|
||||
string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" targets)
|
||||
elseif (ARG_OMITTED_TARGETS)
|
||||
set(omitted_targets ${LLVM_ALL_TARGETS})
|
||||
list(REMOVE_ITEM omitted_targets ${LLVM_TARGETS_TO_BUILD})
|
||||
string(TOUPPER "${omitted_targets}" targets)
|
||||
else()
|
||||
string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
|
||||
endif()
|
||||
foreach (t ${targets})
|
||||
if (
|
||||
capitalized_lib STREQUAL t
|
||||
OR capitalized_lib STREQUAL "${t}"
|
||||
OR capitalized_lib STREQUAL "${t}DESC"
|
||||
OR capitalized_lib STREQUAL "${t}CODEGEN"
|
||||
OR capitalized_lib STREQUAL "${t}ASMPARSER"
|
||||
OR capitalized_lib STREQUAL "${t}ASMPRINTER"
|
||||
OR capitalized_lib STREQUAL "${t}DISASSEMBLER"
|
||||
OR capitalized_lib STREQUAL "${t}INFO"
|
||||
OR capitalized_lib STREQUAL "${t}UTILS"
|
||||
)
|
||||
set(${return_var} ON PARENT_SCOPE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction(is_llvm_target_library)
|
||||
|
||||
function(is_llvm_target_specifier library return_var)
|
||||
is_llvm_target_library(${library} ${return_var} ${ARGN})
|
||||
string(TOUPPER "${library}" capitalized_lib)
|
||||
if (NOT ${return_var})
|
||||
if (
|
||||
capitalized_lib STREQUAL "ALLTARGETSASMPARSERS"
|
||||
OR capitalized_lib STREQUAL "ALLTARGETSDESCS"
|
||||
OR capitalized_lib STREQUAL "ALLTARGETSDISASSEMBLERS"
|
||||
OR capitalized_lib STREQUAL "ALLTARGETSINFOS"
|
||||
OR capitalized_lib STREQUAL "NATIVE"
|
||||
OR capitalized_lib STREQUAL "NATIVECODEGEN"
|
||||
)
|
||||
set(${return_var} ON PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(llvm_config executable)
|
||||
cmake_parse_arguments(ARG "USE_SHARED" "" "" ${ARGN})
|
||||
set(link_components ${ARG_UNPARSED_ARGUMENTS})
|
||||
|
||||
if (ARG_USE_SHARED)
|
||||
# If USE_SHARED is specified, then we link against libLLVM,
|
||||
# but also against the component libraries below. This is
|
||||
# done in case libLLVM does not contain all of the components
|
||||
# the target requires.
|
||||
#
|
||||
# Strip LLVM_DYLIB_COMPONENTS out of link_components.
|
||||
# To do this, we need special handling for "all", since that
|
||||
# may imply linking to libraries that are not included in
|
||||
# libLLVM.
|
||||
|
||||
if (DEFINED link_components AND DEFINED LLVM_DYLIB_COMPONENTS)
|
||||
if ("${LLVM_DYLIB_COMPONENTS}" STREQUAL "all")
|
||||
set(link_components "")
|
||||
else()
|
||||
list(REMOVE_ITEM link_components ${LLVM_DYLIB_COMPONENTS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(${executable} PRIVATE LLVM)
|
||||
endif()
|
||||
|
||||
explicit_llvm_config(${executable} ${link_components})
|
||||
endmacro(llvm_config)
|
||||
|
||||
function(explicit_llvm_config executable)
|
||||
set(link_components ${ARGN})
|
||||
|
||||
llvm_map_components_to_libnames(LIBRARIES ${link_components})
|
||||
get_target_property(t ${executable} TYPE)
|
||||
if (t STREQUAL "STATIC_LIBRARY")
|
||||
target_link_libraries(${executable} INTERFACE ${LIBRARIES})
|
||||
elseif (
|
||||
t STREQUAL "EXECUTABLE"
|
||||
OR t STREQUAL "SHARED_LIBRARY"
|
||||
OR t STREQUAL "MODULE_LIBRARY"
|
||||
)
|
||||
target_link_libraries(${executable} PRIVATE ${LIBRARIES})
|
||||
else()
|
||||
# Use plain form for legacy user.
|
||||
target_link_libraries(${executable} ${LIBRARIES})
|
||||
endif()
|
||||
endfunction(explicit_llvm_config)
|
||||
|
||||
# This is Deprecated
|
||||
function(llvm_map_components_to_libraries OUT_VAR)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Using llvm_map_components_to_libraries() is deprecated. Use llvm_map_components_to_libnames() instead"
|
||||
)
|
||||
explicit_map_components_to_libraries(result ${ARGN})
|
||||
set(${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE)
|
||||
endfunction(llvm_map_components_to_libraries)
|
||||
|
||||
# Expand pseudo-components into real components.
|
||||
# Does not cover 'native', 'backend', or 'engine' as these require special
|
||||
# handling. Also does not cover 'all' as we only have a list of the libnames
|
||||
# available and not a list of the components.
|
||||
function(llvm_expand_pseudo_components out_components)
|
||||
set(link_components ${ARGN})
|
||||
foreach (c ${link_components})
|
||||
# add codegen, asmprinter, asmparser, disassembler
|
||||
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
|
||||
if (NOT idx LESS 0)
|
||||
if (TARGET LLVM${c}CodeGen)
|
||||
list(APPEND expanded_components "${c}CodeGen")
|
||||
else()
|
||||
if (TARGET LLVM${c})
|
||||
list(APPEND expanded_components "${c}")
|
||||
else()
|
||||
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
|
||||
endif()
|
||||
endif()
|
||||
if (TARGET LLVM${c}AsmPrinter)
|
||||
list(APPEND expanded_components "${c}AsmPrinter")
|
||||
endif()
|
||||
if (TARGET LLVM${c}AsmParser)
|
||||
list(APPEND expanded_components "${c}AsmParser")
|
||||
endif()
|
||||
if (TARGET LLVM${c}Desc)
|
||||
list(APPEND expanded_components "${c}Desc")
|
||||
endif()
|
||||
if (TARGET LLVM${c}Disassembler)
|
||||
list(APPEND expanded_components "${c}Disassembler")
|
||||
endif()
|
||||
if (TARGET LLVM${c}Info)
|
||||
list(APPEND expanded_components "${c}Info")
|
||||
endif()
|
||||
if (TARGET LLVM${c}Utils)
|
||||
list(APPEND expanded_components "${c}Utils")
|
||||
endif()
|
||||
elseif (c STREQUAL "nativecodegen")
|
||||
if (TARGET LLVM${LLVM_NATIVE_ARCH}CodeGen)
|
||||
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}CodeGen")
|
||||
endif()
|
||||
if (TARGET LLVM${LLVM_NATIVE_ARCH}Desc)
|
||||
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Desc")
|
||||
endif()
|
||||
if (TARGET LLVM${LLVM_NATIVE_ARCH}Info)
|
||||
list(APPEND expanded_components "${LLVM_NATIVE_ARCH}Info")
|
||||
endif()
|
||||
elseif (c STREQUAL "AllTargetsCodeGens")
|
||||
# Link all the codegens from all the targets
|
||||
foreach (t ${LLVM_TARGETS_TO_BUILD})
|
||||
if (TARGET LLVM${t}CodeGen)
|
||||
list(APPEND expanded_components "${t}CodeGen")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif (c STREQUAL "AllTargetsAsmParsers")
|
||||
# Link all the asm parsers from all the targets
|
||||
foreach (t ${LLVM_TARGETS_TO_BUILD})
|
||||
if (TARGET LLVM${t}AsmParser)
|
||||
list(APPEND expanded_components "${t}AsmParser")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif (c STREQUAL "AllTargetsDescs")
|
||||
# Link all the descs from all the targets
|
||||
foreach (t ${LLVM_TARGETS_TO_BUILD})
|
||||
if (TARGET LLVM${t}Desc)
|
||||
list(APPEND expanded_components "${t}Desc")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif (c STREQUAL "AllTargetsDisassemblers")
|
||||
# Link all the disassemblers from all the targets
|
||||
foreach (t ${LLVM_TARGETS_TO_BUILD})
|
||||
if (TARGET LLVM${t}Disassembler)
|
||||
list(APPEND expanded_components "${t}Disassembler")
|
||||
endif()
|
||||
endforeach(t)
|
||||
elseif (c STREQUAL "AllTargetsInfos")
|
||||
# Link all the infos from all the targets
|
||||
foreach (t ${LLVM_TARGETS_TO_BUILD})
|
||||
if (TARGET LLVM${t}Info)
|
||||
list(APPEND expanded_components "${t}Info")
|
||||
endif()
|
||||
endforeach(t)
|
||||
else()
|
||||
list(APPEND expanded_components "${c}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${out_components} ${expanded_components} PARENT_SCOPE)
|
||||
endfunction(llvm_expand_pseudo_components out_components)
|
||||
|
||||
# This is a variant intended for the final user:
|
||||
# Map LINK_COMPONENTS to actual libnames.
|
||||
function(llvm_map_components_to_libnames out_libs)
|
||||
set(link_components ${ARGN})
|
||||
if (NOT LLVM_AVAILABLE_LIBS)
|
||||
# Inside LLVM itself available libs are in a global property.
|
||||
get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
|
||||
endif()
|
||||
string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
|
||||
|
||||
get_property(LLVM_TARGETS_CONFIGURED GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED)
|
||||
|
||||
# Generally in our build system we avoid order-dependence. Unfortunately since
|
||||
# not all targets create the same set of libraries we actually need to ensure
|
||||
# that all build targets associated with a target are added before we can
|
||||
# process target dependencies.
|
||||
if (NOT LLVM_TARGETS_CONFIGURED)
|
||||
foreach (c ${link_components})
|
||||
is_llvm_target_specifier(${c} iltl_result ALL_TARGETS)
|
||||
if (iltl_result)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Specified target library before target registration is complete."
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Expand some keywords:
|
||||
list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
|
||||
list(FIND link_components "engine" engine_required)
|
||||
if (NOT engine_required EQUAL -1)
|
||||
list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit)
|
||||
if (NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1)
|
||||
list(APPEND link_components "jit")
|
||||
list(APPEND link_components "native")
|
||||
else()
|
||||
list(APPEND link_components "interpreter")
|
||||
endif()
|
||||
endif()
|
||||
list(FIND link_components "native" native_required)
|
||||
if (NOT native_required EQUAL -1)
|
||||
if (NOT have_native_backend EQUAL -1)
|
||||
list(APPEND link_components ${LLVM_NATIVE_ARCH})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Translate symbolic component names to real libraries:
|
||||
llvm_expand_pseudo_components(link_components ${link_components})
|
||||
foreach (c ${link_components})
|
||||
get_property(c_rename GLOBAL PROPERTY LLVM_COMPONENT_NAME_${c})
|
||||
if (c_rename)
|
||||
set(c ${c_rename})
|
||||
endif()
|
||||
if (c STREQUAL "native")
|
||||
# already processed
|
||||
elseif (c STREQUAL "backend")
|
||||
# same case as in `native'.
|
||||
elseif (c STREQUAL "engine")
|
||||
# already processed
|
||||
elseif (c STREQUAL "all")
|
||||
get_property(all_components GLOBAL PROPERTY LLVM_COMPONENT_LIBS)
|
||||
list(APPEND expanded_components ${all_components})
|
||||
else()
|
||||
# Canonize the component name:
|
||||
string(TOUPPER "${c}" capitalized)
|
||||
list(FIND capitalized_libs LLVM${capitalized} lib_idx)
|
||||
if (lib_idx LESS 0)
|
||||
# The component is unknown. Maybe is an omitted target?
|
||||
is_llvm_target_library(${c} iltl_result OMITTED_TARGETS)
|
||||
if (iltl_result)
|
||||
# A missing library to a directly referenced omitted target would be bad.
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Library '${c}' is a direct reference to a target library for an omitted target."
|
||||
)
|
||||
else()
|
||||
# If it is not an omitted target we should assume it is a component
|
||||
# that hasn't yet been processed by CMake. Missing components will
|
||||
# cause errors later in the configuration, so we can safely assume
|
||||
# that this is valid here.
|
||||
list(APPEND expanded_components LLVM${c})
|
||||
endif()
|
||||
else(lib_idx LESS 0)
|
||||
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
|
||||
list(APPEND expanded_components ${canonical_lib})
|
||||
endif(lib_idx LESS 0)
|
||||
endif(c STREQUAL "native")
|
||||
endforeach(c)
|
||||
|
||||
set(${out_libs} ${expanded_components} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Perform a post-order traversal of the dependency graph.
|
||||
# This duplicates the algorithm used by llvm-config, originally
|
||||
# in tools/llvm-config/llvm-config.cpp, function ComputeLibsForComponents.
|
||||
function(expand_topologically name required_libs visited_libs)
|
||||
list(FIND visited_libs ${name} found)
|
||||
if (found LESS 0)
|
||||
list(APPEND visited_libs ${name})
|
||||
set(visited_libs ${visited_libs} PARENT_SCOPE)
|
||||
|
||||
#
|
||||
get_property(libname GLOBAL PROPERTY LLVM_COMPONENT_NAME_${name})
|
||||
if (libname)
|
||||
set(cname LLVM${libname})
|
||||
elseif (TARGET ${name})
|
||||
set(cname ${name})
|
||||
elseif (TARGET LLVM${name})
|
||||
set(cname LLVM${name})
|
||||
else()
|
||||
message(FATAL_ERROR "unknown component ${name}")
|
||||
endif()
|
||||
|
||||
get_property(lib_deps TARGET ${cname} PROPERTY LLVM_LINK_COMPONENTS)
|
||||
foreach (lib_dep ${lib_deps})
|
||||
expand_topologically(${lib_dep} "${required_libs}" "${visited_libs}")
|
||||
set(required_libs ${required_libs} PARENT_SCOPE)
|
||||
set(visited_libs ${visited_libs} PARENT_SCOPE)
|
||||
endforeach()
|
||||
|
||||
list(APPEND required_libs ${cname})
|
||||
set(required_libs ${required_libs} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Expand dependencies while topologically sorting the list of libraries:
|
||||
function(llvm_expand_dependencies out_libs)
|
||||
set(expanded_components ${ARGN})
|
||||
|
||||
set(required_libs)
|
||||
set(visited_libs)
|
||||
foreach (lib ${expanded_components})
|
||||
expand_topologically(${lib} "${required_libs}" "${visited_libs}")
|
||||
endforeach()
|
||||
|
||||
if (required_libs)
|
||||
list(REVERSE required_libs)
|
||||
endif()
|
||||
set(${out_libs} ${required_libs} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(explicit_map_components_to_libraries out_libs)
|
||||
llvm_map_components_to_libnames(link_libs ${ARGN})
|
||||
llvm_expand_dependencies(expanded_components ${link_libs})
|
||||
# Return just the libraries included in this build:
|
||||
set(result)
|
||||
foreach (c ${expanded_components})
|
||||
if (TARGET ${c})
|
||||
set(result ${result} ${c})
|
||||
endif()
|
||||
endforeach(c)
|
||||
set(${out_libs} ${result} PARENT_SCOPE)
|
||||
endfunction(explicit_map_components_to_libraries)
|
||||
129
cccl_upstream/libcudacxx/cmake/LLVMProcessSources.cmake
Normal file
129
cccl_upstream/libcudacxx/cmake/LLVMProcessSources.cmake
Normal file
@@ -0,0 +1,129 @@
|
||||
include(AddFileDependencies)
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(llvm_replace_compiler_option var old new)
|
||||
# Replaces a compiler option or switch `old' in `var' by `new'.
|
||||
# If `old' is not in `var', appends `new' to `var'.
|
||||
# Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
|
||||
# If the option already is on the variable, don't add it:
|
||||
if ("${${var}}" MATCHES "(^| )${new}($| )")
|
||||
set(n "")
|
||||
else()
|
||||
set(n "${new}")
|
||||
endif()
|
||||
if ("${${var}}" MATCHES "(^| )${old}($| )")
|
||||
string(REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}")
|
||||
else()
|
||||
set(${var} "${${var}} ${n}")
|
||||
endif()
|
||||
set(${var} "${${var}}" PARENT_SCOPE)
|
||||
endfunction(llvm_replace_compiler_option)
|
||||
|
||||
macro(add_td_sources srcs)
|
||||
file(GLOB tds *.td)
|
||||
if (tds)
|
||||
source_group("TableGen descriptions" FILES ${tds})
|
||||
set_source_files_properties(${tds} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
list(APPEND ${srcs} ${tds})
|
||||
endif()
|
||||
endmacro(add_td_sources)
|
||||
|
||||
function(add_header_files_for_glob hdrs_out glob)
|
||||
file(GLOB hds ${glob})
|
||||
set(filtered)
|
||||
foreach (file ${hds})
|
||||
# Explicit existence check is necessary to filter dangling symlinks
|
||||
# out. See https://bugs.gentoo.org/674662.
|
||||
if (EXISTS ${file})
|
||||
list(APPEND filtered ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${hdrs_out} ${filtered} PARENT_SCOPE)
|
||||
endfunction(add_header_files_for_glob)
|
||||
|
||||
function(find_all_header_files hdrs_out additional_headerdirs)
|
||||
add_header_files_for_glob(hds *.h)
|
||||
list(APPEND all_headers ${hds})
|
||||
|
||||
foreach (additional_dir ${additional_headerdirs})
|
||||
add_header_files_for_glob(hds "${additional_dir}/*.h")
|
||||
list(APPEND all_headers ${hds})
|
||||
add_header_files_for_glob(hds "${additional_dir}/*.inc")
|
||||
list(APPEND all_headers ${hds})
|
||||
endforeach(additional_dir)
|
||||
|
||||
set(${hdrs_out} ${all_headers} PARENT_SCOPE)
|
||||
endfunction(find_all_header_files)
|
||||
|
||||
function(llvm_process_sources OUT_VAR)
|
||||
cmake_parse_arguments(
|
||||
ARG
|
||||
"PARTIAL_SOURCES_INTENDED"
|
||||
""
|
||||
"ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS"
|
||||
${ARGN}
|
||||
)
|
||||
set(sources ${ARG_UNPARSED_ARGUMENTS})
|
||||
if (NOT ARG_PARTIAL_SOURCES_INTENDED)
|
||||
llvm_check_source_file_list(${sources})
|
||||
endif()
|
||||
|
||||
# This adds .td and .h files to the Visual Studio solution:
|
||||
add_td_sources(sources)
|
||||
find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
|
||||
if (hdrs)
|
||||
set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
set_source_files_properties(
|
||||
${ARG_ADDITIONAL_HEADERS}
|
||||
PROPERTIES HEADER_FILE_ONLY ON
|
||||
)
|
||||
list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
|
||||
|
||||
set(${OUT_VAR} ${sources} PARENT_SCOPE)
|
||||
endfunction(llvm_process_sources)
|
||||
|
||||
function(llvm_check_source_file_list)
|
||||
cmake_parse_arguments(ARG "" "SOURCE_DIR" "" ${ARGN})
|
||||
foreach (l ${ARG_UNPARSED_ARGUMENTS})
|
||||
get_filename_component(fp ${l} REALPATH)
|
||||
list(APPEND listed ${fp})
|
||||
endforeach()
|
||||
|
||||
if (ARG_SOURCE_DIR)
|
||||
file(GLOB globbed "${ARG_SOURCE_DIR}/*.c" "${ARG_SOURCE_DIR}/*.cpp")
|
||||
else()
|
||||
file(GLOB globbed *.c *.cpp)
|
||||
endif()
|
||||
|
||||
foreach (g ${globbed})
|
||||
get_filename_component(fn ${g} NAME)
|
||||
if (ARG_SOURCE_DIR)
|
||||
set(entry "${g}")
|
||||
else()
|
||||
set(entry "${fn}")
|
||||
endif()
|
||||
get_filename_component(gp ${g} REALPATH)
|
||||
|
||||
# Don't reject hidden files. Some editors create backups in the
|
||||
# same directory as the file.
|
||||
if (NOT "${fn}" MATCHES "^\\.")
|
||||
list(FIND LLVM_OPTIONAL_SOURCES ${entry} idx)
|
||||
if (idx LESS 0)
|
||||
list(FIND listed ${gp} idx)
|
||||
if (idx LESS 0)
|
||||
if (ARG_SOURCE_DIR)
|
||||
set(fn_relative "${ARG_SOURCE_DIR}/${fn}")
|
||||
else()
|
||||
set(fn_relative "${fn}")
|
||||
endif()
|
||||
message(
|
||||
SEND_ERROR
|
||||
"Found unknown source file ${fn_relative}
|
||||
Please update ${CMAKE_CURRENT_LIST_FILE}\n"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction(llvm_check_source_file_list)
|
||||
@@ -0,0 +1,53 @@
|
||||
# This file defines the `libcudacxx_build_compiler_targets()` function, which
|
||||
# creates the following interface targets:
|
||||
#
|
||||
# libcudacxx.compiler_interface
|
||||
# - Interface target linked into all targets in the libcudacxx developer build.
|
||||
# Defines common warning flags, definitions, etc, including those defined in
|
||||
# the global CCCL targets.
|
||||
|
||||
cccl_get_libcudacxx()
|
||||
|
||||
function(libcudacxx_build_compiler_targets)
|
||||
set(cuda_compile_options)
|
||||
set(cxx_compile_options)
|
||||
set(cxx_compile_definitions)
|
||||
|
||||
# if (CCCL_USE_LIBCXX)
|
||||
# list(APPEND cxx_compile_options "-stdlib=libc++")
|
||||
# list(APPEND cxx_compile_definitions "_ALLOW_UNSUPPORTED_LIBCPP=1")
|
||||
# endif()
|
||||
|
||||
# Set test specific flags
|
||||
list(APPEND cxx_compile_definitions "CCCL_ENABLE_ASSERTIONS")
|
||||
list(APPEND cxx_compile_definitions "CCCL_IGNORE_DEPRECATED_CPP_DIALECT")
|
||||
list(
|
||||
APPEND cxx_compile_definitions
|
||||
"CCCL_IGNORE_DEPRECATED_DISCARD_MEMORY_HEADER"
|
||||
)
|
||||
list(
|
||||
APPEND cxx_compile_definitions
|
||||
"CCCL_IGNORE_DEPRECATED_STREAM_REF_HEADER"
|
||||
)
|
||||
|
||||
if (CCCL_ENABLE_TILE)
|
||||
list(APPEND cuda_compile_options "--enable-tile")
|
||||
endif()
|
||||
|
||||
cccl_build_compiler_interface(
|
||||
libcudacxx.compiler_flags
|
||||
"${cuda_compile_options}"
|
||||
"${cxx_compile_options}"
|
||||
"${cxx_compile_definitions}"
|
||||
)
|
||||
|
||||
add_library(libcudacxx.compiler_interface INTERFACE)
|
||||
target_link_libraries(
|
||||
libcudacxx.compiler_interface
|
||||
INTERFACE
|
||||
# order matters here, we need the libcudacxx options to override the cccl options.
|
||||
cccl.compiler_interface
|
||||
libcudacxx.compiler_flags
|
||||
libcudacxx::libcudacxx
|
||||
)
|
||||
endfunction()
|
||||
@@ -0,0 +1,125 @@
|
||||
# For every public header, build a translation unit containing `#include <header>`
|
||||
# to let the compiler try to figure out warnings in that header if it is not otherwise
|
||||
# included in tests, and also to verify if the headers are modular enough.
|
||||
# .inl files are not globbed for, because they are not supposed to be used as public
|
||||
# entrypoints.
|
||||
|
||||
cccl_get_cudatoolkit()
|
||||
|
||||
# Meta target for all configs' header builds:
|
||||
add_custom_target(libcudacxx.test.internal_headers)
|
||||
|
||||
# Grep all internal headers
|
||||
file(
|
||||
GLOB_RECURSE internal_headers
|
||||
RELATIVE "${libcudacxx_SOURCE_DIR}/include/"
|
||||
CONFIGURE_DEPENDS
|
||||
${libcudacxx_SOURCE_DIR}/include/cuda/__*/*.h
|
||||
${libcudacxx_SOURCE_DIR}/include/cuda/std/__*/*.h
|
||||
)
|
||||
|
||||
# Exclude <cuda/std/__cccl/(prologue|epilogue|visibility).h> from the test
|
||||
list(
|
||||
FILTER internal_headers
|
||||
EXCLUDE
|
||||
REGEX "__cccl/(prologue|epilogue|visibility)\.h"
|
||||
)
|
||||
|
||||
# headers in `__cuda` are meant to come after the related "cuda" headers so they do not compile on their own
|
||||
list(FILTER internal_headers EXCLUDE REGEX "__cuda/*")
|
||||
|
||||
# generated cuda::ptx headers are not standalone
|
||||
list(FILTER internal_headers EXCLUDE REGEX "__ptx/instructions/generated")
|
||||
|
||||
# don't check nvtx3.h - it's not our header
|
||||
list(FILTER internal_headers EXCLUDE REGEX ".*/__nvtx/nvtx3.h")
|
||||
|
||||
function(libcudacxx_add_internal_header_test_target target_name)
|
||||
if (NOT ARGN)
|
||||
return()
|
||||
endif()
|
||||
|
||||
cccl_generate_header_tests(
|
||||
${target_name}
|
||||
libcudacxx/include
|
||||
NO_METATARGETS
|
||||
LANGUAGE CUDA
|
||||
HEADER_TEMPLATE "${libcudacxx_SOURCE_DIR}/cmake/header_test.cpp.in"
|
||||
HEADERS ${ARGN}
|
||||
)
|
||||
|
||||
target_compile_definitions(${target_name} PRIVATE _CCCL_HEADER_TEST)
|
||||
target_link_libraries(
|
||||
${target_name}
|
||||
PUBLIC #
|
||||
libcudacxx.compiler_interface
|
||||
CUDA::cudart
|
||||
)
|
||||
add_dependencies(libcudacxx.test.internal_headers ${target_name})
|
||||
endfunction()
|
||||
|
||||
libcudacxx_add_internal_header_test_target(
|
||||
libcudacxx.test.internal_headers.base
|
||||
${internal_headers}
|
||||
)
|
||||
|
||||
# We have fallbacks for some type traits that we want to explicitly test so that they do not bitrot.
|
||||
set(internal_headers_fallback)
|
||||
set(internal_headers_fallback_per_header_defines)
|
||||
foreach (header IN LISTS internal_headers)
|
||||
# MSVC cannot handle some of the fallbacks.
|
||||
if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
|
||||
if (
|
||||
"${header}" MATCHES "is_base_of"
|
||||
OR "${header}" MATCHES "is_nothrow_destructible"
|
||||
OR "${header}" MATCHES "is_polymorphic"
|
||||
)
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(READ "${libcudacxx_SOURCE_DIR}/include/${header}" header_file)
|
||||
string(REGEX MATCH "_LIBCUDACXX_[A-Z_]*_FALLBACK" fallback "${header_file}")
|
||||
if (fallback)
|
||||
list(APPEND internal_headers_fallback "${header}")
|
||||
string(
|
||||
REGEX REPLACE
|
||||
"([][+.*^$()|?\\\\])"
|
||||
"\\\\\\1"
|
||||
header_regex
|
||||
"${header}"
|
||||
)
|
||||
list(
|
||||
APPEND internal_headers_fallback_per_header_defines
|
||||
DEFINE
|
||||
"${fallback}"
|
||||
"^${header_regex}$"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (internal_headers_fallback)
|
||||
cccl_generate_header_tests(
|
||||
libcudacxx.test.internal_headers.fallback
|
||||
libcudacxx/include
|
||||
NO_METATARGETS
|
||||
LANGUAGE CUDA
|
||||
HEADER_TEMPLATE "${libcudacxx_SOURCE_DIR}/cmake/header_test.cpp.in"
|
||||
HEADERS ${internal_headers_fallback}
|
||||
PER_HEADER_DEFINES ${internal_headers_fallback_per_header_defines}
|
||||
)
|
||||
target_compile_definitions(
|
||||
libcudacxx.test.internal_headers.fallback
|
||||
PRIVATE _CCCL_HEADER_TEST
|
||||
)
|
||||
target_link_libraries(
|
||||
libcudacxx.test.internal_headers.fallback
|
||||
PUBLIC #
|
||||
libcudacxx.compiler_interface
|
||||
CUDA::cudart
|
||||
)
|
||||
add_dependencies(
|
||||
libcudacxx.test.internal_headers
|
||||
libcudacxx.test.internal_headers.fallback
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,47 @@
|
||||
# For every public header, build a translation unit containing `#include <header>`
|
||||
# to let the compiler try to figure out warnings in that header if it is not otherwise
|
||||
# included in tests, and also to verify if the headers are modular enough.
|
||||
# .inl files are not globbed for, because they are not supposed to be used as public
|
||||
# entrypoints.
|
||||
|
||||
# Meta target for all configs' header builds:
|
||||
add_custom_target(libcudacxx.test.public_headers)
|
||||
|
||||
# Grep all public headers
|
||||
file(
|
||||
GLOB public_headers
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${libcudacxx_SOURCE_DIR}/include"
|
||||
CONFIGURE_DEPENDS
|
||||
"${libcudacxx_SOURCE_DIR}/include/cuda/*"
|
||||
"${libcudacxx_SOURCE_DIR}/include/cuda/std/*"
|
||||
)
|
||||
|
||||
# annotated_ptr does not work with clang cuda due to __nv_associate_access_property
|
||||
if ("Clang" STREQUAL "${CMAKE_CUDA_COMPILER_ID}")
|
||||
list(REMOVE_ITEM public_headers "annotated_ptr")
|
||||
endif()
|
||||
|
||||
function(libcudacxx_add_public_header_test_target target_name)
|
||||
if (NOT ARGN)
|
||||
return()
|
||||
endif()
|
||||
|
||||
cccl_generate_header_tests(
|
||||
${target_name}
|
||||
libcudacxx/include
|
||||
NO_METATARGETS
|
||||
LANGUAGE CUDA
|
||||
HEADER_TEMPLATE "${libcudacxx_SOURCE_DIR}/cmake/header_test.cpp.in"
|
||||
HEADERS ${ARGN}
|
||||
)
|
||||
|
||||
target_compile_definitions(${target_name} PRIVATE _CCCL_HEADER_TEST)
|
||||
target_link_libraries(${target_name} PUBLIC libcudacxx.compiler_interface)
|
||||
add_dependencies(libcudacxx.test.public_headers ${target_name})
|
||||
endfunction()
|
||||
|
||||
libcudacxx_add_public_header_test_target(
|
||||
libcudacxx.test.public_headers.base
|
||||
${public_headers}
|
||||
)
|
||||
@@ -0,0 +1,75 @@
|
||||
# For every public header, build a translation unit containing `#include <header>`
|
||||
# to let the compiler try to figure out warnings in that header if it is not otherwise
|
||||
# included in tests, and also to verify if the headers are modular enough.
|
||||
# .inl files are not globbed for, because they are not supposed to be used as public
|
||||
# entrypoints.
|
||||
|
||||
cccl_get_cudatoolkit()
|
||||
|
||||
# Meta target for all configs' header builds:
|
||||
add_custom_target(libcudacxx.test.public_headers_host_only)
|
||||
add_custom_target(libcudacxx.test.public_headers_host_only_with_ctk)
|
||||
|
||||
if (CCCL_ENABLE_TILE) # TODO(miscco): For now only test public headers with tile
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Grep all public headers
|
||||
file(
|
||||
GLOB public_headers_host_only
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${libcudacxx_SOURCE_DIR}/include"
|
||||
CONFIGURE_DEPENDS
|
||||
"${libcudacxx_SOURCE_DIR}/include/cuda/*"
|
||||
"${libcudacxx_SOURCE_DIR}/include/cuda/std/*"
|
||||
)
|
||||
|
||||
set(public_host_header_cxx_compile_options)
|
||||
set(public_host_header_cxx_compile_definitions)
|
||||
|
||||
# Specifically add libc++ testing if requested to the libcudacxx host suite
|
||||
if (CCCL_USE_LIBCXX)
|
||||
list(APPEND public_host_header_cxx_compile_options "-stdlib=libc++")
|
||||
endif()
|
||||
|
||||
function(
|
||||
libcudacxx_add_public_header_test_host_target
|
||||
target_name
|
||||
parent_target
|
||||
with_ctk
|
||||
)
|
||||
cccl_generate_header_tests(
|
||||
${target_name}
|
||||
libcudacxx/include
|
||||
NO_METATARGETS
|
||||
LANGUAGE CXX
|
||||
HEADER_TEMPLATE "${libcudacxx_SOURCE_DIR}/cmake/header_test.cpp.in"
|
||||
HEADERS ${public_headers_host_only}
|
||||
)
|
||||
target_compile_definitions(
|
||||
${target_name}
|
||||
PRIVATE #
|
||||
${public_host_header_cxx_compile_definitions}
|
||||
_CCCL_HEADER_TEST
|
||||
)
|
||||
target_compile_options(
|
||||
${target_name}
|
||||
PRIVATE ${public_host_header_cxx_compile_options}
|
||||
)
|
||||
target_link_libraries(${target_name} PUBLIC libcudacxx.compiler_interface)
|
||||
if (with_ctk)
|
||||
target_link_libraries(${target_name} PUBLIC CUDA::cudart)
|
||||
endif()
|
||||
add_dependencies(${parent_target} ${target_name})
|
||||
endfunction()
|
||||
|
||||
libcudacxx_add_public_header_test_host_target(
|
||||
libcudacxx.test.public_headers_host_only.base
|
||||
libcudacxx.test.public_headers_host_only
|
||||
OFF
|
||||
)
|
||||
libcudacxx_add_public_header_test_host_target(
|
||||
libcudacxx.test.public_headers_host_only_with_ctk.base
|
||||
libcudacxx.test.public_headers_host_only_with_ctk
|
||||
ON
|
||||
)
|
||||
1569
cccl_upstream/libcudacxx/cmake/config.guess
vendored
Executable file
1569
cccl_upstream/libcudacxx/cmake/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
23
cccl_upstream/libcudacxx/cmake/header_test.cpp.in
Normal file
23
cccl_upstream/libcudacxx/cmake/header_test.cpp.in
Normal file
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of libcu++, the C++ Standard Library for your entire system,
|
||||
// under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// ignore deprecation warnings
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wdeprecated"
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning (disable: 4996)
|
||||
#else
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
// This file tests that the respective header is includable on its own with a cuda compiler
|
||||
#include <@header@>
|
||||
1
cccl_upstream/libcudacxx/cmake/libcudacxxAddSubdir.cmake
Normal file
1
cccl_upstream/libcudacxx/cmake/libcudacxxAddSubdir.cmake
Normal file
@@ -0,0 +1 @@
|
||||
cccl_add_subdir_helper(libcudacxx)
|
||||
Reference in New Issue
Block a user