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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build --flag_alias=release_dpc=@config//:release_dpc
build --flag_alias=device=@config//:device
build --flag_alias=cpu=@config//:cpu
build --flag_alias=enable_assert=@config//:enable_assert
build --flag_alias=stdalloc=@config//:stdalloc

# Always pass this env variable to test rules, because SYCL
# OpenCL backend uses it to determine available devices
Expand Down
3 changes: 3 additions & 0 deletions .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ jobs:
echo "Checking Bazel config: release-dpc"
bazel build --nobuild :release --config=release-dpc --cpu=all

echo "Checking Bazel config: stdalloc"
bazel build --nobuild :release --stdalloc=true --release_dpc=false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Alexandr-Solovev Would this be a problem with the space constraints that you've been trying to address? And wouldn't this potentially increase running times significantly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For the first question, it should not(especially with disabled dpc) For the second: we can take a look on the job time, because it is hard to estimate


echo "Checking Bazel config: dev"
bazel build --nobuild //cpp/oneapi/dal:tests --config=dev
displayName: 'Bazel config smoke checks'
Expand Down
3 changes: 3 additions & 0 deletions cpp/daal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ daal_module(
daal_module(
name = "threading_tbb",
srcs = glob(["src/threading/**/*.cpp"]),
# Match Make STDALLOC=yes: separately built threading objects keep TBB
# scalable allocation while core objects switch away from MKL allocation.
stdalloc = False,
visibility_hidden = False,
local_defines = [
"__TBB_NO_IMPLICIT_LINKAGE",
Expand Down
30 changes: 30 additions & 0 deletions dev/bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ The most used Bazel commands are `build`, `test` and `run`.
bazel test --test_disable_fp64 //cpp/oneapi/dal/algo/pca:tests
```

- `--stdalloc` Selects standard-library aligned allocation for DAAL core
objects. Disabled by default and supported only for Linux targets.

Example:
```sh
bazel build //cpp/daal:core_static --stdalloc=true
```

## Build recipes for oneDAL
### Build release artifacts
- To build the Bazel release artifacts, run:
Expand Down Expand Up @@ -448,6 +456,27 @@ dal_test_suite(
## What is missing in this guide
- How to get make-like release structure

## Standard-library allocator

For Linux DAAL core objects, this is equivalent to the allocator-selection
part of Make `STDALLOC=yes`:

```sh
bazel build //:release --stdalloc=true
```

The option is disabled by default. When enabled, Bazel defines
`USE_STD_ALLOC` only while compiling DAAL core objects, switching the MKL
allocation wrappers to `std::aligned_alloc` and `std::free`. It intentionally
does not define the macro for the separately built `threading_tbb` objects;
this matches the current Make target-specific flag scope, so the threading
library continues to use TBB scalable allocation.

The setting rejects every non-Linux target because this allocator path is
currently supported only on Linux. It controls allocator selection only. Make
builds with `COMPILER=icx STDALLOC=yes` additionally pass
`-static-libstdc++`; `--stdalloc=true` does not change Bazel link options.

## Debug and Sanitizer Builds

### Debug build with assertions
Expand Down Expand Up @@ -631,6 +660,7 @@ build --linkopt=-your-link-flag
| `REQSAN=undefined` | `--config=ubsan` | UBSan |
| `REQSAN=memory` | `--config=msan` | MemorySanitizer (Clang/LLVM + lld; instrumented dependencies recommended) |
| `REQSAN=type` | `--config=type` | TypeSanitizer; Clang-only; GCC/ICPX unsupported |
| `STDALLOC=yes` | `--stdalloc=true` | Allocator-selection equivalent for Linux DAAL core objects; threading objects unchanged. Make ICX also adds `-static-libstdc++` |
| `COMPILER=gnu` | `CC=gcc bazel build ...` | Override compiler via `CC` env |
| `OPTFLAG=O2` | `--copt=-O2` | Override optimization level |
| `COPT=-flag` | `--copt=-flag` (C+C++) / `--cxxopt=-flag` (C++ only) | Arbitrary compiler flag |
Expand Down
10 changes: 10 additions & 0 deletions dev/bazel/config/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ config_bool_flag = rule(
build_setting = config.bool(flag = True),
)

def _unsupported_config_impl(ctx):
fail(ctx.attr.message)

unsupported_config = rule(
implementation = _unsupported_config_impl,
attrs = {
"message": attr.string(mandatory = True),
},
)

CpuInfo = provider(
fields = [
"enabled",
Expand Down
28 changes: 28 additions & 0 deletions dev/bazel/config/config.tpl.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@onedal//dev/bazel/config:config.bzl",
"config_flag",
"config_bool_flag",
"dump_config_info",
"unsupported_config",
)

cpu_info(
Expand Down Expand Up @@ -138,6 +139,33 @@ config_bool_flag(
build_setting_default = False,
)

config_bool_flag(
name = "stdalloc",
build_setting_default = False,
)

config_setting(
name = "stdalloc_enabled",
flag_values = {
":stdalloc": "True",
},
constraint_values = [
"@platforms//os:linux",
],
)

config_setting(
name = "stdalloc_disabled",
flag_values = {
":stdalloc": "False",
},
)

unsupported_config(
name = "stdalloc_non_linux_error",
message = "--stdalloc=true is supported only when targeting Linux",
)

config_setting(
name = "assert_enabled",
flag_values = {
Expand Down
14 changes: 12 additions & 2 deletions dev/bazel/daal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ load("@onedal//dev/bazel/config:config.bzl",

def daal_module(name, features=[], lib_tag="daal",
hdrs=[], srcs=[], auto=False,
local_defines=[], copts=[], visibility_hidden=True, **kwargs):
local_defines=[], copts=[], visibility_hidden=True,
stdalloc=True, **kwargs):
if auto:
auto_hdrs = native.glob(["**/*.h", "**/*.i"], allow_empty=True,)
auto_srcs = native.glob(["**/*.cpp"], allow_empty=True,)
else:
auto_hdrs = []
auto_srcs = []
deps = kwargs.pop("deps", []) + select({
"@config//:stdalloc_enabled": [],
"@config//:stdalloc_disabled": [],
"//conditions:default": ["@config//:stdalloc_non_linux_error"],
})
cc_module(
name = name,
lib_tag = lib_tag,
Expand All @@ -52,6 +58,7 @@ def daal_module(name, features=[], lib_tag="daal",
},
hdrs = auto_hdrs + hdrs,
srcs = auto_srcs + srcs,
deps = deps,
copts = copts + (select({
"@platforms//os:windows": ["/utf-8"],
"//conditions:default": ["-fvisibility=hidden", "-fvisibility-inlines-hidden"],
Expand All @@ -62,7 +69,10 @@ def daal_module(name, features=[], lib_tag="daal",
local_defines = select({
"@config//:assert_enabled": local_defines + ["__DAAL_IMPLEMENTATION", "DEBUG_ASSERT=1"],
"//conditions:default": local_defines + ["__DAAL_IMPLEMENTATION"],
}) + select({
}) + (select({
"@config//:stdalloc_enabled": ["USE_STD_ALLOC"],
"//conditions:default": [],
}) if stdalloc else []) + select({
"@config//:backend_ref": [
"DAAL_REF",
],
Expand Down
Loading