Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 8 additions & 1 deletion 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 All @@ -11,7 +12,6 @@ load("@onedal//dev/bazel:daal.bzl",
"daal_generate_version",
"daal_patch_kernel_defines",
)
load("@rules_shell//shell:sh_test.bzl", "sh_test")

daal_module(
name = "microvmlipp",
Expand Down Expand Up @@ -317,3 +317,10 @@ 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"],
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}

_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),
},
toolchains = [
"@onedal//dev/bazel/toolchains:extra"
Expand Down
5 changes: 4 additions & 1 deletion dev/bazel/tests/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
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.
"mkl_linkage_test.sh",
])
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)
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