Skip to content

Commit

Permalink
sci-libs/composable-kernel: add 6.3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Sv. Lockal <[email protected]>
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
AngryLoki authored and thesamesam committed Jan 5, 2025
1 parent cb1623e commit 9e31f3a
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 1 deletion.
1 change: 1 addition & 0 deletions sci-libs/composable-kernel/Manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DIST composable-kernel-5.7.1.tar.gz 2158402 BLAKE2B 660c205c2a99cd17f29a9077e9e7b8b88e41f42ab40d92d0a235e7a60683a04234cce6b2eb6110265c2f461dd132c40151b2521b7d64df4cebb7f27094d8b2b0 SHA512 3931c5dbcab59513541103ebf7446311a1e318421a9e12aeafa7a98cf0717a75e1519140e6b2fbcaf4cb90829a11f03a724ff3ccc6636139c61667ac82558c55
DIST composable-kernel-6.1.1.tar.gz 2520967 BLAKE2B 549d76c5c36b0a273a4c51159abd162403ad035520f97c43dd4b66560ad30021199d2f4cf7e2c12ffe33beee2fb49604db6d7c40b3b33fdcbfde111b9d4833aa SHA512 3f7667cea91760447c3f6ac0bfc261c0bca95abafbfce209d1c889e04f01ec29849e8d7f0e1cb1d77a4309ac06b3c2557721a773e4a67be383de91668cb279b2
DIST composable-kernel-6.3.0.tar.gz 3376552 BLAKE2B ad3dde27d0134fa8bf6b5935603f7cac17c959ab7b123e8d69cfe82bee188ade0fe9d3666d46d9819de479e875e46c0fdad2574f68a3bcf0e9acbb871f163b24 SHA512 4fa7be3f54d06d894dca7ef9fa8e3db24971fb857fee96e7ccff89844fa466789756d5f140d2791a984311d59a044b5351d0358e676c218ea0b0aadf60954d8e
DIST gtest-1.14.0_p20220421.tar.gz 849107 BLAKE2B e9c32d9c1d98959583b696430a6be411f5d69e3db96669b16cffc0f1dcad42512391c0a4733f6e829c82953ff33fa243ee782f3cf6e86436f0d290f45d1a3db7 SHA512 967aac7d85da0e216fe13b17d10f894a31d763d9b88201bac7d3dfc37600552b5472d30a166a6ef27f2778677e73fd3e43d082695a48f47824262eb9cd4fcd2f
2 changes: 1 addition & 1 deletion sci-libs/composable-kernel/composable-kernel-6.1.1.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ REQUIRED_USE="${ROCM_REQUIRED_USE}"
RESTRICT="!test? ( test )"

RDEPEND="
dev-util/hip
dev-util/hip:${SLOT}
>=dev-db/sqlite-3.17
sci-libs/rocBLAS:${SLOT}[${ROCM_USEDEP}]
>=dev-libs/boost-1.72
Expand Down
119 changes: 119 additions & 0 deletions sci-libs/composable-kernel/composable-kernel-6.3.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# shellcheck disable=SC2317
EAPI=8

ROCM_VERSION=${PV}
PYTHON_COMPAT=( python3_{10..13} python3_13t )

inherit cmake flag-o-matic python-r1 rocm

GTEST_COMMIT="b85864c64758dec007208e56af933fc3f52044ee"
GTEST_FILE="gtest-1.14.0_p20220421.tar.gz"

DESCRIPTION="High Performance Composable Kernel for AMD GPUs"
HOMEPAGE="https://github.com/ROCm/composable_kernel"
SRC_URI="https://github.com/ROCm/composable_kernel/archive/rocm-${PV}.tar.gz -> ${P}.tar.gz
test? ( https://github.com/google/googletest/archive/${GTEST_COMMIT}.tar.gz -> ${GTEST_FILE} )"
S="${WORKDIR}/composable_kernel-rocm-${PV}"

LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64"

IUSE="debug profiler test"
REQUIRED_USE="${ROCM_REQUIRED_USE} ${PYTHON_REQUIRED_USE}"
RESTRICT="!test? ( test )"

RDEPEND="
dev-util/hip:${SLOT}
${PYTHON_DEPS}
"

DEPEND="${RDEPEND}"

BDEPEND="
dev-build/rocm-cmake
"

PATCHES=(
"${FILESDIR}"/${PN}-6.1.1-enable-examples.patch
"${FILESDIR}"/${PN}-6.1.1-no-git-no-hash.patch
"${FILESDIR}"/${PN}-6.3.0-no-inline-all.patch
"${FILESDIR}"/${PN}-6.3.0-conditional-kernels.patch
"${FILESDIR}"/${PN}-6.3.0-conditional-ckprofiler.patch
)

pkg_pretend() {
targets=($AMDGPU_TARGETS)
if [[ ${#targets[@]} -gt 1 ]]; then
ewarn "composable-kernel will be compiled for multiple GPU architectures,"
ewarn "which will take a significant amount of time."
ewarn "Please consider setting AMDGPU_TARGETS USE_EXPAND variable to a single architecture."
fi
}

src_prepare() {
sed -e '/-Werror/d' -i cmake/EnableCompilerWarnings.cmake || die
cmake_src_prepare
}

src_configure() {
rocm_use_hipcc

if ! use debug; then
append-cflags "-DNDEBUG"
append-cxxflags "-DNDEBUG"
CMAKE_BUILD_TYPE="Release"
else
CMAKE_BUILD_TYPE="Debug"
fi

local mycmakeargs=(
-DCMAKE_SKIP_RPATH=ON
-DBUILD_DEV=OFF
-DGPU_TARGETS="$(get_amdgpu_flags)"
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
-DBUILD_TESTING=$(usex test ON OFF)
-DCK_USE_PROFILER=$(usex profiler ON OFF)
-Wno-dev
)

if use test; then
mycmakeargs+=(
-DFETCHCONTENT_SOURCE_DIR_GTEST="${WORKDIR}/googletest-${GTEST_COMMIT}"
)
fi

cmake_src_configure
}

src_install() {
cmake_src_install

installation() {
python_domodule python/ck4inductor

# install package-data manually, as there is no PEP517 compliance
shopt -s globstar
package_data=(
include/ck/**/*.hpp
library/src/tensor_operation_instance/gpu/gemm_universal/**/*.hpp
)
shopt -u globstar

inst_path="${D}$(python_get_sitedir)/ck4inductor"
for file in "${package_data[@]}"; do
location="${inst_path}/$(dirname "$file")"
mkdir -p "${location}"
cp "${file}" "${location}"
done
}
python_foreach_impl installation
}

src_test() {
check_amdgpu
LD_LIBRARY_PATH="${BUILD_DIR}"/lib cmake_src_test -j1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Add a flag to build without ckprofiler, which takes few GB of space and not used in many cases.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -561,11 +561,13 @@ if(NOT GPU_ARCHS AND USER_GPU_TARGETS)
endif()
endif()

+if(CK_USE_PROFILER)
rocm_package_setup_component(profiler
LIBRARY_NAME composablekernel
PACKAGE_NAME ckprofiler
)
add_subdirectory(profiler)
+endif()

if(CK_USE_CODEGEN AND (GPU_TARGETS MATCHES "gfx9" OR GPU_ARCHS))
add_subdirectory(codegen)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Fix component discovery, when some targets are not installed.
Upstream bug: https://github.com/ROCm/composable_kernel/issues/1646
--- a/Config.cmake.in
+++ b/Config.cmake.in
@@ -6,6 +6,10 @@ foreach(_comp ${composable_kernel_FIND_COMPONENTS})
if(NOT _comp IN_LIST _composable_kernel_supported_components)
set(composable_kernel_FOUND False)
set(composable_kernel_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
+ elseif(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/composable_kernel${_comp}Targets.cmake")
+ set(composable_kernel_FOUND False)
+ set(composable_kernel_NOT_FOUND_MESSAGE "Unsupported component for current targets: ${_comp}")
+ else()
+ include("${CMAKE_CURRENT_LIST_DIR}/composable_kernel${_comp}Targets.cmake")
endif()
- include("${CMAKE_CURRENT_LIST_DIR}/composable_kernel${_comp}Targets.cmake")
endforeach()
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Flag -amdgpu-early-inline-all explodes memory consumption, so that build does not fit 64GB of RAM.
LLVM bug: https://github.com/llvm/llvm-project/issues/86332
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -213,11 +213,6 @@ if(NOT WIN32 AND check-coerce AND ${hip_VERSION_FLAT} GREATER 600241132 AND ${hi
message("Adding the amdgpu-coerce-illegal-types=1")
add_compile_options("SHELL: -mllvm -amdgpu-coerce-illegal-types=1")
endif()
-if(NOT WIN32 AND ${hip_VERSION_FLAT} GREATER 600241132)
- message("Adding -amdgpu-early-inline-all=true and -amdgpu-function-calls=false")
- add_compile_options("SHELL: -mllvm -amdgpu-early-inline-all=true")
- add_compile_options("SHELL: -mllvm -amdgpu-function-calls=false")
-endif()
#
# Seperate linking jobs from compiling
# Too many concurrent linking jobs can break the build
3 changes: 3 additions & 0 deletions sci-libs/composable-kernel/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<email>[email protected]</email>
<name>Science Project</name>
</maintainer>
<use>
<flag name="profiler">Build and install the Composable Kernal profiler (ckProfiler)</flag>
</use>
<upstream>
<remote-id type="github">ROCm/composable_kernel</remote-id>
</upstream>
Expand Down

0 comments on commit 9e31f3a

Please sign in to comment.