diff --git a/libc/benchmarks/gpu/src/math/CMakeLists.txt b/libc/benchmarks/gpu/src/math/CMakeLists.txt index 539a57d9c14312..77250edb6bb526 100644 --- a/libc/benchmarks/gpu/src/math/CMakeLists.txt +++ b/libc/benchmarks/gpu/src/math/CMakeLists.txt @@ -1,22 +1,27 @@ add_custom_target(libc-gpu-math-benchmarks) -if(CUDAToolkit_FOUND) - set(libdevice_path ${CUDAToolkit_BIN_DIR}/../nvvm/libdevice/libdevice.10.bc) - if (EXISTS ${libdevice_path}) - set(nvptx_bitcode_link_flags +set(math_benchmark_flags "") +if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX) + if(CUDAToolkit_FOUND) + set(libdevice_path ${CUDAToolkit_BIN_DIR}/../nvvm/libdevice/libdevice.10.bc) + if (EXISTS ${libdevice_path}) + list(APPEND math_benchmark_flags "SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${libdevice_path}") - # Compile definition needed so the benchmark knows to register - # NVPTX benchmarks. - set(nvptx_math_found "-DNVPTX_MATH_FOUND=1") + # Compile definition needed so the benchmark knows to register + # NVPTX benchmarks. + list(APPEND math_benchmark_flags "-DNVPTX_MATH_FOUND=1") + endif() endif() endif() -find_package(AMDDeviceLibs QUIET HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) -if(AMDDeviceLibs_FOUND) - get_target_property(ocml_path ocml IMPORTED_LOCATION) - set(amdgpu_bitcode_link_flags - "SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${ocml_path}") - set(amdgpu_math_found "-DAMDGPU_MATH_FOUND=1") +if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) + find_package(AMDDeviceLibs QUIET HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) + if(AMDDeviceLibs_FOUND) + get_target_property(ocml_path ocml IMPORTED_LOCATION) + list(APPEND math_benchmark_flags + "SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${ocml_path}") + list(APPEND math_benchmark_flags "-DAMDGPU_MATH_FOUND=1") + endif() endif() add_benchmark( @@ -33,10 +38,7 @@ add_benchmark( libc.src.__support.CPP.bit libc.src.__support.CPP.array COMPILE_OPTIONS - ${nvptx_math_found} - ${nvptx_bitcode_link_flags} - ${amdgpu_math_found} - ${amdgpu_bitcode_link_flags} + ${math_benchmark_flags} LOADER_ARGS --threads 64 )