aboutsummaryrefslogtreecommitdiff
path: root/libc/cmake
diff options
context:
space:
mode:
authorjameshu15869 <55058507+jameshu15869@users.noreply.github.com>2024-06-26 16:38:39 -0500
committerGitHub <noreply@github.com>2024-06-26 16:38:39 -0500
commit02b57dedb73134bc81f09e2ff3c56e286091ba13 (patch)
tree93aecc9496025974a5bde255a6081621e5f7bc15 /libc/cmake
parent49e5cd2acc0d12f7cdb80aafd9ab26719d4415aa (diff)
downloadllvm-02b57dedb73134bc81f09e2ff3c56e286091ba13.zip
llvm-02b57dedb73134bc81f09e2ff3c56e286091ba13.tar.gz
llvm-02b57dedb73134bc81f09e2ff3c56e286091ba13.tar.bz2
[libc] NVPTX Profiling (#92009)
PR for adding microbenchmarking infrastructure for NVPTX. `nvlink` cannot perform LTO, so we cannot inline `libc` functions and this function call overhead is not adjusted for during microbenchmarking.
Diffstat (limited to 'libc/cmake')
-rw-r--r--libc/cmake/modules/LLVMLibCTestRules.cmake27
1 files changed, 19 insertions, 8 deletions
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index c8d7c8a..fbeec32 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -526,12 +526,15 @@ function(add_integration_test test_name)
add_dependencies(${INTEGRATION_TEST_SUITE} ${fq_target_name})
endfunction(add_integration_test)
-# Rule to add a hermetic test. A hermetic test is one whose executable is fully
+# Rule to add a hermetic program. A hermetic program is one whose executable is fully
# statically linked and consists of pieces drawn only from LLVM's libc. Nothing,
# including the startup objects, come from the system libc.
#
+# For the GPU, these can be either tests or benchmarks, depending on the value
+# of the LINK_LIBRARIES arg.
+#
# Usage:
-# add_libc_hermetic_test(
+# add_libc_hermetic(
# <target name>
# SUITE <the suite to which the test should belong>
# SRCS <src1.cpp> [src2.cpp ...]
@@ -543,14 +546,14 @@ endfunction(add_integration_test)
# LINK_LIBRARIES <list of linking libraries for this target>
# LOADER_ARGS <list of special args to loaders (like the GPU loader)>
# )
-function(add_libc_hermetic_test test_name)
+function(add_libc_hermetic test_name)
if(NOT TARGET libc.startup.${LIBC_TARGET_OS}.crt1)
message(VERBOSE "Skipping ${fq_target_name} as it is not available on ${LIBC_TARGET_OS}.")
return()
endif()
cmake_parse_arguments(
"HERMETIC_TEST"
- "" # No optional arguments
+ "IS_BENCHMARK" # Optional arguments
"SUITE" # Single value arguments
"SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
${ARGN}
@@ -678,7 +681,6 @@ function(add_libc_hermetic_test test_name)
PRIVATE
libc.startup.${LIBC_TARGET_OS}.crt1${internal_suffix}
${link_libraries}
- LibcTest.hermetic
LibcHermeticTestSupport.hermetic
# The NVIDIA 'nvlink' linker does not currently support static libraries.
$<$<NOT:$<BOOL:${LIBC_TARGET_ARCHITECTURE_IS_NVPTX}>>:${fq_target_name}.__libc__>)
@@ -714,8 +716,12 @@ function(add_libc_hermetic_test test_name)
)
add_dependencies(${HERMETIC_TEST_SUITE} ${fq_target_name})
- add_dependencies(libc-hermetic-tests ${fq_target_name})
-endfunction(add_libc_hermetic_test)
+ if(NOT ${HERMETIC_TEST_IS_BENCHMARK})
+ # If it is a benchmark, it will already have been added to the
+ # gpu-benchmark target
+ add_dependencies(libc-hermetic-tests ${fq_target_name})
+ endif()
+endfunction(add_libc_hermetic)
# A convenience function to add both a unit test as well as a hermetic test.
function(add_libc_test test_name)
@@ -730,7 +736,12 @@ function(add_libc_test test_name)
add_libc_unittest(${test_name}.__unit__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
endif()
if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
- add_libc_hermetic_test(${test_name}.__hermetic__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
+ add_libc_hermetic(
+ ${test_name}.__hermetic__
+ LINK_LIBRARIES
+ LibcTest.hermetic
+ ${LIBC_TEST_UNPARSED_ARGUMENTS}
+ )
get_fq_target_name(${test_name} fq_test_name)
if(TARGET ${fq_test_name}.__hermetic__ AND TARGET ${fq_test_name}.__unit__)
# Tests like the file tests perform file operations on disk file. If we