From 9812a95682e9da351185f1753f15de1616a6acf4 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 15 May 2026 20:28:56 +0800 Subject: [PATCH 1/5] remove uncessary inclusion of memory.h --- source/source_hsolver/hsolver_pw.h | 1 - source/source_lcao/module_deepks/test/klist.h | 1 - source/source_lcao/module_deepks/test/klist_1.cpp | 1 + source/source_lcao/module_deepks/test/parallel_orbitals.h | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/source/source_hsolver/hsolver_pw.h b/source/source_hsolver/hsolver_pw.h index cecce478eca..7300972cc5c 100644 --- a/source/source_hsolver/hsolver_pw.h +++ b/source/source_hsolver/hsolver_pw.h @@ -6,7 +6,6 @@ #include "source_base/macros.h" #include "source_basis/module_pw/pw_basis_k.h" #include -#include "source_base/memory.h" namespace hsolver { diff --git a/source/source_lcao/module_deepks/test/klist.h b/source/source_lcao/module_deepks/test/klist.h index 7400d82c458..373554e5497 100644 --- a/source/source_lcao/module_deepks/test/klist.h +++ b/source/source_lcao/module_deepks/test/klist.h @@ -3,7 +3,6 @@ #include "source_base/global_function.h" #include "source_base/matrix3.h" -#include "source_base/memory.h" #include "source_base/vector3.h" #include diff --git a/source/source_lcao/module_deepks/test/klist_1.cpp b/source/source_lcao/module_deepks/test/klist_1.cpp index 709a193eced..8a16988dfef 100644 --- a/source/source_lcao/module_deepks/test/klist_1.cpp +++ b/source/source_lcao/module_deepks/test/klist_1.cpp @@ -1,5 +1,6 @@ #include "klist.h" #include "source_io/module_parameter/parameter.h" +#include "source_base/memory.h" namespace Test_Deepks { K_Vectors::K_Vectors() diff --git a/source/source_lcao/module_deepks/test/parallel_orbitals.h b/source/source_lcao/module_deepks/test/parallel_orbitals.h index 5445ff87abc..0908a533d25 100644 --- a/source/source_lcao/module_deepks/test/parallel_orbitals.h +++ b/source/source_lcao/module_deepks/test/parallel_orbitals.h @@ -3,7 +3,6 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" namespace Test_Deepks { From cbf3ae0d3e6c6bbff107453a3cac9536d109764f Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 15 May 2026 20:39:49 +0800 Subject: [PATCH 2/5] change source_base/memory.h to source_base/record_memory.h --- source/source_base/CMakeLists.txt | 2 +- .../module_device/cuda/memory_op.cu | 2 +- .../source_base/module_device/memory_op.cpp | 2 +- .../module_mixing/broyden_mixing.cpp | 2 +- .../module_mixing/plain_mixing.cpp | 2 +- .../module_mixing/pulay_mixing.cpp | 2 +- source/source_base/record_memory.cpp | 505 ++++++++++++++++++ source/source_base/record_memory.h | 139 +++++ .../source_base/sph_bessel_recursive-d2.cpp | 2 +- source/source_base/test/CMakeLists.txt | 18 +- .../source_base/test_parallel/CMakeLists.txt | 4 +- .../module_ao/ORB_gaunt_table.cpp | 2 +- .../module_ao/test/CMakeLists.txt | 2 +- .../module_nao/two_center_bundle.cpp | 2 +- .../module_pw/kernels/test/CMakeLists.txt | 2 +- source/source_basis/module_pw/pw_basis_k.cpp | 2 +- .../module_pw/test/CMakeLists.txt | 2 +- source/source_cell/klist.cpp | 2 +- .../source_cell/module_neighbor/sltk_grid.cpp | 2 +- source/source_cell/test/CMakeLists.txt | 2 +- source/source_esolver/esolver_ks_lcaopw.cpp | 2 +- source/source_esolver/esolver_of_tool.cpp | 2 +- source/source_esolver/esolver_sdft_pw.cpp | 2 +- source/source_esolver/pw_others.cpp | 2 +- source/source_estate/elecstate.cpp | 2 +- source/source_estate/module_charge/charge.cpp | 2 +- .../module_charge/charge_init.cpp | 2 +- .../module_dm/density_matrix.cpp | 2 +- .../module_dm/density_matrix_io.cpp | 2 +- .../module_pot/potential_new.cpp | 2 +- .../module_pot/potential_types.cpp | 2 +- .../module_xc/test/CMakeLists.txt | 4 +- source/source_hsolver/hsolver_lcao.cpp | 2 +- source/source_hsolver/parallel_k2d.cpp | 2 +- source/source_io/module_output/cal_test.cpp | 2 +- source/source_io/module_wf/get_wf_lcao.cpp | 2 +- source/source_io/module_wf/write_wfc_nao.cpp | 2 +- source/source_io/test/CMakeLists.txt | 2 +- source/source_lcao/FORCE_gamma.cpp | 2 +- source/source_lcao/FORCE_k.cpp | 2 +- source/source_lcao/edm.cpp | 2 +- source/source_lcao/hamilt_lcao.cpp | 2 +- .../module_deepks/test/Makefile.Objects | 2 +- .../module_deepks/test/klist_1.cpp | 2 +- source/source_lcao/module_dftu/dftu.cpp | 2 +- .../source_lcao/module_gint/biggrid_info.cpp | 2 +- source/source_lcao/module_gint/gint_info.cpp | 2 +- .../module_hcontainer/hcontainer.cpp | 2 +- .../module_operator_lcao/dspin_lcao.cpp | 2 +- source/source_main/driver.cpp | 2 +- source/source_md/test/CMakeLists.txt | 2 +- source/source_psi/psi_initializer.cpp | 2 +- source/source_psi/psi_prepare.cpp | 2 +- .../module_pwdft/fs_nonlocal_tools.cpp | 2 +- .../module_pwdft/kernels/stress_op.cpp | 2 +- .../module_pwdft/onsite_proj_tools.cpp | 2 +- source/source_pw/module_pwdft/stress_nl.cpp | 2 +- .../module_pwdft/structure_factor.cpp | 2 +- .../module_pwdft/structure_factor_k.cpp | 2 +- .../module_pwdft/test/CMakeLists.txt | 2 +- source/source_pw/module_pwdft/vnl_pw.cpp | 2 +- .../source_pw/module_stodft/sto_elecond.cpp | 2 +- source/source_pw/module_stodft/sto_wf.cpp | 2 +- source/source_relax/test/CMakeLists.txt | 4 +- 64 files changed, 717 insertions(+), 73 deletions(-) create mode 100644 source/source_base/record_memory.cpp create mode 100644 source/source_base/record_memory.h diff --git a/source/source_base/CMakeLists.txt b/source/source_base/CMakeLists.txt index 142269fe0b5..49d01a9c408 100644 --- a/source/source_base/CMakeLists.txt +++ b/source/source_base/CMakeLists.txt @@ -36,7 +36,7 @@ add_library( mathzone_add1.cpp matrix.cpp matrix3.cpp - memory.cpp + record_memory.cpp mymath.cpp opt_CG.cpp opt_DCsrch.cpp diff --git a/source/source_base/module_device/cuda/memory_op.cu b/source/source_base/module_device/cuda/memory_op.cu index ccb52ae719e..71ba629e6d6 100644 --- a/source/source_base/module_device/cuda/memory_op.cu +++ b/source/source_base/module_device/cuda/memory_op.cu @@ -1,5 +1,5 @@ #include "source_base/module_device/memory_op.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include #include diff --git a/source/source_base/module_device/memory_op.cpp b/source/source_base/module_device/memory_op.cpp index d31d29c422e..2485b349dd6 100644 --- a/source/source_base/module_device/memory_op.cpp +++ b/source/source_base/module_device/memory_op.cpp @@ -1,6 +1,6 @@ #include "memory_op.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/tool_threading.h" #ifdef __DSP #include "source_base/kernels/dsp/dsp_connector.h" diff --git a/source/source_base/module_mixing/broyden_mixing.cpp b/source/source_base/module_mixing/broyden_mixing.cpp index 04852d7437e..660475870e7 100644 --- a/source/source_base/module_mixing/broyden_mixing.cpp +++ b/source/source_base/module_mixing/broyden_mixing.cpp @@ -1,7 +1,7 @@ #include "broyden_mixing.h" #include "source_base/module_external/lapack_connector.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/module_container/base/third_party/blas.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_base/module_mixing/plain_mixing.cpp b/source/source_base/module_mixing/plain_mixing.cpp index 591519e79f0..05eff22d766 100644 --- a/source/source_base/module_mixing/plain_mixing.cpp +++ b/source/source_base/module_mixing/plain_mixing.cpp @@ -1,6 +1,6 @@ #include "plain_mixing.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" namespace Base_Mixing diff --git a/source/source_base/module_mixing/pulay_mixing.cpp b/source/source_base/module_mixing/pulay_mixing.cpp index b342c0b5f35..a1c8030dd8b 100644 --- a/source/source_base/module_mixing/pulay_mixing.cpp +++ b/source/source_base/module_mixing/pulay_mixing.cpp @@ -1,7 +1,7 @@ #include "pulay_mixing.h" #include "source_base/module_external/lapack_connector.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" namespace Base_Mixing diff --git a/source/source_base/record_memory.cpp b/source/source_base/record_memory.cpp new file mode 100644 index 00000000000..46779670e16 --- /dev/null +++ b/source/source_base/record_memory.cpp @@ -0,0 +1,505 @@ +//========================================================== +// AUTHOR : mohan +// DATE : 2008-11-18 +//========================================================== +#include +#include "record_memory.h" +#include "global_variable.h" +#include "source_base/parallel_reduce.h" + +namespace ModuleBase +{ +// 8 bit = 1 Byte +// 1024 Byte = 1 KB +// 1024 KB = 1 MB +// 1024 MB = 1 GB + +const double memory_warning_threshold_mb = 20.0; + +double Memory::total = 0.0; +int Memory::complex_matrix_memory = 2*sizeof(double); // 16 byte +int Memory::double_memory = sizeof(double); // 8 byte +int Memory::int_memory = sizeof(int); // 4.0 Byte +int Memory::bool_memory = sizeof(bool); // 1.0 Byte +int Memory::float_memory = sizeof(float); // 4.0 Byte +int Memory::short_memory = sizeof(short); // 2.0 Byte + +int Memory::n_memory = 1000; +int Memory::n_now = 0; +bool Memory::init_flag = false; + +#if defined(__CUDA) || defined(__ROCM) + +double Memory::total_gpu = 0.0; +int Memory::n_now_gpu = 0; +bool Memory::init_flag_gpu = false; + +std::string *Memory::name_gpu; +std::string *Memory::class_name_gpu; +double *Memory::consume_gpu; + +#endif + + +std::string *Memory::name; +std::string *Memory::class_name; +double *Memory::consume; + +Memory::Memory() +{ +} + +Memory::~Memory() +{ +} + +double Memory::calculate_mem(const long &n_in,const std::string &type) +{ + double n = static_cast(n_in); + double mem = 0.0; + + double factor = 1.0/1024.0/1024.0; + double complex_matrix_mem = complex_matrix_memory * factor; + double double_mem = double_memory * factor; + double int_mem = int_memory * factor; + double bool_mem = bool_memory * factor; + double float_mem = float_memory * factor; + double short_mem = short_memory * factor; + + if(type=="ModuleBase::ComplexMatrix" || type=="complexmatrix" || type=="cdouble") + { + mem = complex_matrix_mem; + } + else if(type=="real" || type=="double") + { + mem = double_mem; + } + else if(type=="int") + { + mem = int_mem; + } + else if(type=="bool") + { + mem = bool_mem; + } + else if(type=="short") + { + mem = short_mem; + } + else if(type=="float") + { + mem = float_mem; + } + else if(type=="AtomLink") + { + mem = int_mem * 2 + double_mem * 3; + } + else if(type=="ModuleBase::Vector3") + { + mem = 3 * double_mem; + } + else + { + std::cout<<"not this type in memory storage : "<= n_memory) + { + std::cout<<" Error! Too many memories required."; + return 0.0; + } + + consume[find] = Memory::calculate_mem(n_in,type); + + if(consume[find] > memory_warning_threshold_mb) + { + print(name[find], consume[find]); + } + return consume[find]; +} + +void Memory::record +( + const std::string &name_in, + const long &n_in, + const bool accumulate +) +{ + if(!Memory::init_flag) + { + name = new std::string[n_memory]; + class_name = new std::string[n_memory]; + consume = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many memories has been recorded."; + return; + } + + const double factor = 1.0/1024.0/1024.0; + double size_mb = n_in * factor; + + if(accumulate) + { + consume[find] += size_mb; + Memory::total += size_mb; + } + else + { + if(consume[find] < size_mb) + { + Memory::total += size_mb - consume[find]; + consume[find] = size_mb; + if(consume[find] > memory_warning_threshold_mb) + { + print(name[find], consume[find]); + } + } + } + + return; +} + +#if defined(__CUDA) || defined(__ROCM) + +double Memory::record_gpu +( + const std::string &class_name_in, + const std::string &name_in, + const long &n_in, + const std::string &type, + const bool accumulate +) +{ + if(!Memory::init_flag_gpu) + { + name_gpu = new std::string[n_memory]; + class_name_gpu = new std::string[n_memory]; + consume_gpu = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many gpu memories required."; + return 0.0; + } + + consume_gpu[find] = Memory::calculate_mem(n_in,type); + + if(consume_gpu[find] > memory_warning_threshold_mb) + { + print(name_gpu[find], consume_gpu[find]); + } + return consume_gpu[find]; +} + +void Memory::record_gpu +( + const std::string &name_in, + const size_t &n_in, + const bool accumulate +) +{ + if(!Memory::init_flag_gpu) + { + name_gpu = new std::string[n_memory]; + class_name_gpu = new std::string[n_memory]; + consume_gpu = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many gpu memories has been recorded."; + return; + } + + const double factor = 1.0/1024.0/1024.0; + double size_mb = n_in * factor; + + if(accumulate) + { + consume_gpu[find] += size_mb; + Memory::total_gpu += size_mb; + } + else + { + if(consume_gpu[find] < size_mb) + { + Memory::total_gpu += size_mb - consume_gpu[find]; + consume_gpu[find] = size_mb; + if(consume_gpu[find] > memory_warning_threshold_mb) + { + print(name_gpu[find], consume_gpu[find]); + } + } + } + return; +} + +#endif + +void Memory::print(const std::string& mem_name, double size_mb) +{ + GlobalV::ofs_running <<"\n *** Memory Allocation Warning *** " + <<" "<< mem_name <<" "<< size_mb <<" MB" << std::endl; + return; +} + + +void Memory::finish(std::ofstream &ofs) +{ + print_all(ofs); + if(init_flag) + { + delete[] name; + delete[] class_name; + delete[] consume; + init_flag = false; + } +#if defined(__CUDA) || defined(__ROCM) + if(init_flag_gpu) + { + delete[] name_gpu; + delete[] class_name_gpu; + delete[] consume_gpu; + init_flag_gpu = false; + } +#endif + return; +} + +void Memory::print_all(std::ofstream &ofs) +{ + if(!init_flag) + { + return; + } + + const double small = 1.0; // unit is MB +#ifdef __MPI + Parallel_Reduce::reduce_all(Memory::total); +#if defined(__CUDA) || defined(__ROCM) + Parallel_Reduce::reduce_all(Memory::total_gpu); +#endif +#endif + ofs <<"\n NAME-------------------------|MEMORY(MB)------------------" << std::endl; + ofs << std::right; + ofs << std::setw(30)<< "total" << std::setw(15) <0); + + bool *print_flag = new bool[n_memory]; + + for(int i=0; i0); + + bool *print_flag_gpu = new bool[n_memory]; + + for(int i=0; i +#include + +namespace ModuleBase +{ + +/** + * @brief Record memory consumption during computation. + * @author Mohan + * @note 8 bit = 1 Byte; 1024 Byte = 1 KB; + * 1024 KB = 1 MB; 1024 MB = 1 GB + * + */ +class Memory +{ + public: + Memory(); + ~Memory(); + + /** + * @brief Record memory consumed during computation + * + * @param class_name The name of a class + * @param name The name of a quantity + * @param n The number of the quantity + * @param type The type of data + * @param accumulate Useless, always set false + * @return double + */ + static double record(const std::string &class_name, + const std::string &name, + const long &n, + const std::string &type, + const bool accumulate = false); + + /** + * @brief Record memory consumed during computation + * + * @param name The name of a quantity + * @param n The number of the quantity + * @param accumulate Useless, always set false + */ + static void record( + const std::string &name_in, + const long &n_in, + const bool accumulate = false + ); + +#if defined(__CUDA) || defined(__ROCM) + + /** + * @brief Record memory consumed on gpu during computation + * + * @param class_name The name of a class + * @param name The name of a quantity + * @param n The number of the quantity + * @param type The type of data + * @param accumulate Useless, always set false + * @return double + */ + static double record_gpu(const std::string &class_name, + const std::string &name, + const long &n, + const std::string &type, + const bool accumulate = false); + + /** + * @brief Record memory consumed on gpu during computation + * + * @param name The name of a quantity + * @param n The number of the quantity + * @param accumulate Useless, always set false + */ + static void record_gpu( + const std::string &name_in, + const size_t &n_in, + const bool accumulate = false + ); + +#endif + + static double &get_total(void) + { + return total; + } + + static void finish(std::ofstream &ofs); + + /** + * @brief Print memory consumed (> 1 MB) in a file + * + * @param ofs The output file stream for print out memory records + */ + static void print_all(std::ofstream &ofs); + + static void print(const std::string& name, double size_mb); + + /** + * @brief Calculate memory requirements for various + * types of data + * + * @param n The number of a type of data + * @param type The type of data + * @return double + */ + static double calculate_mem(const long &n, const std::string &type); + + private: + static double total; + static std::string *name; + static std::string *class_name; + static double *consume; + static int n_memory; + static int n_now; + static bool init_flag; + +#if defined(__CUDA) || defined(__ROCM) + static double total_gpu; + static std::string *name_gpu; + static std::string *class_name_gpu; + static double *consume_gpu; + static int n_now_gpu; + static bool init_flag_gpu; +#endif + + static int complex_matrix_memory; //(16 Byte) + static int double_memory; //(8 Byte) + static int int_memory; //(4 Byte) + static int bool_memory; + static int short_memory; //(2 Byte) + static int float_memory; //(4 Byte) +}; + +} // namespace ModuleBase + +#endif diff --git a/source/source_base/sph_bessel_recursive-d2.cpp b/source/source_base/sph_bessel_recursive-d2.cpp index f23074e9c3a..987e38cdf90 100644 --- a/source/source_base/sph_bessel_recursive-d2.cpp +++ b/source/source_base/sph_bessel_recursive-d2.cpp @@ -5,7 +5,7 @@ #include "sph_bessel_recursive.h" #include "constants.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include #include diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index 1042569d57b..b2d58f76633 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -18,21 +18,21 @@ AddTest( AddTest( TARGET MODULE_BASE_tool_quit LIBS parameter - SOURCES tool_quit_test.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp + SOURCES tool_quit_test.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_tool_check LIBS parameter - SOURCES tool_check_test.cpp ../tool_check.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp + SOURCES tool_check_test.cpp ../tool_check.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_memory - SOURCES memory_test.cpp ../memory.cpp ../parallel_reduce.cpp + SOURCES memory_test.cpp ../record_memory.cpp ../parallel_reduce.cpp ) ADDTest( TARGET MODULE_BASE_global_function LIBS parameter ${math_libs} - SOURCES global_function_test.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../memory.cpp ../timer.cpp + SOURCES global_function_test.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../record_memory.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_vector3 @@ -62,7 +62,7 @@ AddTest( AddTest( TARGET MODULE_BASE_complexarray LIBS parameter - SOURCES complexarray_test.cpp ../complexarray.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp + SOURCES complexarray_test.cpp ../complexarray.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_complexmatrix @@ -77,7 +77,7 @@ AddTest( AddTest( TARGET MODULE_BASE_sph_bessel_recursive LIBS parameter - SOURCES sph_bessel_recursive_test.cpp ../sph_bessel_recursive-d1.cpp ../sph_bessel_recursive-d2.cpp ../memory.cpp ../global_variable.cpp + SOURCES sph_bessel_recursive_test.cpp ../sph_bessel_recursive-d1.cpp ../sph_bessel_recursive-d2.cpp ../record_memory.cpp ../global_variable.cpp ) AddTest( TARGET MODULE_BASE_ylmreal @@ -157,19 +157,19 @@ AddTest( AddTest( TARGET MODULE_BASE_ylm LIBS parameter - SOURCES ylm_test.cpp ../ylm.cpp ../timer.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp + SOURCES ylm_test.cpp ../ylm.cpp ../timer.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ) AddTest( TARGET MODULE_BASE_global_file LIBS parameter - SOURCES global_file_test.cpp ../global_file.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../memory.cpp ../timer.cpp + SOURCES global_file_test.cpp ../global_file.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../record_memory.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_tool_title LIBS parameter - SOURCES tool_title_test.cpp ../tool_title.cpp ../global_variable.cpp ../global_function.cpp ../timer.cpp ../tool_quit.cpp ../global_file.cpp ../memory.cpp + SOURCES tool_title_test.cpp ../tool_title.cpp ../global_variable.cpp ../global_function.cpp ../timer.cpp ../tool_quit.cpp ../global_file.cpp ../record_memory.cpp ) AddTest( diff --git a/source/source_base/test_parallel/CMakeLists.txt b/source/source_base/test_parallel/CMakeLists.txt index 17c8a8e1155..a1fa7247725 100644 --- a/source/source_base/test_parallel/CMakeLists.txt +++ b/source/source_base/test_parallel/CMakeLists.txt @@ -7,13 +7,13 @@ AddTest( AddTest( TARGET MODULE_BASE_ParaGlobal LIBS parameter MPI::MPI_CXX - SOURCES parallel_global_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp ../parallel_reduce.cpp + SOURCES parallel_global_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ../timer.cpp ../parallel_reduce.cpp ) AddTest( TARGET MODULE_BASE_ParaReduce LIBS parameter MPI::MPI_CXX - SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp + SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../record_memory.cpp ../timer.cpp ) install(FILES parallel_common_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_basis/module_ao/ORB_gaunt_table.cpp b/source/source_basis/module_ao/ORB_gaunt_table.cpp index 416bda7505c..79f34a67cc1 100644 --- a/source/source_basis/module_ao/ORB_gaunt_table.cpp +++ b/source/source_basis/module_ao/ORB_gaunt_table.cpp @@ -2,7 +2,7 @@ #include #include "ORB_gaunt_table.h" #include "source_base/timer.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/mathzone.h" #include "source_base/global_function.h" #include "source_base/vector3.h" diff --git a/source/source_basis/module_ao/test/CMakeLists.txt b/source/source_basis/module_ao/test/CMakeLists.txt index c280937b28a..81aeb776326 100644 --- a/source/source_basis/module_ao/test/CMakeLists.txt +++ b/source/source_basis/module_ao/test/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND depend_files ../../../source_base/math_polyint.cpp ../../../source_base/math_ylmreal.cpp ../../../source_base/ylm.cpp - ../../../source_base/memory.cpp + ../../../source_base/record_memory.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp diff --git a/source/source_basis/module_nao/two_center_bundle.cpp b/source/source_basis/module_nao/two_center_bundle.cpp index b7c9dc9cfb0..9527b7d716e 100644 --- a/source/source_basis/module_nao/two_center_bundle.cpp +++ b/source/source_basis/module_nao/two_center_bundle.cpp @@ -1,7 +1,7 @@ #include "source_basis/module_nao/two_center_bundle.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_common.h" #include "source_base/ylm.h" #include "source_basis/module_nao/real_gaunt_table.h" diff --git a/source/source_basis/module_pw/kernels/test/CMakeLists.txt b/source/source_basis/module_pw/kernels/test/CMakeLists.txt index 7ee73e1df55..cba602b6bfc 100644 --- a/source/source_basis/module_pw/kernels/test/CMakeLists.txt +++ b/source/source_basis/module_pw/kernels/test/CMakeLists.txt @@ -7,7 +7,7 @@ AddTest( ../../../../source_base/tool_quit.cpp ../../../../source_base/global_variable.cpp ../../../../source_base/parallel_global.cpp ../../../../source_base/parallel_reduce.cpp ../../../../source_base/parallel_comm.cpp - ../../../../source_base/complexmatrix.cpp ../../../../source_base/matrix.cpp ../../../../source_base/memory.cpp + ../../../../source_base/complexmatrix.cpp ../../../../source_base/matrix.cpp ../../../../source_base/record_memory.cpp ../../../../source_base/libm/branred.cpp ../../../../source_base/libm/sincos.cpp ../../../../source_base/module_external/blas_connector_base.cpp ../../../../source_base/module_external/blas_connector_vector.cpp ../../../../source_base/module_external/blas_connector_matrix.cpp ) \ No newline at end of file diff --git a/source/source_basis/module_pw/pw_basis_k.cpp b/source/source_basis/module_pw/pw_basis_k.cpp index ece4674c4bf..2285ef664f4 100644 --- a/source/source_basis/module_pw/pw_basis_k.cpp +++ b/source/source_basis/module_pw/pw_basis_k.cpp @@ -2,7 +2,7 @@ #include "source_base/constants.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_basis/module_pw/test/CMakeLists.txt b/source/source_basis/module_pw/test/CMakeLists.txt index 6da769ea2f6..4549b06947c 100644 --- a/source/source_basis/module_pw/test/CMakeLists.txt +++ b/source/source_basis/module_pw/test/CMakeLists.txt @@ -3,7 +3,7 @@ AddTest( TARGET MODULE_PW_pw_test LIBS parameter ${math_libs} planewave device SOURCES ../../../source_base/matrix.cpp ../../../source_base/complexmatrix.cpp ../../../source_base/matrix3.cpp ../../../source_base/tool_quit.cpp - ../../../source_base/mymath.cpp ../../../source_base/timer.cpp ../../../source_base/memory.cpp + ../../../source_base/mymath.cpp ../../../source_base/timer.cpp ../../../source_base/record_memory.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp ../../../source_base/libm/branred.cpp ../../../source_base/libm/sincos.cpp ../../../source_base/module_device/memory_op.cpp diff --git a/source/source_cell/klist.cpp b/source/source_cell/klist.cpp index cca33fb8ba2..22f857a5550 100644 --- a/source/source_cell/klist.cpp +++ b/source/source_cell/klist.cpp @@ -2,7 +2,7 @@ #include "k_vector_utils.h" #include "source_base/formatter.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_common.h" #include "source_base/parallel_global.h" #include "source_base/parallel_reduce.h" diff --git a/source/source_cell/module_neighbor/sltk_grid.cpp b/source/source_cell/module_neighbor/sltk_grid.cpp index 9aad1a64e45..f6e4f4008b6 100644 --- a/source/source_cell/module_neighbor/sltk_grid.cpp +++ b/source/source_cell/module_neighbor/sltk_grid.cpp @@ -2,7 +2,7 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" Grid::Grid(const int& test_grid_in) : test_grid(test_grid_in) diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index c6eab25d01e..f3f5ae6f481 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -91,7 +91,7 @@ AddTest( TARGET MODULE_CELL_ParaKpoints LIBS parameter MPI::MPI_CXX SOURCES parallel_kpoints_test.cpp ../../source_base/global_variable.cpp ../../source_base/parallel_global.cpp - ../../source_base/parallel_common.cpp ../../source_base/parallel_comm.cpp ../parallel_kpoints.cpp ../../source_base/tool_quit.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/memory.cpp ../../source_base/timer.cpp ../../source_base/parallel_reduce.cpp + ../../source_base/parallel_common.cpp ../../source_base/parallel_comm.cpp ../parallel_kpoints.cpp ../../source_base/tool_quit.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/record_memory.cpp ../../source_base/timer.cpp ../../source_base/parallel_reduce.cpp ) # Add unit test for read_atoms_helper diff --git a/source/source_esolver/esolver_ks_lcaopw.cpp b/source/source_esolver/esolver_ks_lcaopw.cpp index c6154ab5b8b..66689955a05 100644 --- a/source/source_esolver/esolver_ks_lcaopw.cpp +++ b/source/source_esolver/esolver_ks_lcaopw.cpp @@ -16,7 +16,7 @@ //-----stress------------------ #include "source_pw/module_pwdft/stress_pw.h" //--------------------------------------------------- -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_estate/elecstate_pw.h" #include "source_pw/module_pwdft/hamilt_lcaopw.h" #include "source_pw/module_pwdft/hamilt_pw.h" diff --git a/source/source_esolver/esolver_of_tool.cpp b/source/source_esolver/esolver_of_tool.cpp index b54f4de53af..d72f0b67bdb 100644 --- a/source/source_esolver/esolver_of_tool.cpp +++ b/source/source_esolver/esolver_of_tool.cpp @@ -1,6 +1,6 @@ #include "esolver_of.h" #include "source_base/formatter.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_estate/module_pot/efield.h" #include "source_estate/module_pot/gatefield.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_esolver/esolver_sdft_pw.cpp b/source/source_esolver/esolver_sdft_pw.cpp index 02300eb3c58..c1ad88f70fd 100644 --- a/source/source_esolver/esolver_sdft_pw.cpp +++ b/source/source_esolver/esolver_sdft_pw.cpp @@ -1,7 +1,7 @@ #include "esolver_sdft_pw.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_estate/module_charge/symmetry_rho.h" #include "source_pw/module_stodft/sto_dos.h" #include "source_pw/module_stodft/sto_elecond.h" diff --git a/source/source_esolver/pw_others.cpp b/source/source_esolver/pw_others.cpp index 49f7465b46e..429f74fa0e3 100644 --- a/source/source_esolver/pw_others.cpp +++ b/source/source_esolver/pw_others.cpp @@ -1,5 +1,5 @@ #include "esolver_ks_pw.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/module_device/device.h" #include "source_io/module_bessel/numerical_basis.h" #include "source_io/module_bessel/numerical_descriptor.h" diff --git a/source/source_estate/elecstate.cpp b/source/source_estate/elecstate.cpp index 5e2c6a8ced9..c6d43280b5f 100644 --- a/source/source_estate/elecstate.cpp +++ b/source/source_estate/elecstate.cpp @@ -2,7 +2,7 @@ #include "source_io/module_parameter/parameter.h" #include "source_base/global_variable.h" #include "source_io/module_parameter/parameter.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/tool_title.h" #include "occupy.h" diff --git a/source/source_estate/module_charge/charge.cpp b/source/source_estate/module_charge/charge.cpp index 62a9e702f90..2c1297610d4 100644 --- a/source/source_estate/module_charge/charge.cpp +++ b/source/source_estate/module_charge/charge.cpp @@ -22,7 +22,7 @@ #include "source_base/global_variable.h" #include "source_base/libm/libm.h" #include "source_base/math_integral.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_threading.h" diff --git a/source/source_estate/module_charge/charge_init.cpp b/source/source_estate/module_charge/charge_init.cpp index 3b72e41903e..7be743e0d44 100644 --- a/source/source_estate/module_charge/charge_init.cpp +++ b/source/source_estate/module_charge/charge_init.cpp @@ -8,7 +8,7 @@ #include "source_base/libm/libm.h" #include "source_base/math_integral.h" #include "source_base/math_sphbes.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_threading.h" diff --git a/source/source_estate/module_dm/density_matrix.cpp b/source/source_estate/module_dm/density_matrix.cpp index d28b6ea19e9..de22dc2f496 100644 --- a/source/source_estate/module_dm/density_matrix.cpp +++ b/source/source_estate/module_dm/density_matrix.cpp @@ -2,7 +2,7 @@ #include "source_io/module_parameter/parameter.h" #include "source_base/libm/libm.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" #include "source_base/tool_quit.h" diff --git a/source/source_estate/module_dm/density_matrix_io.cpp b/source/source_estate/module_dm/density_matrix_io.cpp index 7ee383dfb81..57314ef95a0 100644 --- a/source/source_estate/module_dm/density_matrix_io.cpp +++ b/source/source_estate/module_dm/density_matrix_io.cpp @@ -2,7 +2,7 @@ #include "source_io/module_parameter/parameter.h" #include "source_base/libm/libm.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" #include "source_cell/klist.h" diff --git a/source/source_estate/module_pot/potential_new.cpp b/source/source_estate/module_pot/potential_new.cpp index 85bccb157a4..00996b4c675 100644 --- a/source/source_estate/module_pot/potential_new.cpp +++ b/source/source_estate/module_pot/potential_new.cpp @@ -2,7 +2,7 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_quit.h" #include "source_base/tool_title.h" diff --git a/source/source_estate/module_pot/potential_types.cpp b/source/source_estate/module_pot/potential_types.cpp index f8f1315d8e3..413d9b1ffb4 100644 --- a/source/source_estate/module_pot/potential_types.cpp +++ b/source/source_estate/module_pot/potential_types.cpp @@ -4,7 +4,7 @@ #include "gatefield.h" #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_quit.h" #include "source_base/tool_title.h" diff --git a/source/source_hamilt/module_xc/test/CMakeLists.txt b/source/source_hamilt/module_xc/test/CMakeLists.txt index 0b8bc888c23..82cd12aa8d3 100644 --- a/source/source_hamilt/module_xc/test/CMakeLists.txt +++ b/source/source_hamilt/module_xc/test/CMakeLists.txt @@ -37,7 +37,7 @@ AddTest( ../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp ../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp ../../../source_base/matrix.cpp - ../../../source_base/memory.cpp + ../../../source_base/record_memory.cpp ../../../source_base/libm/branred.cpp ../../../source_base/libm/sincos.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp @@ -75,7 +75,7 @@ AddTest( ../xc_functional_libxc_tools.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp ../../../source_base/matrix.cpp - ../../../source_base/memory.cpp + ../../../source_base/record_memory.cpp ../../../source_base/timer.cpp ../../../source_base/libm/branred.cpp ../../../source_base/libm/sincos.cpp diff --git a/source/source_hsolver/hsolver_lcao.cpp b/source/source_hsolver/hsolver_lcao.cpp index b1c7ba9c95e..18a4471d302 100644 --- a/source/source_hsolver/hsolver_lcao.cpp +++ b/source/source_hsolver/hsolver_lcao.cpp @@ -27,7 +27,7 @@ #include "source_base/global_variable.h" #include "source_base/module_device/device.h" #include "source_estate/elecstate_tools.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_estate/elecstate_lcao.h" #include "source_estate/module_dm/cal_dm_psi.h" diff --git a/source/source_hsolver/parallel_k2d.cpp b/source/source_hsolver/parallel_k2d.cpp index 30ac262258c..8b78020b3d4 100644 --- a/source/source_hsolver/parallel_k2d.cpp +++ b/source/source_hsolver/parallel_k2d.cpp @@ -3,7 +3,7 @@ #include "source_base/parallel_global.h" #include "source_base/module_external/scalapack_connector.h" #include "source_base/timer.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" template void Parallel_K2D::set_para_env(int nks, diff --git a/source/source_io/module_output/cal_test.cpp b/source/source_io/module_output/cal_test.cpp index d162bb7137b..8f3855b5572 100644 --- a/source/source_io/module_output/cal_test.cpp +++ b/source/source_io/module_output/cal_test.cpp @@ -3,7 +3,7 @@ #include "source_io/module_parameter/parameter.h" #undef private #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "cal_test.h" double Cal_Test::mporter=0.0; diff --git a/source/source_io/module_wf/get_wf_lcao.cpp b/source/source_io/module_wf/get_wf_lcao.cpp index d23dc085950..be00b469134 100644 --- a/source/source_io/module_wf/get_wf_lcao.cpp +++ b/source/source_io/module_wf/get_wf_lcao.cpp @@ -3,7 +3,7 @@ #include "source_base/module_external/blacs_connector.h" #include "source_io/module_output/cube_io.h" #include "source_io/module_wf/write_wfc_pw.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_lcao/module_gint/gint_env_gamma.h" #include "source_lcao/module_gint/gint_env_k.h" diff --git a/source/source_io/module_wf/write_wfc_nao.cpp b/source/source_io/module_wf/write_wfc_nao.cpp index 7c6c520a7b4..48e8fa9c893 100644 --- a/source/source_io/module_wf/write_wfc_nao.cpp +++ b/source/source_io/module_wf/write_wfc_nao.cpp @@ -1,7 +1,7 @@ #include "write_wfc_nao.h" #include "source_io/module_parameter/parameter.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" #include "source_base/parallel_2d.h" diff --git a/source/source_io/test/CMakeLists.txt b/source/source_io/test/CMakeLists.txt index 94c5e8e69bb..746e4d94747 100644 --- a/source/source_io/test/CMakeLists.txt +++ b/source/source_io/test/CMakeLists.txt @@ -73,7 +73,7 @@ AddTest( ../../source_base/parallel_common.cpp ../../source_base/parallel_global.cpp ../../source_base/parallel_comm.cpp - ../../source_base/tool_quit.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/memory.cpp ../../source_base/timer.cpp + ../../source_base/tool_quit.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/record_memory.cpp ../../source_base/timer.cpp ) AddTest( diff --git a/source/source_lcao/FORCE_gamma.cpp b/source/source_lcao/FORCE_gamma.cpp index 56489287baf..ef381d52bad 100644 --- a/source/source_lcao/FORCE_gamma.cpp +++ b/source/source_lcao/FORCE_gamma.cpp @@ -1,5 +1,5 @@ #include "FORCE.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_cell/module_neighbor/sltk_grid_driver.h" diff --git a/source/source_lcao/FORCE_k.cpp b/source/source_lcao/FORCE_k.cpp index ed07782da3c..6d3d578b8ef 100644 --- a/source/source_lcao/FORCE_k.cpp +++ b/source/source_lcao/FORCE_k.cpp @@ -1,5 +1,5 @@ #include "FORCE.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_threading.h" diff --git a/source/source_lcao/edm.cpp b/source/source_lcao/edm.cpp index 7ad1b30fbe7..70c39566093 100644 --- a/source/source_lcao/edm.cpp +++ b/source/source_lcao/edm.cpp @@ -1,7 +1,7 @@ #include "FORCE.h" #include "source_estate/module_dm/cal_dm_psi.h" #include "source_estate/elecstate_lcao.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_io/module_parameter/parameter.h" template<> elecstate::DensityMatrix Force_LCAO::cal_edm(const elecstate::ElecState* pelec, diff --git a/source/source_lcao/hamilt_lcao.cpp b/source/source_lcao/hamilt_lcao.cpp index 276db964696..69a4fdf3e1e 100644 --- a/source/source_lcao/hamilt_lcao.cpp +++ b/source/source_lcao/hamilt_lcao.cpp @@ -1,7 +1,7 @@ #include "source_lcao/hamilt_lcao.h" #include "source_base/global_variable.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_lcao/module_dftu/dftu.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_lcao/module_deepks/test/Makefile.Objects b/source/source_lcao/module_deepks/test/Makefile.Objects index 31b32cef5ab..b2aa27896c1 100644 --- a/source/source_lcao/module_deepks/test/Makefile.Objects +++ b/source/source_lcao/module_deepks/test/Makefile.Objects @@ -26,7 +26,7 @@ math_sphbes.o\ math_polyint.o\ math_ylmreal.o\ ylm.o\ -memory.o\ +record_memory.o\ matrix3.o\ matrix.o\ intarray.o\ diff --git a/source/source_lcao/module_deepks/test/klist_1.cpp b/source/source_lcao/module_deepks/test/klist_1.cpp index 8a16988dfef..254c5b9caee 100644 --- a/source/source_lcao/module_deepks/test/klist_1.cpp +++ b/source/source_lcao/module_deepks/test/klist_1.cpp @@ -1,6 +1,6 @@ #include "klist.h" #include "source_io/module_parameter/parameter.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" namespace Test_Deepks { K_Vectors::K_Vectors() diff --git a/source/source_lcao/module_dftu/dftu.cpp b/source/source_lcao/module_dftu/dftu.cpp index 2680aed37a6..b49bd2e00b1 100644 --- a/source/source_lcao/module_dftu/dftu.cpp +++ b/source/source_lcao/module_dftu/dftu.cpp @@ -4,7 +4,7 @@ #include "source_base/constants.h" #include "source_base/global_function.h" #include "source_base/inverse_matrix.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_estate/magnetism.h" #include "source_estate/module_charge/charge.h" diff --git a/source/source_lcao/module_gint/biggrid_info.cpp b/source/source_lcao/module_gint/biggrid_info.cpp index 061563735e4..cae8f6e2bd4 100644 --- a/source/source_lcao/module_gint/biggrid_info.cpp +++ b/source/source_lcao/module_gint/biggrid_info.cpp @@ -1,7 +1,7 @@ #include "biggrid_info.h" #include "gint_helper.h" #include "gint_type.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" namespace ModuleGint { diff --git a/source/source_lcao/module_gint/gint_info.cpp b/source/source_lcao/module_gint/gint_info.cpp index c162befb149..9cfa2e11a6c 100644 --- a/source/source_lcao/module_gint/gint_info.cpp +++ b/source/source_lcao/module_gint/gint_info.cpp @@ -4,7 +4,7 @@ #include "source_base/timer.h" #include "gint_info.h" #include "gint_type.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" namespace ModuleGint { diff --git a/source/source_lcao/module_hcontainer/hcontainer.cpp b/source/source_lcao/module_hcontainer/hcontainer.cpp index 6c4ff0d16bc..e99ca0f24aa 100644 --- a/source/source_lcao/module_hcontainer/hcontainer.cpp +++ b/source/source_lcao/module_hcontainer/hcontainer.cpp @@ -1,5 +1,5 @@ #include "hcontainer.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" namespace hamilt { diff --git a/source/source_lcao/module_operator_lcao/dspin_lcao.cpp b/source/source_lcao/module_operator_lcao/dspin_lcao.cpp index 7954ae8ab22..2768beac681 100644 --- a/source/source_lcao/module_operator_lcao/dspin_lcao.cpp +++ b/source/source_lcao/module_operator_lcao/dspin_lcao.cpp @@ -1,7 +1,7 @@ #include "dspin_lcao.h" #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_base/timer.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/tool_title.h" #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_main/driver.cpp b/source/source_main/driver.cpp index 9a802abfad2..4c7afcfc092 100644 --- a/source/source_main/driver.cpp +++ b/source/source_main/driver.cpp @@ -1,7 +1,7 @@ #include "source_main/driver.h" #include "source_base/global_file.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_esolver/esolver.h" #include "source_io/module_output/cal_test.h" diff --git a/source/source_md/test/CMakeLists.txt b/source/source_md/test/CMakeLists.txt index 4d685cc331f..514a12e244b 100644 --- a/source/source_md/test/CMakeLists.txt +++ b/source/source_md/test/CMakeLists.txt @@ -26,7 +26,7 @@ list(APPEND depend_files ../../source_base/module_external/blas_connector_base.cpp ../../source_base/module_external/blas_connector_matrix.cpp ../../source_base/module_external/blas_connector_vector.cpp - ../../source_base/memory.cpp + ../../source_base/record_memory.cpp ../../source_base/global_variable.cpp ../../source_base/global_function.cpp ../../source_base/global_file.cpp diff --git a/source/source_psi/psi_initializer.cpp b/source/source_psi/psi_initializer.cpp index e5dda9af381..6b96c3dff07 100644 --- a/source/source_psi/psi_initializer.cpp +++ b/source/source_psi/psi_initializer.cpp @@ -1,6 +1,6 @@ #include "psi_initializer.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_global.h" // basic functions support #include "source_base/timer.h" diff --git a/source/source_psi/psi_prepare.cpp b/source/source_psi/psi_prepare.cpp index 2f0530d8b96..8d58796b13c 100644 --- a/source/source_psi/psi_prepare.cpp +++ b/source/source_psi/psi_prepare.cpp @@ -1,7 +1,7 @@ #include "psi_prepare.h" #include "source_base/macros.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_device.h" #include "source_base/parallel_global.h" #include "source_base/timer.h" diff --git a/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp b/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp index 64f4015dafe..eced1194dd8 100644 --- a/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp +++ b/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp @@ -2,7 +2,7 @@ #include "source_base/math_polyint.h" #include "source_base/math_ylmreal.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_device.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_pw/module_pwdft/kernels/stress_op.cpp b/source/source_pw/module_pwdft/kernels/stress_op.cpp index 169b9c932c3..26a6e92f90a 100644 --- a/source/source_pw/module_pwdft/kernels/stress_op.cpp +++ b/source/source_pw/module_pwdft/kernels/stress_op.cpp @@ -4,7 +4,7 @@ #include "source_base/constants.h" #include "source_base/libm/libm.h" #include "source_base/math_polyint.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_pw/module_pwdft/kernels/vnl_op.h" #include "vnl_tools.hpp" diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.cpp b/source/source_pw/module_pwdft/onsite_proj_tools.cpp index 488b6e76177..070835ab80b 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.cpp +++ b/source/source_pw/module_pwdft/onsite_proj_tools.cpp @@ -2,7 +2,7 @@ #include "source_base/math_polyint.h" #include "source_base/math_ylmreal.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_pw/module_pwdft/stress_nl.cpp b/source/source_pw/module_pwdft/stress_nl.cpp index ae421d7b16c..bff2e04283e 100644 --- a/source/source_pw/module_pwdft/stress_nl.cpp +++ b/source/source_pw/module_pwdft/stress_nl.cpp @@ -2,7 +2,7 @@ #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" #include "source_base/math_ylmreal.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/module_device/device.h" #include "source_base/timer.h" #include "source_pw/module_pwdft/fs_nonlocal_tools.h" diff --git a/source/source_pw/module_pwdft/structure_factor.cpp b/source/source_pw/module_pwdft/structure_factor.cpp index c9dac45cc69..c1bb74e34c7 100644 --- a/source/source_pw/module_pwdft/structure_factor.cpp +++ b/source/source_pw/module_pwdft/structure_factor.cpp @@ -4,7 +4,7 @@ #include "structure_factor.h" #include "source_base/constants.h" #include "source_base/math_bspline.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/libm/libm.h" diff --git a/source/source_pw/module_pwdft/structure_factor_k.cpp b/source/source_pw/module_pwdft/structure_factor_k.cpp index 732323c6cc8..1daf67c1a52 100644 --- a/source/source_pw/module_pwdft/structure_factor_k.cpp +++ b/source/source_pw/module_pwdft/structure_factor_k.cpp @@ -1,4 +1,4 @@ -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_pw/module_pwdft/kernels/wf_op.h" #include "source_base/module_device/device.h" diff --git a/source/source_pw/module_pwdft/test/CMakeLists.txt b/source/source_pw/module_pwdft/test/CMakeLists.txt index 2a588d1729c..17f517fb548 100644 --- a/source/source_pw/module_pwdft/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/test/CMakeLists.txt @@ -13,7 +13,7 @@ AddTest( ../../../source_base/tool_quit.cpp ../../../source_base/global_variable.cpp ../../../source_base/global_file.cpp - ../../../source_base/memory.cpp + ../../../source_base/record_memory.cpp ../../../source_base/timer.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp ../../../source_base/parallel_global.cpp diff --git a/source/source_pw/module_pwdft/vnl_pw.cpp b/source/source_pw/module_pwdft/vnl_pw.cpp index ac149130a9d..49fdde43ab8 100644 --- a/source/source_pw/module_pwdft/vnl_pw.cpp +++ b/source/source_pw/module_pwdft/vnl_pw.cpp @@ -9,7 +9,7 @@ #include "source_io/module_output/output.h" #include "source_base/math_sphbes.h" #include "source_base/math_ylmreal.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/module_device/device.h" #include "source_base/timer.h" diff --git a/source/source_pw/module_stodft/sto_elecond.cpp b/source/source_pw/module_stodft/sto_elecond.cpp index 59117dcbaec..1d0f55345a4 100644 --- a/source/source_pw/module_stodft/sto_elecond.cpp +++ b/source/source_pw/module_stodft/sto_elecond.cpp @@ -2,7 +2,7 @@ #include "source_base/complexmatrix.h" #include "source_base/constants.h" -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_base/module_container/ATen/tensor.h" #include "source_base/parallel_device.h" #include "source_base/parallel_reduce.h" diff --git a/source/source_pw/module_stodft/sto_wf.cpp b/source/source_pw/module_stodft/sto_wf.cpp index 2de8a8c28c9..fc187775668 100644 --- a/source/source_pw/module_stodft/sto_wf.cpp +++ b/source/source_pw/module_stodft/sto_wf.cpp @@ -1,7 +1,7 @@ #include "sto_wf.h" #include "source_base/parallel_comm.h" // use POOL_WORLD -#include "source_base/memory.h" +#include "source_base/record_memory.h" #include "source_io/module_parameter/parameter.h" #include diff --git a/source/source_relax/test/CMakeLists.txt b/source/source_relax/test/CMakeLists.txt index 5bb86f60e6e..eda8790c5b3 100644 --- a/source/source_relax/test/CMakeLists.txt +++ b/source/source_relax/test/CMakeLists.txt @@ -9,12 +9,12 @@ install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_RELAX_relax_new_line_search LIBS parameter - SOURCES line_search_test.cpp ../line_search.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/memory.cpp ../../source_base/timer.cpp ../../source_base/tool_quit.cpp + SOURCES line_search_test.cpp ../line_search.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/record_memory.cpp ../../source_base/timer.cpp ../../source_base/tool_quit.cpp ) AddTest( TARGET MODULE_RELAX_relax_new_relax - SOURCES relax_test.cpp ../relax_sync.cpp ../line_search.cpp ../../source_base/tool_quit.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/memory.cpp ../../source_base/timer.cpp + SOURCES relax_test.cpp ../relax_sync.cpp ../line_search.cpp ../../source_base/tool_quit.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/record_memory.cpp ../../source_base/timer.cpp ../../source_base/matrix3.cpp ../../source_base/intarray.cpp ../../source_base/tool_title.cpp ../../source_base/global_function.cpp ../../source_base/complexmatrix.cpp ../../source_base/matrix.cpp ../../source_base/complexarray.cpp ../../source_base/tool_quit.cpp ../../source_base/realarray.cpp From ae770149aa27937723c6d90f3a604745e74ff093 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 15 May 2026 20:54:54 +0800 Subject: [PATCH 3/5] delete useless inclusion of record_memory.h --- source/source_base/module_mixing/broyden_mixing.cpp | 1 - source/source_base/module_mixing/plain_mixing.cpp | 1 - source/source_base/module_mixing/pulay_mixing.cpp | 1 - source/source_cell/klist.cpp | 1 - source/source_cell/module_neighbor/sltk_grid.cpp | 1 - source/source_esolver/esolver_ks_lcaopw.cpp | 1 - source/source_esolver/pw_others.cpp | 1 - source/source_estate/elecstate.cpp | 3 +-- source/source_estate/module_charge/charge_init.cpp | 1 - source/source_estate/module_pot/potential_types.cpp | 1 - source/source_io/module_wf/get_wf_lcao.cpp | 1 - source/source_psi/psi_initializer.cpp | 1 - source/source_pw/module_pwdft/fs_nonlocal_tools.cpp | 1 - source/source_pw/module_pwdft/kernels/stress_op.cpp | 1 - source/source_pw/module_pwdft/onsite_proj_tools.cpp | 1 - source/source_pw/module_pwdft/stress_nl.cpp | 1 - source/source_pw/module_pwdft/structure_factor_k.cpp | 1 - 17 files changed, 1 insertion(+), 18 deletions(-) diff --git a/source/source_base/module_mixing/broyden_mixing.cpp b/source/source_base/module_mixing/broyden_mixing.cpp index 660475870e7..ca9ae2cb6b6 100644 --- a/source/source_base/module_mixing/broyden_mixing.cpp +++ b/source/source_base/module_mixing/broyden_mixing.cpp @@ -1,7 +1,6 @@ #include "broyden_mixing.h" #include "source_base/module_external/lapack_connector.h" -#include "source_base/record_memory.h" #include "source_base/module_container/base/third_party/blas.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_base/module_mixing/plain_mixing.cpp b/source/source_base/module_mixing/plain_mixing.cpp index 05eff22d766..fb570cc53f2 100644 --- a/source/source_base/module_mixing/plain_mixing.cpp +++ b/source/source_base/module_mixing/plain_mixing.cpp @@ -1,6 +1,5 @@ #include "plain_mixing.h" -#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" namespace Base_Mixing diff --git a/source/source_base/module_mixing/pulay_mixing.cpp b/source/source_base/module_mixing/pulay_mixing.cpp index a1c8030dd8b..71905fbaa13 100644 --- a/source/source_base/module_mixing/pulay_mixing.cpp +++ b/source/source_base/module_mixing/pulay_mixing.cpp @@ -1,7 +1,6 @@ #include "pulay_mixing.h" #include "source_base/module_external/lapack_connector.h" -#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" namespace Base_Mixing diff --git a/source/source_cell/klist.cpp b/source/source_cell/klist.cpp index 22f857a5550..1fd028ccc6e 100644 --- a/source/source_cell/klist.cpp +++ b/source/source_cell/klist.cpp @@ -2,7 +2,6 @@ #include "k_vector_utils.h" #include "source_base/formatter.h" -#include "source_base/record_memory.h" #include "source_base/parallel_common.h" #include "source_base/parallel_global.h" #include "source_base/parallel_reduce.h" diff --git a/source/source_cell/module_neighbor/sltk_grid.cpp b/source/source_cell/module_neighbor/sltk_grid.cpp index f6e4f4008b6..2fe7a77b8ea 100644 --- a/source/source_cell/module_neighbor/sltk_grid.cpp +++ b/source/source_cell/module_neighbor/sltk_grid.cpp @@ -2,7 +2,6 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/record_memory.h" #include "source_base/timer.h" Grid::Grid(const int& test_grid_in) : test_grid(test_grid_in) diff --git a/source/source_esolver/esolver_ks_lcaopw.cpp b/source/source_esolver/esolver_ks_lcaopw.cpp index 66689955a05..6c5cb703bfa 100644 --- a/source/source_esolver/esolver_ks_lcaopw.cpp +++ b/source/source_esolver/esolver_ks_lcaopw.cpp @@ -16,7 +16,6 @@ //-----stress------------------ #include "source_pw/module_pwdft/stress_pw.h" //--------------------------------------------------- -#include "source_base/record_memory.h" #include "source_estate/elecstate_pw.h" #include "source_pw/module_pwdft/hamilt_lcaopw.h" #include "source_pw/module_pwdft/hamilt_pw.h" diff --git a/source/source_esolver/pw_others.cpp b/source/source_esolver/pw_others.cpp index 429f74fa0e3..bbacac36566 100644 --- a/source/source_esolver/pw_others.cpp +++ b/source/source_esolver/pw_others.cpp @@ -1,5 +1,4 @@ #include "esolver_ks_pw.h" -#include "source_base/record_memory.h" #include "source_base/module_device/device.h" #include "source_io/module_bessel/numerical_basis.h" #include "source_io/module_bessel/numerical_descriptor.h" diff --git a/source/source_estate/elecstate.cpp b/source/source_estate/elecstate.cpp index c6d43280b5f..d3af34ccd53 100644 --- a/source/source_estate/elecstate.cpp +++ b/source/source_estate/elecstate.cpp @@ -1,8 +1,7 @@ #include "elecstate.h" #include "source_io/module_parameter/parameter.h" -#include "source_base/global_variable.h" #include "source_io/module_parameter/parameter.h" -#include "source_base/record_memory.h" +#include "source_io/module_parameter/parameter.h" #include "source_base/parallel_reduce.h" #include "source_base/tool_title.h" #include "occupy.h" diff --git a/source/source_estate/module_charge/charge_init.cpp b/source/source_estate/module_charge/charge_init.cpp index 7be743e0d44..ed3c62b0fc1 100644 --- a/source/source_estate/module_charge/charge_init.cpp +++ b/source/source_estate/module_charge/charge_init.cpp @@ -8,7 +8,6 @@ #include "source_base/libm/libm.h" #include "source_base/math_integral.h" #include "source_base/math_sphbes.h" -#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_threading.h" diff --git a/source/source_estate/module_pot/potential_types.cpp b/source/source_estate/module_pot/potential_types.cpp index 413d9b1ffb4..37a93371059 100644 --- a/source/source_estate/module_pot/potential_types.cpp +++ b/source/source_estate/module_pot/potential_types.cpp @@ -4,7 +4,6 @@ #include "gatefield.h" #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_base/tool_quit.h" #include "source_base/tool_title.h" diff --git a/source/source_io/module_wf/get_wf_lcao.cpp b/source/source_io/module_wf/get_wf_lcao.cpp index be00b469134..cadf8d0edc0 100644 --- a/source/source_io/module_wf/get_wf_lcao.cpp +++ b/source/source_io/module_wf/get_wf_lcao.cpp @@ -3,7 +3,6 @@ #include "source_base/module_external/blacs_connector.h" #include "source_io/module_output/cube_io.h" #include "source_io/module_wf/write_wfc_pw.h" -#include "source_base/record_memory.h" #include "source_lcao/module_gint/gint_env_gamma.h" #include "source_lcao/module_gint/gint_env_k.h" diff --git a/source/source_psi/psi_initializer.cpp b/source/source_psi/psi_initializer.cpp index 6b96c3dff07..2432c39e0f3 100644 --- a/source/source_psi/psi_initializer.cpp +++ b/source/source_psi/psi_initializer.cpp @@ -1,6 +1,5 @@ #include "psi_initializer.h" -#include "source_base/record_memory.h" #include "source_base/parallel_global.h" // basic functions support #include "source_base/timer.h" diff --git a/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp b/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp index eced1194dd8..072a80a23c3 100644 --- a/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp +++ b/source/source_pw/module_pwdft/fs_nonlocal_tools.cpp @@ -2,7 +2,6 @@ #include "source_base/math_polyint.h" #include "source_base/math_ylmreal.h" -#include "source_base/record_memory.h" #include "source_base/parallel_device.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_pw/module_pwdft/kernels/stress_op.cpp b/source/source_pw/module_pwdft/kernels/stress_op.cpp index 26a6e92f90a..0afa7b3c6a9 100644 --- a/source/source_pw/module_pwdft/kernels/stress_op.cpp +++ b/source/source_pw/module_pwdft/kernels/stress_op.cpp @@ -4,7 +4,6 @@ #include "source_base/constants.h" #include "source_base/libm/libm.h" #include "source_base/math_polyint.h" -#include "source_base/record_memory.h" #include "source_pw/module_pwdft/kernels/vnl_op.h" #include "vnl_tools.hpp" diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.cpp b/source/source_pw/module_pwdft/onsite_proj_tools.cpp index 070835ab80b..53bca1746b7 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.cpp +++ b/source/source_pw/module_pwdft/onsite_proj_tools.cpp @@ -2,7 +2,6 @@ #include "source_base/math_polyint.h" #include "source_base/math_ylmreal.h" -#include "source_base/record_memory.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" #include "source_base/tool_title.h" diff --git a/source/source_pw/module_pwdft/stress_nl.cpp b/source/source_pw/module_pwdft/stress_nl.cpp index bff2e04283e..7b9b84925cb 100644 --- a/source/source_pw/module_pwdft/stress_nl.cpp +++ b/source/source_pw/module_pwdft/stress_nl.cpp @@ -2,7 +2,6 @@ #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" #include "source_base/math_ylmreal.h" -#include "source_base/record_memory.h" #include "source_base/module_device/device.h" #include "source_base/timer.h" #include "source_pw/module_pwdft/fs_nonlocal_tools.h" diff --git a/source/source_pw/module_pwdft/structure_factor_k.cpp b/source/source_pw/module_pwdft/structure_factor_k.cpp index 1daf67c1a52..f5ce21c7bf7 100644 --- a/source/source_pw/module_pwdft/structure_factor_k.cpp +++ b/source/source_pw/module_pwdft/structure_factor_k.cpp @@ -1,4 +1,3 @@ -#include "source_base/record_memory.h" #include "source_base/timer.h" #include "source_pw/module_pwdft/kernels/wf_op.h" #include "source_base/module_device/device.h" From 30dddb866875fc0d4b9ed5c983f5b545d3506e9d Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 15 May 2026 21:02:04 +0800 Subject: [PATCH 4/5] Remove old memory files --- source/source_base/memory.cpp | 505 ---------------------------------- source/source_base/memory.h | 139 ---------- 2 files changed, 644 deletions(-) delete mode 100644 source/source_base/memory.cpp delete mode 100644 source/source_base/memory.h diff --git a/source/source_base/memory.cpp b/source/source_base/memory.cpp deleted file mode 100644 index dd927de6ea3..00000000000 --- a/source/source_base/memory.cpp +++ /dev/null @@ -1,505 +0,0 @@ -//========================================================== -// AUTHOR : mohan -// DATE : 2008-11-18 -//========================================================== -#include -#include "memory.h" -#include "global_variable.h" -#include "source_base/parallel_reduce.h" - -namespace ModuleBase -{ -// 8 bit = 1 Byte -// 1024 Byte = 1 KB -// 1024 KB = 1 MB -// 1024 MB = 1 GB - -const double memory_warning_threshold_mb = 20.0; - -double Memory::total = 0.0; -int Memory::complex_matrix_memory = 2*sizeof(double); // 16 byte -int Memory::double_memory = sizeof(double); // 8 byte -int Memory::int_memory = sizeof(int); // 4.0 Byte -int Memory::bool_memory = sizeof(bool); // 1.0 Byte -int Memory::float_memory = sizeof(float); // 4.0 Byte -int Memory::short_memory = sizeof(short); // 2.0 Byte - -int Memory::n_memory = 1000; -int Memory::n_now = 0; -bool Memory::init_flag = false; - -#if defined(__CUDA) || defined(__ROCM) - -double Memory::total_gpu = 0.0; -int Memory::n_now_gpu = 0; -bool Memory::init_flag_gpu = false; - -std::string *Memory::name_gpu; -std::string *Memory::class_name_gpu; -double *Memory::consume_gpu; - -#endif - - -std::string *Memory::name; -std::string *Memory::class_name; -double *Memory::consume; - -Memory::Memory() -{ -} - -Memory::~Memory() -{ -} - -double Memory::calculate_mem(const long &n_in,const std::string &type) -{ - double n = static_cast(n_in); - double mem = 0.0; - - double factor = 1.0/1024.0/1024.0; - double complex_matrix_mem = complex_matrix_memory * factor; - double double_mem = double_memory * factor; - double int_mem = int_memory * factor; - double bool_mem = bool_memory * factor; - double float_mem = float_memory * factor; - double short_mem = short_memory * factor; - - if(type=="ModuleBase::ComplexMatrix" || type=="complexmatrix" || type=="cdouble") - { - mem = complex_matrix_mem; - } - else if(type=="real" || type=="double") - { - mem = double_mem; - } - else if(type=="int") - { - mem = int_mem; - } - else if(type=="bool") - { - mem = bool_mem; - } - else if(type=="short") - { - mem = short_mem; - } - else if(type=="float") - { - mem = float_mem; - } - else if(type=="AtomLink") - { - mem = int_mem * 2 + double_mem * 3; - } - else if(type=="ModuleBase::Vector3") - { - mem = 3 * double_mem; - } - else - { - std::cout<<"not this type in memory storage : "<= n_memory) - { - std::cout<<" Error! Too many memories required."; - return 0.0; - } - - consume[find] = Memory::calculate_mem(n_in,type); - - if(consume[find] > memory_warning_threshold_mb) - { - print(name[find], consume[find]); - } - return consume[find]; -} - -void Memory::record -( - const std::string &name_in, - const long &n_in, - const bool accumulate -) -{ - if(!Memory::init_flag) - { - name = new std::string[n_memory]; - class_name = new std::string[n_memory]; - consume = new double[n_memory]; - for(int i=0;i= n_memory) - { - std::cout<<" Error! Too many memories has been recorded."; - return; - } - - const double factor = 1.0/1024.0/1024.0; - double size_mb = n_in * factor; - - if(accumulate) - { - consume[find] += size_mb; - Memory::total += size_mb; - } - else - { - if(consume[find] < size_mb) - { - Memory::total += size_mb - consume[find]; - consume[find] = size_mb; - if(consume[find] > memory_warning_threshold_mb) - { - print(name[find], consume[find]); - } - } - } - - return; -} - -#if defined(__CUDA) || defined(__ROCM) - -double Memory::record_gpu -( - const std::string &class_name_in, - const std::string &name_in, - const long &n_in, - const std::string &type, - const bool accumulate -) -{ - if(!Memory::init_flag_gpu) - { - name_gpu = new std::string[n_memory]; - class_name_gpu = new std::string[n_memory]; - consume_gpu = new double[n_memory]; - for(int i=0;i= n_memory) - { - std::cout<<" Error! Too many gpu memories required."; - return 0.0; - } - - consume_gpu[find] = Memory::calculate_mem(n_in,type); - - if(consume_gpu[find] > memory_warning_threshold_mb) - { - print(name_gpu[find], consume_gpu[find]); - } - return consume_gpu[find]; -} - -void Memory::record_gpu -( - const std::string &name_in, - const size_t &n_in, - const bool accumulate -) -{ - if(!Memory::init_flag_gpu) - { - name_gpu = new std::string[n_memory]; - class_name_gpu = new std::string[n_memory]; - consume_gpu = new double[n_memory]; - for(int i=0;i= n_memory) - { - std::cout<<" Error! Too many gpu memories has been recorded."; - return; - } - - const double factor = 1.0/1024.0/1024.0; - double size_mb = n_in * factor; - - if(accumulate) - { - consume_gpu[find] += size_mb; - Memory::total_gpu += size_mb; - } - else - { - if(consume_gpu[find] < size_mb) - { - Memory::total_gpu += size_mb - consume_gpu[find]; - consume_gpu[find] = size_mb; - if(consume_gpu[find] > memory_warning_threshold_mb) - { - print(name_gpu[find], consume_gpu[find]); - } - } - } - return; -} - -#endif - -void Memory::print(const std::string& mem_name, double size_mb) -{ - GlobalV::ofs_running <<"\n *** Memory Allocation Warning *** " - <<" "<< mem_name <<" "<< size_mb <<" MB" << std::endl; - return; -} - - -void Memory::finish(std::ofstream &ofs) -{ - print_all(ofs); - if(init_flag) - { - delete[] name; - delete[] class_name; - delete[] consume; - init_flag = false; - } -#if defined(__CUDA) || defined(__ROCM) - if(init_flag_gpu) - { - delete[] name_gpu; - delete[] class_name_gpu; - delete[] consume_gpu; - init_flag_gpu = false; - } -#endif - return; -} - -void Memory::print_all(std::ofstream &ofs) -{ - if(!init_flag) - { - return; - } - - const double small = 1.0; // unit is MB -#ifdef __MPI - Parallel_Reduce::reduce_all(Memory::total); -#if defined(__CUDA) || defined(__ROCM) - Parallel_Reduce::reduce_all(Memory::total_gpu); -#endif -#endif - ofs <<"\n NAME-------------------------|MEMORY(MB)------------------" << std::endl; - ofs << std::right; - ofs << std::setw(30)<< "total" << std::setw(15) <0); - - bool *print_flag = new bool[n_memory]; - - for(int i=0; i0); - - bool *print_flag_gpu = new bool[n_memory]; - - for(int i=0; i -#include - -namespace ModuleBase -{ - -/** - * @brief Record memory consumption during computation. - * @author Mohan - * @note 8 bit = 1 Byte; 1024 Byte = 1 KB; - * 1024 KB = 1 MB; 1024 MB = 1 GB - * - */ -class Memory -{ - public: - Memory(); - ~Memory(); - - /** - * @brief Record memory consumed during computation - * - * @param class_name The name of a class - * @param name The name of a quantity - * @param n The number of the quantity - * @param type The type of data - * @param accumulate Useless, always set false - * @return double - */ - static double record(const std::string &class_name, - const std::string &name, - const long &n, - const std::string &type, - const bool accumulate = false); - - /** - * @brief Record memory consumed during computation - * - * @param name The name of a quantity - * @param n The number of the quantity - * @param accumulate Useless, always set false - */ - static void record( - const std::string &name_in, - const long &n_in, - const bool accumulate = false - ); - -#if defined(__CUDA) || defined(__ROCM) - - /** - * @brief Record memory consumed on gpu during computation - * - * @param class_name The name of a class - * @param name The name of a quantity - * @param n The number of the quantity - * @param type The type of data - * @param accumulate Useless, always set false - * @return double - */ - static double record_gpu(const std::string &class_name, - const std::string &name, - const long &n, - const std::string &type, - const bool accumulate = false); - - /** - * @brief Record memory consumed on gpu during computation - * - * @param name The name of a quantity - * @param n The number of the quantity - * @param accumulate Useless, always set false - */ - static void record_gpu( - const std::string &name_in, - const size_t &n_in, - const bool accumulate = false - ); - -#endif - - static double &get_total(void) - { - return total; - } - - static void finish(std::ofstream &ofs); - - /** - * @brief Print memory consumed (> 1 MB) in a file - * - * @param ofs The output file stream for print out memory records - */ - static void print_all(std::ofstream &ofs); - - static void print(const std::string& name, double size_mb); - - /** - * @brief Calculate memory requirements for various - * types of data - * - * @param n The number of a type of data - * @param type The type of data - * @return double - */ - static double calculate_mem(const long &n, const std::string &type); - - private: - static double total; - static std::string *name; - static std::string *class_name; - static double *consume; - static int n_memory; - static int n_now; - static bool init_flag; - -#if defined(__CUDA) || defined(__ROCM) - static double total_gpu; - static std::string *name_gpu; - static std::string *class_name_gpu; - static double *consume_gpu; - static int n_now_gpu; - static bool init_flag_gpu; -#endif - - static int complex_matrix_memory; //(16 Byte) - static int double_memory; //(8 Byte) - static int int_memory; //(4 Byte) - static int bool_memory; - static int short_memory; //(2 Byte) - static int float_memory; //(4 Byte) -}; - -} // namespace ModuleBase - -#endif From dedd8ba55b7e9444f8d268588a31fdcd03ee8c82 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 15 May 2026 21:03:16 +0800 Subject: [PATCH 5/5] Revert "Remove old memory files" This reverts commit 30dddb866875fc0d4b9ed5c983f5b545d3506e9d. --- source/source_base/memory.cpp | 505 ++++++++++++++++++++++++++++++++++ source/source_base/memory.h | 139 ++++++++++ 2 files changed, 644 insertions(+) create mode 100644 source/source_base/memory.cpp create mode 100644 source/source_base/memory.h diff --git a/source/source_base/memory.cpp b/source/source_base/memory.cpp new file mode 100644 index 00000000000..dd927de6ea3 --- /dev/null +++ b/source/source_base/memory.cpp @@ -0,0 +1,505 @@ +//========================================================== +// AUTHOR : mohan +// DATE : 2008-11-18 +//========================================================== +#include +#include "memory.h" +#include "global_variable.h" +#include "source_base/parallel_reduce.h" + +namespace ModuleBase +{ +// 8 bit = 1 Byte +// 1024 Byte = 1 KB +// 1024 KB = 1 MB +// 1024 MB = 1 GB + +const double memory_warning_threshold_mb = 20.0; + +double Memory::total = 0.0; +int Memory::complex_matrix_memory = 2*sizeof(double); // 16 byte +int Memory::double_memory = sizeof(double); // 8 byte +int Memory::int_memory = sizeof(int); // 4.0 Byte +int Memory::bool_memory = sizeof(bool); // 1.0 Byte +int Memory::float_memory = sizeof(float); // 4.0 Byte +int Memory::short_memory = sizeof(short); // 2.0 Byte + +int Memory::n_memory = 1000; +int Memory::n_now = 0; +bool Memory::init_flag = false; + +#if defined(__CUDA) || defined(__ROCM) + +double Memory::total_gpu = 0.0; +int Memory::n_now_gpu = 0; +bool Memory::init_flag_gpu = false; + +std::string *Memory::name_gpu; +std::string *Memory::class_name_gpu; +double *Memory::consume_gpu; + +#endif + + +std::string *Memory::name; +std::string *Memory::class_name; +double *Memory::consume; + +Memory::Memory() +{ +} + +Memory::~Memory() +{ +} + +double Memory::calculate_mem(const long &n_in,const std::string &type) +{ + double n = static_cast(n_in); + double mem = 0.0; + + double factor = 1.0/1024.0/1024.0; + double complex_matrix_mem = complex_matrix_memory * factor; + double double_mem = double_memory * factor; + double int_mem = int_memory * factor; + double bool_mem = bool_memory * factor; + double float_mem = float_memory * factor; + double short_mem = short_memory * factor; + + if(type=="ModuleBase::ComplexMatrix" || type=="complexmatrix" || type=="cdouble") + { + mem = complex_matrix_mem; + } + else if(type=="real" || type=="double") + { + mem = double_mem; + } + else if(type=="int") + { + mem = int_mem; + } + else if(type=="bool") + { + mem = bool_mem; + } + else if(type=="short") + { + mem = short_mem; + } + else if(type=="float") + { + mem = float_mem; + } + else if(type=="AtomLink") + { + mem = int_mem * 2 + double_mem * 3; + } + else if(type=="ModuleBase::Vector3") + { + mem = 3 * double_mem; + } + else + { + std::cout<<"not this type in memory storage : "<= n_memory) + { + std::cout<<" Error! Too many memories required."; + return 0.0; + } + + consume[find] = Memory::calculate_mem(n_in,type); + + if(consume[find] > memory_warning_threshold_mb) + { + print(name[find], consume[find]); + } + return consume[find]; +} + +void Memory::record +( + const std::string &name_in, + const long &n_in, + const bool accumulate +) +{ + if(!Memory::init_flag) + { + name = new std::string[n_memory]; + class_name = new std::string[n_memory]; + consume = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many memories has been recorded."; + return; + } + + const double factor = 1.0/1024.0/1024.0; + double size_mb = n_in * factor; + + if(accumulate) + { + consume[find] += size_mb; + Memory::total += size_mb; + } + else + { + if(consume[find] < size_mb) + { + Memory::total += size_mb - consume[find]; + consume[find] = size_mb; + if(consume[find] > memory_warning_threshold_mb) + { + print(name[find], consume[find]); + } + } + } + + return; +} + +#if defined(__CUDA) || defined(__ROCM) + +double Memory::record_gpu +( + const std::string &class_name_in, + const std::string &name_in, + const long &n_in, + const std::string &type, + const bool accumulate +) +{ + if(!Memory::init_flag_gpu) + { + name_gpu = new std::string[n_memory]; + class_name_gpu = new std::string[n_memory]; + consume_gpu = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many gpu memories required."; + return 0.0; + } + + consume_gpu[find] = Memory::calculate_mem(n_in,type); + + if(consume_gpu[find] > memory_warning_threshold_mb) + { + print(name_gpu[find], consume_gpu[find]); + } + return consume_gpu[find]; +} + +void Memory::record_gpu +( + const std::string &name_in, + const size_t &n_in, + const bool accumulate +) +{ + if(!Memory::init_flag_gpu) + { + name_gpu = new std::string[n_memory]; + class_name_gpu = new std::string[n_memory]; + consume_gpu = new double[n_memory]; + for(int i=0;i= n_memory) + { + std::cout<<" Error! Too many gpu memories has been recorded."; + return; + } + + const double factor = 1.0/1024.0/1024.0; + double size_mb = n_in * factor; + + if(accumulate) + { + consume_gpu[find] += size_mb; + Memory::total_gpu += size_mb; + } + else + { + if(consume_gpu[find] < size_mb) + { + Memory::total_gpu += size_mb - consume_gpu[find]; + consume_gpu[find] = size_mb; + if(consume_gpu[find] > memory_warning_threshold_mb) + { + print(name_gpu[find], consume_gpu[find]); + } + } + } + return; +} + +#endif + +void Memory::print(const std::string& mem_name, double size_mb) +{ + GlobalV::ofs_running <<"\n *** Memory Allocation Warning *** " + <<" "<< mem_name <<" "<< size_mb <<" MB" << std::endl; + return; +} + + +void Memory::finish(std::ofstream &ofs) +{ + print_all(ofs); + if(init_flag) + { + delete[] name; + delete[] class_name; + delete[] consume; + init_flag = false; + } +#if defined(__CUDA) || defined(__ROCM) + if(init_flag_gpu) + { + delete[] name_gpu; + delete[] class_name_gpu; + delete[] consume_gpu; + init_flag_gpu = false; + } +#endif + return; +} + +void Memory::print_all(std::ofstream &ofs) +{ + if(!init_flag) + { + return; + } + + const double small = 1.0; // unit is MB +#ifdef __MPI + Parallel_Reduce::reduce_all(Memory::total); +#if defined(__CUDA) || defined(__ROCM) + Parallel_Reduce::reduce_all(Memory::total_gpu); +#endif +#endif + ofs <<"\n NAME-------------------------|MEMORY(MB)------------------" << std::endl; + ofs << std::right; + ofs << std::setw(30)<< "total" << std::setw(15) <0); + + bool *print_flag = new bool[n_memory]; + + for(int i=0; i0); + + bool *print_flag_gpu = new bool[n_memory]; + + for(int i=0; i +#include + +namespace ModuleBase +{ + +/** + * @brief Record memory consumption during computation. + * @author Mohan + * @note 8 bit = 1 Byte; 1024 Byte = 1 KB; + * 1024 KB = 1 MB; 1024 MB = 1 GB + * + */ +class Memory +{ + public: + Memory(); + ~Memory(); + + /** + * @brief Record memory consumed during computation + * + * @param class_name The name of a class + * @param name The name of a quantity + * @param n The number of the quantity + * @param type The type of data + * @param accumulate Useless, always set false + * @return double + */ + static double record(const std::string &class_name, + const std::string &name, + const long &n, + const std::string &type, + const bool accumulate = false); + + /** + * @brief Record memory consumed during computation + * + * @param name The name of a quantity + * @param n The number of the quantity + * @param accumulate Useless, always set false + */ + static void record( + const std::string &name_in, + const long &n_in, + const bool accumulate = false + ); + +#if defined(__CUDA) || defined(__ROCM) + + /** + * @brief Record memory consumed on gpu during computation + * + * @param class_name The name of a class + * @param name The name of a quantity + * @param n The number of the quantity + * @param type The type of data + * @param accumulate Useless, always set false + * @return double + */ + static double record_gpu(const std::string &class_name, + const std::string &name, + const long &n, + const std::string &type, + const bool accumulate = false); + + /** + * @brief Record memory consumed on gpu during computation + * + * @param name The name of a quantity + * @param n The number of the quantity + * @param accumulate Useless, always set false + */ + static void record_gpu( + const std::string &name_in, + const size_t &n_in, + const bool accumulate = false + ); + +#endif + + static double &get_total(void) + { + return total; + } + + static void finish(std::ofstream &ofs); + + /** + * @brief Print memory consumed (> 1 MB) in a file + * + * @param ofs The output file stream for print out memory records + */ + static void print_all(std::ofstream &ofs); + + static void print(const std::string& name, double size_mb); + + /** + * @brief Calculate memory requirements for various + * types of data + * + * @param n The number of a type of data + * @param type The type of data + * @return double + */ + static double calculate_mem(const long &n, const std::string &type); + + private: + static double total; + static std::string *name; + static std::string *class_name; + static double *consume; + static int n_memory; + static int n_now; + static bool init_flag; + +#if defined(__CUDA) || defined(__ROCM) + static double total_gpu; + static std::string *name_gpu; + static std::string *class_name_gpu; + static double *consume_gpu; + static int n_now_gpu; + static bool init_flag_gpu; +#endif + + static int complex_matrix_memory; //(16 Byte) + static int double_memory; //(8 Byte) + static int int_memory; //(4 Byte) + static int bool_memory; + static int short_memory; //(2 Byte) + static int float_memory; //(4 Byte) +}; + +} // namespace ModuleBase + +#endif