Revision | 493bc212a1af46fcb3e7391c0b95af40dea73a2a (tree) |
---|---|
Time | 2013-10-04 19:26:37 |
Author | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
MPI use in ZindoS is refactored. #31814
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1535 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -1437,26 +1437,24 @@ void Cndo2::CalcFockMatrix(double** fockMatrix, | ||
1437 | 1437 | } // end of if(mpiRank == calcRank) |
1438 | 1438 | |
1439 | 1439 | // set data to gather in mpiHeadRank with asynchronous MPI |
1440 | - int tag = mu; | |
1441 | - int source = calcRank; | |
1442 | - int dest = mpiHeadRank; | |
1440 | + int tag = mu; | |
1441 | + int source = calcRank; | |
1442 | + int dest = mpiHeadRank; | |
1443 | + double* buff = &fockMatrix[mu][mu]; | |
1444 | + MolDS_mpi::molds_mpi_int num = totalNumberAOs-mu; | |
1443 | 1445 | if(mpiRank == mpiHeadRank && mpiRank != calcRank){ |
1444 | - asyncCommunicator.SetRecvedVector(&fockMatrix[mu][mu], | |
1445 | - totalNumberAOs-mu, | |
1446 | - source, | |
1447 | - tag); | |
1446 | + asyncCommunicator.SetRecvedVector(buff, num, source, tag); | |
1448 | 1447 | } |
1449 | 1448 | if(mpiRank != mpiHeadRank && mpiRank == calcRank){ |
1450 | - asyncCommunicator.SetSentVector(&fockMatrix[mu][mu], | |
1451 | - totalNumberAOs-mu, | |
1452 | - dest, | |
1453 | - tag); | |
1449 | + asyncCommunicator.SetSentVector(buff, num, dest, tag); | |
1454 | 1450 | } |
1455 | 1451 | } // end of loop mu parallelized with MPI |
1456 | 1452 | } // end of loop A |
1457 | 1453 | // Delete the communication thread. |
1458 | 1454 | communicationThread.join(); |
1459 | - MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&fockMatrix[0][0], totalNumberAOs*totalNumberAOs, mpiHeadRank); | |
1455 | + double* buff = &fockMatrix[0][0]; | |
1456 | + MolDS_mpi::molds_mpi_int num = totalNumberAOs*totalNumberAOs; | |
1457 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(buff, num, mpiHeadRank); | |
1460 | 1458 | |
1461 | 1459 | /* |
1462 | 1460 | this->OutputLog("fock matrix\n"); |
@@ -1669,24 +1667,22 @@ void Cndo2::CalcGammaAB(double** gammaAB, const Molecule& molecule) const{ | ||
1669 | 1667 | } // end of if(mpiRank==calcRank) |
1670 | 1668 | |
1671 | 1669 | // set data to gater in mpiHeadRank with asynchronous MPI |
1672 | - int tag = A; | |
1673 | - int source = calcRank; | |
1674 | - int dest = mpiHeadRank; | |
1670 | + int tag = A; | |
1671 | + int source = calcRank; | |
1672 | + int dest = mpiHeadRank; | |
1673 | + double* buff = &gammaAB[A][A]; | |
1674 | + MolDS_mpi::molds_mpi_int num = totalAtomNumber-A; | |
1675 | 1675 | if(mpiRank == mpiHeadRank && mpiRank != calcRank){ |
1676 | - asyncCommunicator.SetRecvedVector(&gammaAB[A][A], | |
1677 | - totalAtomNumber-A, | |
1678 | - source, | |
1679 | - tag); | |
1676 | + asyncCommunicator.SetRecvedVector(buff, num, source, tag); | |
1680 | 1677 | } |
1681 | 1678 | if(mpiRank != mpiHeadRank && mpiRank == calcRank){ |
1682 | - asyncCommunicator.SetSentVector(&gammaAB[A][A], | |
1683 | - totalAtomNumber-A, | |
1684 | - dest, | |
1685 | - tag); | |
1679 | + asyncCommunicator.SetSentVector(buff, num, dest, tag); | |
1686 | 1680 | } |
1687 | 1681 | } // end of loop A prallelized by MPI |
1688 | 1682 | communicationThread.join(); |
1689 | - MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&gammaAB[0][0], totalAtomNumber*totalAtomNumber, mpiHeadRank); | |
1683 | + double* buff = &gammaAB[0][0]; | |
1684 | + MolDS_mpi::molds_mpi_int num = totalAtomNumber*totalAtomNumber; | |
1685 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(buff, num, mpiHeadRank); | |
1690 | 1686 | |
1691 | 1687 | #pragma omp parallel for schedule(auto) |
1692 | 1688 | for(int A=0; A<totalAtomNumber; A++){ |
@@ -1836,43 +1832,31 @@ void Cndo2::CalcCartesianMatrixByGTOExpansion(double*** cartesianMatrix, | ||
1836 | 1832 | } // end lof if(mpiRank == calcRank) |
1837 | 1833 | |
1838 | 1834 | // set data to gater in mpiHeadRank with asynchronous MPI |
1839 | - int tagX = A* CartesianType_end + XAxis; | |
1840 | - int tagY = A* CartesianType_end + YAxis; | |
1841 | - int tagZ = A* CartesianType_end + ZAxis; | |
1842 | - int source = calcRank; | |
1843 | - int dest = mpiHeadRank; | |
1835 | + int tagX = A* CartesianType_end + XAxis; | |
1836 | + int tagY = A* CartesianType_end + YAxis; | |
1837 | + int tagZ = A* CartesianType_end + ZAxis; | |
1838 | + int source = calcRank; | |
1839 | + int dest = mpiHeadRank; | |
1840 | + double* buffX = &cartesianMatrix[XAxis][firstAOIndexA][0]; | |
1841 | + double* buffY = &cartesianMatrix[YAxis][firstAOIndexA][0]; | |
1842 | + double* buffZ = &cartesianMatrix[ZAxis][firstAOIndexA][0]; | |
1843 | + MolDS_mpi::molds_mpi_int num = numValenceAOsA*totalAONumber; | |
1844 | 1844 | if(mpiRank == mpiHeadRank && mpiRank != calcRank){ |
1845 | - asyncCommunicator.SetRecvedVector(&cartesianMatrix[XAxis][firstAOIndexA][0], | |
1846 | - numValenceAOsA*totalAONumber, | |
1847 | - source, | |
1848 | - tagX); | |
1849 | - asyncCommunicator.SetRecvedVector(&cartesianMatrix[YAxis][firstAOIndexA][0], | |
1850 | - numValenceAOsA*totalAONumber, | |
1851 | - source, | |
1852 | - tagY); | |
1853 | - asyncCommunicator.SetRecvedVector(&cartesianMatrix[ZAxis][firstAOIndexA][0], | |
1854 | - numValenceAOsA*totalAONumber, | |
1855 | - source, | |
1856 | - tagZ); | |
1845 | + asyncCommunicator.SetRecvedVector(buffX, num, source, tagX); | |
1846 | + asyncCommunicator.SetRecvedVector(buffY, num, source, tagY); | |
1847 | + asyncCommunicator.SetRecvedVector(buffZ, num, source, tagZ); | |
1857 | 1848 | } |
1858 | 1849 | if(mpiRank != mpiHeadRank && mpiRank == calcRank){ |
1859 | - asyncCommunicator.SetSentVector(&cartesianMatrix[XAxis][firstAOIndexA][0], | |
1860 | - numValenceAOsA*totalAONumber, | |
1861 | - dest, | |
1862 | - tagX); | |
1863 | - asyncCommunicator.SetSentVector(&cartesianMatrix[YAxis][firstAOIndexA][0], | |
1864 | - numValenceAOsA*totalAONumber, | |
1865 | - dest, | |
1866 | - tagY); | |
1867 | - asyncCommunicator.SetSentVector(&cartesianMatrix[ZAxis][firstAOIndexA][0], | |
1868 | - numValenceAOsA*totalAONumber, | |
1869 | - dest, | |
1870 | - tagZ); | |
1850 | + asyncCommunicator.SetSentVector(buffX, num, dest, tagX); | |
1851 | + asyncCommunicator.SetSentVector(buffY, num, dest, tagY); | |
1852 | + asyncCommunicator.SetSentVector(buffZ, num, dest, tagZ); | |
1871 | 1853 | } |
1872 | 1854 | } // end of loop for int A with MPI |
1873 | 1855 | // Delete the communication thread. |
1874 | 1856 | communicationThread.join(); |
1875 | - MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&cartesianMatrix[0][0][0], CartesianType_end*totalAONumber*totalAONumber, mpiHeadRank); | |
1857 | + double* buff = &cartesianMatrix[0][0][0]; | |
1858 | + MolDS_mpi::molds_mpi_int num = CartesianType_end*totalAONumber*totalAONumber; | |
1859 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(buff, num, mpiHeadRank); | |
1876 | 1860 | |
1877 | 1861 | /* |
1878 | 1862 | // communication to collect all matrix data on head-rank |
@@ -3976,24 +3960,22 @@ void Cndo2::CalcOverlapAOs(double** overlapAOs, const Molecule& molecule) const{ | ||
3976 | 3960 | } // end of if(mpiRank == calcRnak) |
3977 | 3961 | |
3978 | 3962 | // set data to gather in mpiHeadRank with asynchronous MPI |
3979 | - int tag = A; | |
3980 | - int source = calcRank; | |
3981 | - int dest = mpiHeadRank; | |
3963 | + int tag = A; | |
3964 | + int source = calcRank; | |
3965 | + int dest = mpiHeadRank; | |
3966 | + double* buff = overlapAOs[firstAOIndexA]; | |
3967 | + MolDS_mpi::molds_mpi_int num = totalAONumber*numValenceAOs; | |
3982 | 3968 | if(mpiRank == mpiHeadRank && mpiRank != calcRank){ |
3983 | - asyncCommunicator.SetRecvedVector(overlapAOs[firstAOIndexA], | |
3984 | - totalAONumber*numValenceAOs, | |
3985 | - source, | |
3986 | - tag); | |
3969 | + asyncCommunicator.SetRecvedVector(buff, num, source, tag); | |
3987 | 3970 | } |
3988 | 3971 | if(mpiRank != mpiHeadRank && mpiRank == calcRank){ |
3989 | - asyncCommunicator.SetSentVector(overlapAOs[firstAOIndexA], | |
3990 | - totalAONumber*numValenceAOs, | |
3991 | - dest, | |
3992 | - tag); | |
3972 | + asyncCommunicator.SetSentVector(buff, num, dest, tag); | |
3993 | 3973 | } |
3994 | 3974 | } // end of loop A parallelized with MPI |
3995 | 3975 | communicationThread.join(); |
3996 | - MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&overlapAOs[0][0], totalAONumber*totalAONumber, mpiHeadRank); | |
3976 | + double* buff = &overlapAOs[0][0]; | |
3977 | + MolDS_mpi::molds_mpi_int num = totalAONumber*totalAONumber; | |
3978 | + MolDS_mpi::MpiProcess::GetInstance()->Broadcast(buff, num, mpiHeadRank); | |
3997 | 3979 | |
3998 | 3980 | #pragma omp parallel for schedule(auto) |
3999 | 3981 | for(int mu=0; mu<totalAONumber; mu++){ |