blob: 3a7d941a0e74811dd66794f95788ab9bd6f3c942 [file] [log] [blame]
David Svantessone0c42ef2022-12-15 16:25:57 +00001# Copyright (c) 2023 Arm Limited.
2#
3# SPDX-License-Identifier: MIT
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to
7# deal in the Software without restriction, including without limitation the
8# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9# sell copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in all
13# copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22
23load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
24load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
25
26#---------------------------------------------------------------------
27# Config setting for Tensorflow build
28config_setting(
29 name = "build_with_acl",
30 define_values = {
31 "build_with_acl": "true",
32 },
33 visibility = ["//visibility:public"],
34)
35
36#---------------------------------------------------------------------
37# Flags for build options. Example: --//:debug=true
38# All flags have aliases in .bazelrc so can use for example --debug=true when building
39bool_flag(
40 name = "debug",
41 build_setting_default = False,
42 visibility = ["//visibility:public"],
43)
44
45bool_flag(
46 name = "Werror",
47 build_setting_default = False,
48 visibility = ["//visibility:public"],
49)
50
51bool_flag(
52 name = "logging",
53 build_setting_default = False,
54 visibility = ["//visibility:public"],
55)
56
57bool_flag(
58 name = "openmp",
59 build_setting_default = True,
60 visibility = ["//visibility:public"],
61)
62
63bool_flag(
64 name = "cppthreads",
65 build_setting_default = False,
66 visibility = ["//visibility:public"],
67)
68
David Svantesson45370892023-02-22 11:08:57 +000069bool_flag(
70 name = "enable_bf16_validation",
71 build_setting_default = False,
72 visibility = ["//visibility:public"],
73)
74
David Svantesson3b162e52023-03-28 14:13:32 +000075bool_flag(
76 name = "enable_sve_validation",
77 build_setting_default = False,
78 visibility = ["//visibility:public"],
79)
80
David Svantesson90d15b92023-06-08 10:05:59 +000081string_flag(
82 name = "arch",
83 build_setting_default = "armv8-a",
84 values = [
85 "armv8-a",
86 "armv8.2-a+fp16"
87 ]
88)
89
David Svantessone0c42ef2022-12-15 16:25:57 +000090#---------------------------------------------------------------------
91# Flag variables
92config_setting(
93 name = "debug_flag",
94 flag_values = {
95 ":debug": "true",
96 },
97)
98
99config_setting(
100 name = "Werror_flag",
101 flag_values = {
102 ":Werror": "true",
103 },
104)
105
106config_setting(
107 name = "logging_flag",
108 flag_values = {
109 ":logging": "true",
110 },
111)
112
113config_setting(
114 name = "openmp_flag",
115 flag_values = {
116 ":openmp": "true",
117 },
118)
119
120config_setting(
121 name = "cppthreads_flag",
122 flag_values = {
123 ":cppthreads": "true",
124 },
125)
126
David Svantesson45370892023-02-22 11:08:57 +0000127config_setting(
128 name = "bf16_validation_flag",
129 flag_values = {
130 ":enable_bf16_validation": "true",
131 },
132)
133
David Svantesson3b162e52023-03-28 14:13:32 +0000134config_setting(
135 name = "sve_validation_flag",
136 flag_values = {
137 ":enable_sve_validation": "true",
138 },
139)
140
David Svantesson90d15b92023-06-08 10:05:59 +0000141config_setting(
142 name = "arch_armv8-a",
143 flag_values = {
144 "arch": "armv8-a"
145 }
146)
147
148config_setting(
149 name = "arch_armv8.2-a+fp16",
150 flag_values = {
151 "arch": "armv8.2-a+fp16"
152 }
153)
154
David Svantesson45370892023-02-22 11:08:57 +0000155
David Svantessone0c42ef2022-12-15 16:25:57 +0000156#---------------------------------------------------------------------
157# Common defines used for all targets
158cc_library(
159 name = "common_defines",
160 defines = [
161 "ENABLE_NEON",
162 "ARM_COMPUTE_CPU_ENABLED",
163 "ARM_COMPUTE_ENABLE_NEON",
David Svantessone0c42ef2022-12-15 16:25:57 +0000164 "ARM_COMPUTE_ENABLE_I8MM",
David Svantessone0c42ef2022-12-15 16:25:57 +0000165 "ENABLE_FP32_KERNELS",
166 "ENABLE_QASYMM8_KERNELS",
167 "ENABLE_QASYMM8_SIGNED_KERNELS",
168 "ENABLE_QSYMM16_KERNELS",
169 "ENABLE_INTEGER_KERNELS",
170 "ENABLE_NHWC_KERNELS",
171 "ENABLE_NCHW_KERNELS",
David Svantesson90d15b92023-06-08 10:05:59 +0000172 "ARM_COMPUTE_GRAPH_ENABLED",
David Svantessone0c42ef2022-12-15 16:25:57 +0000173 "ARM_COMPUTE_ENABLE_SVEF32MM",
174 "ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS",
David Svantesson45370892023-02-22 11:08:57 +0000175 "_GLIBCXX_USE_NANOSLEEP"
David Svantessone0c42ef2022-12-15 16:25:57 +0000176 ] + select({
177 "//:debug_flag": [
178 "ARM_COMPUTE_DEBUG_ENABLED",
179 "ARM_COMPUTE_ASSERTS_ENABLED",
180 ],
181 "//conditions:default": [],
182 }) +
183 select({
184 "//:logging_flag": ["ARM_COMPUTE_LOGGING_ENABLED"],
185 "//conditions:default": [],
186 }) +
187 select({
188 "//:cppthreads_flag": ["ARM_COMPUTE_CPP_SCHEDULER"],
189 "//conditions:default": [],
190 }) +
191 select({
192 "//:openmp_flag": ["ARM_COMPUTE_OPENMP_SCHEDULER"],
193 "//conditions:default": [],
David Svantesson90d15b92023-06-08 10:05:59 +0000194 }) +
195 select({
196 "//:arch_armv8-a": [],
197 "//:arch_armv8.2-a+fp16": ["ENABLE_FP16_KERNELS", "ARM_COMPUTE_ENABLE_FP16"],
198 "//conditions:default": [],
David Svantessone0c42ef2022-12-15 16:25:57 +0000199 }),
200 visibility = ["//visibility:public"],
201)
202
203#---------------------------------------------------------------------
204# Rule for creating file "arm_compute_version.embed"
205genrule(
206 name = "create_version_file",
David Svantesson90d15b92023-06-08 10:05:59 +0000207 srcs = ["SConscript"],
David Svantessone0c42ef2022-12-15 16:25:57 +0000208 outs = ["arm_compute_version.embed"],
David Svantesson90d15b92023-06-08 10:05:59 +0000209 cmd = "$(location //scripts:print_version_file) 'n/a' 'n/a' 'true' > $@",
David Svantessone0c42ef2022-12-15 16:25:57 +0000210 tools = ["//scripts:print_version_file"],
211 visibility = ["//visibility:public"],
212)
213
214#---------------------------------------------------------------------
215# Graph library
216
217cc_library(
218 name = "arm_compute_graph",
219 srcs = ["//src:arm_compute_graph_srcs"],
David Svantesson90d15b92023-06-08 10:05:59 +0000220 copts = [] + select({
221 "//:arch_armv8-a": ["-march=armv8-a"],
222 "//:arch_armv8.2-a+fp16": ["-march=armv8.2-a+fp16"],
223 "//conditions:default": ["-march=armv8-a"],
224 }) + select({
David Svantessone0c42ef2022-12-15 16:25:57 +0000225 "//:debug_flag": [
226 "-O0",
227 "-g",
228 "-gdwarf-2",
229 ],
230 "//conditions:default": ["-O3"],
231 }) +
232 select({
233 "//:openmp_flag": ["-fopenmp"],
234 "//conditions:default": [],
235 }) +
236 select({
237 "//:Werror_flag": ["-Werror"],
238 "//conditions:default": [],
239 }),
240 visibility = ["//visibility:public"],
241 deps = [
David Svantesson90d15b92023-06-08 10:05:59 +0000242 "arm_compute",
David Svantessone0c42ef2022-12-15 16:25:57 +0000243 "//:common_defines",
244 "//arm_compute:graph_headers",
245 ],
246 alwayslink = True,
247)
248
249#---------------------------------------------------------------------
250# SVE2 library
251
252cc_library(
253 name = "arm_compute_sve2",
254 srcs = ["//src:arm_compute_sve2_srcs"],
255 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000256 "-march=armv8.6-a+sve2+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000257 ] + select({
258 "//:debug_flag": [
259 "-O0",
260 "-g",
261 "-gdwarf-2",
262 ],
263 "//conditions:default": ["-O3"],
264 }) +
265 select({
266 "//:openmp_flag": ["-fopenmp"],
267 "//conditions:default": [],
268 }) +
269 select({
270 "//:Werror_flag": ["-Werror"],
271 "//conditions:default": [],
272 }),
273 includes = [
274 "src/core/NEON/kernels/arm_conv",
275 "src/core/NEON/kernels/arm_gemm",
276 "src/core/NEON/kernels/assembly",
277 "src/core/cpu/kernels/assembly",
278 "src/cpu/kernels/assembly",
279 ],
280 linkopts = select({
281 "//:openmp_flag": ["-fopenmp"],
282 "//conditions:default": [],
283 }),
284 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000285 "ENABLE_SVE",
286 "ARM_COMPUTE_ENABLE_SVE",
David Svantessone0c42ef2022-12-15 16:25:57 +0000287 "ARM_COMPUTE_ENABLE_SVE2",
David Svantesson3b162e52023-03-28 14:13:32 +0000288 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000289 ],
290 deps = [
291 "//:common_defines",
292 "//arm_compute:core_headers",
293 "//arm_compute:runtime_headers",
294 "//include",
295 "//support",
296 ],
297 alwayslink = True,
298)
299
300#---------------------------------------------------------------------
301# SVE library
302
303cc_library(
304 name = "arm_compute_sve",
305 srcs = ["//src:arm_compute_sve_srcs"],
306 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000307 "-march=armv8.2-a+sve+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000308 ] + select({
309 "//:debug_flag": [
310 "-O0",
311 "-g",
312 "-gdwarf-2",
313 ],
314 "//conditions:default": ["-O3"],
315 }) +
316 select({
317 "//:openmp_flag": ["-fopenmp"],
318 "//conditions:default": [],
319 }) +
320 select({
321 "//:Werror_flag": ["-Werror"],
322 "//conditions:default": [],
323 }),
324 includes = [
325 "src/core/NEON/kernels/arm_conv",
326 "src/core/NEON/kernels/arm_gemm",
327 "src/core/NEON/kernels/assembly",
328 "src/core/cpu/kernels/assembly",
329 "src/cpu/kernels/assembly",
330 ],
331 linkopts = select({
332 "//:openmp_flag": ["-fopenmp"],
333 "//conditions:default": [],
334 }),
335 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000336 "ENABLE_SVE",
337 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000338 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000339 ],
340 deps = [
341 "//:common_defines",
342 "//arm_compute:core_headers",
343 "//arm_compute:runtime_headers",
344 "//include",
345 "//support",
346 ],
347 alwayslink = True,
348)
349
350#---------------------------------------------------------------------
351# Core and Runtime library
352
353cc_library(
David Svantesson90d15b92023-06-08 10:05:59 +0000354 name = "arm_compute",
355 srcs = ["//src:arm_compute_srcs"],
David Svantessone0c42ef2022-12-15 16:25:57 +0000356 hdrs = glob([
357 "core/NEON/kernels/**/*.h",
358 "core/NEON/kernels/**/*.hpp",
359 "**/*.inl",
360 ]) + [
361 "//:create_version_file",
362 ],
David Svantesson90d15b92023-06-08 10:05:59 +0000363 copts = [] + select({
364 "//:arch_armv8-a": ["-march=armv8-a"],
365 "//:arch_armv8.2-a+fp16": ["-march=armv8.2-a+fp16"],
366 "//conditions:default": ["-march=armv8-a"],
367 }) + select({
David Svantessone0c42ef2022-12-15 16:25:57 +0000368 "//:debug_flag": [
369 "-O0",
370 "-g",
371 "-gdwarf-2",
372 ],
373 "//conditions:default": ["-O3"],
374 }) +
375 select({
376 "//:openmp_flag": ["-fopenmp"],
377 "//conditions:default": [],
378 }) +
379 select({
380 "//:Werror_flag": ["-Werror"],
381 "//conditions:default": [],
382 }),
383 includes = [
384 "arm_compute/runtime",
Michael Tyler74921ee2023-04-12 17:43:17 +0100385 "src/core/NEON/kernels/arm_gemm",
David Svantessone0c42ef2022-12-15 16:25:57 +0000386 "src/core/NEON/kernels/assembly",
387 "src/core/NEON/kernels/convolution/common",
388 "src/core/NEON/kernels/convolution/winograd",
389 "src/core/cpu/kernels/assembly",
390 "src/cpu/kernels/assembly",
391 ],
392 linkopts = select({
393 "//:openmp_flag": ["-fopenmp"],
394 "//conditions:default": [],
395 }),
David Svantesson45370892023-02-22 11:08:57 +0000396 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000397 "ENABLE_SVE",
398 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000399 "ARM_COMPUTE_ENABLE_BF16",
400 ],
David Svantessone0c42ef2022-12-15 16:25:57 +0000401 visibility = ["//visibility:public"],
402 deps = [
403 "//:common_defines",
404 "//arm_compute:core_headers",
405 "//arm_compute:graph_headers",
406 "//arm_compute:runtime_headers",
407 "//include",
408 "//support",
409 "//utils",
David Svantesson45370892023-02-22 11:08:57 +0000410 "//:arm_compute_sve",
411 "//:arm_compute_sve2"
David Svantessone0c42ef2022-12-15 16:25:57 +0000412 ],
413 alwayslink = True,
414)