Refactor code to reduce inter-file dependencies.#7430
Open
mohanchen wants to merge 15 commits into
Open
Conversation
…depth from 25 to 4 - Move cal_mag() template function to new cal_mag.h header - Remove heavy includes (elecstate_lcao.h, dspin_lcao.h, density_matrix.h) from output_mulliken.h that were only needed by cal_mag() - Replace output_dmk.h and output_sk.h includes with forward declarations in output_mulliken.h (class only holds pointers) - Add output_dmk.h and output_sk.h includes to output_mulliken.cpp (implementation needs complete types) - Update ctrl_scf_lcao.cpp to include cal_mag.h instead of output_mulliken.h
added 3 commits
June 5, 2026 10:58
added 11 commits
June 5, 2026 12:38
Step 2-4 of include dependency refactoring for source_base/module_container/ATen/core/tensor.h: Step 2 - Create tensor_enums.h and decouple macros.h: - Extract DataType, DeviceType enums, DEVICE_CPU/DEVICE_GPU structs, and DataTypeToEnum/DeviceTypeToEnum template specializations from tensor_types.h into new tensor_enums.h - macros.h now includes tensor_enums.h instead of tensor_types.h, breaking the chain: macros.h -> tensor_types.h -> cuda.h/rocm.h - tensor_types.h includes tensor_enums.h and removes duplicate definitions - Added downstream includes in einsum_op.h, tensor_utils.h, output_device.cpp, diago_bpcg.h to resolve implicit dependencies Step 3 - Replace cuda.h/rocm.h with thrust/complex.h in tensor_types.h: - tensor_types.h only needs thrust::complex for DataTypeToEnum specializations, not the full GPU library headers (GetTypeCuda, GetTypeRocm, cublas/cusolver types) - Replaced #include <base/macros/cuda.h>/<base/macros/rocm.h> with #include <thrust/complex.h>, a lightweight header Step 4 - Remove array_ref.h dependency from tensor_accessor.h: - TensorAccessorBase::sizes() and strides() previously returned int_array_ref (from array_ref.h), but this type was rarely used by callers - Changed return type to const index_t* (raw pointer), removing the array_ref.h -> macros.h dependency chain - Added AT_HOST_DEVICE annotation (was AT_HOST only) Risk notes (documented in code comments): - macros.h no longer transitively provides GetTypeReal/PsiToContainer/ContainerToPsi; downstream code needing these must include tensor_types.h directly - tensor_types.h no longer transitively provides GetTypeThrust/GetTypeCuda/GetTypeRocm; GPU code needing these must include cuda.h/rocm.h directly - TensorAccessorBase::sizes()/strides() return const index_t* instead of int_array_ref; code using array_ref methods (.size(), iterators) must include array_ref.h directly
- Remove unnecessary #include "gint_dvlocal.h" from gint_interface.h - Add forward declarations for Parallel_Orbitals, UnitCell, Grid_Driver, LCAO_HS_Arrays - Move #include "gint_dvlocal.h" to gint_interface.cpp (only needed for cal_dvlocal_R_sparse implementation) This optimization reduces the include dependency depth for files that only use cal_gint_rho() and cal_gint_tau() functions, such as elecstate_lcao.cpp, which now has a significantly reduced dependency chain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…depth from 25 to 4
Reminder
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
Any changes of core modules? (ignore if not applicable)