{ lib, stdenv, fetchFromGitHub, rocmUpdateScript, cmake, rocm-cmake, llvm, clr, rocminfo, python3, hipify, gitMinimal, gtest, zstd, buildTests ? false, buildExamples ? false, # limits prebuilt kernel selection to those needed for MIOPEN (currently "*conv*") # Other kernels can still be used if treating CK as a header only library # and building specific instances, as done with ck4inductor/torch miOpenReqLibsOnly ? true, withDeprecatedKernels ? false, gpuTargets ? ( clr.localGpuTargets or [ "gfx900" "gfx906" "gfx908" "gfx90a" "gfx942" "gfx950" "gfx10-3-generic" "gfx11-generic" "gfx12-generic" ] ), }: stdenv.mkDerivation (finalAttrs: { preBuild = '' echo "This derivation isn't intended to be built directly and only exists to be overridden and built in chunks"; exit 1 ''; pname = "composable_kernel_base"; version = "7.1.1"; outputs = [ "out" ] ++ lib.optionals buildTests [ "test" ] ++ lib.optionals buildExamples [ "example" ]; src = fetchFromGitHub { owner = "ROCm"; repo = "composable_kernel"; rev = "rocm-${finalAttrs.version}"; hash = "sha256-exdkyTIK03dzlCXHm3j8ehEb9NxLOxPX9QyfMsiCgSs="; }; nativeBuildInputs = [ # Deliberately not using ninja # because we're jankily composing build outputs from multiple drvs # ninja won't believe they're up to date gitMinimal cmake rocminfo clr hipify zstd python3 ]; buildInputs = [ rocm-cmake clr zstd ]; strictDeps = true; enableParallelBuilding = true; env.ROCM_PATH = clr; cmakeFlags = [ (lib.cmakeBool "MIOPEN_REQ_LIBS_ONLY" miOpenReqLibsOnly) (lib.cmakeBool "BUILD_MHA_LIB" (!miOpenReqLibsOnly)) (lib.cmakeBool "DISABLE_DL_KERNELS" true) (lib.cmakeBool "DISABLE_DPP_KERNELS" true) (lib.cmakeBool "CK_TIME_KERNEL" false) "-DCMAKE_MODULE_PATH=${clr}/hip/cmake" "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW" "-DDL_KERNELS=OFF" # CK_USE_CODEGEN Required for migraphx which uses device_gemm_multiple_d.hpp # but migraphx requires an incompatible fork of CK and fails anyway # "-DCK_USE_CODEGEN=ON" # It might be worth skipping fp64 in future with this: # "-DDTYPES=fp32;fp16;fp8;bf16;int8" # Manually define CMAKE_INSTALL_