forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
844 additions
and
1,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
-13.3178 | ||
-13.31774791420906 | ||
E_H2O: -466.1219344619547 | ||
E_O: -427.6267373722137 | ||
E_H1: -12.58872471938786 | ||
E_H2: -12.58872445614408 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
source/module_base/test_parallel/blacs_connector_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#ifdef __MPI | ||
|
||
#include "../blacs_connector.h" | ||
#include <mpi.h> | ||
#include "gtest/gtest.h" | ||
|
||
/************************************************ | ||
* unit test of functions in blacs_connector.h | ||
***********************************************/ | ||
|
||
/** | ||
* - Tested Function | ||
* - Cblacs_gridinit | ||
* - Initializes a grid of processors with a given number of rows and columns. | ||
* The function creates a cartesian topology of all the processors initialized | ||
* by the BLS library. In this topology, each processor is identified by its | ||
* coordinates (row, col) in the grid. | ||
*/ | ||
|
||
class BLACSTest: public testing::Test | ||
{ | ||
protected: | ||
void SetUp(); | ||
|
||
int rank = 0; | ||
int nprocs = 0; | ||
char layout = 'R'; | ||
|
||
// number of rows and columns in the process grid | ||
int nprow = 0; | ||
int npcol = 0; | ||
|
||
// process coordinate | ||
int iprow = -1; | ||
int ipcol = -1; | ||
}; | ||
|
||
void BLACSTest::SetUp() | ||
{ | ||
Cblacs_pinfo(&rank, &nprocs); | ||
} | ||
|
||
|
||
TEST_F(BLACSTest, WorldGrid) | ||
{ | ||
// generate a grid of size 1 x nproc | ||
nprow = 1; | ||
npcol = nprocs; | ||
|
||
int ictxt_row = Csys2blacs_handle(MPI_COMM_WORLD); | ||
Cblacs_gridinit(&ictxt_row, &layout, nprow, npcol); | ||
Cblacs_gridinfo(ictxt_row, &nprow, &npcol, &iprow, &ipcol); | ||
|
||
EXPECT_EQ(iprow, 0); | ||
EXPECT_EQ(ipcol, rank); | ||
|
||
// generate a grid of size nproc x 1 | ||
nprow = nprocs; | ||
npcol = 1; | ||
|
||
int ictxt_col = Csys2blacs_handle(MPI_COMM_WORLD); | ||
Cblacs_gridinit(&ictxt_col, &layout, nprow, npcol); | ||
Cblacs_gridinfo(ictxt_col, &nprow, &npcol, &iprow, &ipcol); | ||
|
||
EXPECT_EQ(iprow, rank); | ||
EXPECT_EQ(ipcol, 0); | ||
|
||
|
||
// two BLACS grids should have difference context index | ||
EXPECT_NE(ictxt_row, ictxt_col); | ||
} | ||
|
||
TEST_F(BLACSTest, SplitGrid) | ||
{ | ||
// this test create BLACS grids based on a disjoint communicator | ||
|
||
const int n_blacs = 2; | ||
int rank_sub = -1; | ||
int nprocs_sub = 0; | ||
|
||
// sub communicators are divided based on odd / even ranks | ||
MPI_Comm comm_sub; | ||
MPI_Comm_split(MPI_COMM_WORLD, rank % n_blacs, rank, &comm_sub); | ||
MPI_Comm_rank(comm_sub, &rank_sub); | ||
MPI_Comm_size(comm_sub, &nprocs_sub); | ||
|
||
int ctxt_sub = Csys2blacs_handle(comm_sub); | ||
|
||
nprow = 1, npcol = nprocs_sub; // row-like grids | ||
Cblacs_gridinit(&ctxt_sub, &layout, nprow, npcol); | ||
Cblacs_gridinfo(ctxt_sub, &nprow, &npcol, &iprow, &ipcol); | ||
|
||
// verifies that the BLACS grid is created based on comm_sub instead of MPI_COMM_WORLD | ||
EXPECT_EQ(iprow, 0); | ||
EXPECT_EQ(ipcol, rank_sub); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
MPI_Init(&argc, &argv); | ||
testing::InitGoogleTest(&argc, argv); | ||
|
||
int result = RUN_ALL_TESTS(); | ||
|
||
MPI_Finalize(); | ||
|
||
return result; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash -e | ||
|
||
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'` | ||
echo "nprocs in this machine is $np" | ||
|
||
for i in {8..2}; | ||
do | ||
if [[ $i -gt $np ]];then | ||
continue | ||
fi | ||
echo "TEST in parallel, nprocs=$i" | ||
mpirun -np $i ./blacs_connector | ||
break | ||
done | ||
|
Oops, something went wrong.