Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,22 @@ build:dpc-private \

test:dpc-private \
--test_tag_filters="dpc,-public"


# Configuration: 'release'
# The //:release target automatically builds all ISA variants when
# --cpu is unset (auto), and includes DPC++ libs by default.
# Use --cpu=<isa> to restrict ISAs for CI speed, or --release_dpc=false
# to disable DPC++ libs.
# bazel build //:release # CPU + DPC++, all ISAs
# bazel build //:release --release_dpc=false # CPU only, all ISAs
# bazel build //:release --cpu=avx2 # CI: avx2 only


# Configuration: 'dev'
# Fast local development build — compiles only for the host machine's
# highest ISA (auto-detected). Use this to speed up iterative builds.
# NOT suitable for release/packaging.
# bazel build //cpp/oneapi/dal:tests --config=dev
build:dev \
--cpu=auto
2 changes: 1 addition & 1 deletion .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ jobs:
displayName: 'bazel-configure'

- script: |
bazel build :release
bazel build :release --release_dpc=false
displayName: 'release'

- script: |
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/docker-validation-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ jobs:
mkdir -p ${{ github.workspace }}/bazel-cache

docker run \
-v ${{ github.workspace }}/bazel-cache:/root/.cache/bazel \
-v ${{ github.workspace }}/bazel-cache:/root/.cache/bazel-disk \
onedal-dev sh -c "
# Use external disk cache
echo 'build --disk_cache=/root/.cache/bazel' > ~/.bazelrc
bazel build :release
echo 'build --disk_cache=/root/.cache/bazel-disk' > ~/.bazelrc
# In CI we build for avx2 only (override default "all" ISA release build).
# For a full release with all ISA variants, omit --cpu or use --cpu=all.
bazel build :release --cpu=avx2 --release_dpc=false
"
Comment on lines +82 to 85
Copy link

Copilot AI Feb 25, 2026

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 to bazel 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 to avx2 (or update the PR description accordingly).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

9 changes: 9 additions & 0 deletions cpp/daal/BUILD
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",
Expand Down Expand Up @@ -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"],
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isa_coverage_test.sh assumes an ELF .so and uses nm -D, so this sh_test will not work on Windows (and likely macOS). Even though it’s tagged manual, it’s easy for someone to run it and get a confusing failure. Consider restricting it with target_compatible_with to Linux (and/or teaching the script to handle .dylib/.dll and use the appropriate nm flags).

Suggested change
tags = ["manual"],
tags = ["manual"],
target_compatible_with = ["@platforms//os:linux"],

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

Copy link

Copilot AI Mar 2, 2026

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.

Suggested change
tags = ["manual"],
tags = ["isa_coverage"],

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

target_compatible_with = ["@platforms//os:linux"],
)
16 changes: 16 additions & 0 deletions dev/bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ The most used Bazel commands are `build`, `test` and `run`.
```

## Build recipes for oneDAL
### Build release artifacts
- To build the library release artifacts (similar to Make build), run:
```sh
bazel build //:release
```
This automatically builds all required ISA variants (SSE2, SSE4.2, AVX2, AVX-512) and includes DPC++ libraries by default.

- To build for a specific CPU architecture only (useful for speeding up CI), use `--cpu`:
```sh
bazel build //:release --cpu=avx2
```
- To disable building DPC++ libraries, use `--release_dpc=false`:
```sh
bazel build //:release --release_dpc=false
```

### Run oneAPI examples
- To run all oneAPI C++ example use the following commands:
```sh
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/config/config.tpl.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ config_setting(

config_bool_flag(
name = "release_dpc",
build_setting_default = False,
build_setting_default = True,
)

config_bool_flag(
Expand Down
21 changes: 19 additions & 2 deletions dev/bazel/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transition forces @config//:cpu to all whenever the value is auto, but Bazel cannot distinguish between the default (--cpu unset) and an explicit --cpu=auto. The surrounding comment/PR description says explicit --cpu overrides are respected; please adjust the wording (or introduce a separate flag) so it reflects actual behavior (i.e., auto will always be overridden to all for this rule).

Copilot uses AI. Check for mistakes.

_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:
Expand Down Expand Up @@ -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
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --cpu=all transition is applied only to the lib attribute. However, the //:release rule also packages generated headers (e.g., cpp/daal:kernel_defines) via the include attribute, and those headers depend on the CPU build setting. As written, //:release can end up shipping headers generated for --cpu=auto while shipping libraries built for --cpu=all, which is inconsistent. Apply the same transition to include (or at least to the CPU-dependent header-producing deps) so packaged headers match the release libraries.

Copilot uses AI. Check for mistakes.
toolchains = [
"@onedal//dev/bazel/toolchains:extra"
Expand Down
4 changes: 3 additions & 1 deletion dev/bazel/tests/BUILD
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",
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkl_linkage_test.sh is no longer exported from this package, but it’s referenced as a file target from //cpp/daal: mkl_linkage_test (srcs = ["//dev/bazel/tests:mkl_linkage_test.sh"]). This will make that test (and LinuxBazel CI) fail to load the script with “no such target … mkl_linkage_test.sh”. Add mkl_linkage_test.sh back to exports_files (alongside isa_coverage_test.sh).

Suggested change
"isa_coverage_test.sh",
"isa_coverage_test.sh",
"mkl_linkage_test.sh",

Copilot uses AI. Check for mistakes.
])
69 changes: 69 additions & 0 deletions dev/bazel/tests/isa_coverage_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)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm -D output includes undefined dynamic symbols as well as defined ones. As written, this test can report a CPU variant as present even if only undefined references containing the CpuTypeE* substring exist. Consider restricting the check to defined symbols (e.g., nm -D --defined-only or filtering out lines starting with spaces + 'U') so the test actually verifies the library contains implementations for each ISA variant.

Suggested change
count=$(nm -D "${LIB}" | grep -c "${cpu_type}" || true)
count=$(nm -D --defined-only "${LIB}" | grep -c "${cpu_type}" || true)

Copilot uses AI. Check for mistakes.
if [[ "${count}" -gt 0 ]]; then
echo " OK ${isa_name} (${cpu_type}): ${count} dispatch symbols"
PASS=$((PASS + 1))
else
echo " FAIL ${isa_name} (${cpu_type}): 0 dispatch symbols found"
echo " Build via //:release (uses all ISAs via cfg transition) or pass --cpu=all"
FAIL=$((FAIL + 1))
fi
}

echo "=== ISA coverage check: $(basename "${LIB}") ==="
check_isa "CpuTypeE0" "sse2"
check_isa "CpuTypeE2" "sse42"
check_isa "CpuTypeE4" "avx2"
check_isa "CpuTypeE6" "avx512"

echo ""
if [[ "${FAIL}" -gt 0 ]]; then
echo "RESULT: FAILED (${FAIL} ISA(s) missing, ${PASS} present)"
exit 1
else
echo "RESULT: PASSED (all 4 ISA variants present)"
exit 0
fi
Loading