2023-01-02 14:28:25 +00:00
|
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
2025-05-12 12:10:27 +00:00
|
|
|
load("@aspect_bazel_lib//lib:tar.bzl", "tar")
|
2023-01-02 14:28:25 +00:00
|
|
|
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_list_flag")
|
2025-04-30 15:53:51 +00:00
|
|
|
load("@zml//bazel:patchelf.bzl", "patchelf")
|
2023-01-02 14:28:25 +00:00
|
|
|
|
|
|
|
|
string_list_flag(
|
|
|
|
|
name = "gfx",
|
|
|
|
|
build_setting_default = ["all"],
|
2024-05-20 11:28:25 +00:00
|
|
|
visibility = ["//visibility:public"],
|
2023-01-02 14:28:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
bool_flag(
|
|
|
|
|
name = "hipblaslt",
|
|
|
|
|
build_setting_default = True,
|
2024-05-20 11:28:25 +00:00
|
|
|
visibility = ["//visibility:public"],
|
2023-01-02 14:28:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
config_setting(
|
|
|
|
|
name = "_hipblaslt",
|
|
|
|
|
flag_values = {":hipblaslt": "True"},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cc_shared_library(
|
2023-05-03 17:33:46 +00:00
|
|
|
name = "zmlxrocm_so",
|
2025-04-14 16:38:15 +00:00
|
|
|
shared_lib_name = "lib/libzmlxrocm.so.0",
|
|
|
|
|
deps = ["@zml//runtimes/rocm:zmlxrocm_lib"],
|
2023-01-02 14:28:25 +00:00
|
|
|
)
|
|
|
|
|
|
2025-04-14 16:38:15 +00:00
|
|
|
patchelf(
|
|
|
|
|
name = "libpjrt_rocm.patchelf",
|
|
|
|
|
shared_library = "libpjrt_rocm.so",
|
|
|
|
|
add_needed = [
|
|
|
|
|
"libzmlxrocm.so.0",
|
|
|
|
|
# So that RPATH is taken into account.
|
|
|
|
|
"librocblas.so.4",
|
|
|
|
|
"libMIOpen.so.1",
|
2023-01-02 14:28:25 +00:00
|
|
|
] + select({
|
2025-04-14 16:38:15 +00:00
|
|
|
"_hipblaslt": [
|
|
|
|
|
"libhipblaslt.so.0",
|
|
|
|
|
],
|
2023-01-02 14:28:25 +00:00
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
2024-01-26 13:02:23 +00:00
|
|
|
rename_dynamic_symbols = {
|
|
|
|
|
"dlopen": "zmlxrocm_dlopen",
|
|
|
|
|
},
|
2025-04-14 16:38:15 +00:00
|
|
|
set_rpath = "$ORIGIN",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
copy_to_directory(
|
|
|
|
|
name = "sandbox",
|
|
|
|
|
srcs = [
|
|
|
|
|
":zmlxrocm_so",
|
|
|
|
|
":libpjrt_rocm.patchelf",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@comgr//:amd_comgr",
|
2025-05-12 12:10:27 +00:00
|
|
|
"@hip-runtime-amd//:amdhip_patched",
|
2025-04-14 16:38:15 +00:00
|
|
|
"@hip-runtime-amd//:hiprtc",
|
|
|
|
|
"@hipblaslt//:hipblaslt",
|
|
|
|
|
"@hipfft",
|
|
|
|
|
"@hipsolver",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@hsa-amd-aqlprofile//:hsa-amd-aqlprofile",
|
|
|
|
|
"@hsa-rocr//:hsa-runtime",
|
|
|
|
|
"@miopen-hip//:MIOpen",
|
|
|
|
|
"@rccl",
|
2025-04-14 16:38:15 +00:00
|
|
|
"@rocblas//:rocblas",
|
|
|
|
|
"@rocblas//:runfiles",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@rocm-core",
|
2025-04-14 16:38:15 +00:00
|
|
|
"@rocm-device-libs//:runfiles",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@rocm-smi-lib//:rocm_smi",
|
|
|
|
|
"@rocprofiler-register",
|
2025-04-14 16:38:15 +00:00
|
|
|
"@rocfft",
|
|
|
|
|
"@rocsolver",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@roctracer",
|
2025-04-14 16:38:15 +00:00
|
|
|
"@roctracer//:roctx",
|
2024-06-25 11:00:29 +00:00
|
|
|
"@libelf1",
|
2025-04-30 15:53:51 +00:00
|
|
|
"@libdrm2-amdgpu",
|
2024-06-25 11:00:29 +00:00
|
|
|
"@libnuma1",
|
|
|
|
|
"@libzstd1",
|
2025-04-30 15:53:51 +00:00
|
|
|
"@libdrm-amdgpu-amdgpu1",
|
2024-06-25 11:00:29 +00:00
|
|
|
"@libtinfo6",
|
2023-01-02 14:28:25 +00:00
|
|
|
"@zlib1g",
|
2025-04-14 16:38:15 +00:00
|
|
|
] + select({
|
|
|
|
|
":_hipblaslt": ["@hipblaslt//:runfiles"],
|
|
|
|
|
"//conditions:default": [],
|
|
|
|
|
}),
|
|
|
|
|
replace_prefixes = {
|
|
|
|
|
"libpjrt_rocm.patchelf": "lib",
|
|
|
|
|
"lib/x86_64-linux-gnu": "lib",
|
|
|
|
|
"usr/lib/x86_64-linux-gnu": "lib",
|
|
|
|
|
"libelf1": "lib",
|
|
|
|
|
"hipblaslt": "lib",
|
|
|
|
|
"rocblas": "lib",
|
2025-04-30 15:53:51 +00:00
|
|
|
"opt/amdgpu/lib/x86_64-linux-gnu": "lib",
|
|
|
|
|
"libdrm-amdgpu-amdgpu1": "lib",
|
2025-05-12 12:10:27 +00:00
|
|
|
"amdhip_patched": "lib",
|
2025-04-14 16:38:15 +00:00
|
|
|
},
|
|
|
|
|
add_directory_to_runfiles = True,
|
|
|
|
|
include_external_repositories = ["**"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-30 15:53:51 +00:00
|
|
|
tar(
|
|
|
|
|
name = "amdgpu_ids_layer",
|
|
|
|
|
srcs = ["@libdrm-amdgpu-common//:amdgpu_ids"],
|
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-14 16:38:15 +00:00
|
|
|
cc_library(
|
|
|
|
|
name = "libpjrt_rocm",
|
|
|
|
|
data = [":sandbox"],
|
|
|
|
|
visibility = ["@zml//runtimes/rocm:__subpackages__"],
|
2023-01-02 14:28:25 +00:00
|
|
|
)
|