diff --git a/source/source_base/parallel_global.cpp b/source/source_base/parallel_global.cpp index 6e5d1b2185..dcfea10d30 100644 --- a/source/source_base/parallel_global.cpp +++ b/source/source_base/parallel_global.cpp @@ -15,7 +15,7 @@ #include "source_base/parallel_common.h" #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" -// #include "source_base/tool_quit.h" +#include "source_base/tool_quit.h" #include "source_main/version.h" #include @@ -88,10 +88,10 @@ void Parallel_Global::split_grid_world(const int diag_np, const int& nproc, cons } // changed from read_mpi_parameters in 2024-1018 -void Parallel_Global::read_pal_param(int argc, - char** argv, - int& NPROC, - int& NTHREAD_PER_PROC, +void Parallel_Global::read_pal_param(int argc, + char** argv, + int& NPROC, + int& NTHREAD_PER_PROC, int& MY_RANK) { #ifdef __MPI @@ -339,7 +339,7 @@ void Parallel_Global::divide_pools(const int& NPROC, // band parallelization MPICommGroup bndpar_group(kpar_group.group_comm); bndpar_group.divide_group_comm(BNDPAR, true); - + // Set parallel index. // In previous versions, the order of k-point parallelization and band parallelization is reversed. // So we need to keep some variables for compatibility. @@ -355,7 +355,7 @@ void Parallel_Global::divide_pools(const int& NPROC, { KP_WORLD = MPI_COMM_NULL; } - + if(BNDPAR > 1) { NPROC_IN_BNDGROUP = kpar_group.ngroups * bndpar_group.nprocs_in_group; @@ -385,14 +385,19 @@ void Parallel_Global::divide_mpi_groups(const int& procs, { if (num_groups == 0) { - std::cout << "Error: Number of groups must be greater than 0." << std::endl; - exit(1); + ModuleBase::WARNING_QUIT( + "Parallel_Global::divide_mpi_groups", + "Number of groups must be greater than 0." + ); } if (procs < num_groups) { std::cout << "Error: Number of processes (" << procs << ") must be greater than the number of groups (" << num_groups << ")." << std::endl; - exit(1); + ModuleBase::WARNING_QUIT( + "Parallel_Global::divide_mpi_groups", + "Number of processes must be greater than the number of groups." + ); } // Calculate the distribution of processes among pools. procs_in_group = procs / num_groups; diff --git a/source/source_base/test_parallel/CMakeLists.txt b/source/source_base/test_parallel/CMakeLists.txt index f3fedb2ef4..17c8a8e115 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 + 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 ) 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 + 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 ) install(FILES parallel_common_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) @@ -54,7 +54,7 @@ add_test(NAME MODULE_BASE_para_gemm_parallel AddTest( TARGET MODULE_BASE_parallel_2d_test SOURCES parallel_2d_test.cpp ../parallel_2d.cpp - LIBS parameter ${math_libs} + LIBS parameter ${math_libs} ) install(FILES parallel_2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) @@ -82,4 +82,3 @@ add_test(NAME MODULE_BASE_parallel_2d_test_para COMMAND ${BASH} blacs_connector_test.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - diff --git a/source/source_base/test_parallel/parallel_global_test.cpp b/source/source_base/test_parallel/parallel_global_test.cpp index bb31af30bc..9b8799a0c6 100644 --- a/source/source_base/test_parallel/parallel_global_test.cpp +++ b/source/source_base/test_parallel/parallel_global_test.cpp @@ -9,6 +9,8 @@ #include #include +#include "source_base/tool_quit.h" + /************************************************ * unit test of functions in parallel_global.cpp ***********************************************/ @@ -207,4 +209,4 @@ int main(int argc, char** argv) MPI_Finalize(); return result; } -#endif +#endif // __MPI diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index 6217e90be4..9e8ba3ce6f 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -90,7 +90,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/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 ) find_program(BASH bash) diff --git a/source/source_io/test/CMakeLists.txt b/source/source_io/test/CMakeLists.txt index 6f6c947801..407eadecec 100644 --- a/source/source_io/test/CMakeLists.txt +++ b/source/source_io/test/CMakeLists.txt @@ -8,7 +8,7 @@ install(FILES INPUTs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_IO_input_test_para - LIBS parameter ${math_libs} base device io_input + LIBS parameter ${math_libs} base device io_input SOURCES read_input_ptest.cpp ) @@ -19,7 +19,7 @@ add_test(NAME MODULE_IO_input_test_para_4 AddTest( TARGET MODULE_IO_read_exit_file_test - LIBS parameter ${math_libs} base device + LIBS parameter ${math_libs} base device SOURCES read_exit_file_test.cpp ../read_exit_file.cpp ) @@ -41,7 +41,7 @@ AddTest( AddTest( TARGET MODULE_IO_write_eig_occ_test - LIBS parameter ${math_libs} base device symmetry + LIBS parameter ${math_libs} base device symmetry SOURCES write_eig_occ_test.cpp ../write_eig_occ.cpp ../output.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/klist.cpp ../../source_cell/k_vector_utils.cpp ../cif_io.cpp ) @@ -60,7 +60,7 @@ AddTest( AddTest( TARGET MODULE_IO_print_info - LIBS parameter ${math_libs} base device symmetry cell_info + LIBS parameter ${math_libs} base device symmetry cell_info SOURCES print_info_test.cpp ../print_info.cpp ../output.cpp ../../source_cell/klist.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/k_vector_utils.cpp ) @@ -73,6 +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 ) AddTest( @@ -90,7 +91,7 @@ add_test(NAME MODULE_IO_write_wfc_nao_para AddTest( TARGET MODULE_IO_write_orb_info - LIBS parameter ${math_libs} base device cell_info + LIBS parameter ${math_libs} base device cell_info SOURCES write_orb_info_test.cpp ../write_orb_info.cpp ../output.cpp ) @@ -108,7 +109,7 @@ AddTest( AddTest( TARGET MODULE_IO_output_log_test - LIBS parameter base ${math_libs} device + LIBS parameter base ${math_libs} device SOURCES ../output_log.cpp outputlog_test.cpp ../../source_basis/module_pw/test/test_tool.cpp ) @@ -139,8 +140,8 @@ AddTest( if(ENABLE_LCAO) AddTest( TARGET MODULE_IO_to_qo_test - LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb - SOURCES + LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb + SOURCES to_qo_test.cpp ../to_qo_kernel.cpp ../to_qo_mpi.cpp @@ -178,9 +179,9 @@ add_test(NAME MODULE_IO_read_wf2rho_pw_parallel AddTest( TARGET MODULE_IO_numerical_basis_test - LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb - SOURCES numerical_basis_test.cpp - ../numerical_basis_jyjy.cpp + LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb + SOURCES numerical_basis_test.cpp + ../numerical_basis_jyjy.cpp ../../source_lcao/center2_orb.cpp ../orb_io.cpp ) @@ -233,7 +234,7 @@ add_test(NAME MODULE_IO_orb_io_test_parallel AddTest( TARGET MODULE_IO_write_dmk - LIBS parameter ${math_libs} base device cell_info + LIBS parameter ${math_libs} base device cell_info SOURCES write_dmk_test.cpp ../write_dmk.cpp ../output.cpp ) @@ -259,8 +260,8 @@ if(ENABLE_LCAO) AddTest( TARGET MODULE_IO_cal_pLpR_test LIBS parameter base ${math_libs} device neighbor - SOURCES - cal_pLpR_test.cpp + SOURCES + cal_pLpR_test.cpp ../cal_pLpR.cpp ../../source_basis/module_ao/ORB_atomic_lm.cpp ../../source_basis/module_ao/ORB_atomic.cpp diff --git a/source/source_main/driver_run.cpp b/source/source_main/driver_run.cpp index 1ba2ea9d51..e84b4f3505 100644 --- a/source/source_main/driver_run.cpp +++ b/source/source_main/driver_run.cpp @@ -87,7 +87,7 @@ void Driver::driver_run() { p_esolver->runner(ucell, 0); } - else if (cal == "get_pchg" || cal == "get_wf" || cal == "gen_bessel" || cal == "gen_opt_abfs" || + else if (cal == "get_pchg" || cal == "get_wf" || cal == "gen_bessel" || cal == "gen_opt_abfs" || cal == "test_memory" || cal == "test_neighbour") { //! supported "other" functions: @@ -128,6 +128,13 @@ void Driver::init_hardware() #endif #ifdef __DSP + if (GlobalV::NPROC > PARAM.inp.KPAR) + { + ModuleBase::WARNING_QUIT( + "Driver::init_hardware", + "Number of processors must be equal to KPAR for DSP hardware initialization." + ); + } std::cout << " ** Initializing DSP Hardware..." << std::endl; mtfunc::dspInitHandle(GlobalV::MY_RANK % PARAM.inp.dsp_count); #endif @@ -149,4 +156,4 @@ void Driver::finalize_hardware() std::cout << " ** Closing DSP Hardware..." << std::endl; mtfunc::dspDestoryHandle(GlobalV::MY_RANK); #endif -} \ No newline at end of file +}