Skip to content

Commit

Permalink
Adjust to latest openxla changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alekstheod committed Dec 3, 2024
1 parent 34ab8f9 commit 20e1a47
Show file tree
Hide file tree
Showing 12 changed files with 533 additions and 162 deletions.
182 changes: 133 additions & 49 deletions third_party/gpus/rocm/BUILD.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@local_config_rocm//rocm:build_defs.bzl", "rocm_version_number", "select_threshold")

licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like

package(default_visibility = ["//visibility:public"])
package(default_visibility = ["//visibility:private"])

bool_flag(
name = "hermetic",
build_setting_default = False,
)

config_setting(
name = "build_hermetic",
flag_values = {
":hermetic": "True",
},
)

config_setting(
name = "using_hipcc",
Expand All @@ -13,13 +26,34 @@ config_setting(
)

cc_library(
name = "rocm_config",
name = "config",
hdrs = [
"rocm_config/rocm_config.h",
],
include_prefix = "rocm",
strip_include_prefix = "rocm_config",
)

cc_library(
name = "config_hermetic",
hdrs = [
"rocm_config_hermetic/rocm_config.h",
],
include_prefix = "rocm",
strip_include_prefix = "rocm_config_hermetic",
)

cc_library(
name = "rocm_config",
visibility = ["//visibility:public"],
deps = select({
":build_hermetic": [
":config_hermetic",
],
"//conditions:default": [
"config",
],
}),
)

cc_library(
Expand Down Expand Up @@ -73,65 +107,56 @@ cc_library(
],
linkstatic = 1,
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
)

cc_library(
name = "rocm_rpath",
linkopts = select({
":build_hermetic": [
"-Wl,-rpath=%{rocm_toolkit_path}/lib",
"-Wl,-rpath=%{rocm_toolkit_path}/lib",
],
"//conditions:default": [
"-Wl,-rpath=/opt/rocm/lib",
],
}),
visibility = ["//visibility:public"],
)

cc_library(
name = "hip",
data = glob(["%{rocm_root}/lib/**"]),
visibility = ["//visibility:public"],
deps = [
":rocm_hip",
":rocm_rpath",
],
)

cc_library(
name = "rocm_hip",
srcs = glob(["%{rocm_root}/lib/libamdhip*.so*"]),
hdrs = glob(["%{rocm_root}/include/hip/**"]),
data = glob(["%{rocm_root}/lib/hip/**"]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
linkstatic = 1,
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [
":amd_comgr",
":hsa_rocr",
":rocm_config",
":rocm_smi",
":rocprofiler_register",
":system_libs",
],
)

cc_library(
name = "rocprofiler_register",
srcs = glob([
"%{rocm_root}/lib/librocprofiler-register.so*",
]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
)

cc_library(
name = "amd_comgr",
srcs = glob([
"%{rocm_root}/lib/libamd_comgr.so*",
]),
hdrs = glob(["%{rocm_root}/include/amd_comgr/**"]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
)

cc_library(
name = "rocblas",
hdrs = glob(["%{rocm_root}/include/rocblas/**"]),
# workaround to bring tensile files to the same fs layout as expected in the lib
# rocblas assumes that tensile files are located in ../roblas/libraries directory
copts = ["-rpath local_config_rocm/rocm/rocm_dis/lib"],
data = glob([
"%{rocm_root}/lib/librocblas*.so*",
"%{rocm_root}/lib/rocblas/**",
Expand All @@ -140,6 +165,9 @@ cc_library(
includes = [
"%{rocm_root}/include",
],
# workaround to bring tensile files to the same fs layout as expected in the lib
# rocblas assumes that tensile files are located in ../roblas/libraries directory
linkopts = ["-Wl,-rpath=local_config_rocm/rocm/rocm_dis/lib"],
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
Expand All @@ -154,6 +182,7 @@ cc_library(
"%{rocm_root}/include",
],
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [":rocm_config"],
)

Expand Down Expand Up @@ -188,9 +217,6 @@ cc_library(
cc_library(
name = "miopen",
hdrs = glob(["%{rocm_root}/include/rccl/**"]),
# workaround to bring miopen db files to the same fs layout as expected in the lib
# rocblas assumes that miopen db files are located in ../share/miopen/db directory
copts = ["-rpath local_config_rocm/rocm/rocm_dis/lib"],
data = glob([
"%{rocm_root}/lib/libMIOpen*.so*",
"%{rocm_root}/share/miopen/**",
Expand All @@ -199,6 +225,9 @@ cc_library(
includes = [
"%{rocm_root}/include",
],
# workaround to bring miopen db files to the same fs layout as expected in the lib
# rocblas assumes that miopen db files are located in ../share/miopen/db directory
linkopts = ["-Wl,-rpath=local_config_rocm/rocm/rocm_dis/lib"],
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
Expand All @@ -219,15 +248,10 @@ cc_library(
deps = [":rocm_config"],
)

filegroup(
name = "rocm_bin",
srcs = glob(["%{rocm_root}/bin/**/*"]),
visibility = ["//visibility:public"],
)

bzl_library(
name = "build_defs_bzl",
srcs = ["build_defs.bzl"],
visibility = ["//visibility:public"],
)

cc_library(
Expand Down Expand Up @@ -325,9 +349,6 @@ cc_library(
cc_library(
name = "hipblaslt",
hdrs = glob(["%{rocm_root}/include/hipblaslt/**"]),
# workaround to bring tensile files to the same fs layout as expected in the lib
# hibplatslt assumes that tensile files are located in ../hipblaslt/libraries directory
copts = ["-rpath local_config_rocm/rocm/rocm_dis/lib"],
data = glob([
"%{rocm_root}/lib/hipblaslt/**",
"%{rocm_root}/lib/libhipblaslt.so*",
Expand All @@ -336,6 +357,9 @@ cc_library(
includes = [
"%{rocm_root}/include/",
],
# workaround to bring tensile files to the same fs layout as expected in the lib
# hibplatslt assumes that tensile files are located in ../hipblaslt/libraries directory
linkopts = ["-Wl,-rpath=local_config_rocm/rocm/rocm_dis/lib"],
strip_include_prefix = "%{rocm_root}",
visibility = ["//visibility:public"],
deps = [":rocm_config"],
Expand All @@ -354,14 +378,74 @@ cc_library(
deps = [":rocm_config"],
)

cc_library(
name = "rocprofiler_register",
srcs = glob([
"%{rocm_root}/lib/librocprofiler-register.so*",
]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
strip_include_prefix = "%{rocm_root}",
deps = [":rocm_config"],
)

cc_library(
name = "amd_comgr",
srcs = glob([
"%{rocm_root}/lib/libamd_comgr.so*",
]),
hdrs = glob(["%{rocm_root}/include/amd_comgr/**"]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
strip_include_prefix = "%{rocm_root}",
deps = [":rocm_config"],
)

cc_library(
name = "rocm_smi",
srcs = glob([
"%{rocm_root}/lib/librocm_smi64.so*",
"%{rocm_root}/lib/libroam.so*",
]),
hdrs = glob([
"%{rocm_root}/include/oam/**",
"%{rocm_root}/include/rocm_smi/**",
]),
include_prefix = "rocm",
includes = [
"%{rocm_root}/include",
],
strip_include_prefix = "%{rocm_root}",
deps = [":rocm_config"],
)

cc_library(
name = "system_libs",
srcs = glob([
"rocm_dist/usr/lib/**/libelf.so*",
"rocm_dist/usr/lib/**/libdrm.so*",
"rocm_dist/usr/lib/**/libnuma.so*",
"rocm_dist/usr/lib/**/libdrm_amdgpu.so*",
]),
data = glob([
"rocm_dist/usr/**",
]),
)

filegroup(
name = "rocm_root",
srcs = [
"%{rocm_root}/bin/clang-offload-bundler",
],
visibility = ["//visibility:public"],
)

filegroup(
name = "all_files",
srcs = glob(["%{rocm_root}/**"]),
visibility = ["//visibility:public"],
)
20 changes: 20 additions & 0 deletions third_party/gpus/rocm/rocm_redist_ubuntu_20_04.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ rocm_redist_ubuntu_20_04 = {
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocm-llvm-dev/rocm-llvm-dev_18.0.0.24292.60200-66~20.04_amd64.deb",
sha256 = "322ca8425c3a8f2ec17c551bad606b96d957b0c1eea07196dd66ac9f15460ed5",
),
struct(
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocm-smi-lib6.2.0/rocm-smi-lib6.2.0_7.3.0.60200-66~20.04_amd64.deb",
sha256 = "1bbdb32d21dbc12bf9a736f6ca8726df9673e4401465d2b9b537c47b358b67f1",
),
struct(
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocprim-dev6.2.0/rocprim-dev6.2.0_3.2.0.60200-66~20.04_amd64.deb",
sha256 = "e74e1907eb90a692344626e881cb88eeed5565ac3b487eb94ad4ac02ffd838ed",
Expand Down Expand Up @@ -149,6 +153,22 @@ rocm_redist_ubuntu_20_04 = {
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocsolver-dev6.2.0/rocsolver-dev6.2.0_3.26.0.60200-66~20.04_amd64.deb",
sha256 = "21e4aa1957e7bc5d293a418a983d9b3c3917fb78eb79d3d4d55a253b9bae7743",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libdrm2_2.4.101-2_amd64.deb",
sha256 = "4cd2e10f9486456a2782487f8bfd39f330f35a4d5bd6d693412b9e4ca2a6acbd",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libdrm-amdgpu1_2.4.101-2_amd64.deb",
sha256 = "d4567a30f7d68b4dcf794f8677b96e89083693c94e88279fecf577ceba8b9774",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libelf1_0.176-1.1build1_amd64.deb",
sha256 = "78a8761227efc04a1e37527f2f33ba608c6fb5d6c911616346ada5d7b9b72ee3",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libnuma1_2.0.12-1_amd64.deb",
sha256 = "0b1edf08cf9befecd21fe94e298ac25e476f87fd876ddd4adf42ef713449e637",
),
],
"rocm_root": "opt/rocm-6.2.0",
},
Expand Down
20 changes: 20 additions & 0 deletions third_party/gpus/rocm/rocm_redist_ubuntu_22_04.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ rocm_redist_ubuntu_22_04 = {
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocprim-dev6.2.0/rocprim-dev6.2.0_3.2.0.60200-66~22.04_amd64.deb",
sha256 = "3d859bb735ff8bf1962ce680e9257dcc574ab36224f50069f833fa19c6d7e69d",
),
struct(
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocm-smi-lib6.2.0/rocm-smi-lib6.2.0_7.3.0.60200-66~22.04_amd64.deb",
sha256 = "ffd4e064e8a1d52b9e72114e8a1d51c78004a960f1d923448af8ed07a1b6f30b",
),
struct(
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocprofiler-register6.2.0/rocprofiler-register6.2.0_0.4.0.60200-66~22.04_amd64.deb",
sha256 = "66df78d8c5e2d1a0ae43cd4a5e41cf75ec120c870a0bbd7da18a2ba4dec42f9c",
Expand All @@ -149,6 +153,22 @@ rocm_redist_ubuntu_22_04 = {
url = "https://repo.radeon.com/rocm/apt/6.2/pool/main/r/rocsolver-dev6.2.0/rocsolver-dev6.2.0_3.26.0.60200-66~22.04_amd64.deb",
sha256 = "4573f99191fbe3a2afab84fdf5a05e024bd230ca7866d7eba71a5f2560a3a0bf",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libdrm2_2.4.110-1ubuntu1_amd64.deb",
sha256 = "e5ea68db36b31aab442c790e1c78ecdf53646c16b0cd83db15966632ba04152c",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libdrm-amdgpu1_2.4.110-1ubuntu1_amd64.deb",
sha256 = "ae1f0d77668d7275d085ba820206ba91e90833dd1a02b8e251af0c73aa119ba3",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libelf1_0.186-1build1_amd64.deb",
sha256 = "8effc4d7a0cc341bcf6cb11af0134f3defa6292376ecfdfc697a9b228606345c",
),
struct(
url = "https://mirror.bazel.build/github.com/alekstheod/rocm-deps/releases/download/rocm-6.2.0/libnuma1_2.0.14-3ubuntu2_amd64.deb",
sha256 = "0721c89001fbbd1ada23e89da5d60e762763c1a7b3dc814a2e9a518480a8043d",
),
],
"rocm_root": "opt/rocm-6.2.0",
},
Expand Down
Loading

0 comments on commit 20e1a47

Please sign in to comment.