summaryrefslogtreecommitdiff
path: root/libc/benchmarks/gpu/src/math/CMakeLists.txt
blob: 53da45d9eb2ba8d0b99b650851ed1f6b3d4d66ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
add_custom_target(libc-gpu-math-benchmarks)

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.
      list(APPEND math_benchmark_flags "-DNVPTX_MATH_FOUND=1")
    endif()
  endif()
endif()

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(
  atan2_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    atan2_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.math.atan2
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  exp_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    exp_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.math.exp
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  expf_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    expf_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.math.expf
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  expf16_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    expf16_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.math.expf16
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  log_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    log_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.__support.sign
    libc.src.math.log
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  logf_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    logf_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.__support.sign
    libc.src.math.logf
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  logf16_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    logf16_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.__support.sign
    libc.src.math.logf16
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)

add_benchmark(
  sin_benchmark
  SUITE
    libc-gpu-math-benchmarks
  SRCS
    sin_benchmark.cpp
  HDRS
    platform.h
  DEPENDS
    libc.hdr.stdint_proxy
    libc.src.__support.macros.attributes
    libc.src.__support.macros.config
    libc.src.__support.macros.properties.types
    libc.src.math.sin
    libc.src.math.sinf
  COMPILE_OPTIONS
    ${math_benchmark_flags}
  LOADER_ARGS
    --threads 64
)