Skip to content

Commit

Permalink
Logger file improvements (#160)
Browse files Browse the repository at this point in the history
* Switch to a setable UNIT number

* Logging to file infastructure

* Fixing of yaml logging

* Explicit unit override

* Linting

* Update Fortran examples

* Fixes for C++ interface to logger

* Python examples updated

* Better interface to the logger in c++

* yaml dependency for unit tests

* linting

* Simplified configuration on a Mac (#161)

* Switch to a setable UNIT number

* Logging to file infastructure

* Fixing of yaml logging

* Explicit unit override

* Linting

* Update Fortran examples

* Fixes for C++ interface to logger

* Python examples updated

* Better interface to the logger in c++

* yaml dependency for unit tests

* linting

* Barrier in case that was messing with file system

* Try to verify that it is in the reading

* Output on failure

* Spaces not tabs

* It seems I needed to increase the integer print out size
  • Loading branch information
william-dawson authored Nov 16, 2020
1 parent 67d28ef commit b833530
Show file tree
Hide file tree
Showing 45 changed files with 499 additions and 170 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- name: regression tests
run: |
cd Build
export CTEST_OUTPUT_ON_FAILURE=1
eval "$MAKETEST"
cd ../
env:
Expand Down
7 changes: 7 additions & 0 deletions Examples/ComplexMatrix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using std::string;
#include <sstream>
using std::stringstream;
#include "ExponentialSolvers.h"
#include "Logging.h"
#include "PSMatrix.h"
#include "ProcessGrid.h"
#include "SolverParameters.h"
Expand Down Expand Up @@ -96,6 +97,9 @@ int main(int argc, char *argv[]) {
// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}

// Compute the Hermitian Matrix
NTPoly::Matrix_ps InMat(input_file);
Expand All @@ -113,6 +117,9 @@ int main(int argc, char *argv[]) {
OMat.WriteToMatrixMarket(exponential_file);

// Cleanup
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::DeactivateLogger();
}
NTPoly::DestructGlobalProcessGrid();
MPI_Finalize();
return 0;
Expand Down
16 changes: 13 additions & 3 deletions Examples/ComplexMatrix/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
PROGRAM ComplexMatrix
USE DataTypesModule, ONLY : NTREAL, NTCOMPLEX
USE ExponentialSolversModule, ONLY : ComputeExponential
USE LoggingModule, ONLY : EnterSubLog, ExitSubLog, WriteElement, WriteHeader
USE LoggingModule, ONLY : ActivateLogger, DeactivateLogger, EnterSubLog, &
& ExitSubLog, WriteElement, WriteHeader
USE MatrixMarketModule, ONLY : MM_SYMMETRIC
USE PSMatrixAlgebraModule, ONLY : IncrementMatrix, ScaleMatrix
USE PSMatrixModule, ONLY : Matrix_ps, ConstructMatrixFromMatrixMarket, &
& DestructMatrix, TransposeMatrix, GetMatrixTripletList, &
& FillMatrixFromTripletList, ConstructEmptyMatrix, ConjugateMatrix, &
& PrintMatrix, CopyMatrix, WriteMatrixToMatrixMarket
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid, &
& IsRoot
USE SolverParametersModule, ONLY : SolverParameters_t
USE TripletListModule, ONLY : TripletList_r, DestructTripletList, &
& GetTripletAt, TripletList_c, ConstructTripletList, &
Expand Down Expand Up @@ -40,7 +42,6 @@ PROGRAM ComplexMatrix
CALL MPI_Init_thread(MPI_THREAD_SERIALIZED, provided, ierr)

!! Process The Input
!! Process the input parameters.
DO counter=1,COMMAND_ARGUMENT_COUNT(),2
CALL GET_COMMAND_ARGUMENT(counter,argument)
CALL GET_COMMAND_ARGUMENT(counter+1,argument_value)
Expand All @@ -64,6 +65,10 @@ PROGRAM ComplexMatrix
CALL ConstructProcessGrid(MPI_COMM_WORLD, process_rows, process_columns, &
& process_slices)

!! Write Out Parameters
IF (IsRoot()) THEN
CALL ActivateLogger
END IF
CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="input_file", VALUE=input_file)
Expand All @@ -89,6 +94,11 @@ PROGRAM ComplexMatrix
!! Cleanup
CALL DestructMatrix(InMat)
CALL DestructMatrix(GMat)

!! Cleanup
IF (IsRoot()) THEN
CALL DeactivateLogger
END IF
CALL DestructProcessGrid
CALL MPI_Finalize(ierr)

Expand Down
6 changes: 6 additions & 0 deletions Examples/ComplexMatrix/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def ConstructGuoMatrix(InMat, OutMat):
# Setup the process grid.
nt.ConstructGlobalProcessGrid(
process_rows, process_columns, process_slices)
if nt.GetGlobalIsRoot():
nt.ActivateLogger()

# Construct The Hermitian Matrix
InMat = nt.Matrix_ps(input_file)
Expand All @@ -92,4 +94,8 @@ def ConstructGuoMatrix(InMat, OutMat):

# Write To File
OMat.WriteToMatrixMarket(exponential_file)

# Cleanup
if nt.GetGlobalIsRoot():
nt.DeactivateLogger()
nt.DestructGlobalProcessGrid()
8 changes: 8 additions & 0 deletions Examples/GraphTheory/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using std::vector;
#include <iostream>
// NTPoly Headers
#include "InverseSolvers.h"
#include "Logging.h"
#include "PSMatrix.h"
#include "ProcessGrid.h"
#include "SolverParameters.h"
Expand Down Expand Up @@ -67,6 +68,10 @@ int main(int argc, char *argv[]) {
// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}

// Set Up The Solver Parameters.
NTPoly::SolverParameters solver_parameters;
solver_parameters.SetConvergeDiff(convergence_threshold);
Expand Down Expand Up @@ -166,6 +171,9 @@ int main(int argc, char *argv[]) {
ResultMat.WriteToMatrixMarket(output_file);

// Cleanup
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::DeactivateLogger();
}
NTPoly::DestructGlobalProcessGrid();
MPI_Finalize();
return 0;
Expand Down
27 changes: 26 additions & 1 deletion Examples/GraphTheory/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
PROGRAM GraphTheory
USE DataTypesModule, ONLY : NTREAL
USE InverseSolversModule, ONLY : Invert
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid
USE LoggingModule, ONLY : ActivateLogger, DeactivateLogger, WriteElement, &
& WriteHeader, EnterSubLog, ExitSubLog
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid, &
& IsRoot
USE PSMatrixModule, ONLY : Matrix_ps, WriteMatrixToMatrixMarket, &
& ConstructEmptyMatrix, FillMatrixFromTripletList, DestructMatrix, &
& CopyMatrix, FillMatrixIdentity
Expand Down Expand Up @@ -76,6 +79,23 @@ PROGRAM GraphTheory
CALL ConstructProcessGrid(MPI_COMM_WORLD, process_rows, process_columns, &
& process_slices)

!! Write Out Parameters
IF (IsRoot()) THEN
CALL ActivateLogger
END IF
CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="number_of_nodes", VALUE=number_of_nodes)
CALL WriteElement(key="extra_connections", VALUE=extra_connections)
CALL WriteElement(key="threshold", VALUE=threshold)
CALL WriteElement(key="convergence_threshold", VALUE=convergence_threshold)
CALL WriteElement(key="attenuation", VALUE=attenuation)
CALL WriteElement(key="process_rows", VALUE=process_rows)
CALL WriteElement(key="process_columns", VALUE=process_columns)
CALL WriteElement(key="process_slices", VALUE=process_slices)
CALL WriteElement(key="output_file", VALUE=output_file)
CALL ExitSubLog

!! Set Up The Solver Parameters.
solver_parameters = SolverParameters_t( be_verbose_in=.TRUE., &
& converge_diff_in=convergence_threshold, threshold_in=threshold)
Expand All @@ -96,6 +116,11 @@ PROGRAM GraphTheory
!! Cleanup
CALL DestructMatrix(NetworkMat)
CALL DestructMatrix(ResultMat)

!! Cleanup
IF (IsRoot()) THEN
CALL DeactivateLogger
END IF
CALL DestructProcessGrid
CALL MPI_Finalize(ierr)
CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
6 changes: 6 additions & 0 deletions Examples/GraphTheory/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
# Setup the process grid.
nt.ConstructGlobalProcessGrid(
process_rows, process_columns, process_slices)
if nt.GetGlobalIsRoot():
nt.ActivateLogger()

# Set Up The Solver Parameters.
solver_parameters = nt.SolverParameters()
Expand Down Expand Up @@ -133,4 +135,8 @@

# Print the density matrix to file.
ResultMat.WriteToMatrixMarket(output_file)

# Cleanup
if nt.GetGlobalIsRoot():
nt.DeactivateLogger()
nt.DestructGlobalProcessGrid()
8 changes: 8 additions & 0 deletions Examples/HydrogenAtom/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using std::vector;
#include <iostream>
// NTPoly Headers
#include "DensityMatrixSolvers.h"
#include "Logging.h"
#include "PSMatrix.h"
#include "ProcessGrid.h"
#include "SolverParameters.h"
Expand Down Expand Up @@ -66,6 +67,10 @@ int main(int argc, char *argv[]) {
// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_rows,
process_columns, process_slices, true);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}

// Set Up The Solver Parameters.
NTPoly::SolverParameters solver_parameters;
solver_parameters.SetConvergeDiff(convergence_threshold);
Expand Down Expand Up @@ -163,6 +168,9 @@ int main(int argc, char *argv[]) {
Density.WriteToMatrixMarket(density_file_out);

// Cleanup
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::DeactivateLogger();
}
NTPoly::DestructGlobalProcessGrid();
MPI_Finalize();
return 0;
Expand Down
23 changes: 22 additions & 1 deletion Examples/HydrogenAtom/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
PROGRAM HydrogenAtom
USE DataTypesModule, ONLY : NTREAL
USE DensityMatrixSolversModule, ONLY : TRS2
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid
USE LoggingModule, ONLY : ActivateLogger, DeactivateLogger, WriteHeader, &
& WriteElement, EnterSubLog, ExitSubLog
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid, &
& IsRoot
USE PSMatrixModule, ONLY : Matrix_ps, WriteMatrixToMatrixMarket, &
& ConstructEmptyMatrix, FillMatrixFromTripletList, CopyMatrix, &
& FillMatrixIdentity
Expand Down Expand Up @@ -76,6 +79,21 @@ PROGRAM HydrogenAtom
CALL ConstructProcessGrid(MPI_COMM_WORLD, process_rows, process_columns, &
& process_slices)

!! Write Out Parameters
IF (IsRoot()) THEN
CALL ActivateLogger
END IF
CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="convergence_threshold", VALUE=convergence_threshold)
CALL WriteElement(key="grid_points", VALUE=grid_points)
CALL WriteElement(key="threshold", VALUE=threshold)
CALL WriteElement(key="process_rows", VALUE=process_rows)
CALL WriteElement(key="process_columns", VALUE=process_columns)
CALL WriteElement(key="process_slices", VALUE=process_slices)
CALL WriteElement(key="density_file_out", VALUE=density_file_out)
CALL ExitSubLog

!! Set Up The Solver Parameters.
solver_parameters = SolverParameters_t( be_verbose_in=.TRUE., &
& converge_diff_in=convergence_threshold, threshold_in=threshold)
Expand Down Expand Up @@ -110,6 +128,9 @@ PROGRAM HydrogenAtom
CALL WriteMatrixToMatrixMarket(Density,density_file_out)

!! Cleanup
IF (IsRoot()) THEN
CALL DeactivateLogger
END IF
CALL DestructProcessGrid
CALL MPI_Finalize(ierr)
CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
6 changes: 6 additions & 0 deletions Examples/HydrogenAtom/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# Setup the process grid.
nt.ConstructGlobalProcessGrid(
process_rows, process_columns, process_slices)
if nt.GetGlobalIsRoot():
nt.ActivateLogger()

# Set Up The Solver Parameters.
solver_parameters = nt.SolverParameters()
Expand Down Expand Up @@ -121,4 +123,8 @@

# Print the density matrix to file.
Density.WriteToMatrixMarket(density_file_out)

# Cleanup
if nt.GetGlobalIsRoot():
nt.DeactivateLogger()
nt.DestructGlobalProcessGrid()
7 changes: 7 additions & 0 deletions Examples/MatrixMaps/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using std::string;
#include <sstream>
using std::stringstream;
// NTPoly Headers
#include "Logging.h"
#include "MatrixMapper.h"
#include "PSMatrix.h"
#include "ProcessGrid.h"
Expand Down Expand Up @@ -53,6 +54,9 @@ int main(int argc, char *argv[]) {

// Setup the process grid.
NTPoly::ConstructGlobalProcessGrid(MPI_COMM_WORLD, process_slices, true);
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::ActivateLogger();
}

// Read in the matrices from file.
NTPoly::Matrix_ps Input(input_file);
Expand All @@ -66,6 +70,9 @@ int main(int argc, char *argv[]) {
Output.WriteToMatrixMarket(output_file);

// Cleanup
if (NTPoly::GetGlobalIsRoot()) {
NTPoly::DeactivateLogger();
}
NTPoly::DestructGlobalProcessGrid();
MPI_Finalize();
return 0;
Expand Down
12 changes: 10 additions & 2 deletions Examples/MatrixMaps/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
!> An example which shows how to use the matrix mapping feature of NTPoly.
PROGRAM MatrixMapsProgram
USE DataTypesModule, ONLY : NTREAL
USE LoggingModule, ONLY : EnterSubLog, ExitSubLog, WriteElement, WriteHeader
USE LoggingModule, ONLY : EnterSubLog, ExitSubLog, ActivateLogger, &
& DeactivateLogger, WriteElement, WriteHeader
USE MatrixMapsModule, ONLY : MapMatrix_psr
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid
USE ProcessGridModule, ONLY : ConstructProcessGrid, DestructProcessGrid, &
& IsRoot
USE PSMatrixModule, ONLY : Matrix_ps, ConstructMatrixFromMatrixMarket, &
& DestructMatrix, WriteMatrixToMatrixMarket
USE MPI
Expand Down Expand Up @@ -43,6 +45,9 @@ PROGRAM MatrixMapsProgram
CALL ConstructProcessGrid(MPI_COMM_WORLD, process_slices)

!! Print out parameters.
IF (IsRoot()) THEN
CALL ActivateLogger
END IF
CALL WriteHeader("Command Line Parameters")
CALL EnterSubLog
CALL WriteElement(key="input_matrix", VALUE=input_matrix)
Expand All @@ -64,6 +69,9 @@ PROGRAM MatrixMapsProgram
CALL DestructMatrix(OutMatrix)

!! Cleanup
IF (IsRoot()) THEN
CALL DeactivateLogger
END IF
CALL DestructProcessGrid
CALL MPI_Finalize(ierr)
CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
6 changes: 6 additions & 0 deletions Examples/MatrixMaps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def __call__(self):

# Setup the process grid.
nt.ConstructGlobalProcessGrid(process_slices)
if nt.GetGlobalIsRoot():
nt.ActivateLogger()

# Read in the matrices from file.
Input = nt.Matrix_ps(input_matrix)
Expand All @@ -48,4 +50,8 @@ def __call__(self):

# Print the density matrix to file.
Output.WriteToMatrixMarket(output_matrix)

# Cleanup
if nt.GetGlobalIsRoot():
nt.DeactivateLogger()
nt.DestructGlobalProcessGrid()
Loading

0 comments on commit b833530

Please sign in to comment.