blob: 50340c6c39fc6af8ede0665ca54858b84c52acee [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 Svantessonded5b182023-08-02 14:23:00 +000081bool_flag(
82 name = "thread_local_scheduler",
83 build_setting_default = False,
84 visibility = ["//visibility:public"],
85)
86
David Svantesson90d15b92023-06-08 10:05:59 +000087string_flag(
88 name = "arch",
89 build_setting_default = "armv8-a",
90 values = [
91 "armv8-a",
92 "armv8.2-a+fp16"
93 ]
94)
95
David Svantessone0c42ef2022-12-15 16:25:57 +000096#---------------------------------------------------------------------
97# Flag variables
98config_setting(
99 name = "debug_flag",
100 flag_values = {
101 ":debug": "true",
102 },
103)
104
105config_setting(
106 name = "Werror_flag",
107 flag_values = {
108 ":Werror": "true",
109 },
110)
111
112config_setting(
113 name = "logging_flag",
114 flag_values = {
115 ":logging": "true",
116 },
117)
118
119config_setting(
120 name = "openmp_flag",
121 flag_values = {
122 ":openmp": "true",
123 },
124)
125
126config_setting(
127 name = "cppthreads_flag",
128 flag_values = {
129 ":cppthreads": "true",
130 },
131)
132
David Svantesson45370892023-02-22 11:08:57 +0000133config_setting(
134 name = "bf16_validation_flag",
135 flag_values = {
136 ":enable_bf16_validation": "true",
137 },
138)
139
David Svantesson3b162e52023-03-28 14:13:32 +0000140config_setting(
141 name = "sve_validation_flag",
142 flag_values = {
143 ":enable_sve_validation": "true",
144 },
145)
146
David Svantesson90d15b92023-06-08 10:05:59 +0000147config_setting(
148 name = "arch_armv8-a",
149 flag_values = {
150 "arch": "armv8-a"
151 }
152)
153
154config_setting(
155 name = "arch_armv8.2-a+fp16",
156 flag_values = {
157 "arch": "armv8.2-a+fp16"
158 }
159)
160
David Svantessonded5b182023-08-02 14:23:00 +0000161config_setting(
162 name = "thread_local_scheduler_flag",
163 flag_values = {
164 ":thread_local_scheduler": "true",
165 },
166)
David Svantesson45370892023-02-22 11:08:57 +0000167
David Svantessone0c42ef2022-12-15 16:25:57 +0000168#---------------------------------------------------------------------
169# Common defines used for all targets
170cc_library(
171 name = "common_defines",
172 defines = [
173 "ENABLE_NEON",
174 "ARM_COMPUTE_CPU_ENABLED",
175 "ARM_COMPUTE_ENABLE_NEON",
David Svantessone0c42ef2022-12-15 16:25:57 +0000176 "ARM_COMPUTE_ENABLE_I8MM",
David Svantessone0c42ef2022-12-15 16:25:57 +0000177 "ENABLE_FP32_KERNELS",
178 "ENABLE_QASYMM8_KERNELS",
179 "ENABLE_QASYMM8_SIGNED_KERNELS",
180 "ENABLE_QSYMM16_KERNELS",
181 "ENABLE_INTEGER_KERNELS",
182 "ENABLE_NHWC_KERNELS",
183 "ENABLE_NCHW_KERNELS",
David Svantesson90d15b92023-06-08 10:05:59 +0000184 "ARM_COMPUTE_GRAPH_ENABLED",
David Svantessone0c42ef2022-12-15 16:25:57 +0000185 "ARM_COMPUTE_ENABLE_SVEF32MM",
186 "ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS",
David Svantesson45370892023-02-22 11:08:57 +0000187 "_GLIBCXX_USE_NANOSLEEP"
David Svantessone0c42ef2022-12-15 16:25:57 +0000188 ] + select({
189 "//:debug_flag": [
190 "ARM_COMPUTE_DEBUG_ENABLED",
191 "ARM_COMPUTE_ASSERTS_ENABLED",
192 ],
193 "//conditions:default": [],
194 }) +
195 select({
196 "//:logging_flag": ["ARM_COMPUTE_LOGGING_ENABLED"],
197 "//conditions:default": [],
198 }) +
199 select({
200 "//:cppthreads_flag": ["ARM_COMPUTE_CPP_SCHEDULER"],
201 "//conditions:default": [],
202 }) +
203 select({
204 "//:openmp_flag": ["ARM_COMPUTE_OPENMP_SCHEDULER"],
205 "//conditions:default": [],
David Svantesson90d15b92023-06-08 10:05:59 +0000206 }) +
207 select({
208 "//:arch_armv8-a": [],
209 "//:arch_armv8.2-a+fp16": ["ENABLE_FP16_KERNELS", "ARM_COMPUTE_ENABLE_FP16"],
210 "//conditions:default": [],
David Svantessonded5b182023-08-02 14:23:00 +0000211 }) +
212 select({
213 "//:thread_local_scheduler_flag": ["ARM_COMPUTE_THREAD_LOCAL_SCHEDULER"],
214 "//conditions:default": [],
David Svantessone0c42ef2022-12-15 16:25:57 +0000215 }),
216 visibility = ["//visibility:public"],
217)
218
219#---------------------------------------------------------------------
220# Rule for creating file "arm_compute_version.embed"
221genrule(
222 name = "create_version_file",
David Svantesson90d15b92023-06-08 10:05:59 +0000223 srcs = ["SConscript"],
David Svantessone0c42ef2022-12-15 16:25:57 +0000224 outs = ["arm_compute_version.embed"],
David Svantesson90d15b92023-06-08 10:05:59 +0000225 cmd = "$(location //scripts:print_version_file) 'n/a' 'n/a' 'true' > $@",
David Svantessone0c42ef2022-12-15 16:25:57 +0000226 tools = ["//scripts:print_version_file"],
227 visibility = ["//visibility:public"],
228)
229
230#---------------------------------------------------------------------
231# Graph library
232
233cc_library(
234 name = "arm_compute_graph",
235 srcs = ["//src:arm_compute_graph_srcs"],
David Svantesson90d15b92023-06-08 10:05:59 +0000236 copts = [] + select({
237 "//:arch_armv8-a": ["-march=armv8-a"],
238 "//:arch_armv8.2-a+fp16": ["-march=armv8.2-a+fp16"],
239 "//conditions:default": ["-march=armv8-a"],
240 }) + select({
David Svantessone0c42ef2022-12-15 16:25:57 +0000241 "//:debug_flag": [
242 "-O0",
243 "-g",
244 "-gdwarf-2",
245 ],
246 "//conditions:default": ["-O3"],
247 }) +
248 select({
249 "//:openmp_flag": ["-fopenmp"],
250 "//conditions:default": [],
251 }) +
252 select({
253 "//:Werror_flag": ["-Werror"],
254 "//conditions:default": [],
255 }),
256 visibility = ["//visibility:public"],
257 deps = [
David Svantesson90d15b92023-06-08 10:05:59 +0000258 "arm_compute",
David Svantessone0c42ef2022-12-15 16:25:57 +0000259 "//:common_defines",
260 "//arm_compute:graph_headers",
261 ],
262 alwayslink = True,
263)
264
265#---------------------------------------------------------------------
266# SVE2 library
267
268cc_library(
269 name = "arm_compute_sve2",
270 srcs = ["//src:arm_compute_sve2_srcs"],
271 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000272 "-march=armv8.6-a+sve2+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000273 ] + select({
274 "//:debug_flag": [
275 "-O0",
276 "-g",
277 "-gdwarf-2",
278 ],
279 "//conditions:default": ["-O3"],
280 }) +
281 select({
282 "//:openmp_flag": ["-fopenmp"],
283 "//conditions:default": [],
284 }) +
285 select({
286 "//:Werror_flag": ["-Werror"],
287 "//conditions:default": [],
288 }),
289 includes = [
290 "src/core/NEON/kernels/arm_conv",
291 "src/core/NEON/kernels/arm_gemm",
292 "src/core/NEON/kernels/assembly",
293 "src/core/cpu/kernels/assembly",
294 "src/cpu/kernels/assembly",
295 ],
296 linkopts = select({
297 "//:openmp_flag": ["-fopenmp"],
298 "//conditions:default": [],
299 }),
300 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000301 "ENABLE_SVE",
302 "ARM_COMPUTE_ENABLE_SVE",
David Svantessone0c42ef2022-12-15 16:25:57 +0000303 "ARM_COMPUTE_ENABLE_SVE2",
David Svantesson3b162e52023-03-28 14:13:32 +0000304 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000305 ],
306 deps = [
307 "//:common_defines",
308 "//arm_compute:core_headers",
309 "//arm_compute:runtime_headers",
310 "//include",
311 "//support",
312 ],
313 alwayslink = True,
314)
315
316#---------------------------------------------------------------------
317# SVE library
318
319cc_library(
320 name = "arm_compute_sve",
321 srcs = ["//src:arm_compute_sve_srcs"],
322 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000323 "-march=armv8.2-a+sve+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000324 ] + select({
325 "//:debug_flag": [
326 "-O0",
327 "-g",
328 "-gdwarf-2",
329 ],
330 "//conditions:default": ["-O3"],
331 }) +
332 select({
333 "//:openmp_flag": ["-fopenmp"],
334 "//conditions:default": [],
335 }) +
336 select({
337 "//:Werror_flag": ["-Werror"],
338 "//conditions:default": [],
339 }),
340 includes = [
341 "src/core/NEON/kernels/arm_conv",
342 "src/core/NEON/kernels/arm_gemm",
343 "src/core/NEON/kernels/assembly",
344 "src/core/cpu/kernels/assembly",
345 "src/cpu/kernels/assembly",
346 ],
347 linkopts = select({
348 "//:openmp_flag": ["-fopenmp"],
349 "//conditions:default": [],
350 }),
351 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000352 "ENABLE_SVE",
353 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000354 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000355 ],
356 deps = [
357 "//:common_defines",
358 "//arm_compute:core_headers",
359 "//arm_compute:runtime_headers",
360 "//include",
361 "//support",
362 ],
363 alwayslink = True,
364)
365
366#---------------------------------------------------------------------
367# Core and Runtime library
368
369cc_library(
David Svantesson90d15b92023-06-08 10:05:59 +0000370 name = "arm_compute",
371 srcs = ["//src:arm_compute_srcs"],
David Svantessone0c42ef2022-12-15 16:25:57 +0000372 hdrs = glob([
373 "core/NEON/kernels/**/*.h",
374 "core/NEON/kernels/**/*.hpp",
375 "**/*.inl",
376 ]) + [
377 "//:create_version_file",
378 ],
David Svantesson90d15b92023-06-08 10:05:59 +0000379 copts = [] + select({
380 "//:arch_armv8-a": ["-march=armv8-a"],
381 "//:arch_armv8.2-a+fp16": ["-march=armv8.2-a+fp16"],
382 "//conditions:default": ["-march=armv8-a"],
383 }) + select({
David Svantessone0c42ef2022-12-15 16:25:57 +0000384 "//:debug_flag": [
385 "-O0",
386 "-g",
387 "-gdwarf-2",
388 ],
389 "//conditions:default": ["-O3"],
390 }) +
391 select({
392 "//:openmp_flag": ["-fopenmp"],
393 "//conditions:default": [],
394 }) +
395 select({
396 "//:Werror_flag": ["-Werror"],
397 "//conditions:default": [],
398 }),
399 includes = [
400 "arm_compute/runtime",
Michael Tyler74921ee2023-04-12 17:43:17 +0100401 "src/core/NEON/kernels/arm_gemm",
David Svantessone0c42ef2022-12-15 16:25:57 +0000402 "src/core/NEON/kernels/assembly",
403 "src/core/NEON/kernels/convolution/common",
404 "src/core/NEON/kernels/convolution/winograd",
405 "src/core/cpu/kernels/assembly",
406 "src/cpu/kernels/assembly",
407 ],
408 linkopts = select({
409 "//:openmp_flag": ["-fopenmp"],
410 "//conditions:default": [],
411 }),
David Svantesson45370892023-02-22 11:08:57 +0000412 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000413 "ENABLE_SVE",
414 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000415 "ARM_COMPUTE_ENABLE_BF16",
416 ],
David Svantessone0c42ef2022-12-15 16:25:57 +0000417 visibility = ["//visibility:public"],
418 deps = [
419 "//:common_defines",
420 "//arm_compute:core_headers",
421 "//arm_compute:graph_headers",
422 "//arm_compute:runtime_headers",
423 "//include",
424 "//support",
425 "//utils",
David Svantesson45370892023-02-22 11:08:57 +0000426 "//:arm_compute_sve",
427 "//:arm_compute_sve2"
David Svantessone0c42ef2022-12-15 16:25:57 +0000428 ],
429 alwayslink = True,
430)