Skip to content
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

feature: support to build oneDAL with bazel #2746

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ build --flag_alias=device=@config//:device
build --flag_alias=cpu=@config//:cpu
build --flag_alias=enable_assert=@config//:enable_assert

#Build oneDAL via bazel
build --release_dpc

# Always pass this env variable to test rules, because SYCL
# OpenCL backend uses it to determine available devices
test --test_env=OCL_ICD_FILENAMES \
Expand Down
7 changes: 6 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@onedal//dev/bazel:release.bzl",
"release",
"release_include",
"release_env"
)

release(
Expand All @@ -14,6 +15,10 @@ release(
hdrs = [ "@onedal//cpp/daal:kernel_defines" ],
add_prefix = "services/internal",
),
release_include(
hdrs = [ "@micromkl_dpc//:headers" ],
skip_prefix = "external/micromkl_dpc/include/",
),
release_include(
hdrs = [ "@onedal//cpp/oneapi/dal:public_includes" ],
skip_prefix = "cpp",
Expand All @@ -34,8 +39,8 @@ release(
"@onedal//cpp/oneapi/dal:dynamic_dpc",
"@onedal//cpp/oneapi/dal:static_parameters_dpc",
"@onedal//cpp/oneapi/dal:dynamic_parameters_dpc",
# TODO: Add onedal_sycl
],
"//conditions:default": [],
}),
env = release_env()
)
33 changes: 32 additions & 1 deletion dev/bazel/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,38 @@ def _copy_lib(ctx, prefix):
dst_files.append(dst_file)
return dst_files

def _copy_env(ctx, prefix):
lib_prefix = paths.join(prefix, "env")
env_files = env_scripts_generator(ctx)
dst_files = []
for lib in env_files:
dst_path = paths.join(lib_prefix, lib.basename)
dst_file = _copy(ctx, lib, dst_path)
dst_files.append(dst_file)
return dst_files

#draft version for env script, its necessary to do it autogenerated
def env_scripts_generator(ctx):
Copy link
Contributor

Choose a reason for hiding this comment

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

we just need to take vars scripts from here - https://github.com/oneapi-src/oneDAL/tree/main/deploy/local
files have to be renamed on copy

out = ctx.actions.declare_file("vars.sh")
ctx.actions.write(
output=out,
content="""\
export CMAKE_PREFIX_PATH="`pwd`/bazel-bin/release/daal/latest":$CMAKE_PREFIX_PATH
export CPATH="`pwd`/bazel-bin/release/daal/latest/include":$CPATH
export DALROOT="`pwd`/bazel-bin/release/daal/latest"
export LD_LIBRARY_PATH="`pwd`/bazel-bin/release/daal/latest/lib/intel64":$LD_LIBRARY_PATH
export LIBRARY_PATH="`pwd`/bazel-bin/release/daal/latest/lib/intel64":$LIBRARY_PATH
""",
)
return [out]

def _copy_to_release_impl(ctx):
extra_toolchain = ctx.toolchains["@onedal//dev/bazel/toolchains:extra"]
prefix = ctx.attr.name + "/daal/latest"
files = []
files += _copy_include(ctx, prefix)
files += _copy_lib(ctx, prefix)
files += _copy_env(ctx, prefix)
return [DefaultInfo(files=depset(files))]

_release = rule(
Expand All @@ -97,6 +123,7 @@ _release = rule(
"include_prefix": attr.string_list(),
"include_skip_prefix": attr.string_list(),
"lib": attr.label_list(allow_files=True),
"env": attr.label_list(allow_files=True),
},
toolchains = [
"@onedal//dev/bazel/toolchains:extra"
Expand Down Expand Up @@ -130,7 +157,10 @@ headers_filter = rule(
def release_include(hdrs, skip_prefix="", add_prefix=""):
return (hdrs, add_prefix, skip_prefix)

def release(name, include, lib):
def release_env():
return ()

def release(name, include, lib, env):
rule_include = []
rule_include_prefix = []
rule_include_skip_prefix = []
Expand All @@ -145,4 +175,5 @@ def release(name, include, lib):
include_prefix = rule_include_prefix,
include_skip_prefix = rule_include_skip_prefix,
lib = lib,
env = env,
)
Loading