Skip to content

Commit 79afb94

Browse files
committed
[libc] Make NVPTX benchmarks use LTO for linking
Summary: Now that we can do LTO, we can make the benchmarks more accurate by allowing optimization + inlining of the implementation.
1 parent 66ce4f7 commit 79afb94

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

libc/benchmarks/gpu/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function(add_benchmark benchmark_name)
2424
libc.src.stdio.printf
2525
${BENCHMARK_DEPENDS}
2626
${BENCHMARK_UNPARSED_ARGUMENTS}
27+
COMPILE_OPTIONS
28+
-flto
2729
)
2830
get_fq_target_name(${benchmark_name} fq_target_name)
2931
set(fq_build_target_name ${fq_target_name}.__build__)

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ function(add_integration_test test_name)
474474
target_link_options(${fq_build_target_name} PRIVATE
475475
${LIBC_COMPILE_OPTIONS_DEFAULT} -Wno-multi-gpu
476476
"-Wl,--suppress-stack-size-warning"
477+
"-Wl,-mllvm,-nvptx-lower-global-ctor-dtor=1"
478+
"-Wl,-mllvm,-nvptx-emit-init-fini-kernel"
477479
-march=${LIBC_GPU_TARGET_ARCHITECTURE} -nostdlib -static
478480
"--cuda-path=${LIBC_CUDA_ROOT}")
479481
elseif(LIBC_CC_SUPPORTS_NOSTDLIBPP)
@@ -657,6 +659,8 @@ function(add_libc_hermetic test_name)
657659
target_link_options(${fq_build_target_name} PRIVATE
658660
${LIBC_COMPILE_OPTIONS_DEFAULT} -Wno-multi-gpu
659661
"-Wl,--suppress-stack-size-warning"
662+
"-Wl,-mllvm,-nvptx-lower-global-ctor-dtor=1"
663+
"-Wl,-mllvm,-nvptx-emit-init-fini-kernel"
660664
-march=${LIBC_GPU_TARGET_ARCHITECTURE} -nostdlib -static
661665
"--cuda-path=${LIBC_CUDA_ROOT}")
662666
elseif(LIBC_CC_SUPPORTS_NOSTDLIBPP)

0 commit comments

Comments
 (0)