Skip to content

Commit

Permalink
Merge pull request #574 from Nix-QChem/gauxc2
Browse files Browse the repository at this point in the history
gauxc: init at unstable-2024-09-20
  • Loading branch information
markuskowa authored Oct 25, 2024
2 parents 111f1bc + 9c77a88 commit 6b4144e
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 0 deletions.
10 changes: 10 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,22 @@ let
inherit (self) exatensor;
};

exchcxx = callPackage ./pkgs/by-name/exchcxx/package.nix {
inherit cfg;
};

gamess-us = callPackage ./pkgs/by-name/gamess-us/package.nix {
gfortran = final.gfortran12;
};

gator = super.python3.pkgs.toPythonApplication self.python3.pkgs.gator;

gau2grid = super.python3.pkgs.toPythonApplication self.python3.pkgs.gau2grid;

gauxc = callPackage ./pkgs/by-name/gauxc/package.nix {
inherit cfg;
};

iboview = prev.libsForQt5.callPackage ./pkgs/apps/iboview { };

# Molcas with optimisation and LibWFA support. Note, that this disables
Expand Down
82 changes: 82 additions & 0 deletions pkgs/by-name/exchcxx/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{ stdenv
, lib
, fetchFromGitHub
, symlinkJoin
, cmake
, libxc
, cfg
, enableCuda ? cfg.useCuda
, cudaPackages
, autoAddDriverRunpath
, enableHip ? false
, rocmPackages
}:

assert enableCuda -> !enableHip;

let
rocmMerged = symlinkJoin {
name = "rocm-merged";

paths = with rocmPackages; [
clr
rocm-comgr
rocm-device-libs
rocm-runtime
clr.icd
];
};

in
stdenv.mkDerivation rec {
pname = "ExchCXX";
version = "unstable-2024-07-28";

# Upstream version is from wavefunction91, but has HIP bugs not fixed yet
src = fetchFromGitHub {
owner = "ryanstocks00";
repo = pname;
rev = "8a0004609afc710bdad4367867026a9daa0a758b";
hash = "sha256-38jicRJzoTKM1wIm2rj++4mUPCUwW6ZYvmNepkFlG0Y=";
};

nativeBuildInputs = [
cmake
] ++ lib.optional (enableCuda || enableHip) autoAddDriverRunpath;

buildInputs = lib.optionals enableCuda
(with cudaPackages; [
cudatoolkit
cuda_cudart
]) ++ lib.optionals enableHip [
rocmMerged
];

# Yes, really. This needs to be propagated. Otherwise downstream CMake will
# complain when trying to find ExchCXX.
propagatedBuildInputs = [
libxc
];

# Required to make the HIP compiler work in this CMake setup
preConfigure = lib.strings.optionalString enableHip ''
export ROCM_PATH=${rocmMerged}
'';

cmakeFlags = with lib.strings; [
(cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
(cmakeBool "EXCHCXX_ENABLE_CUDA" enableCuda)
(cmakeBool "EXCHCXX_ENABLE_HIP" enableHip)
];

# Checks with accelerators don't work in the sandbox
doCheck = !enableCuda && !enableHip;

meta = with lib; {
description = "Exchange correlation library for density functional theory calculations";
homepage = "https://github.com/wavefunction91/ExchCXX";
license = licenses.bsd3;
platforms = [ "x86_64-linux" ];
maintainers = [ maintainers.sheepforce ];
};
}
13 changes: 13 additions & 0 deletions pkgs/by-name/gauxc/CmakeConfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/gauxc-config.cmake.in b/cmake/gauxc-config.cmake.in
index 648192f..df7968f 100644
--- a/cmake/gauxc-config.cmake.in
+++ b/cmake/gauxc-config.cmake.in
@@ -63,7 +63,7 @@ if( GAUXC_HAS_HIP )
find_package( hipblas REQUIRED )

list(REMOVE_AT CMAKE_PREFIX_PATH 0 1 2)
-endif
+endif()

if( GAUXC_HAS_MPI )
find_dependency( MPI )
13 changes: 13 additions & 0 deletions pkgs/by-name/gauxc/DynamicLinking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c733ec9..752bfcc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,7 +28,7 @@ include( gauxc-integratorxx )
include( gauxc-exchcxx )


-add_library( gauxc STATIC
+add_library( gauxc
grid.cxx
grid_impl.cxx
grid_factory.cxx
51 changes: 51 additions & 0 deletions pkgs/by-name/gauxc/HighFive.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt
index 3df13b3..3f7bd62 100644
--- a/src/external/CMakeLists.txt
+++ b/src/external/CMakeLists.txt
@@ -11,19 +11,26 @@ if( GAUXC_ENABLE_HDF5 )
if(HDF5_FOUND)
set(GAUXC_HAS_HDF5 TRUE CACHE BOOL "" FORCE)
message(STATUS "Enabling HDF5 Bindings")
- message(STATUS "HighFive REPO = ${GAUXC_HIGHFIVE_REPOSITORY}")
- message(STATUS "HighFive REV = ${GAUXC_HIGHFIVE_REVISION} ")
- FetchContent_Declare( HighFive
- GIT_REPOSITORY ${GAUXC_HIGHFIVE_REPOSITORY}
- GIT_TAG ${GAUXC_HIGHFIVE_REVISION}
- )
-
- set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" )
- set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" )
- set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" )
- #set(HIGHFIVE_PARALLEL_HDF5 ON CACHE BOOL "" )
- set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "" )
- FetchContent_MakeAvailable( HighFive )
+
+ find_package(HighFive)
+ if(HighFive_FOUND)
+ message(STATUS "Found installed HighFive")
+ else()
+ message(STATUS "HighFive not found, fetching from repository")
+ message(STATUS "HighFive REPO = ${GAUXC_HIGHFIVE_REPOSITORY}")
+ message(STATUS "HighFive REV = ${GAUXC_HIGHFIVE_REVISION} ")
+ FetchContent_Declare( HighFive
+ GIT_REPOSITORY ${GAUXC_HIGHFIVE_REPOSITORY}
+ GIT_TAG ${GAUXC_HIGHFIVE_REVISION}
+ )
+
+ set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" )
+ set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" )
+ set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" )
+ #set(HIGHFIVE_PARALLEL_HDF5 ON CACHE BOOL "" )
+ set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "" )
+ FetchContent_MakeAvailable( HighFive )
+ endif()

target_sources( gauxc PRIVATE hdf5_write.cxx hdf5_read.cxx )
target_link_libraries( gauxc PUBLIC HighFive )
@@ -32,4 +39,4 @@ if( GAUXC_ENABLE_HDF5 )
endif()
else()
message(STATUS "Disabling HDF5 Bindings")
-endif()
+endif()
\ No newline at end of file
44 changes: 44 additions & 0 deletions pkgs/by-name/gauxc/Linalg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/cmake/gauxc-linalg-modules.cmake b/cmake/gauxc-linalg-modules.cmake
index 69a69a7..8640328 100644
--- a/cmake/gauxc-linalg-modules.cmake
+++ b/cmake/gauxc-linalg-modules.cmake
@@ -1,11 +1,18 @@
include( FetchContent )
include( gauxc-dep-versions )
-FetchContent_Declare( linalg-cmake-modules
- GIT_REPOSITORY ${GAUXC_LINALG_MODULES_REPOSITORY}
- GIT_TAG ${GAUXC_LINALG_MODULES_REVISION}
-)
-FetchContent_GetProperties( linalg-cmake-modules )
-if( NOT linalg-cmake-modules_POPULATED )
- FetchContent_Populate( linalg-cmake-modules )
- list( PREPEND CMAKE_MODULE_PATH ${linalg-cmake-modules_SOURCE_DIR} )
-endif()
+
+set(LINALG_CMAKE_MODULES_DIR @LINALG_CMAKE_MODULES_DIR@)
+
+if(EXISTS ${LINALG_CMAKE_MODULES_DIR})
+ list(PREPEND CMAKE_MODULE_PATH ${LINALG_CMAKE_MODULES_DIR})
+else()
+ FetchContent_Declare( linalg-cmake-modules
+ GIT_REPOSITORY ${GAUXC_LINALG_MODULES_REPOSITORY}
+ GIT_TAG ${GAUXC_LINALG_MODULES_REVISION}
+ )
+ FetchContent_GetProperties( linalg-cmake-modules )
+ if( NOT linalg-cmake-modules_POPULATED )
+ FetchContent_Populate( linalg-cmake-modules )
+ list( PREPEND CMAKE_MODULE_PATH ${linalg-cmake-modules_SOURCE_DIR} )
+ endif()
+endif()
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7e51e9f..c733ec9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -222,5 +222,5 @@ install( FILES
)

# Install Custom Find Modules
-include( ${linalg-cmake-modules_SOURCE_DIR}/LinAlgModulesMacros.cmake )
+include( @LINALG_CMAKE_MODULES_DIR@/LinAlgModulesMacros.cmake )
install_linalg_modules( INSTALL_CONFIGDIR )
10 changes: 10 additions & 0 deletions pkgs/by-name/gauxc/TestSerial.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d3881e9..2a9b664 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -94,4 +94,5 @@ if( GAUXC_ENABLE_MPI )
add_test( NAME GAUXC_MPI_TEST
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 ${MPIEXEC_PREFLAGS} $<TARGET_FILE:gauxc_test> ${MPIEXEC_POSTFLAGS}
)
+ set_tests_properties(GAUXC_SERIAL_TEST GAUXC_MPI_TEST PROPERTIES RUN_SERIAL TRUE)
endif()
104 changes: 104 additions & 0 deletions pkgs/by-name/gauxc/cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
diff --git a/cmake/gauxc-linalg-modules.cmake b/cmake/gauxc-linalg-modules.cmake
index 69a69a7..8640328 100644
--- a/cmake/gauxc-linalg-modules.cmake
+++ b/cmake/gauxc-linalg-modules.cmake
@@ -1,11 +1,18 @@
include( FetchContent )
include( gauxc-dep-versions )
-FetchContent_Declare( linalg-cmake-modules
- GIT_REPOSITORY ${GAUXC_LINALG_MODULES_REPOSITORY}
- GIT_TAG ${GAUXC_LINALG_MODULES_REVISION}
-)
-FetchContent_GetProperties( linalg-cmake-modules )
-if( NOT linalg-cmake-modules_POPULATED )
- FetchContent_Populate( linalg-cmake-modules )
- list( PREPEND CMAKE_MODULE_PATH ${linalg-cmake-modules_SOURCE_DIR} )
-endif()
+
+set(LINALG_CMAKE_MODULES_DIR @LINALG_CMAKE_MODULES_DIR@)
+
+if(EXISTS ${LINALG_CMAKE_MODULES_DIR})
+ list(PREPEND CMAKE_MODULE_PATH ${LINALG_CMAKE_MODULES_DIR})
+else()
+ FetchContent_Declare( linalg-cmake-modules
+ GIT_REPOSITORY ${GAUXC_LINALG_MODULES_REPOSITORY}
+ GIT_TAG ${GAUXC_LINALG_MODULES_REVISION}
+ )
+ FetchContent_GetProperties( linalg-cmake-modules )
+ if( NOT linalg-cmake-modules_POPULATED )
+ FetchContent_Populate( linalg-cmake-modules )
+ list( PREPEND CMAKE_MODULE_PATH ${linalg-cmake-modules_SOURCE_DIR} )
+ endif()
+endif()
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7e51e9f..752bfcc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,7 +28,7 @@ include( gauxc-integratorxx )
include( gauxc-exchcxx )


-add_library( gauxc STATIC
+add_library( gauxc
grid.cxx
grid_impl.cxx
grid_factory.cxx
@@ -222,5 +222,5 @@ install( FILES
)

# Install Custom Find Modules
-include( ${linalg-cmake-modules_SOURCE_DIR}/LinAlgModulesMacros.cmake )
+include( @LINALG_CMAKE_MODULES_DIR@/LinAlgModulesMacros.cmake )
install_linalg_modules( INSTALL_CONFIGDIR )
diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt
index 3df13b3..3f7bd62 100644
--- a/src/external/CMakeLists.txt
+++ b/src/external/CMakeLists.txt
@@ -11,19 +11,26 @@ if( GAUXC_ENABLE_HDF5 )
if(HDF5_FOUND)
set(GAUXC_HAS_HDF5 TRUE CACHE BOOL "" FORCE)
message(STATUS "Enabling HDF5 Bindings")
- message(STATUS "HighFive REPO = ${GAUXC_HIGHFIVE_REPOSITORY}")
- message(STATUS "HighFive REV = ${GAUXC_HIGHFIVE_REVISION} ")
- FetchContent_Declare( HighFive
- GIT_REPOSITORY ${GAUXC_HIGHFIVE_REPOSITORY}
- GIT_TAG ${GAUXC_HIGHFIVE_REVISION}
- )
-
- set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" )
- set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" )
- set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" )
- #set(HIGHFIVE_PARALLEL_HDF5 ON CACHE BOOL "" )
- set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "" )
- FetchContent_MakeAvailable( HighFive )
+
+ find_package(HighFive)
+ if(HighFive_FOUND)
+ message(STATUS "Found installed HighFive")
+ else()
+ message(STATUS "HighFive not found, fetching from repository")
+ message(STATUS "HighFive REPO = ${GAUXC_HIGHFIVE_REPOSITORY}")
+ message(STATUS "HighFive REV = ${GAUXC_HIGHFIVE_REVISION} ")
+ FetchContent_Declare( HighFive
+ GIT_REPOSITORY ${GAUXC_HIGHFIVE_REPOSITORY}
+ GIT_TAG ${GAUXC_HIGHFIVE_REVISION}
+ )
+
+ set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" )
+ set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" )
+ set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" )
+ #set(HIGHFIVE_PARALLEL_HDF5 ON CACHE BOOL "" )
+ set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "" )
+ FetchContent_MakeAvailable( HighFive )
+ endif()

target_sources( gauxc PRIVATE hdf5_write.cxx hdf5_read.cxx )
target_link_libraries( gauxc PUBLIC HighFive )
@@ -32,4 +39,4 @@ if( GAUXC_ENABLE_HDF5 )
endif()
else()
message(STATUS "Disabling HDF5 Bindings")
-endif()
+endif()
\ No newline at end of file
Loading

0 comments on commit 6b4144e

Please sign in to comment.