new package composable kernel (#39222)

* initial commit to add composable kernel package
* change dependencies to type build and add amdgpu_target variant
* fix spacing
* fix styling
* remove rocmmlir from miopen-hip recipe
* enable miopen with ck after 5.5.1
* fix typo
This commit is contained in:
afzpatel 2023-09-18 17:24:45 -04:00 committed by GitHub
parent 84d2097a8c
commit 4fd7fa5fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 79 additions and 4 deletions

View File

@ -0,0 +1,70 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class ComposableKernel(CMakePackage):
"""Composable Kernel: Performance Portable Programming Model
for Machine Learning Tensor Operators."""
homepage = "https://github.com/ROCmSoftwarePlatform/composable_kernel"
git = "https://github.com/ROCmSoftwarePlatform/composable_kernel.git"
maintainers("srekolam", "afzpatel")
version("master", branch="develop")
version("5.5.1", commit="ac9e01e2cc3721be24619807adc444e1f59a9d25")
version("5.5.0", commit="8b76b832420a3d69708401de6607a033163edcce")
version("5.4.3", commit="bb3d9546f186e39cefedc3e7f01d88924ba20168")
version("5.4.0", commit="236bd148b98c7f1ec61ee850fcc0c5d433576305")
amdgpu_targets = ROCmPackage.amdgpu_targets
variant(
"amdgpu_target",
values=auto_or_any_combination_of(*amdgpu_targets),
sticky=True,
description="set gpu targets",
)
depends_on("python", type="build")
depends_on("z3", type="build")
depends_on("zlib", type="build")
depends_on("ncurses+termlib", type="build")
depends_on("bzip2", type="build")
depends_on("sqlite", type="build")
depends_on("half", type="build")
depends_on("pkgconfig", type="build")
depends_on("cmake@3.16:", type="build")
for ver in ["master", "5.5.1", "5.5.0", "5.4.3", "5.4.0"]:
depends_on("hip@" + ver, when="@" + ver)
depends_on("llvm-amdgpu@" + ver, when="@" + ver)
depends_on("rocm-cmake@" + ver, when="@" + ver, type="build")
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
def cmake_args(self):
spec = self.spec
args = [
self.define(
"CMAKE_CXX_COMPILER", "{0}/bin/clang++".format(spec["llvm-amdgpu"].prefix)
),
self.define("CMAKE_C_COMPILER", "{0}/bin/clang".format(spec["llvm-amdgpu"].prefix)),
self.define("HIP_PATH", spec["hip"].prefix),
self.define("HIP_ROOT_DIR", "{0}".format(spec["hip"].prefix)),
self.define("CMAKE_CXX_FLAGS", "-O3"),
self.define("CMAKE_BUILD_TYPE", "Release"),
]
if "auto" not in self.spec.variants["amdgpu_target"]:
args.append(self.define_from_variant("AMDGPU_TARGETS", "amdgpu_target"))
return args
def build(self, spec, prefix):
with working_dir(self.build_directory):
# only instances is necessary to build and install
make("instances")

View File

@ -154,8 +154,11 @@ class MiopenHip(CMakePackage):
depends_on("mlirmiopen@" + ver, when="@" + ver)
for ver in ["5.4.0", "5.4.3", "5.5.0", "5.5.1"]:
depends_on("rocmlir@" + ver, when="@" + ver)
depends_on("nlohmann-json", type="link")
for ver in ["5.4.0", "5.4.3", "5.5.0"]:
depends_on("rocmlir@" + ver, when="@" + ver)
for ver in ["5.5.1"]:
depends_on("composable-kernel@" + ver, when="@" + ver)
def setup_build_environment(self, env):
if "@3.9.0:" in self.spec:
@ -200,11 +203,13 @@ def cmake_args(self):
if self.spec.satisfies("@5.1.0:5.3"):
mlir_inc = spec["mlirmiopen"].prefix.include
args.append(self.define("CMAKE_CXX_FLAGS", "-I{0}".format(mlir_inc)))
# TODO: need to turn on composable-kernel to on at a later date
# requires a new recipe for composable-kernel
if self.spec.satisfies("@5.4.0:"):
args.append(self.define("MIOPEN_USE_COMPOSABLEKERNEL", "OFF"))
args.append(
"-DNLOHMANN_JSON_INCLUDE={0}".format(self.spec["nlohmann-json"].prefix.include)
)
if self.spec.satisfies("@5.4.0:5.5.0"):
args.append(self.define("MIOPEN_USE_COMPOSABLEKERNEL", "OFF"))
if self.spec.satisfies("@5.5.1:"):
args.append(self.define("MIOPEN_USE_COMPOSABLEKERNEL", "ON"))
args.append(self.define("MIOPEN_USE_MLIR", "OFF"))
return args