GPU/CPU interoperability and X2C functionality #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Github copilot pull request summary
This pull request introduces significant improvements to the build system and codebase to better support both GPU-accelerated and CPU-only builds. It adds conditional logic for CUDA/GPU dependencies, improves compatibility by providing CPU fallbacks or error messages for GPU-only routines, and introduces new utility functions and interface enhancements. The changes also clarify when GPU code is active and ensure that code paths are appropriately guarded.
Build system and GPU/CPU support:
CMakeLists.txtin bothexamplesandsrc/integralsto conditionally enable CUDA, set GPU/CPU-specific libraries, and provide clear messages about the build mode. Now, GPU dependencies and linking are only included whenUSE_ACCis enabled, while CPU-only builds avoid linking unused GPU libraries. (examples/CMakeLists.txt,src/integrals/CMakeLists.txt) [1] [2] [3]Conditional GPU/CPU code execution:
#if USE_ACCpreprocessor guards throughout the codebase, especially incuda_util.cppandgpu_util.cpp. For CPU-only builds, functions that require GPU support now print an error and exit, preventing undefined behavior. (src/integrals/cuda_util.cpp,src/integrals/gpu_util.cpp) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]Interface and utility function enhancements:
mat_times_mat_at_cpufor matrix multiplication and an overloadedget_hcorefunction, improving flexibility and code reuse. (include/cpu_util.h,src/integrals/cpu_util.cpp,include/cintwrapper.h) [1] [2] [3]compute_integrals_gtointegrals.hfor more flexible integral computation.Input handling and conditional output:
main.cppto conditionally compute and write certain integrals (e.g.,pVp) based on theX2Cinput parameter, making the code more configurable and efficient. [1] [2]Minor cleanups and formatting:
include/cuda_util.h,include/cusp.h) [1] [2] [3]These changes collectively make the codebase more robust, modular, and easier to maintain for both GPU and CPU environments.