Skip to content

Commit ebdcb76

Browse files
committed
[libc] Only link in the appropriate architecture's device libs
1 parent 12189f8 commit ebdcb76

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
add_custom_target(libc-gpu-math-benchmarks)
22

3-
if(CUDAToolkit_FOUND)
4-
set(libdevice_path ${CUDAToolkit_BIN_DIR}/../nvvm/libdevice/libdevice.10.bc)
5-
if (EXISTS ${libdevice_path})
6-
set(nvptx_bitcode_link_flags
3+
set(math_benchmark_flags "")
4+
if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
5+
if(CUDAToolkit_FOUND)
6+
set(libdevice_path ${CUDAToolkit_BIN_DIR}/../nvvm/libdevice/libdevice.10.bc)
7+
if (EXISTS ${libdevice_path})
8+
list(APPEND math_benchmark_flags
79
"SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${libdevice_path}")
8-
# Compile definition needed so the benchmark knows to register
9-
# NVPTX benchmarks.
10-
set(nvptx_math_found "-DNVPTX_MATH_FOUND=1")
10+
# Compile definition needed so the benchmark knows to register
11+
# NVPTX benchmarks.
12+
list(APPEND math_benchmark_flags "-DNVPTX_MATH_FOUND=1")
13+
endif()
1114
endif()
1215
endif()
1316

14-
find_package(AMDDeviceLibs QUIET HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
15-
if(AMDDeviceLibs_FOUND)
16-
get_target_property(ocml_path ocml IMPORTED_LOCATION)
17-
set(amdgpu_bitcode_link_flags
18-
"SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${ocml_path}")
19-
set(amdgpu_math_found "-DAMDGPU_MATH_FOUND=1")
17+
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
18+
find_package(AMDDeviceLibs QUIET HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
19+
if(AMDDeviceLibs_FOUND)
20+
get_target_property(ocml_path ocml IMPORTED_LOCATION)
21+
list(APPEND math_benchmark_flags
22+
"SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${ocml_path}")
23+
list(APPEND math_benchmark_flags "-DAMDGPU_MATH_FOUND=1")
24+
endif()
2025
endif()
2126

2227
add_benchmark(
@@ -33,10 +38,7 @@ add_benchmark(
3338
libc.src.__support.CPP.bit
3439
libc.src.__support.CPP.array
3540
COMPILE_OPTIONS
36-
${nvptx_math_found}
37-
${nvptx_bitcode_link_flags}
38-
${amdgpu_math_found}
39-
${amdgpu_bitcode_link_flags}
41+
${math_benchmark_flags}
4042
LOADER_ARGS
4143
--threads 64
4244
)

0 commit comments

Comments
 (0)