Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rocwmma: init at 0.8-5.3.3 #202685

Merged
merged 1 commit into from
Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7e0f2c8..db54eab 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -31,14 +31,6 @@ cmake_dependent_option( ROCWMMA_BUILD_BENCHMARK_TESTS "Build benchmarking tests"
cmake_dependent_option( ROCWMMA_BUILD_EXTENDED_TESTS "Build extended test parameter coverage" OFF "ROCWMMA_BUILD_TESTS" OFF )

# Test/benchmark requires additional dependencies
-include( FetchContent )
-
-FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
-)
-FetchContent_MakeAvailable(googletest)
-
include(GoogleTest)

set(ROCWMMA_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
157 changes: 157 additions & 0 deletions pkgs/development/libraries/rocwmma/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{ lib
, stdenv
, fetchFromGitHub
, writeScript
, cmake
, rocm-cmake
, hip
, openmp
, gtest ? null
, rocblas ? null
, texlive ? null
, doxygen ? null
, sphinx ? null
, python3Packages ? null
, buildTests ? false
, buildSamples ? false
, buildDocs ? false
, gpuTargets ? null # gpuTargets = [ "gfx908:xnack-" "gfx90a:xnack-" "gfx90a:xnack+" ... ]
Comment on lines +9 to +18
Copy link
Member

@SuperSandro2000 SuperSandro2000 Nov 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be added new instances where packages are being overwritten to null to disable features. This is an anti pattern and is totally not required here including the asserts below. This is a legacy artifact from before callPackage when import was still used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression it was to not include those packages and make the closure smaller.
If it's not, I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpuTargets is however null for a different reason.
Is there a reason to change it?
Would it be better to change it to something like [ ]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression it was to not include those packages and make the closure smaller.

It is enough to use lib.optional(s) or if else then for that.

Would it be better to change it to something like [ ]?

That depends on how it should be handled. If only the entries in the list matter than having it by default an empty list is better defined. If there is a difference between null and empty list then it maybe shouldn't be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no discernible difference, so it should be fine.

}:

assert buildTests -> gtest != null;
assert buildTests -> rocblas != null;
assert buildDocs -> texlive != null;
assert buildDocs -> doxygen != null;
assert buildDocs -> sphinx != null;
assert buildDocs -> python3Packages != null;

# Building tests isn't working for now
# undefined reference to symbol '_ZTIN7testing4TestE'
assert buildTests == false;

let
latex = lib.optionalAttrs buildDocs (texlive.combine {
inherit (texlive) scheme-small
latexmk
tex-gyre
fncychap
wrapfig
capt-of
framed
needspace
tabulary
varwidth
titlesec;
});
in stdenv.mkDerivation (finalAttrs: {
pname = "rocwmma";
repoVersion = "0.8";
rocmVersion = "5.3.3";
version = "${finalAttrs.repoVersion}-${finalAttrs.rocmVersion}";

outputs = [
"out"
] ++ lib.optionals buildTests [
"test"
] ++ lib.optionals buildSamples [
"sample"
] ++ lib.optionals buildDocs [
"docs"
];

src = fetchFromGitHub {
owner = "ROCmSoftwarePlatform";
repo = "rocWMMA";
rev = "rocm-${finalAttrs.rocmVersion}";
hash = "sha256-wU3R1XGTy7uFbceUyE0wy+XayicuyJIVfd1ih6pbTN0=";
};

patches = lib.optionals buildTests [
./0000-dont-fetch-googletest.patch
];

nativeBuildInputs = [
cmake
rocm-cmake
hip
];

buildInputs = [
openmp
] ++ lib.optionals buildTests [
gtest
rocblas
] ++ lib.optionals buildDocs [
latex
doxygen
sphinx
python3Packages.sphinx_rtd_theme
python3Packages.breathe
];

cmakeFlags = [
"-DCMAKE_CXX_COMPILER=hipcc"
"-DROCWMMA_BUILD_TESTS=${if buildTests then "ON" else "OFF"}"
"-DROCWMMA_BUILD_SAMPLES=${if buildSamples then "ON" else "OFF"}"
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
] ++ lib.optionals (gpuTargets != null) [
"-DGPU_TARGETS=${lib.strings.concatStringsSep ";" gpuTargets}"
] ++ lib.optionals buildTests [
"-DROCWMMA_BUILD_VALIDATION_TESTS=ON"
"-DROCWMMA_BUILD_BENCHMARK_TESTS=ON"
"-DROCWMMA_BUILD_EXTENDED_TESTS=ON"
"-DROCWMMA_VALIDATE_WITH_ROCBLAS=ON"
"-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON"
];

postPatch = lib.optionalString buildDocs ''
patchShebangs docs/*.sh
'';

# Unfortunately, it seems like we have to call make on this manually
# -DROCWMMA_BUILD_DOCS=ON is invalid, despite being on the README
postBuild = lib.optionalString buildDocs ''
export HOME=$(mktemp -d)
../docs/run_doc.sh
'';

postInstall = lib.optionalString buildTests ''
mkdir -p $test/bin
mv $out/bin/*_test* $test/bin
'' + lib.optionalString buildSamples ''
mkdir -p $sample/bin
mv $out/bin/sgemmv $sample/bin
mv $out/bin/simple_gemm $sample/bin
mv $out/bin/simple_dlrm $sample/bin
'' + lib.optionalString (buildTests || buildSamples) ''
rmdir $out/bin
'';

postFixup = lib.optionalString buildDocs ''
mkdir -p $docs/share/doc/rocwmma
mv ../docs/source/_build/html $docs/share/doc/rocwmma
mv ../docs/source/_build/latex/rocWMMA.pdf $docs/share/doc/rocwmma
'';

passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
json="$(curl -sL "https://api.github.com/repos/ROCmSoftwarePlatform/rocWMMA/releases?per_page=1")"
repoVersion="$(echo "$json" | jq '.[0].name | split(" ") | .[1]' --raw-output)"
rocmVersion="$(echo "$json" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
update-source-version rocwmma "$repoVersion" --ignore-same-hash --version-key=repoVersion
update-source-version rocwmma "$rocmVersion" --ignore-same-hash --version-key=rocmVersion
'';

meta = with lib; {
description = "Mixed precision matrix multiplication and accumulation";
homepage = "https://github.com/ROCmSoftwarePlatform/rocWMMA";
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
broken = finalAttrs.rocmVersion != hip.version;
};
})
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14979,6 +14979,10 @@ with pkgs;

tensile = python3Packages.callPackage ../development/libraries/tensile { };

rocwmma = callPackage ../development/libraries/rocwmma {
inherit (llvmPackages) openmp;
};

rocblas = callPackage ../development/libraries/rocblas {
inherit (llvmPackages_rocm) llvm;
};
Expand Down