Skip to content

Commit

Permalink
dpc bazel test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanglaser committed Jul 8, 2024
1 parent 6183276 commit c5e9e9b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ declare_onedal_extra_toolchain(
name = "onedal_extra_toolchain",
)

load("@onedal//dev/bazel/deps:opencl.bzl", "opencl_repo")
opencl_repo(
name = "opencl",
)

load("@onedal//dev/bazel/deps:micromkl.bzl", "micromkl_repo", "micromkl_dpc_repo")
micromkl_repo(
name = "micromkl",
Expand Down
1 change: 1 addition & 0 deletions dev/bazel/deps/micromkldpc.tpl.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ cc_library(
],
deps = [
":headers",
"@opencl//:opencl_binary",
],
)
46 changes: 46 additions & 0 deletions dev/bazel/deps/opencl.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#===============================================================================
# Copyright 2020 Intel Corporation
#
# 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.
#===============================================================================

load("@onedal//dev/bazel:repos.bzl", "repos")
load("@onedal//dev/bazel:utils.bzl", "paths")

def _get_dpcpp_compiler_root(repo_ctx):
dpcpp_path = repo_ctx.which("icpx")
return dpcpp_path and str(dpcpp_path.dirname.dirname.realpath)

def _opencl_repo_impl(repo_ctx):
dpcpp_root = _get_dpcpp_compiler_root(repo_ctx)
if dpcpp_root:
lib_dir = paths.join(dpcpp_root, "lib")
libs = [
"libOpenCL.so",
"libOpenCL.so.1",
"libOpenCL.so.1.2",
]
repos.create_symlinks(repo_ctx, lib_dir, libs)
repo_ctx.template(
"BUILD",
Label("@onedal//dev/bazel/deps:opencl.tpl.BUILD"),
)

opencl_repo = repository_rule(
implementation = _opencl_repo_impl,
environ = [
"PATH",
],
local = True,
configure = True,
)
8 changes: 8 additions & 0 deletions dev/bazel/deps/opencl.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "opencl_binary",
srcs = [
"libOpenCL.so.1.2",
],
)

0 comments on commit c5e9e9b

Please sign in to comment.