From a4414731640221444c64439eafc46134e6166677 Mon Sep 17 00:00:00 2001 From: qbisi Date: Mon, 3 Mar 2025 01:28:13 +0800 Subject: [PATCH] superlu_dist: init at 9.1.0 --- .../su/superlu_dist/mc64ad_dist-stub.patch | 31 ++++++ pkgs/by-name/su/superlu_dist/package.nix | 103 ++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch create mode 100644 pkgs/by-name/su/superlu_dist/package.nix diff --git a/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch b/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch new file mode 100644 index 000000000000..5de52014518d --- /dev/null +++ b/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch @@ -0,0 +1,31 @@ +mc64ad_dist.c was removed (DFSG nonfree), create stubs +--- /dev/null ++++ b/SRC/prec-independent/mc64ad_dist.c +@@ -0,0 +1,27 @@ ++/* The original mc64ad_dist.c is nonfree and has been removed. ++ We provide a stub interface here instead. ++*/ ++ ++#include ++#include ++ ++#include "superlu_ddefs.h" ++ ++/* only mc64id_dist and mc64ad_dist are referenced by SuperLU-Dist code */ ++ ++/* Subroutine */ int_t mc64id_dist(int_t *icntl) ++{ ++ fprintf(stderr, "SuperLU-Dist: MC64 functionality not available.\n(It uses code under a non-free HSL licence which does not permit redistribution).\nAborting mc64id_dist.\n"); ++ abort(); ++ return 0; ++} ++ ++int_t mc64ad_dist(int_t *job, int_t *n, int_t *ne, int_t * ++ ip, int_t *irn, double *a, int_t *num, int_t *cperm, ++ int_t *liw, int_t *iw, int_t *ldw, double *dw, int_t * ++ icntl, int_t *info) ++{ ++ fprintf(stderr, "SuperLU-Dist: MC64 functionality not available.\n(It uses code under a non-free HSL licence which does not permit redistribution).\nAborting mc64ad_dist.\n"); ++ abort(); ++ return 0; ++} diff --git a/pkgs/by-name/su/superlu_dist/package.nix b/pkgs/by-name/su/superlu_dist/package.nix new file mode 100644 index 000000000000..61103a169eca --- /dev/null +++ b/pkgs/by-name/su/superlu_dist/package.nix @@ -0,0 +1,103 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchDebianPatch, + cmake, + gfortran, + blas, + lapack, + mpi, + mpiCheckPhaseHook, + metis, + parmetis, + + # Todo: ask for permission of unfree parmetis + withParmetis ? false, +}: + +assert (!blas.isILP64) && (!lapack.isILP64); + +stdenv.mkDerivation (finalAttrs: { + pname = "superlu_dist"; + version = "9.1.0"; + + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "xiaoyeli"; + repo = "superlu_dist"; + tag = "v${finalAttrs.version}"; + # Remove non‐free files. + postFetch = "rm $out/SRC/prec-independent/mc64ad_dist.c"; + hash = "sha256-NMAEtTmTY189p8BlmsTugwMuxKZh+Bs1GyuwUHkLA1U="; + }; + + patches = [ + ./mc64ad_dist-stub.patch + ]; + + postPatch = '' + substituteInPlace SRC/prec-independent/util.c \ + --replace-fail "LargeDiag_MC64" "NOROWPERM" + ''; + + nativeBuildInputs = [ + cmake + gfortran + ]; + + buildInputs = + [ + mpi + lapack + ] + ++ lib.optionals withParmetis [ + metis + parmetis + ]; + + propagatedBuildInputs = [ blas ]; + + cmakeFlags = + [ + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + (lib.cmakeBool "enable_fortran" true) + (lib.cmakeBool "enable_complex16" true) + (lib.cmakeBool "TPL_ENABLE_INTERNAL_BLASLIB" false) + (lib.cmakeBool "TPL_ENABLE_LAPACKLIB" true) + (lib.cmakeBool "TPL_ENABLE_PARMETISLIB" withParmetis) + ] + ++ lib.optionals withParmetis [ + (lib.cmakeFeature "TPL_PARMETIS_LIBRARIES" "-lmetis -lparmetis") + (lib.cmakeFeature "TPL_PARMETIS_INCLUDE_DIRS" "${lib.getDev parmetis}/include") + ]; + + doCheck = true; + + nativeCheckInputs = [ mpiCheckPhaseHook ]; + + meta = { + homepage = "https://portal.nersc.gov/project/sparse/superlu/"; + license = with lib.licenses; [ + # Files: * + # Lawrence Berkeley National Labs BSD variant license + bsd3Lbnl + + # Files: SRC/prec-independent/symbfact.c + # Xerox code; actually `Boehm-GC` variant. + mit + + # Files: SRC/include/*colamd.h + # University of Florida code; permissive COLAMD licence. + free + + # Files: SRC/include/wingetopt.* + # Microsoft code; Obtained from https://github.com/iotivity/iotivity/tree/master/resource/c_common/windows. + asl20 + ]; + description = "Library for the solution of large, sparse, nonsymmetric systems of linear equations"; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ qbisi ]; + }; +})