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
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ set (MGMOL_WITH_SCALAPACK True CACHE BOOL "Build with SCALAPACK")
if (${MGMOL_WITH_SCALAPACK} OR DEFINED SCALAPACK_ROOT)
find_package(SCALAPACK)
if(${SCALAPACK_FOUND})
add_definitions(-DSCALAPACK)
add_definitions(-DMGMOL_USE_SCALAPACK)
message(STATUS "SCALAPACK_INCLUDE_DIRS: ${SCALAPACK_INCLUDE_DIRS}")
message(STATUS "SCALAPACK_LIBARIES: ${SCALAPACK_LIBRARIES}")
else(${SCALAPACK_FOUND})
Expand Down Expand Up @@ -220,7 +220,8 @@ FortranCInterface_HEADER(
DGETRF DGETRS DLACPY
)

FortranCInterface_HEADER(
if(${SCALAPACK_FOUND})
FortranCInterface_HEADER(
scalapack_mangle.h
MACRO_NAMESPACE "FC_SCALAPACK_"
SYMBOLS
Expand All @@ -233,7 +234,8 @@ FortranCInterface_HEADER(
pdtrtri pstrtri pdpocon pspocon pdsygst pssygst pdsyev pssyev
pdelset pselset pdelget pselget pdlatra pslatra pdlaset pslaset pdgesvd psgesvd
pdamax psamax
)
)
endif(${SCALAPACK_FOUND})

FortranCInterface_HEADER(
arpack_mangle.h
Expand Down
16 changes: 11 additions & 5 deletions src/AOMMprojector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
AOMMprojector::AOMMprojector(LocGridOrbitals<ORBDTYPE>& phi,
const std::shared_ptr<LocalizationRegions>& lrs)
{
Control& ct = *(Control::instance());
Mesh* mymesh = Mesh::instance();
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
Control& ct = *(Control::instance());
Mesh* mymesh = Mesh::instance();

bool with_spin = (mmpi.nspin() > 1);
const short subdivx = mymesh->subdivx();

// radius of kernel functions
Expand All @@ -43,10 +41,18 @@ AOMMprojector::AOMMprojector(LocGridOrbitals<ORBDTYPE>& phi,
kernel_proj_matrices_
= new ProjectedMatricesSparse(ct.numst, ct.occ_width, lrs);
else
{
#ifdef MGMOL_USE_SCALAPACK
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
bool with_spin = (mmpi.nspin() > 1);
kernel_proj_matrices_
= new ProjectedMatrices<dist_matrix::DistMatrix<DISTMATDTYPE>>(
ct.numst, with_spin, ct.occ_width);

#else
std::cerr << "AOMMprojector requires ScaLapack" << std::endl;
abort();
#endif
}
// kernel functions use their own projected matrices and masks
kernel_phi_ = new LocGridOrbitals<ORBDTYPE>(
"AOMM", phi, kernel_proj_matrices_, kernelMasks_, nullptr);
Expand Down
46 changes: 33 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

add_subdirectory(DistMatrix)
add_subdirectory(linear_algebra)
add_subdirectory(local_matrices)
add_subdirectory(numerical_kernels)
add_subdirectory(pb)
add_subdirectory(radial)
add_subdirectory(sparse_linear_algebra)
add_subdirectory(tools)
if(${MGMOL_WITH_SCALAPACK})
add_subdirectory(DistMatrix)
endif(${MGMOL_WITH_SCALAPACK})

if(${MGMOL_WITH_SCALAPACK})
set(link_libs mgmol_distmatrix
mgmol_linear_algebra
mgmol_local_matrices
Expand All @@ -17,6 +20,17 @@ set(link_libs mgmol_distmatrix
mgmol_sparse_linear_algebra
mgmol_tools
)
else(${MGMOL_WITH_SCALAPACK})
set(link_libs
mgmol_linear_algebra
mgmol_local_matrices
mgmol_numerical_kernels
mgmol_pb
mgmol_radial
mgmol_sparse_linear_algebra
mgmol_tools
)
endif(${MGMOL_WITH_SCALAPACK})

set(SOURCES
mgmol_run.cc
Expand All @@ -31,10 +45,6 @@ set(SOURCES
DielectricControl.cc
ReplicatedMatrix.cc
ReplicatedVector.cc
SquareSubMatrix2DistMatrix.cc
LocalMatrices2DistMatrix.cc
DistMatrix2SquareLocalMatrices.cc
GrassmanCGFactory.cc
DMStrategyFactory.cc
manage_memory.cc
SubCell.cc
Expand Down Expand Up @@ -71,9 +81,6 @@ set(SOURCES
MGmol.cc
MGmol_NEB.cc
ABPG.cc
GrassmanLineMinimization.cc
GrassmanCG.cc
GrassmanCGSparse.cc
LBFGS.cc
IonicStepper.cc
Energy.cc
Expand Down Expand Up @@ -112,8 +119,6 @@ set(SOURCES
MultipoleExpansion.cc
SpreadsAndCenters.cc
Preconditioning.cc
OrbitalsTransform.cc
NOLMOTransform.cc
LocalizationRegions.cc
Hartree.cc
ShiftedHartree.cc
Expand All @@ -132,7 +137,6 @@ set(SOURCES
lbfgsrlx.cc
OrthoAndersonMix.cc
AndersonMix.cc
MLWFTransform.cc
Ion.cc
GridMask.cc
GridMaskMult.cc
Expand All @@ -142,7 +146,6 @@ set(SOURCES
md.cc
get_vnlpsi.cc
quench.cc
mlwf.cc
readInput.cc
Forces.cc
computeHij.cc
Expand All @@ -161,9 +164,26 @@ set(SOURCES
magma_singleton.cc
ChebyshevApproximation.cc
ChebyshevApproximationInterface.cc
mlwf.cc
)

add_library(mgmol_src ${SOURCES})
if(${MGMOL_WITH_SCALAPACK})
set(SCALAPACK_SOURCES
SquareSubMatrix2DistMatrix.cc
LocalMatrices2DistMatrix.cc
DistMatrix2SquareLocalMatrices.cc
GrassmanCGFactory.cc
GrassmanLineMinimization.cc
GrassmanCG.cc
GrassmanCGSparse.cc
MLWFTransform.cc
NOLMOTransform.cc
OrbitalsTransform.cc
)
add_library(mgmol_src ${SOURCES} ${SCALAPACK_SOURCES})
else()
add_library(mgmol_src ${SOURCES})
endif(${MGMOL_WITH_SCALAPACK})

target_include_directories(mgmol_src PRIVATE ${HDF5_INCLUDE_DIRS})
target_include_directories(mgmol_src PRIVATE ${Boost_INCLUDE_DIRS})
Expand Down
7 changes: 6 additions & 1 deletion src/ChebyshevApproximation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
// Please also read this link https://github.com/llnl/mgmol/LICENSE

#include "ChebyshevApproximation.h"
#include "DistMatrix.h"
#include "MPIdata.h"
#include "ReplicatedMatrix.h"

#ifdef MGMOL_USE_SCALAPACK
#include "DistMatrix.h"
#endif

#include <iostream>

template <class MatrixType>
Expand Down Expand Up @@ -217,5 +220,7 @@ MatrixType ChebyshevApproximation<MatrixType>::computeChebyshevApproximation(
return mat;
}

#ifdef MGMOL_USE_SCALAPACK
template class ChebyshevApproximation<dist_matrix::DistMatrix<DISTMATDTYPE>>;
#endif
template class ChebyshevApproximation<ReplicatedMatrix>;
7 changes: 6 additions & 1 deletion src/DFTsolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
#include "DMStrategy.h"
#include "Electrostatic.h"
#include "Energy.h"
#include "GrassmanCGFactory.h"
#include "Ions.h"
#include "MGmol.h"
#include "Potentials.h"
#include "ProjectedMatricesInterface.h"
#include "Rho.h"

#ifdef MGMOL_USE_SCALAPACK
#include "GrassmanCGFactory.h"
#endif

template <class OrbitalsType>
DFTsolver<OrbitalsType>::DFTsolver(Hamiltonian<OrbitalsType>* hamiltonian,
ProjectedMatricesInterface* proj_matrices, Energy<OrbitalsType>* energy,
Expand Down Expand Up @@ -48,6 +51,7 @@ DFTsolver<OrbitalsType>::DFTsolver(Hamiltonian<OrbitalsType>* hamiltonian,
break;
}

#ifdef MGMOL_USE_SCALAPACK
case OuterSolverType::NLCG:
{
orbitals_stepper_ = GrassmanCGFactory<OrbitalsType>::create(
Expand All @@ -56,6 +60,7 @@ DFTsolver<OrbitalsType>::DFTsolver(Hamiltonian<OrbitalsType>* hamiltonian,

break;
}
#endif

default:
std::cerr << "DFTsolver: Undefined iterative electronic structure "
Expand Down
4 changes: 4 additions & 0 deletions src/DMStrategyFactory.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DMStrategyFactory.h"
#include "ReplicatedMatrix.h"

#ifdef MGMOL_USE_SCALAPACK
template <>
DMStrategy<LocGridOrbitals<ORBDTYPE>>*
DMStrategyFactory<LocGridOrbitals<ORBDTYPE>,
Expand Down Expand Up @@ -35,6 +36,7 @@ DMStrategyFactory<LocGridOrbitals<ORBDTYPE>,
return dm_strategy;
}
}
#endif

template <>
DMStrategy<LocGridOrbitals<ORBDTYPE>>*
Expand All @@ -56,6 +58,7 @@ DMStrategyFactory<LocGridOrbitals<ORBDTYPE>,
return nullptr;
}

#ifdef MGMOL_USE_SCALAPACK
template <>
DMStrategy<ExtendedGridOrbitals<ORBDTYPE>>*
DMStrategyFactory<ExtendedGridOrbitals<ORBDTYPE>,
Expand All @@ -78,6 +81,7 @@ DMStrategyFactory<ExtendedGridOrbitals<ORBDTYPE>,

return dm_strategy;
}
#endif

template <>
DMStrategy<ExtendedGridOrbitals<ORBDTYPE>>*
Expand Down
2 changes: 2 additions & 0 deletions src/DavidsonSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ void DavidsonSolver<OrbitalsType, MatrixType>::printTimers(std::ostream& os)
target_tm_.print(os);
}

#ifdef MGMOL_USE_SCALAPACK
template class DavidsonSolver<ExtendedGridOrbitals<ORBDTYPE>,
dist_matrix::DistMatrix<DISTMATDTYPE>>;
#endif
template class DavidsonSolver<ExtendedGridOrbitals<ORBDTYPE>, ReplicatedMatrix>;
9 changes: 8 additions & 1 deletion src/DensityMatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@

#include "DensityMatrix.h"

#include "DistMatrix.h"
#include "MGmol_MPI.h"
#include "ReplicatedMatrix.h"
#include "ReplicatedWorkSpace.h"
#include "hdf_tools.h"

#ifdef MGMOL_USE_SCALAPACK
#include "DistMatrix.h"
#else
typedef double DISTMATDTYPE;
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -477,5 +482,7 @@ int DensityMatrix<MatrixType>::read(HDFrestart& h5f_file, std::string& name)
return ierr;
}

#ifdef MGMOL_USE_SCALAPACK
template class DensityMatrix<dist_matrix::DistMatrix<double>>;
#endif
template class DensityMatrix<ReplicatedMatrix>;
4 changes: 2 additions & 2 deletions src/DistMatrix/BlacsContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include <cmath>
#include <iostream>

#ifdef SCALAPACK
#ifdef MGMOL_USE_SCALAPACK
#include "blacs.h"
#endif

#ifndef SCALAPACK
#ifndef MGMOL_USE_SCALAPACK

void Cblacs_pinfo(int* mypnum, int* nprocs)
{
Expand Down
Loading