20 #include "wrapperMPI.hpp" 30 int NDimInterPE, SmallDim, SpinNum, ishift;
31 int ipivot, isiteMax, isiteMax0;
42 case HubbardNConserved:
53 if (NDimInterPE ==
nproc) {
61 fprintf(
stdoutMPI,
"%s",
"Error ! The number of PROCESS should be 4-exponent !\n");
67 if (NDimInterPE >
nproc) {
68 ilargeNproc = NDimInterPE;
70 ismallNproc = NDimInterPE/4;
75 fprintf(
stdoutMPI,
" Set the number of PROCESS as %d or %d.\n",ismallNproc, ilargeNproc );
89 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
90 SpinNum = SmallDim % 4;
96 else if (SpinNum == 2 ) {
100 else if (SpinNum == 3 ){
109 case HubbardNConserved:
115 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
116 SpinNum = SmallDim % 4;
118 if (SpinNum == 1 || SpinNum == 2 ) X->
Def.
Ne -= 1;
119 else if (SpinNum == 3 ) X->
Def.
Ne -= 2;
131 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++)
136 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
137 SpinNum = SmallDim % 4;
144 else if (SpinNum == 2 ) {
148 else if (SpinNum == 3 ) {
155 fprintf(
stdoutMPI,
"\n Stop because local spin in the inter process region\n");
187 for (isite = X->
Def.
NsiteMPI; isite > 0; isite--) {
188 if (NDimInterPE ==
nproc) {
196 fprintf(
stdoutMPI,
"%s",
"Error ! The number of PROCESS should be 2-exponent !\n");
201 for (isite = X->
Def.
NsiteMPI; isite > 0; isite--) {
202 if (NDimInterPE >
nproc) {
203 ilargeNproc = NDimInterPE;
205 ismallNproc = NDimInterPE/2;
210 fprintf(
stdoutMPI,
" Set the number of PROCESS as %d or %d.\n",ismallNproc, ilargeNproc );
219 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
220 SpinNum = SmallDim % 2;
239 for (isite = X->
Def.
NsiteMPI; isite > 0; isite--) {
240 if (NDimInterPE ==
nproc) {
248 fprintf(
stdoutMPI,
"%s",
"Error ! The number of PROCESS is wrong !\n");
253 for (isite = X->
Def.
NsiteMPI; isite > 0; isite--) {
254 if (NDimInterPE >
nproc) {
255 ilargeNproc = NDimInterPE;
262 fprintf(
stdoutMPI,
" Set the number of PROCESS as %d or %d.\n",ismallNproc, ilargeNproc );
271 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
284 fprintf(
stdoutMPI,
"Error ! Wrong model !\n");
300 if (ishift > 1) isiteMax0 = X->
Def.
NsiteMPI - isiteMax0 - 1 - ishift;
302 if (isiteMax0 < isiteMax) isiteMax = isiteMax0;
307 for (isite = 0; isite < isiteMax; isite++) NDimInterPE *= 2;
309 if (NDimInterPE <
nproc) {
310 fprintf(stderr,
"\n Error ! in ReadDefFileIdxPara.\n");
311 fprintf(stderr,
"Too many MPI processes ! It should be <= %d. \n\n", NDimInterPE);
325 int iproc, SmallDim, SpinNum, Nelec;
330 fprintf(
stdoutMPI,
"\n\n###### MPI site separation summary ######\n\n");
331 fprintf(
stdoutMPI,
" INTRA process site\n");
333 for (isite = 0; isite < X->
Def.
Nsite; isite++) {
337 case HubbardNConserved:
341 fprintf(
stdoutMPI,
" %4d %4d\n", isite, 4);
348 fprintf(
stdoutMPI,
" %4d %4d\n", isite, 2);
359 fprintf(
stdoutMPI,
"\n INTER process site\n");
361 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
365 case HubbardNConserved:
369 fprintf(
stdoutMPI,
" %4d %4d\n", isite, 4);
376 fprintf(
stdoutMPI,
" %4d %4d\n", isite, 2);
387 fprintf(
stdoutMPI,
"\n Process element info\n");
388 fprintf(
stdoutMPI,
" Process Dimension Nup Ndown Nelec Total2Sz State\n");
390 for (iproc = 0; iproc <
nproc; iproc++) {
423 case HubbardNConserved:
428 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
429 SpinNum = SmallDim % 4;
431 if (SpinNum == 0) fprintf(
stdoutMPI,
"00");
432 else if (SpinNum == 1) fprintf(
stdoutMPI,
"01");
433 else if (SpinNum == 2) fprintf(
stdoutMPI,
"10");
434 else if (SpinNum == 3) fprintf(
stdoutMPI,
"11");
444 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
445 SpinNum = SmallDim % 2;
452 for (isite = X->
Def.
Nsite; isite < X->Def.NsiteMPI; isite++) {
468 fprintf(
stdoutMPI,
"ERROR! Total dimension < 1\n");
485 case HubbardNConserved:
490 for (isite = 2 * X->
Def.
Nsite + 1; isite < 2 * X->Def.NsiteMPI; isite++)
494 for (isite = 1; isite < 2 * X->
Def.
NsiteMPI; isite++)
505 for (isite = X->
Def.
Nsite + 1; isite < X->Def.NsiteMPI; isite++)
512 for (isite = X->
Def.
Nsite + 1; isite < X->Def.NsiteMPI; isite++)
void exitMPI(int errorcode)
MPI Abortation wrapper.
int Nup
Number of spin-up electrons in this process.
struct DefineList Def
Definision of system (Hamiltonian) etc.
int nproc
Number of processors, defined in InitializeMPI()
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
long int * OrgTpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
int Total2Sz
Total in this process.
long int SumMPI_li(long int idim)
MPI wrapper function to obtain sum of unsigned long integer across processes.
int Nsite
Number of sites in the INTRA process region.
long int idim_maxMPI
The total dimension across process.
int * LocSpn
[DefineList::NLocSpn] Flag (and size) of the local spin. malloc in setmem_def().
int iFlgScaLAPACK
ScaLAPACK mode ( only for FullDiag )
int CheckMPI(struct BindStruct *X)
Define the number of sites in each PE (DefineList.Nsite). Reduce the number of electrons (DefineList...
int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
int Ne
Number of electrons in this process.
struct BoostList Boost
For Boost.
int SumMPI_i(int idim)
MPI wrapper function to obtain sum of integer across processes.
int myrank
Process ID, defined in InitializeMPI()
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
long int * SiteToBit
[DefineList::NsiteMPI] Similar to DefineList::Tpow. For general spin.
long int * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
int flgBoost
Flag whether use CMA algorithm.
int Ndown
Number of spin-down electrons in this process.
int NLocSpn
Number of local spins.
struct CheckList Check
Size of the Hilbert space.
void CheckMPI_Summary(struct BindStruct *X)
Print infomation of MPI parallelization Modify Definelist::Tpow in the inter process region...
long int idim_max
The dimension of the Hilbert space of this process.
int Total2SzMPI
Total across processes.