Revision | f68202403659b55e093da1045d06af88122c8a26 (tree) |
---|---|
Zeit | 2013-07-31 20:06:38 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Calculating of forces of ZindoS is partially MPI-parallelized. #31814
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1448 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<boost/shared_ptr.hpp> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"base/Uncopyable.h" |
27 | -#include"mpi/MpiProcess.h" | |
28 | 27 | #include"base/PrintController.h" |
29 | 28 | #include"base/MolDSException.h" |
29 | +#include"base/MallocerFreer.h" | |
30 | +#include"mpi/MpiProcess.h" | |
30 | 31 | #include"base/Enums.h" |
31 | 32 | #include"base/EularAngle.h" |
32 | 33 | #include"base/atoms/Atom.h" |
@@ -37,9 +37,9 @@ EXENAME = MolDS.out | ||
37 | 37 | DEPFILE = obj/objfile.dep |
38 | 38 | LDFLAGS = |
39 | 39 | |
40 | -ALL_CPP_FILES = Main.cpp mpi/MpiProcess.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
41 | -ALL_HEAD_FILES = base/Uncopyable.h mpi/MpiProcess.h base/PrintController.h base/MolDSException.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
42 | -ALL_OBJ_FILES = obj/MpiProcess.o obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
40 | +ALL_CPP_FILES = base/PrintController.cpp base/MolDSException.cpp base/MallocerFreer.cpp mpi/MpiProcess.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp Main.cpp | |
41 | +ALL_HEAD_FILES = base/Uncopyable.h base/PrintController.h base/MolDSException.h base/MallocerFreer.h mpi/MpiProcess.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
42 | +ALL_OBJ_FILES = obj/PrintController.o obj/MolDSException.o obj/MallocerFreer.o obj/MpiProcess.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o obj/Main.o | |
43 | 43 | |
44 | 44 | $(EXENAME): $(ALL_OBJ_FILES) |
45 | 45 | $(CC) -o $@ -Wl,-rpath=$(BOOST_LIB_DIR) -L$(BOOST_LIB_DIR) $(LDFLAGS) $(ALL_OBJ_FILES) $(LIBS) |
@@ -34,9 +34,9 @@ EXENAME = MolDS.out | ||
34 | 34 | DEPFILE = obj/objfile.dep |
35 | 35 | LDFLAGS = |
36 | 36 | |
37 | -ALL_CPP_FILES = Main.cpp mpi/MpiProcess.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp | |
38 | -ALL_HEAD_FILES = base/Uncopyable.h mpi/MpiProcess.h base/PrintController.h base/MolDSException.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
39 | -ALL_OBJ_FILES = obj/MpiProcess.o obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o | |
37 | +ALL_CPP_FILES = base/PrintController.cpp base/MolDSException.cpp base/MallocerFreer.cpp mpi/MpiProcess.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp Main.cpp | |
38 | +ALL_HEAD_FILES = base/Uncopyable.h base/PrintController.h base/MolDSException.h base/MallocerFreer.h mpi/MpiProcess.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h | |
39 | +ALL_OBJ_FILES = obj/PrintController.o obj/MolDSException.o obj/MallocerFreer.o obj/MpiProcess.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o obj/Main.o | |
40 | 40 | |
41 | 41 | $(EXENAME): $(ALL_OBJ_FILES) |
42 | 42 | $(CC) -o $@ $(LDFLAGS) -Wl,-rpath=$(BOOST_LIB_DIR) -Wl,-rpath=$(OPENBLAS_LIB_DIR) $(LDFLAGS) $(ALL_OBJ_FILES) -L$(BOOST_LIB_DIR) -L$(OPENBLAS_LIB_DIR) $(LIBS) |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Parameters.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Parameters.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<stdexcept> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"Uncopyable.h" |
32 | -#include"../mpi/MpiProcess.h" | |
33 | 32 | #include"PrintController.h" |
34 | 33 | #include"MolDSException.h" |
34 | +#include"MallocerFreer.h" | |
35 | +#include"../mpi/MpiProcess.h" | |
35 | 36 | #include"Utilities.h" |
36 | 37 | #include"Enums.h" |
37 | 38 | #include"EularAngle.h" |
@@ -26,11 +26,11 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"Uncopyable.h" |
29 | -#include"../mpi/MpiProcess.h" | |
30 | 29 | #include"PrintController.h" |
31 | 30 | #include"MolDSException.h" |
32 | -#include"Enums.h" | |
33 | 31 | #include"MallocerFreer.h" |
32 | +#include"../mpi/MpiProcess.h" | |
33 | +#include"Enums.h" | |
34 | 34 | #include"EularAngle.h" |
35 | 35 | #include"Parameters.h" |
36 | 36 | using namespace std; |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include<boost/math/special_functions/factorials.hpp> |
27 | 27 | #include"Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"PrintController.h" |
30 | 29 | #include"MolDSException.h" |
30 | +#include"MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../wrappers/Lapack.h" |
32 | 33 | #include"Enums.h" |
33 | 34 | #include"MathUtilities.h" |
@@ -31,14 +31,14 @@ | ||
31 | 31 | #include<boost/random.hpp> |
32 | 32 | #include<boost/format.hpp> |
33 | 33 | #include"Uncopyable.h" |
34 | -#include"../mpi/MpiProcess.h" | |
35 | 34 | #include"PrintController.h" |
36 | 35 | #include"MolDSException.h" |
36 | +#include"MallocerFreer.h" | |
37 | +#include"../mpi/MpiProcess.h" | |
37 | 38 | #include"../wrappers/Blas.h" |
38 | 39 | #include"../wrappers/Lapack.h" |
39 | 40 | #include"Utilities.h" |
40 | 41 | #include"Enums.h" |
41 | -#include"MallocerFreer.h" | |
42 | 42 | #include"EularAngle.h" |
43 | 43 | #include"Parameters.h" |
44 | 44 | #include"atoms/Atom.h" |
@@ -26,13 +26,13 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"Uncopyable.h" |
29 | -#include"../mpi/MpiProcess.h" | |
30 | 29 | #include"PrintController.h" |
31 | 30 | #include"MolDSException.h" |
31 | +#include"MallocerFreer.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
32 | 33 | #include"../wrappers/Lapack.h" |
33 | 34 | #include"Enums.h" |
34 | 35 | #include"MathUtilities.h" |
35 | -#include"MallocerFreer.h" | |
36 | 36 | #include"EularAngle.h" |
37 | 37 | #include"Parameters.h" |
38 | 38 | #include"atoms/Atom.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<stdexcept> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"PrintController.h" |
33 | 32 | #include"MolDSException.h" |
33 | +#include"MallocerFreer.h" | |
34 | +#include"../mpi/MpiProcess.h" | |
34 | 35 | #include"Enums.h" |
35 | 36 | #include"MallocerFreer.h" |
36 | 37 | #include"EularAngle.h" |
@@ -0,0 +1,64 @@ | ||
1 | +//************************************************************************// | |
2 | +// Copyright (C) 2011-2013 Mikiya Fujii // | |
3 | +// Copyright (C) 2011-2013 Katsuhiko Nishimra // | |
4 | +// // | |
5 | +// This file is part of MolDS. // | |
6 | +// // | |
7 | +// MolDS is free software: you can redistribute it and/or modify // | |
8 | +// it under the terms of the GNU General Public License as published by // | |
9 | +// the Free Software Foundation, either version 3 of the License, or // | |
10 | +// (at your option) any later version. // | |
11 | +// // | |
12 | +// MolDS is distributed in the hope that it will be useful, // | |
13 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
14 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
15 | +// GNU General Public License for more details. // | |
16 | +// // | |
17 | +// You should have received a copy of the GNU General Public License // | |
18 | +// along with MolDS. If not, see <http://www.gnu.org/licenses/>. // | |
19 | +//************************************************************************// | |
20 | +#include<sstream> | |
21 | +#include<string> | |
22 | +#include<iostream> | |
23 | +#include<cctype> | |
24 | +#include<boost/format.hpp> | |
25 | +#include"Uncopyable.h" | |
26 | +#include"PrintController.h" | |
27 | +#include"MolDSException.h" | |
28 | +#include"MallocerFreer.h" | |
29 | +#include"../mpi/MpiProcess.h" | |
30 | +using namespace std; | |
31 | +namespace MolDS_base{ | |
32 | + | |
33 | +PrintController::PrintController(){ | |
34 | + this->canOutputLogs = true; | |
35 | + //this->OutputLog("printController is created.\n"); | |
36 | +} | |
37 | + | |
38 | +PrintController::~PrintController(){ | |
39 | + //this->OutputLog("printController is destructed.\n"; | |
40 | +} | |
41 | + | |
42 | +void PrintController::OutputLog(string log) const{ | |
43 | + if(this->canOutputLogs){ | |
44 | +#ifndef MOLDS_DBG | |
45 | + if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;} | |
46 | +#endif | |
47 | + bool endl = false; | |
48 | + string::reverse_iterator iter; | |
49 | + for(iter = log.rbegin(); iter != log.rend(); iter++){ | |
50 | + if(*iter == '\n'){ | |
51 | + string::iterator fwditer = iter.base(); | |
52 | + log.erase(--fwditer); | |
53 | + endl = true; | |
54 | + break; | |
55 | + } | |
56 | + else if(*iter != '\0'){ | |
57 | + break; | |
58 | + } | |
59 | + } | |
60 | + cout << log; | |
61 | + if(endl){cout << std::endl;} | |
62 | + } | |
63 | +} | |
64 | +} |
@@ -23,45 +23,13 @@ namespace MolDS_base{ | ||
23 | 23 | |
24 | 24 | class PrintController{ |
25 | 25 | public: |
26 | - PrintController(){ | |
27 | - this->canOutputLogs = true; | |
28 | - //this->OutputLog("printController is created.\n"); | |
29 | - } | |
30 | - virtual ~PrintController(){ | |
31 | - //this->OutputLog("printController is destructed.\n"; | |
32 | - } | |
33 | - bool CanOutputLogs() const{ | |
34 | - return this->canOutputLogs; | |
35 | - } | |
36 | - void SetCanOutputLogs(bool canOutputLogs){ | |
37 | - this->canOutputLogs = canOutputLogs; | |
38 | - } | |
26 | + PrintController(); | |
27 | + virtual ~PrintController(); | |
28 | + bool CanOutputLogs() const {return this->canOutputLogs;} | |
29 | + void SetCanOutputLogs(bool canOutputLogs){this->canOutputLogs = canOutputLogs;} | |
39 | 30 | protected: |
40 | - void OutputLog(const boost::format& log) const{ | |
41 | - this->OutputLog(log.str()); | |
42 | - } | |
43 | - void OutputLog(std::string log) const{ | |
44 | - if(this->canOutputLogs){ | |
45 | -#ifndef MOLDS_DBG | |
46 | - if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;} | |
47 | -#endif | |
48 | - bool endl = false; | |
49 | - std::string::reverse_iterator iter; | |
50 | - for(iter = log.rbegin(); iter != log.rend(); iter++){ | |
51 | - if(*iter == '\n'){ | |
52 | - std::string::iterator fwditer = iter.base(); | |
53 | - log.erase(--fwditer); | |
54 | - endl = true; | |
55 | - break; | |
56 | - } | |
57 | - else if(*iter != '\0'){ | |
58 | - break; | |
59 | - } | |
60 | - } | |
61 | - std::cout << log; | |
62 | - if(endl){std::cout << std::endl;} | |
63 | - } | |
64 | - } | |
31 | + void OutputLog(const boost::format& log) const{this->OutputLog(log.str());} | |
32 | + void OutputLog(std::string log) const; | |
65 | 33 | private: |
66 | 34 | bool canOutputLogs; |
67 | 35 | }; |
@@ -26,8 +26,10 @@ | ||
26 | 26 | #include<omp.h> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"Uncopyable.h" |
29 | -#include"../mpi/MpiProcess.h" | |
30 | 29 | #include"PrintController.h" |
30 | +#include"MolDSException.h" | |
31 | +#include"MallocerFreer.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
31 | 33 | #include"Utilities.h" |
32 | 34 | using namespace std; |
33 | 35 |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<stdexcept> |
28 | 28 | #include<boost/format.hpp> |
29 | 29 | #include"../Uncopyable.h" |
30 | -#include"../../mpi/MpiProcess.h" | |
31 | 30 | #include"../PrintController.h" |
32 | 31 | #include"../MolDSException.h" |
32 | +#include"../MallocerFreer.h" | |
33 | +#include"../../mpi/MpiProcess.h" | |
33 | 34 | #include"../Enums.h" |
34 | 35 | #include"../MathUtilities.h" |
35 | 36 | #include"../MallocerFreer.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,8 +24,10 @@ | ||
24 | 24 | #include<vector> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
28 | +#include"../MolDSException.h" | |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
29 | 31 | #include"../Enums.h" |
30 | 32 | #include"../EularAngle.h" |
31 | 33 | #include"../Parameters.h" |
@@ -24,9 +24,10 @@ | ||
24 | 24 | #include<stdexcept> |
25 | 25 | #include<boost/format.hpp> |
26 | 26 | #include"../Uncopyable.h" |
27 | -#include"../../mpi/MpiProcess.h" | |
28 | 27 | #include"../PrintController.h" |
29 | 28 | #include"../MolDSException.h" |
29 | +#include"../MallocerFreer.h" | |
30 | +#include"../../mpi/MpiProcess.h" | |
30 | 31 | #include"../Enums.h" |
31 | 32 | #include"../atoms/Atom.h" |
32 | 33 | #include"../atoms/Hatom.h" |
@@ -25,11 +25,11 @@ | ||
25 | 25 | #include<stdexcept> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../Uncopyable.h" |
28 | -#include"../../mpi/MpiProcess.h" | |
29 | 28 | #include"../PrintController.h" |
30 | 29 | #include"../MolDSException.h" |
31 | -#include"../Enums.h" | |
32 | 30 | #include"../MallocerFreer.h" |
31 | +#include"../../mpi/MpiProcess.h" | |
32 | +#include"../Enums.h" | |
33 | 33 | #include"../EularAngle.h" |
34 | 34 | #include"../Parameters.h" |
35 | 35 | #include"../atoms/Atom.h" |
@@ -26,11 +26,11 @@ | ||
26 | 26 | #include<boost/shared_ptr.hpp> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"../Uncopyable.h" |
29 | -#include"../../mpi/MpiProcess.h" | |
30 | 29 | #include"../PrintController.h" |
31 | 30 | #include"../MolDSException.h" |
32 | -#include"../Enums.h" | |
33 | 31 | #include"../MallocerFreer.h" |
32 | +#include"../../mpi/MpiProcess.h" | |
33 | +#include"../Enums.h" | |
34 | 34 | #include"../EularAngle.h" |
35 | 35 | #include"../Parameters.h" |
36 | 36 | #include"../atoms/Atom.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../Uncopyable.h" |
32 | -#include"../../mpi/MpiProcess.h" | |
33 | 32 | #include"../PrintController.h" |
34 | 33 | #include"../MolDSException.h" |
34 | +#include"../MallocerFreer.h" | |
35 | +#include"../../mpi/MpiProcess.h" | |
35 | 36 | #include"../Utilities.h" |
36 | 37 | #include"../Enums.h" |
37 | 38 | #include"../MallocerFreer.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../Uncopyable.h" |
32 | -#include"../../mpi/MpiProcess.h" | |
33 | 32 | #include"../PrintController.h" |
34 | 33 | #include"../MolDSException.h" |
34 | +#include"../MallocerFreer.h" | |
35 | +#include"../../mpi/MpiProcess.h" | |
35 | 36 | #include"../Utilities.h" |
36 | 37 | #include"../Enums.h" |
37 | 38 | #include"../EularAngle.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../Uncopyable.h" |
32 | -#include"../../mpi/MpiProcess.h" | |
33 | 32 | #include"../PrintController.h" |
34 | 33 | #include"../MolDSException.h" |
34 | +#include"../MallocerFreer.h" | |
35 | +#include"../../mpi/MpiProcess.h" | |
35 | 36 | #include"../Utilities.h" |
36 | 37 | #include"../Enums.h" |
37 | 38 | #include"../EularAngle.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../Uncopyable.h" |
32 | -#include"../../mpi/MpiProcess.h" | |
33 | 32 | #include"../PrintController.h" |
34 | 33 | #include"../MolDSException.h" |
34 | +#include"../MallocerFreer.h" | |
35 | +#include"../../mpi/MpiProcess.h" | |
35 | 36 | #include"../Utilities.h" |
36 | 37 | #include"../Enums.h" |
37 | 38 | #include"../EularAngle.h" |
@@ -29,9 +29,10 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../base/Uncopyable.h" |
32 | -#include"../mpi/MpiProcess.h" | |
33 | 32 | #include"../base/PrintController.h" |
34 | 33 | #include"../base/MolDSException.h" |
34 | +#include"../base/MallocerFreer.h" | |
35 | +#include"../mpi/MpiProcess.h" | |
35 | 36 | #include"../wrappers/Blas.h" |
36 | 37 | #include"../wrappers/Lapack.h" |
37 | 38 | #include"../base/Enums.h" |
@@ -26,9 +26,10 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"../base/Uncopyable.h" |
29 | -#include"../mpi/MpiProcess.h" | |
30 | 29 | #include"../base/PrintController.h" |
31 | 30 | #include"../base/MolDSException.h" |
31 | +#include"../base/MallocerFreer.h" | |
32 | +#include"../mpi/MpiProcess.h" | |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/atoms/Atom.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
33 | +#include"../base/MallocerFreer.h" | |
34 | +#include"../mpi/MpiProcess.h" | |
34 | 35 | #include"../base/Enums.h" |
35 | 36 | #include"../base/EularAngle.h" |
36 | 37 | #include"../base/Parameters.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<boost/shared_ptr.hpp> |
28 | 28 | #include<boost/format.hpp> |
29 | 29 | #include"../base/Uncopyable.h" |
30 | -#include"../mpi/MpiProcess.h" | |
31 | 30 | #include"../base/PrintController.h" |
32 | 31 | #include"../base/MolDSException.h" |
32 | +#include"../base/MallocerFreer.h" | |
33 | +#include"../mpi/MpiProcess.h" | |
33 | 34 | #include"../base/Enums.h" |
34 | 35 | #include"../base/EularAngle.h" |
35 | 36 | #include"../base/Parameters.h" |
@@ -27,9 +27,10 @@ | ||
27 | 27 | #include<omp.h> |
28 | 28 | #include<boost/format.hpp> |
29 | 29 | #include"../base/Uncopyable.h" |
30 | -#include"../mpi/MpiProcess.h" | |
31 | 30 | #include"../base/PrintController.h" |
32 | 31 | #include"../base/MolDSException.h" |
32 | +#include"../base/MallocerFreer.h" | |
33 | +#include"../mpi/MpiProcess.h" | |
33 | 34 | #include"../wrappers/Blas.h" |
34 | 35 | #include"../wrappers/Lapack.h" |
35 | 36 | #include"../base/Enums.h" |
@@ -23,8 +23,11 @@ | ||
23 | 23 | #include<math.h> |
24 | 24 | #include<string> |
25 | 25 | #include<stdexcept> |
26 | -#include"../base/MolDSException.h" | |
26 | +#include<boost/format.hpp> | |
27 | 27 | #include"../base/Uncopyable.h" |
28 | +#include"../base/PrintController.h" | |
29 | +#include"../base/MolDSException.h" | |
30 | +#include"../base/MallocerFreer.h" | |
28 | 31 | #include"MpiProcess.h" |
29 | 32 | using namespace std; |
30 | 33 | namespace MolDS_mpi{ |
@@ -51,6 +51,38 @@ public: | ||
51 | 51 | broadcast(*this->communicator, &values[chunks[i].first], chunks[i].num, root); |
52 | 52 | } |
53 | 53 | } |
54 | + template<typename T, typename Op> void Reduce(const T* inValues, intptr_t num, T* outValues, Op op, int root) const{ | |
55 | + std::vector<Chunk> chunks; | |
56 | + intptr_t tag=0; | |
57 | + this->SplitMessage2Chunks(chunks, tag, inValues, num); | |
58 | + for(intptr_t i=0; i<chunks.size(); i++){ | |
59 | + reduce(*this->communicator, &inValues[chunks[i].first], chunks[i].num, &outValues[chunks[i].first], op, root); | |
60 | + } | |
61 | + } | |
62 | + template<typename T, typename Op> void AllReduce(const T* inValues, intptr_t num, T* outValues, Op op) const{ | |
63 | + std::vector<Chunk> chunks; | |
64 | + intptr_t tag=0; | |
65 | + this->SplitMessage2Chunks(chunks, tag, inValues, num); | |
66 | + for(intptr_t i=0; i<chunks.size(); i++){ | |
67 | + all_reduce(*this->communicator, &inValues[chunks[i].first], chunks[i].num, &outValues[chunks[i].first], op); | |
68 | + } | |
69 | + } | |
70 | + template<typename T, typename Op> void AllReduce(T* values, intptr_t num, Op op) const{ | |
71 | + double* tmpValues=NULL; | |
72 | + try{ | |
73 | + MolDS_base::MallocerFreer::GetInstance()->Malloc<double>(&tmpValues, num); | |
74 | + this->AllReduce(values, num, tmpValues, op); | |
75 | + for(intptr_t i=0; i<num; i++){ | |
76 | + values[i] = tmpValues[i]; | |
77 | + } | |
78 | + } | |
79 | + catch(MolDS_base::MolDSException ex){ | |
80 | + MolDS_base::MallocerFreer::GetInstance()->Free<double>(&tmpValues, num); | |
81 | + throw ex; | |
82 | + } | |
83 | + MolDS_base::MallocerFreer::GetInstance()->Free<double>(&tmpValues, num); | |
84 | + } | |
85 | + | |
54 | 86 | private: |
55 | 87 | static MpiProcess* mpiProcess; |
56 | 88 | MpiProcess(); |
@@ -28,11 +28,11 @@ | ||
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
34 | -#include"../base/Enums.h" | |
35 | 33 | #include"../base/MallocerFreer.h" |
34 | +#include"../mpi/MpiProcess.h" | |
35 | +#include"../base/Enums.h" | |
36 | 36 | #include"../base/EularAngle.h" |
37 | 37 | #include"../base/Parameters.h" |
38 | 38 | #include"../base/atoms/Atom.h" |
@@ -29,13 +29,13 @@ | ||
29 | 29 | #include<boost/shared_ptr.hpp> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../base/Uncopyable.h" |
32 | -#include"../mpi/MpiProcess.h" | |
33 | 32 | #include"../base/PrintController.h" |
34 | 33 | #include"../base/MolDSException.h" |
34 | +#include"../base/MallocerFreer.h" | |
35 | +#include"../mpi/MpiProcess.h" | |
35 | 36 | #include"../wrappers/Blas.h" |
36 | 37 | #include"../wrappers/Lapack.h" |
37 | 38 | #include"../base/Enums.h" |
38 | -#include"../base/MallocerFreer.h" | |
39 | 39 | #include"../base/EularAngle.h" |
40 | 40 | #include"../base/Parameters.h" |
41 | 41 | #include"../base/atoms/Atom.h" |
@@ -28,11 +28,11 @@ | ||
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
34 | -#include"../base/Enums.h" | |
35 | 33 | #include"../base/MallocerFreer.h" |
34 | +#include"../mpi/MpiProcess.h" | |
35 | +#include"../base/Enums.h" | |
36 | 36 | #include"../base/EularAngle.h" |
37 | 37 | #include"../base/Parameters.h" |
38 | 38 | #include"../base/atoms/Atom.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
33 | +#include"../base/MallocerFreer.h" | |
34 | +#include"../mpi/MpiProcess.h" | |
34 | 35 | #include"../base/Enums.h" |
35 | 36 | #include"../base/EularAngle.h" |
36 | 37 | #include"../base/Parameters.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<boost/shared_ptr.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
33 | +#include"../base/MallocerFreer.h" | |
34 | +#include"../mpi/MpiProcess.h" | |
34 | 35 | #include"../base/Enums.h" |
35 | 36 | #include"../base/EularAngle.h" |
36 | 37 | #include"../base/Parameters.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Parameters.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Parameters.h" |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<vector> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"../base/EularAngle.h" |
33 | 34 | #include"../base/Parameters.h" |
@@ -28,9 +28,10 @@ | ||
28 | 28 | #include<boost/random.hpp> |
29 | 29 | #include<boost/format.hpp> |
30 | 30 | #include"../base/Uncopyable.h" |
31 | -#include"../mpi/MpiProcess.h" | |
32 | 31 | #include"../base/PrintController.h" |
33 | 32 | #include"../base/MolDSException.h" |
33 | +#include"../base/MallocerFreer.h" | |
34 | +#include"../mpi/MpiProcess.h" | |
34 | 35 | #include"../base/Enums.h" |
35 | 36 | #include"../base/EularAngle.h" |
36 | 37 | #include"../base/Parameters.h" |
@@ -26,10 +26,10 @@ | ||
26 | 26 | #include<stdexcept> |
27 | 27 | #include<boost/format.hpp> |
28 | 28 | #include"../base/Uncopyable.h" |
29 | -#include"../mpi/MpiProcess.h" | |
30 | 29 | #include"../base/PrintController.h" |
31 | 30 | #include"../base/MolDSException.h" |
32 | 31 | #include"../base/MallocerFreer.h" |
32 | +#include"../mpi/MpiProcess.h" | |
33 | 33 | #include"Blas.h" |
34 | 34 | |
35 | 35 | #ifdef __INTEL_COMPILER |
@@ -25,9 +25,10 @@ | ||
25 | 25 | #include<stdexcept> |
26 | 26 | #include<boost/format.hpp> |
27 | 27 | #include"../base/Uncopyable.h" |
28 | -#include"../mpi/MpiProcess.h" | |
29 | 28 | #include"../base/PrintController.h" |
30 | 29 | #include"../base/MolDSException.h" |
30 | +#include"../base/MallocerFreer.h" | |
31 | +#include"../mpi/MpiProcess.h" | |
31 | 32 | #include"../base/Enums.h" |
32 | 33 | #include"Lapack.h" |
33 | 34 |
@@ -29,14 +29,14 @@ | ||
29 | 29 | #include<omp.h> |
30 | 30 | #include<boost/format.hpp> |
31 | 31 | #include"../base/Uncopyable.h" |
32 | -#include"../mpi/MpiProcess.h" | |
33 | 32 | #include"../base/PrintController.h" |
34 | 33 | #include"../base/MolDSException.h" |
34 | +#include"../base/MallocerFreer.h" | |
35 | +#include"../mpi/MpiProcess.h" | |
35 | 36 | #include"../wrappers/Blas.h" |
36 | 37 | #include"../wrappers/Lapack.h" |
37 | 38 | #include"../base/Enums.h" |
38 | 39 | #include"../base/MathUtilities.h" |
39 | -#include"../base/MallocerFreer.h" | |
40 | 40 | #include"../base/EularAngle.h" |
41 | 41 | #include"../base/Parameters.h" |
42 | 42 | #include"../base/atoms/Atom.h" |
@@ -3574,31 +3574,35 @@ void ZindoS::CalcDiatomicTwoElecTwoCore1stDerivatives(double*** matrix, | ||
3574 | 3574 | // elecStates is indeces of the electroinc eigen states. |
3575 | 3575 | // The index = 0 means electronic ground state. |
3576 | 3576 | void ZindoS::CalcForce(const vector<int>& elecStates){ |
3577 | + int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank(); | |
3578 | + int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize(); | |
3577 | 3579 | this->CheckMatrixForce(elecStates); |
3578 | 3580 | if(this->RequiresExcitedStatesForce(elecStates)){ |
3579 | 3581 | this->CalcEtaMatrixForce(elecStates); |
3580 | 3582 | this->CalcZMatrixForce(elecStates); |
3581 | 3583 | } |
3582 | - stringstream ompErrors; | |
3584 | + | |
3585 | + // this loop is MPI-parallelized | |
3586 | + for(int a=0; a<this->molecule->GetNumberAtoms(); a++){ | |
3587 | + if(a%mpiSize != mpiRank){continue;} | |
3588 | + const Atom& atomA = *molecule->GetAtom(a); | |
3589 | + int firstAOIndexA = atomA.GetFirstAOIndex(); | |
3590 | + int lastAOIndexA = atomA.GetLastAOIndex(); | |
3591 | + stringstream ompErrors; | |
3583 | 3592 | #pragma omp parallel |
3584 | - { | |
3585 | - double*** diatomicTwoElecTwoCore1stDerivs = NULL; | |
3586 | - double*** diatomicOverlapAOs1stDerivs = NULL; | |
3587 | - try{ | |
3588 | - MallocerFreer::GetInstance()->Malloc<double>(&diatomicTwoElecTwoCore1stDerivs, | |
3589 | - OrbitalType_end, | |
3590 | - OrbitalType_end, | |
3591 | - CartesianType_end); | |
3592 | - MallocerFreer::GetInstance()->Malloc<double>(&diatomicOverlapAOs1stDerivs, | |
3593 | - OrbitalType_end, | |
3594 | - OrbitalType_end, | |
3595 | - CartesianType_end); | |
3596 | - | |
3593 | + { | |
3594 | + double*** diatomicTwoElecTwoCore1stDerivs = NULL; | |
3595 | + double*** diatomicOverlapAOs1stDerivs = NULL; | |
3596 | + try{ | |
3597 | + MallocerFreer::GetInstance()->Malloc<double>(&diatomicTwoElecTwoCore1stDerivs, | |
3598 | + OrbitalType_end, | |
3599 | + OrbitalType_end, | |
3600 | + CartesianType_end); | |
3601 | + MallocerFreer::GetInstance()->Malloc<double>(&diatomicOverlapAOs1stDerivs, | |
3602 | + OrbitalType_end, | |
3603 | + OrbitalType_end, | |
3604 | + CartesianType_end); | |
3597 | 3605 | #pragma omp for schedule(auto) |
3598 | - for(int a=0; a<this->molecule->GetNumberAtoms(); a++){ | |
3599 | - const Atom& atomA = *molecule->GetAtom(a); | |
3600 | - int firstAOIndexA = atomA.GetFirstAOIndex(); | |
3601 | - int lastAOIndexA = atomA.GetLastAOIndex(); | |
3602 | 3606 | for(int b=0; b<this->molecule->GetNumberAtoms(); b++){ |
3603 | 3607 | if(a == b){continue;} |
3604 | 3608 | const Atom& atomB = *molecule->GetAtom(b); |
@@ -3713,27 +3717,60 @@ void ZindoS::CalcForce(const vector<int>& elecStates){ | ||
3713 | 3717 | } |
3714 | 3718 | } |
3715 | 3719 | } |
3716 | - } // end of for(int b) | |
3717 | - } // end of for(int a) | |
3718 | - } // end of try | |
3719 | - catch(MolDSException ex){ | |
3720 | + } // end of for(int b) with omp parallelization | |
3721 | + }// end of try for omp-for | |
3722 | + catch(MolDSException ex){ | |
3720 | 3723 | #pragma omp critical |
3721 | - ex.Serialize(ompErrors); | |
3724 | + ex.Serialize(ompErrors); | |
3725 | + } | |
3726 | + MallocerFreer::GetInstance()->Free<double>(&diatomicTwoElecTwoCore1stDerivs, | |
3727 | + OrbitalType_end, | |
3728 | + OrbitalType_end, | |
3729 | + CartesianType_end); | |
3730 | + MallocerFreer::GetInstance()->Free<double>(&diatomicOverlapAOs1stDerivs, | |
3731 | + OrbitalType_end, | |
3732 | + OrbitalType_end, | |
3733 | + CartesianType_end); | |
3734 | + } //end of parallelized region | |
3735 | + // Exception throwing for omp-region | |
3736 | + if(!ompErrors.str().empty()){ | |
3737 | + throw MolDSException::Deserialize(ompErrors); | |
3738 | + } | |
3739 | + } // end of for(int a) with MPI parallelization | |
3740 | + | |
3741 | + // communication to reduce thsi->matrixForce on all node (namely, all_reduce) | |
3742 | + int numTransported = elecStates.size()*this->molecule->GetNumberAtoms()*CartesianType_end; | |
3743 | + MolDS_mpi::MpiProcess::GetInstance()->AllReduce(&this->matrixForce[0][0][0], numTransported, std::plus<double>()); | |
3744 | + /* | |
3745 | + double*** tmp=NULL; | |
3746 | + try{ | |
3747 | + MallocerFreer::GetInstance()->Malloc<double>(&tmp, | |
3748 | + elecStates.size(), | |
3749 | + this->molecule->GetNumberAtoms(), | |
3750 | + CartesianType_end); | |
3751 | + MolDS_mpi::MpiProcess::GetInstance()->AllReduce(&this->matrixForce[0][0][0], numTransported, &tmp[0][0][0], std::plus<double>()); | |
3752 | + for(int n=0; n<elecStates.size(); n++){ | |
3753 | + for(int a=0; a<this->molecule->GetNumberAtoms(); a++){ | |
3754 | + for(int i=0; i<CartesianType_end; i++){ | |
3755 | + this->matrixForce[n][a][i] = tmp[n][a][i]; | |
3756 | + } | |
3757 | + } | |
3722 | 3758 | } |
3723 | - MallocerFreer::GetInstance()->Free<double>(&diatomicTwoElecTwoCore1stDerivs, | |
3724 | - OrbitalType_end, | |
3725 | - OrbitalType_end, | |
3726 | - CartesianType_end); | |
3727 | - MallocerFreer::GetInstance()->Free<double>(&diatomicOverlapAOs1stDerivs, | |
3728 | - OrbitalType_end, | |
3729 | - OrbitalType_end, | |
3730 | - CartesianType_end); | |
3731 | 3759 | } |
3732 | - // Exception throwing for omp-region | |
3733 | - if(!ompErrors.str().empty()){ | |
3734 | - throw MolDSException::Deserialize(ompErrors); | |
3760 | + catch(MolDSException ex){ | |
3761 | + MallocerFreer::GetInstance()->Free<double>(&tmp, | |
3762 | + elecStates.size(), | |
3763 | + this->molecule->GetNumberAtoms(), | |
3764 | + CartesianType_end); | |
3765 | + throw ex; | |
3735 | 3766 | } |
3736 | - | |
3767 | + MallocerFreer::GetInstance()->Free<double>(&tmp, | |
3768 | + elecStates.size(), | |
3769 | + this->molecule->GetNumberAtoms(), | |
3770 | + CartesianType_end); | |
3771 | + */ | |
3772 | + // end of communication | |
3773 | + | |
3737 | 3774 | /* |
3738 | 3775 | // Calculate force (on the ground state only). |
3739 | 3776 | // First derivative of overlapAOs integral is |