Skip to content

Commit

Permalink
Remove be_verbose option from the process grid (#237)
Browse files Browse the repository at this point in the history
* Remove be_verbose option from the process grid

Since it was doing nothing

* Fix CI

* Missed a few places for getH

* Fix examples
  • Loading branch information
william-dawson authored Aug 27, 2024
1 parent a963d8b commit 7a94b35
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Examples/ComplexMatrix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
process_columns, process_slices);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/GraphTheory/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) {

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
process_columns, process_slices);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/HydrogenAtom/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
process_columns, process_slices);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/MatrixMaps/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) {
}

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_slices, true);
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_slices);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/PremadeMatrix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
process_columns, process_slices);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}
Expand Down
9 changes: 3 additions & 6 deletions Source/C/ProcessGrid_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
void ConstructGlobalProcessGrid_wrp(const int *world_comm,
const int *process_rows,
const int *process_columns,
const int *process_slices,
const bool *be_verbose);
const int *process_slices);
void ConstructGlobalProcessGrid_onlyslice_wrp(const int *world_comm,
const int *process_slices,
const bool *be_verbose);
void ConstructGlobalProcessGrid_default_wrp(const int *world_comm,
const bool *be_verbose);
const int *process_slices);
void ConstructGlobalProcessGrid_default_wrp(const int *world_comm);
void CopyProcessGrid_wrp(const int *ih_old_grid, int *ih_new_grid);
int GetGlobalMySlice_wrp();
int GetGlobalMyColumn_wrp();
Expand Down
24 changes: 10 additions & 14 deletions Source/CPlusPlus/ProcessGrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,40 +73,36 @@ ProcessGrid::~ProcessGrid() { DestructProcessGrid_wrp(ih_this); }

////////////////////////////////////////////////////////////////////////////////
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_rows,
int process_columns, int process_slices,
bool be_verbose) {
int process_columns, int process_slices) {
MPI_Fint temp_comm = MPI_Comm_c2f(world_comm);
ConstructGlobalProcessGrid_wrp(&temp_comm, &process_rows, &process_columns,
&process_slices, &be_verbose);
&process_slices);
}

////////////////////////////////////////////////////////////////////////////////
void ConstructGlobalProcessGrid(int process_rows, int process_columns,
int process_slices, bool be_verbose) {
int process_slices) {
MPI_Fint temp_comm = MPI_Comm_c2f(MPI_COMM_WORLD);
ConstructGlobalProcessGrid_wrp(&temp_comm, &process_rows, &process_columns,
&process_slices, &be_verbose);
&process_slices);
}

////////////////////////////////////////////////////////////////////////////////
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_slices,
bool be_verbose) {
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_slices) {
MPI_Fint temp_comm = MPI_Comm_c2f(world_comm);
ConstructGlobalProcessGrid_onlyslice_wrp(&temp_comm, &process_slices,
&be_verbose);
ConstructGlobalProcessGrid_onlyslice_wrp(&temp_comm, &process_slices);
}

////////////////////////////////////////////////////////////////////////////////
void ConstructGlobalProcessGrid(int process_slices, bool be_verbose) {
void ConstructGlobalProcessGrid(int process_slices) {
MPI_Fint temp_comm = MPI_Comm_c2f(MPI_COMM_WORLD);
ConstructGlobalProcessGrid_onlyslice_wrp(&temp_comm, &process_slices,
&be_verbose);
ConstructGlobalProcessGrid_onlyslice_wrp(&temp_comm, &process_slices);
}

////////////////////////////////////////////////////////////////////////////////
void ConstructGlobalProcessGrid(bool be_verbose) {
void ConstructGlobalProcessGrid() {
MPI_Fint temp_comm = MPI_Comm_c2f(MPI_COMM_WORLD);
ConstructGlobalProcessGrid_default_wrp(&temp_comm, &be_verbose);
ConstructGlobalProcessGrid_default_wrp(&temp_comm);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 5 additions & 12 deletions Source/CPlusPlus/ProcessGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,24 @@ class ProcessGrid {
//! \param[in] process_rows number of grid rows.
//! \param[in] process_columns number of grid columns.
//! \param[in] process_slices number of grid slices.
//! \param[in] be_verbose verbosity flag.
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_rows,
int process_columns, int process_slices,
bool be_verbose = false);
int process_columns, int process_slices);
//! Construct the global process grid from comm world
//! \param[in] process_rows number of grid rows.
//! \param[in] process_columns number of grid columns.
//! \param[in] process_slices number of grid slices.
//! \param[in] be_verbose verbosity flag.
void ConstructGlobalProcessGrid(int process_rows, int process_columns,
int process_slices, bool be_verbose = false);
int process_slices);
//! Construct the global process grid.
//! \param[in] world_comm a communicator that every process in the grid is
//! a part of.
//! \param[in] process_slices number of grid slices.
//! \param[in] be_verbose verbosity flag.
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_slices,
bool be_verbose = false);
void ConstructGlobalProcessGrid(MPI_Comm world_comm, int process_slices);
//! Construct the global process grid from comm world
//! \param[in] process_slices number of grid slices.
//! \param[in] be_verbose verbosity flag.
void ConstructGlobalProcessGrid(int process_slices, bool be_verbose = false);
void ConstructGlobalProcessGrid(int process_slices);
//! Construct the global process grid from comm world
//! \param[in] be_verbose verbosity flag.
void ConstructGlobalProcessGrid(bool be_verbose = false);
void ConstructGlobalProcessGrid();
//! Get the slice of the current process.
int GetGlobalMySlice();
//! Get the column of the current process.
Expand Down
27 changes: 3 additions & 24 deletions Source/Fortran/ProcessGridModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ MODULE ProcessGridModule
CONTAINS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Setup the default process grid.
SUBROUTINE ConstructProcessGrid_full(world_comm, process_rows, &
& process_columns, process_slices, be_verbose_in)
& process_columns, process_slices)
!> A communicator that every process in the grid is a part of.
INTEGER, INTENT(IN) :: world_comm
!> The number of grid rows.
Expand All @@ -91,33 +91,18 @@ SUBROUTINE ConstructProcessGrid_full(world_comm, process_rows, &
INTEGER, INTENT(IN) :: process_columns
!> The number of grid slices.
INTEGER, INTENT(IN) :: process_slices
!> Set true to print process grid info.
LOGICAL, INTENT(IN), OPTIONAL :: be_verbose_in
!! Local Data
LOGICAL :: be_verbose

!! Process Optional Parameters
IF (PRESENT(be_verbose_in)) THEN
be_verbose = be_verbose_in
ELSE
be_verbose = .FALSE.
END IF

CALL ConstructNewProcessGrid(global_grid, world_comm, process_rows, &
& process_columns, process_slices)
END SUBROUTINE ConstructProcessGrid_full
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Setup a process grid specifying only the slices
SUBROUTINE ConstructProcessGrid_onlyslice(world_comm, process_slices_in, &
& be_verbose_in)
SUBROUTINE ConstructProcessGrid_onlyslice(world_comm, process_slices_in)
!> A communicator that every process in the grid is a part of.
INTEGER, INTENT(IN) :: world_comm
!> The number of grid slices.
INTEGER, INTENT(IN), OPTIONAL :: process_slices_in
!> Set true to print process grid info.
LOGICAL, INTENT(IN), OPTIONAL :: be_verbose_in
!! Local Data
LOGICAL :: be_verbose
INTEGER :: process_rows, process_columns, process_slices
INTEGER :: total_processors
INTEGER :: ierr
Expand All @@ -126,12 +111,6 @@ SUBROUTINE ConstructProcessGrid_onlyslice(world_comm, process_slices_in, &
CALL MPI_COMM_SIZE(world_comm, total_processors, ierr)

!! Process Optional Parameters
IF (PRESENT(be_verbose_in)) THEN
be_verbose = be_verbose_in
ELSE
be_verbose = .FALSE.
END IF

IF (PRESENT(process_slices_in)) THEN
process_slices = process_slices_in
ELSE
Expand All @@ -144,7 +123,7 @@ SUBROUTINE ConstructProcessGrid_onlyslice(world_comm, process_slices_in, &

!! Now call the full setup
CALL ConstructProcessGrid(world_comm, process_rows, process_columns, &
& process_slices, be_verbose)
& process_slices)
END SUBROUTINE ConstructProcessGrid_onlyslice
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Construct a process grid.
Expand Down
16 changes: 6 additions & 10 deletions Source/Wrapper/ProcessGridModule_wrp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,30 @@ MODULE ProcessGridModule_wrp
CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Wrap the process grid construction routine.
SUBROUTINE ConstructGlobalProcessGrid_wrp(world_comm_, process_rows_, &
& process_columns_, process_slices_, be_verbose) &
& process_columns_, process_slices_) &
& BIND(c,name="ConstructGlobalProcessGrid_wrp")
INTEGER(kind=c_int), INTENT(IN) :: world_comm_
INTEGER(kind=c_int), INTENT(IN) :: process_rows_
INTEGER(kind=c_int), INTENT(IN) :: process_columns_
INTEGER(kind=c_int), INTENT(IN) :: process_slices_
LOGICAL(kind=c_bool), INTENT(IN) :: be_verbose
CALL ConstructProcessGrid(world_comm_, process_rows_, process_columns_, &
& process_slices_, LOGICAL(be_verbose))
& process_slices_)
END SUBROUTINE ConstructGlobalProcessGrid_wrp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Wrap the process grid construction routine.
SUBROUTINE ConstructGlobalProcessGrid_onlyslice_wrp(world_comm_, &
& process_slices_, be_verbose) &
& process_slices_) &
& BIND(c,name="ConstructGlobalProcessGrid_onlyslice_wrp")
INTEGER(kind=c_int), INTENT(IN) :: world_comm_
INTEGER(kind=c_int), INTENT(IN) :: process_slices_
LOGICAL(kind=c_bool), INTENT(IN) :: be_verbose
CALL ConstructProcessGrid(world_comm_, process_slices_in=process_slices_, &
& be_verbose_in=LOGICAL(be_verbose))
CALL ConstructProcessGrid(world_comm_, process_slices_in=process_slices_)
END SUBROUTINE ConstructGlobalProcessGrid_onlyslice_wrp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Wrap the process grid construction routine.
SUBROUTINE ConstructGlobalProcessGrid_default_wrp(world_comm_, be_verbose) &
SUBROUTINE ConstructGlobalProcessGrid_default_wrp(world_comm_) &
& BIND(c,name="ConstructGlobalProcessGrid_default_wrp")
INTEGER(kind=c_int), INTENT(IN) :: world_comm_
LOGICAL(kind=c_bool), INTENT(IN) :: be_verbose
CALL ConstructProcessGrid(world_comm_, be_verbose_in=LOGICAL(be_verbose))
CALL ConstructProcessGrid(world_comm_)
END SUBROUTINE ConstructGlobalProcessGrid_default_wrp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!> Get the slice of the current process.
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/test_chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create_matrices(self):
fock = rand(self.mat_dim, self.mat_dim, density=1.0)
if self.is_complex:
fock += 1j * rand(self.mat_dim, self.mat_dim, density=1.0)
fock = fock + fock.H
fock = fock + fock.getH()
else:
fock = fock + fock.T
overlap = rand(self.mat_dim, self.mat_dim, density=1.0)
Expand Down Expand Up @@ -76,7 +76,7 @@ def setUpClass(self):
rows = int(environ['PROCESS_ROWS'])
columns = int(environ['PROCESS_COLUMNS'])
slices = int(environ['PROCESS_SLICES'])
nt.ConstructGlobalProcessGrid(rows, columns, slices, True)
nt.ConstructGlobalProcessGrid(rows, columns, slices)

@classmethod
def tearDownClass(self):
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_wom_gc(self):
we = [1.0/(1 + exp(beta*(x - mu))) for x in w]

if self.is_complex:
DOrth = v @ diag(we) @ matrix(v).H
DOrth = v @ diag(we) @ matrix(v).getH()
else:
DOrth = v @ diag(we) @ v.T
D = ISQ.dot(DOrth).dot(ISQ)
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_wom_c(self):
while abs(trace(DOrth) - self.nel) > 1e-12:
we = [1.0/(1 + exp(beta*(x - mu))) for x in w]
if self.is_complex:
DOrth = v @ diag(we) @ matrix(v).H
DOrth = v @ diag(we) @ matrix(v).getH()
else:
DOrth = v @ diag(we) @ v.T
D = ISQ.dot(DOrth).dot(ISQ)
Expand Down
14 changes: 7 additions & 7 deletions UnitTests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_readsymmetric(self):
'''Test routines to read and write matrices.'''
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex, square=True)
matrix1 = matrix1 + matrix1.H
matrix1 = matrix1 + matrix1.getH()
mmwrite(self.file1, matrix1)
matrix2 = self.SMatrix(self.file1)
matrix2.WriteToMatrixMarket(self.file2)
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_multiply(self):
from random import uniform
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex)
matrix2 = param.create_matrix(complex=self.complex).H
matrix2 = param.create_matrix(complex=self.complex).getH()
mmwrite(self.file1, matrix1)
mmwrite(self.file2, matrix2)
alpha = uniform(1.0, 2.0)
Expand Down Expand Up @@ -254,7 +254,7 @@ def test_multiply_nt(self):
from random import uniform
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex)
matrix2 = param.create_matrix(complex=self.complex).H
matrix2 = param.create_matrix(complex=self.complex).getH()
mmwrite(self.file1, matrix1)
mmwrite(self.file2, matrix2.T)
alpha = uniform(1.0, 2.0)
Expand Down Expand Up @@ -282,7 +282,7 @@ def test_multiply_tn(self):
from random import uniform
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex)
matrix2 = param.create_matrix(complex=self.complex).H
matrix2 = param.create_matrix(complex=self.complex).getH()
mmwrite(self.file1, matrix1.T)
mmwrite(self.file2, matrix2)
alpha = uniform(1.0, 2.0)
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_multiply_tt(self):
from random import uniform
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex)
matrix2 = param.create_matrix(complex=self.complex).H
matrix2 = param.create_matrix(complex=self.complex).getH()
mmwrite(self.file1, matrix1.T)
mmwrite(self.file2, matrix2.T)
alpha = uniform(1.0, 2.0)
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_multiply_zero(self):
from random import uniform
for param in self.parameters:
matrix1 = param.create_matrix(complex=self.complex)
matrix2 = 0 * param.create_matrix(complex=self.complex).H
matrix2 = 0 * param.create_matrix(complex=self.complex).getH()
mmwrite(self.file1, matrix1)
mmwrite(self.file2, matrix2)
alpha = uniform(1.0, 2.0)
Expand Down Expand Up @@ -443,7 +443,7 @@ def test_conjugatetranspose(self):
matrix2T.Conjugate()
matrix2T.WriteToMatrixMarket(self.file2)

CheckMat = matrix1.H
CheckMat = matrix1.getH()
ResultMat = mmread(self.file2)
self._compare_mat(CheckMat, ResultMat)

Expand Down
2 changes: 1 addition & 1 deletion UnitTests/test_psmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def test_conjugatetranspose(self):
matrix1 = param.create_matrix(self.complex)
self.write_matrix(matrix1, self.input_file1)

self.CheckMat = matrix1.H
self.CheckMat = matrix1.getH()

ntmatrix1 = nt.Matrix_ps(self.input_file1, False)
ntmatrix2 = nt.Matrix_ps(ntmatrix1.GetActualDimension())
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/test_psmatrixalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_asymmetry(self):
else:
ntmatrix1 = nt.Matrix_ps(param.rows)

diff = matrix1 - matrix1.H
diff = matrix1 - matrix1.getH()
ref = norm(diff.todense(), ord=inf)
comp = ntmatrix1.MeasureAsymmetry()
comm.barrier()
Expand All @@ -320,7 +320,7 @@ def test_symmetrize(self):
else:
ntmatrix1 = nt.Matrix_ps(param.rows)

self.CheckMat = 0.5 * (matrix1 + matrix1.H)
self.CheckMat = 0.5 * (matrix1 + matrix1.getH())
ntmatrix1 = nt.Matrix_ps(self.input_file1, False)
ntmatrix1.Symmetrize()
ntmatrix1.WriteToMatrixMarket(self.result_file)
Expand Down
Loading

0 comments on commit 7a94b35

Please sign in to comment.