From 95ae05dadb894f6257cad2176c73986bd41bd6fe Mon Sep 17 00:00:00 2001 From: Thijs Vogels Date: Tue, 31 Mar 2026 21:38:03 +0200 Subject: [PATCH 1/2] Guard OneDFT code with GAUXC_HAS_ONEDFT and remove unused CUDA header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix build failure when using CPU-only LibTorch with GAUXC_ENABLE_CUDA=ON: onedft_util.hpp included torch/csrc/cuda/CUDAPluggableAllocator.h which transitively requires c10/cuda/impl/cuda_cmake_macros.h — a header only present in CUDA-aware LibTorch distributions. Also fix build when GAUXC_ENABLE_ONEDFT=OFF: onedft_util.cxx was unconditionally compiled, pulling in torch/script.h even when LibTorch is not available. Changes: - Remove unused CUDAPluggableAllocator.h include from onedft_util.hpp (only used by commented-out code in device integrator) - Guard onedft_util.cxx compilation with if(GAUXC_HAS_ONEDFT) in CMake - Guard #include ..._onedft.hpp in host/device integrator .cxx files with #ifdef GAUXC_HAS_ONEDFT - Guard OneDFT method declarations in host integrator header with #ifdef GAUXC_HAS_ONEDFT and provide #else throw stubs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/xc_integrator/integrator_util/CMakeLists.txt | 6 ++++-- src/xc_integrator/integrator_util/onedft_util.hpp | 3 --- .../device/incore_replicated_xc_device_integrator.cxx | 2 ++ .../incore_replicated_xc_device_integrator_onedft.hpp | 1 + .../host/reference_replicated_xc_host_integrator.cxx | 2 ++ .../host/reference_replicated_xc_host_integrator.hpp | 10 ++++++++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/xc_integrator/integrator_util/CMakeLists.txt b/src/xc_integrator/integrator_util/CMakeLists.txt index 01b617a6..ab7635d5 100644 --- a/src/xc_integrator/integrator_util/CMakeLists.txt +++ b/src/xc_integrator/integrator_util/CMakeLists.txt @@ -11,5 +11,7 @@ # target_sources( gauxc PRIVATE integrator_common.cxx integral_bounds.cxx exx_screening.cxx - spherical_harmonics.cxx - onedft_util.cxx ) + spherical_harmonics.cxx ) +if( GAUXC_HAS_ONEDFT ) + target_sources( gauxc PRIVATE onedft_util.cxx ) +endif() diff --git a/src/xc_integrator/integrator_util/onedft_util.hpp b/src/xc_integrator/integrator_util/onedft_util.hpp index ccd5b2c6..6cf27e12 100644 --- a/src/xc_integrator/integrator_util/onedft_util.hpp +++ b/src/xc_integrator/integrator_util/onedft_util.hpp @@ -1,9 +1,6 @@ #include #include #include -#ifdef GAUXC_HAS_CUDA -#include -#endif #include #include diff --git a/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator.cxx b/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator.cxx index e3659db5..e7411944 100644 --- a/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator.cxx +++ b/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator.cxx @@ -16,7 +16,9 @@ #include "incore_replicated_xc_device_integrator_exx.hpp" #include "incore_replicated_xc_device_integrator_fxc_contraction.hpp" #include "incore_replicated_xc_device_integrator_dd.hpp" +#ifdef GAUXC_HAS_ONEDFT #include "incore_replicated_xc_device_integrator_onedft.hpp" +#endif namespace GauXC { namespace detail { diff --git a/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator_onedft.hpp b/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator_onedft.hpp index b742baa3..bc183e71 100644 --- a/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator_onedft.hpp +++ b/src/xc_integrator/replicated/device/incore_replicated_xc_device_integrator_onedft.hpp @@ -13,6 +13,7 @@ #include "device/common/device_blas.hpp" #include "integrator_util/onedft_util.hpp" #include +#include #include "device/cuda/cuda_backend.hpp" #include // for size_t diff --git a/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.cxx b/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.cxx index 7a0830a9..39d00001 100644 --- a/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.cxx +++ b/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.cxx @@ -17,7 +17,9 @@ #include "reference_replicated_xc_host_integrator_fxc_contraction.hpp" #include "reference_replicated_xc_host_integrator_dd_psi.hpp" #include "reference_replicated_xc_host_integrator_dd_psi_potential.hpp" +#ifdef GAUXC_HAS_ONEDFT #include "reference_replicated_xc_host_integrator_onedft.hpp" +#endif namespace GauXC::detail { diff --git a/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.hpp b/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.hpp index ce68930f..ab87877b 100644 --- a/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.hpp +++ b/src/xc_integrator/replicated/host/reference_replicated_xc_host_integrator.hpp @@ -75,9 +75,17 @@ class ReferenceReplicatedXCHostIntegrator : value_type* EXC, const IntegratorSettingsXC& ks_settings ) override; /// Onedft +#ifdef GAUXC_HAS_ONEDFT void eval_exc_vxc_onedft_( int64_t m, int64_t n, const value_type* Ps, int64_t ldps, const value_type* Pz, int64_t ldpz, value_type* VXCs, int64_t ldvxcs, value_type* VXCz, int64_t ldvxcz, value_type* EXC, const IntegratorSettingsXC& ks_settings ) override; +#else + void eval_exc_vxc_onedft_( int64_t, int64_t, const value_type*, int64_t, + const value_type*, int64_t, value_type*, int64_t, + value_type*, int64_t, value_type*, const IntegratorSettingsXC& ) override { + throw std::runtime_error("OneDFT support not compiled"); + } +#endif /// RKS EXC Gradient void eval_exc_grad_( int64_t m, int64_t n, const value_type* P, int64_t ldp, @@ -154,6 +162,7 @@ class ReferenceReplicatedXCHostIntegrator : void dd_psi_potential_local_work_( const value_type* X, value_type* Vddx, unsigned max_Ylm ); +#ifdef GAUXC_HAS_ONEDFT void pre_onedft_local_work_( const basis_type& basis, const value_type* Ps, int64_t ldps, const value_type* Pz, int64_t ldpz, value_type *N_EL, const bool is_gga, const bool is_mgga, const bool needs_laplacian); @@ -163,6 +172,7 @@ class ReferenceReplicatedXCHostIntegrator : value_type* VXCs, int64_t ldvxcs, value_type* VXCz, int64_t ldvxcz, const bool is_gga, const bool is_mgga, const bool needs_laplacian); +#endif public: From 91e261c7b95c80ab88b81d3a637657019c7527c3 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:06:05 +0200 Subject: [PATCH 2/2] Use GAUXC_ENABLE_ONEDFT in CMake --- src/xc_integrator/integrator_util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xc_integrator/integrator_util/CMakeLists.txt b/src/xc_integrator/integrator_util/CMakeLists.txt index ab7635d5..b78db0c0 100644 --- a/src/xc_integrator/integrator_util/CMakeLists.txt +++ b/src/xc_integrator/integrator_util/CMakeLists.txt @@ -12,6 +12,6 @@ target_sources( gauxc PRIVATE integrator_common.cxx integral_bounds.cxx exx_screening.cxx spherical_harmonics.cxx ) -if( GAUXC_HAS_ONEDFT ) +if( GAUXC_ENABLE_ONEDFT ) target_sources( gauxc PRIVATE onedft_util.cxx ) endif()