From a9281f952cb98c1ec84ddcd58d692aaaaaf18b02 Mon Sep 17 00:00:00 2001 From: qbisi Date: Mon, 27 Oct 2025 18:54:21 +0800 Subject: [PATCH] superlu_dist: support ilp64 --- .../su/superlu_dist/mc64ad_dist-stub.patch | 21 ++++++++++++---- pkgs/by-name/su/superlu_dist/package.nix | 25 ++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch b/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch index 5de52014518d..9ce1cc0042e1 100644 --- a/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch +++ b/pkgs/by-name/su/superlu_dist/mc64ad_dist-stub.patch @@ -13,19 +13,30 @@ mc64ad_dist.c was removed (DFSG nonfree), create stubs + +/* only mc64id_dist and mc64ad_dist are referenced by SuperLU-Dist code */ + -+/* Subroutine */ int_t mc64id_dist(int_t *icntl) ++/* Subroutine */ int mc64id_dist(int *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) ++int mc64ad_dist(int *job, int *n, int_t *ne, int_t * ++ ip, int_t *irn, double *a, int *num, int_t *cperm, ++ int_t *liw, int_t *iw, int_t *ldw, double *dw, int * ++ icntl, int *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; +} +--- a/SRC/prec-independent/util.c ++++ b/SRC/prec-independent/util.c +@@ -217,7 +217,7 @@ void set_default_options_dist(superlu_dist_options_t *options) + #else + options->ColPerm = MMD_AT_PLUS_A; + #endif +- options->RowPerm = LargeDiag_MC64; ++ options->RowPerm = NOROWPERM; + options->ReplaceTinyPivot = NO; + options->IterRefine = SLU_DOUBLE; + options->Trans = NOTRANS; \ No newline at end of file diff --git a/pkgs/by-name/su/superlu_dist/package.nix b/pkgs/by-name/su/superlu_dist/package.nix index 87842f815848..2cb3af3d2532 100644 --- a/pkgs/by-name/su/superlu_dist/package.nix +++ b/pkgs/by-name/su/superlu_dist/package.nix @@ -15,9 +15,11 @@ parmetis, # Todo: ask for permission of unfree parmetis withParmetis ? false, -}: + isILP64 ? false, -assert (!blas.isILP64) && (!lapack.isILP64); + # passthru.tests + superlu_dist, +}: stdenv.mkDerivation (finalAttrs: { pname = "superlu_dist"; @@ -38,11 +40,6 @@ stdenv.mkDerivation (finalAttrs: { ./mc64ad_dist-stub.patch ]; - postPatch = '' - substituteInPlace SRC/prec-independent/util.c \ - --replace-fail "LargeDiag_MC64" "NOROWPERM" - ''; - nativeBuildInputs = [ cmake pkg-config @@ -51,8 +48,10 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ mpi - blas - lapack + # always build with lp64 BLAS/LAPACK. + # see https://github.com/xiaoyeli/superlu_dist/issues/132#issuecomment-2323093701 + (blas.override { isILP64 = false; }) + (lapack.override { isILP64 = false; }) ] ++ lib.optionals withParmetis [ metis @@ -73,6 +72,7 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "TPL_ENABLE_INTERNAL_BLASLIB" false) (lib.cmakeBool "TPL_ENABLE_LAPACKLIB" true) (lib.cmakeBool "TPL_ENABLE_PARMETISLIB" withParmetis) + (lib.cmakeFeature "XSDK_INDEX_SIZE" (if isILP64 then "64" else "32")) ] ++ lib.optionals withParmetis [ (lib.cmakeFeature "TPL_PARMETIS_LIBRARIES" "-lmetis -lparmetis") @@ -85,6 +85,13 @@ stdenv.mkDerivation (finalAttrs: { nativeCheckInputs = [ mpiCheckPhaseHook ]; + passthru = { + inherit isILP64; + tests = { + ilp64 = superlu_dist.override { isILP64 = true; }; + }; + }; + meta = { homepage = "https://portal.nersc.gov/project/sparse/superlu/"; license = with lib.licenses; [