-
Notifications
You must be signed in to change notification settings - Fork 224
bazel: release target auto-compiles all ISAs and DPC++ by default #3537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
a6519c5
dd03ca7
d98f6c4
970b86f
ec91166
3a4e03b
b89addf
4fd605f
476819a
38afec2
a9906be
93a2e73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||
| package(default_visibility = ["//visibility:public"]) | ||||||||||||
| load("@rules_shell//shell:sh_test.bzl", "sh_test") | ||||||||||||
| load("@onedal//dev/bazel:dal.bzl", | ||||||||||||
| "dal_test_suite", | ||||||||||||
| "dal_collect_test_suites", | ||||||||||||
|
|
@@ -317,3 +318,11 @@ sh_test( | |||||||||||
| }) + ["@platforms//os:linux"], | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| sh_test( | ||||||||||||
| name = "isa_coverage_test", | ||||||||||||
| srcs = ["@onedal//dev/bazel/tests:isa_coverage_test.sh"], | ||||||||||||
| args = ["$(location :core_dynamic)"], | ||||||||||||
| data = [":core_dynamic"], | ||||||||||||
| tags = ["manual"], | ||||||||||||
|
||||||||||||
| tags = ["manual"], | |
| tags = ["manual"], | |
| target_compatible_with = ["@platforms//os:linux"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test already has target_compatible_with = ["@platforms//os:linux"], which prevents it from running on Windows/macOS. The manual tag was redundant — removed in 38afec2.
Outdated
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is tagged manual, which means it will be skipped by default in bazel test //.... If the intent is to continuously enforce ISA coverage in CI (as described), consider removing the manual tag or adding a CI job that explicitly runs this test.
| tags = ["manual"], | |
| tags = ["isa_coverage"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the manual tag in 38afec2: isa_coverage_test now runs automatically under bazel test //... on Linux CI. Windows/macOS are excluded via target_compatible_with.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,23 @@ load("@onedal//dev/bazel:utils.bzl", "utils", "paths") | |
| load("@onedal//dev/bazel:cc.bzl", "ModuleInfo") | ||
| load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") | ||
|
|
||
| # Transition: force --cpu=all when building release libs, | ||
| # unless --cpu is explicitly overridden (e.g. --cpu=avx2 in CI). | ||
| # This ensures bazel build //:release compiles all ISA variants | ||
| # (sse2, sse42, avx2, avx512) by default without any extra flags. | ||
| def _release_cpu_all_impl(settings, attr): | ||
| current = settings["@config//:cpu"] | ||
| # Respect explicit --cpu flag; only force "all" for the default "auto". | ||
| if current == "auto": | ||
| return {"@config//:cpu": "all"} | ||
| return {"@config//:cpu": current} | ||
|
Comment on lines
+21
to
+30
|
||
|
|
||
| _release_cpu_all_transition = transition( | ||
| implementation = _release_cpu_all_impl, | ||
| inputs = ["@config//:cpu"], | ||
| outputs = ["@config//:cpu"], | ||
| ) | ||
|
|
||
| def _match_file_name(file, entries): | ||
| for entry in entries: | ||
| if entry in file.path: | ||
|
|
@@ -94,10 +111,10 @@ def _copy_to_release_impl(ctx): | |
| _release = rule( | ||
| implementation = _copy_to_release_impl, | ||
| attrs = { | ||
| "include": attr.label_list(allow_files=True), | ||
| "include": attr.label_list(allow_files=True, cfg=_release_cpu_all_transition), | ||
| "include_prefix": attr.string_list(), | ||
| "include_skip_prefix": attr.string_list(), | ||
| "lib": attr.label_list(allow_files=True), | ||
| "lib": attr.label_list(allow_files=True, cfg=_release_cpu_all_transition), | ||
| }, | ||
|
Comment on lines
111
to
118
|
||
| toolchains = [ | ||
| "@onedal//dev/bazel/toolchains:extra" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||
| package(default_visibility = ["//visibility:public"]) | ||||||||
|
|
||||||||
| exports_files(["mkl_linkage_test.sh"]) | ||||||||
| exports_files([ | ||||||||
| "isa_coverage_test.sh", | ||||||||
|
||||||||
| "isa_coverage_test.sh", | |
| "isa_coverage_test.sh", | |
| "mkl_linkage_test.sh", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| #=============================================================================== | ||||||
| # Copyright contributors to the oneDAL project | ||||||
| # | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| # you may not use this file except in compliance with the License. | ||||||
| # You may obtain a copy of the License at | ||||||
| # | ||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||
| # | ||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
| # See the License for the specific language governing permissions and | ||||||
| # limitations under the License. | ||||||
| #=============================================================================== | ||||||
| # | ||||||
| # Verifies that libonedal_core.so contains CPU dispatch symbols for all | ||||||
| # required ISA variants: sse2, sse42, avx2, avx512 (CpuType E0/E2/E4/E6). | ||||||
| # | ||||||
| # Make builds all 4 ISA variants by default. Building via //:release | ||||||
| # automatically compiles all ISA variants (cfg transition on release rule). | ||||||
| # This test enforces that contract. | ||||||
|
|
||||||
| set -euo pipefail | ||||||
|
|
||||||
| LIB="${1:-}" | ||||||
| if [[ -z "${LIB}" ]]; then | ||||||
| echo "Usage: $0 <path-to-libonedal_core.so>" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| if [[ ! -f "${LIB}" ]]; then | ||||||
| echo "ERROR: Library not found: ${LIB}" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| PASS=0 | ||||||
| FAIL=0 | ||||||
|
|
||||||
| check_isa() { | ||||||
| local cpu_type="$1" # e.g. CpuTypeE2 | ||||||
| local isa_name="$2" # e.g. sse42 | ||||||
| local count | ||||||
| count=$(nm -D "${LIB}" | grep -c "${cpu_type}" || true) | ||||||
|
||||||
| count=$(nm -D "${LIB}" | grep -c "${cpu_type}" || true) | |
| count=$(nm -D --defined-only "${LIB}" | grep -c "${cpu_type}" || true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says CI workflows were updated to build with
--config=release, but this workflow was changed tobazel build :release --cpu=avx2. If the intent is to validate the new release behavior (all ISA variants) in CI, this should use the release config/behavior rather than restricting toavx2(or update the PR description accordingly).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow intentionally uses --cpu=avx2 for faster CI (documented in the inline comment above the bazel build line). The PR description was inaccurate — updated to clarify that CI overrides the ISA to avx2 for speed, while the //:release transition handles all ISAs when cpu is unset.