Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions source/source_base/parallel_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions source/source_base/test_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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}
)

4 changes: 3 additions & 1 deletion source/source_base/test_parallel/parallel_global_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <cstring>
#include <string>

#include "source_base/tool_quit.h"

/************************************************
* unit test of functions in parallel_global.cpp
***********************************************/
Expand Down Expand Up @@ -207,4 +209,4 @@ int main(int argc, char** argv)
MPI_Finalize();
return result;
}
#endif
#endif // __MPI
2 changes: 1 addition & 1 deletion source/source_cell/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 15 additions & 14 deletions source/source_io/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
)
Expand All @@ -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
)

Expand All @@ -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(
Expand All @@ -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
)

Expand All @@ -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
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)

Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions source/source_main/driver_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -149,4 +156,4 @@ void Driver::finalize_hardware()
std::cout << " ** Closing DSP Hardware..." << std::endl;
mtfunc::dspDestoryHandle(GlobalV::MY_RANK);
#endif
}
}
Loading