24 #include "wrapperMPI.h"    25 #include "mltplyCommon.h"    26 #include "mltplyMPIHubbard.h"    34  unsigned long int itrans,
    36  double complex *tmp_v0,
    37  double complex *tmp_v1
    40   double complex dam_pr = 0;
    42     X->Def.EDGeneralTransfer[itrans][0], 
X->Def.EDGeneralTransfer[itrans][1],
    43     X->Def.EDGeneralTransfer[itrans][2], 
X->Def.EDGeneralTransfer[itrans][3],
    44     X->Def.EDParaGeneralTransfer[itrans], 
X, tmp_v0, tmp_v1);
    45   X->Large.prdct += dam_pr;
    59   double complex tmp_trans,
    61   double complex *tmp_v0,
    62   double complex *tmp_v1 
    65   int mask1, mask2, state1, state2, ierr, origin, bitdiff, Fsgn;
    66   unsigned long int idim_max_buf, j;
    68   double complex trans, dmv, dam_pr;
    70   mask1 = (int)
X->Def.Tpow[2 * org_isite1 + org_ispin1];
    71   mask2 = (
int)
X->Def.Tpow[2 * org_isite2 + org_ispin2];
    72   if (mask2 > mask1) bitdiff = mask2 - mask1 * 2;
    73   else bitdiff = mask1 - mask2 * 2;
    74   origin = 
myrank ^ (mask1 + mask2);
    76   state1 = origin & mask1;
    77   state2 = origin & mask2;
    79   SgnBit((
unsigned long int) (origin & bitdiff), &Fsgn); 
    81   if (state1 == 0 && state2 == mask2) {
    82     trans = -(double)Fsgn * tmp_trans;
    84   else if (state1 == mask1 && state2 == 0) {
    85     trans = -(double)Fsgn * conj(tmp_trans);
    86     if (
X->Large.mode == M_CORR || 
X->Large.mode == M_CALCSPEC) trans = 0.0;
    90   ierr = MPI_Sendrecv(&
X->Check.idim_max, 1, MPI_UNSIGNED_LONG, origin, 0,
    91                       &idim_max_buf,      1, MPI_UNSIGNED_LONG, origin, 0, 
    92                       MPI_COMM_WORLD, &statusMPI);
    94   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_max + 1, MPI_DOUBLE_COMPLEX, origin, 0,
    95                       v1buf,       idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0, 
    96                       MPI_COMM_WORLD, &statusMPI);
   100 #pragma omp parallel default(none) reduction(+:dam_pr) private(j, dmv) \   101 firstprivate(idim_max_buf, trans, X) shared(v1buf, tmp_v1, tmp_v0)   103     if (
X->Large.mode == M_MLTPLY || 
X->Large.mode == M_CALCSPEC) {
   105       for (j = 1; j <= idim_max_buf; j++) {
   106         dmv = trans * 
v1buf[j];
   108         dam_pr += conj(tmp_v1[j]) * dmv;
   113       for (j = 1; j <= idim_max_buf; j++) {
   114         dmv = trans * 
v1buf[j];
   115         dam_pr += conj(tmp_v1[j]) * dmv;
   135   double complex tmp_trans,
   137   double complex *tmp_v0,
   138   double complex *tmp_v1,
   139   double complex *
v1buf,
   142   long unsigned int *list_2_1_target,
   143   long unsigned int *list_2_2_target
   146   int mask1, mask2, state1, state2, ierr, origin, bitdiff, Fsgn;
   147   unsigned long int idim_max_buf, j, ioff;
   148   MPI_Status statusMPI;
   149   double complex trans, dmv;
   151   mask1 = (int) 
X->Def.Tpow[2 * org_isite1 + org_ispin1];
   152   mask2 = (
int) 
X->Def.Tpow[2 * org_isite2 + org_ispin2];
   153   if (mask2 > mask1) bitdiff = mask2 - mask1 * 2;
   154   else bitdiff = mask1 - mask2 * 2;
   155   origin = 
myrank ^ (mask1 + mask2);
   157   state1 = origin & mask1;
   158   state2 = origin & mask2;
   160   SgnBit((
unsigned long int) (origin & bitdiff), &Fsgn); 
   162   if (state1 == 0 && state2 == mask2) {
   163     trans = -(double) Fsgn * tmp_trans;
   165   else if (state1 == mask1 && state2 == 0) {
   166     trans = -(double) Fsgn * conj(tmp_trans);
   167     if (
X->Large.mode == M_CORR|| 
X->Large.mode == M_CALCSPEC) {
   173   ierr = MPI_Sendrecv(&
X->Check.idim_maxOrg, 1, MPI_UNSIGNED_LONG, origin, 0,
   174                       &idim_max_buf,         1, MPI_UNSIGNED_LONG, origin, 0,
   175                       MPI_COMM_WORLD, &statusMPI);
   178   ierr = MPI_Sendrecv(
list_1_org, 
X->Check.idim_maxOrg + 1, MPI_UNSIGNED_LONG, origin, 0,
   179                       list_1buf_org,      idim_max_buf + 1, MPI_UNSIGNED_LONG, origin, 0,
   180                       MPI_COMM_WORLD, &statusMPI);
   183   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_maxOrg + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   184                       v1buf,          idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   185                       MPI_COMM_WORLD, &statusMPI);
   188   if (
X->Large.mode == M_MLTPLY|| 
X->Large.mode == M_CALCSPEC) {
   189 #pragma omp parallel for default(none) private(j, dmv, ioff) \   190   firstprivate(idim_max_buf, trans, X, list_2_1_target, list_2_2_target, list_1buf_org) \   191   shared(v1buf, tmp_v0)   192     for (j = 1; j <= idim_max_buf; j++){
   193       dmv = trans * 
v1buf[j];
   195                  X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   212   unsigned long int itrans,
   214   double complex *tmp_v0,
   215   double complex *tmp_v1
   218   double complex dam_pr=0;
   220     X->Def.EDGeneralTransfer[itrans][0], 
X->Def.EDGeneralTransfer[itrans][1],
   221     X->Def.EDGeneralTransfer[itrans][2], 
X->Def.EDGeneralTransfer[itrans][3],
   222     X->Def.EDParaGeneralTransfer[itrans], 
X, tmp_v0, tmp_v1       );
   223   X->Large.prdct += dam_pr;
   238   double complex tmp_trans,
   240   double complex *tmp_v0,
   241   double complex *tmp_v1
   244   int mask2, state1, state2, ierr, origin, bit2diff, Fsgn;
   245   unsigned long int idim_max_buf, j, mask1, state1check, bit1diff, ioff;
   246   MPI_Status statusMPI;
   247   double complex trans, dmv, dam_pr;
   251   mask2 = (int) 
X->Def.Tpow[2 * org_isite2 + org_ispin2];
   252   bit2diff = mask2 - 1;
   254   state2 = origin & mask2;
   256   SgnBit((
unsigned long int) (origin & bit2diff), &Fsgn); 
   258   ierr = MPI_Sendrecv(&
X->Check.idim_max, 1, MPI_UNSIGNED_LONG, origin, 0,
   259                       &idim_max_buf,      1, MPI_UNSIGNED_LONG, origin, 0,
   260                       MPI_COMM_WORLD, &statusMPI);
   263   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_max + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   264                       v1buf,       idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   265                       MPI_COMM_WORLD, &statusMPI);
   271   mask1 = 
X->Def.Tpow[2 * org_isite1 + org_ispin1];
   273   if (state2 == mask2) {
   274     trans = -(double) Fsgn * tmp_trans;
   277   else if (state2 == 0) {
   279     trans = -(double) Fsgn * conj(tmp_trans);
   280     if (
X->Large.mode == M_CORR|| 
X->Large.mode == M_CALCSPEC) trans = 0;
   284   bit1diff = 
X->Def.Tpow[2 * 
X->Def.Nsite - 1] * 2 - mask1 * 2;
   287 #pragma omp parallel default(none) reduction(+:dam_pr) private(j, dmv, state1, Fsgn, ioff) \   288   firstprivate(idim_max_buf, trans, X, mask1, state1check, bit1diff) shared(v1buf, tmp_v1, tmp_v0)   290     if (
X->Large.mode == M_MLTPLY || 
X->Large.mode == M_CALCSPEC) {
   292       for (j = 0; j < idim_max_buf; j++) {
   296         if (state1 == state1check) {
   298           SgnBit(j & bit1diff, &Fsgn);
   301           dmv = (double)Fsgn * trans * 
v1buf[j + 1];
   302           tmp_v0[ioff + 1] += dmv;
   303           dam_pr += conj(tmp_v1[ioff + 1]) * dmv;
   309       for (j = 0; j < idim_max_buf; j++) {
   313         if (state1 == state1check) {
   315           SgnBit(j & bit1diff, &Fsgn);
   318           dmv = (double)Fsgn * trans * 
v1buf[j + 1];
   319           dam_pr += conj(tmp_v1[ioff + 1]) * dmv;
   335   unsigned long int itrans,
   337   double complex *tmp_v0,
   338   double complex *tmp_v1
   341   double complex dam_pr;
   343     X->Def.EDGeneralTransfer[itrans][0], 
X->Def.EDGeneralTransfer[itrans][1],
   344     X->Def.EDGeneralTransfer[itrans][2], 
X->Def.EDGeneralTransfer[itrans][3],
   345     X->Def.EDParaGeneralTransfer[itrans], 
X, tmp_v0, tmp_v1);
   346   X->Large.prdct += dam_pr;
   360   double complex tmp_trans,
   362   double complex *tmp_v0,
   363   double complex *tmp_v1
   366   int mask1, mask2, state1, state2, ierr, origin, bitdiff, Fsgn;
   367   unsigned long int idim_max_buf, j, ioff;
   368   MPI_Status statusMPI;
   369   double complex trans, dmv, dam_pr;
   371   mask1 = (int) 
X->Def.Tpow[2 * org_isite1 + org_ispin1];
   372   mask2 = (
int) 
X->Def.Tpow[2 * org_isite2 + org_ispin2];
   374   if (mask2 > mask1) bitdiff = mask2 - mask1 * 2;
   375   else bitdiff = mask1 - mask2 * 2;
   376   origin = 
myrank ^ (mask1 + mask2);
   378   state1 = origin & mask1;
   379   state2 = origin & mask2;
   381   SgnBit((
unsigned long int) (origin & bitdiff), &Fsgn); 
   383   if (state1 == 0 && state2 == mask2) {
   384     trans = -(double) Fsgn * tmp_trans;
   386   else if (state1 == mask1 && state2 == 0) {
   387     trans = -(double) Fsgn * conj(tmp_trans);
   388     if (
X->Large.mode == M_CORR|| 
X->Large.mode == M_CALCSPEC) trans = 0;
   392   ierr = MPI_Sendrecv(&
X->Check.idim_max, 1, MPI_UNSIGNED_LONG, origin, 0,
   393                       &idim_max_buf,      1, MPI_UNSIGNED_LONG, origin, 0,
   394                       MPI_COMM_WORLD, &statusMPI);
   396   ierr = MPI_Sendrecv(
list_1, 
X->Check.idim_max + 1, MPI_UNSIGNED_LONG, origin, 0,
   397                       list_1buf,   idim_max_buf + 1, MPI_UNSIGNED_LONG, origin, 0,
   398                       MPI_COMM_WORLD, &statusMPI);
   400   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_max + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   401                       v1buf,       idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0, 
   402                       MPI_COMM_WORLD, &statusMPI);
   406 #pragma omp parallel default(none) reduction(+:dam_pr) private(j, dmv, Fsgn, ioff) \   407   firstprivate(idim_max_buf, trans, X) shared(list_2_1, list_2_2, list_1buf, v1buf, tmp_v1, tmp_v0)   409     if (
X->Large.mode == M_MLTPLY || 
X->Large.mode == M_CALCSPEC) {
   411       for (j = 1; j <= idim_max_buf; j++) {
   413           X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   414         dmv = trans * 
v1buf[j];
   416         dam_pr += conj(tmp_v1[ioff]) * dmv;
   421       for (j = 1; j <= idim_max_buf; j++) {
   423           X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   424         dmv = trans * 
v1buf[j];
   425         dam_pr += conj(tmp_v1[ioff]) * dmv;
   440   unsigned long int itrans,
   442   double complex *tmp_v0,
   443   double complex *tmp_v1
   446   double complex dam_pr;
   448     X->Def.EDGeneralTransfer[itrans][0], 
X->Def.EDGeneralTransfer[itrans][1],
   449     X->Def.EDGeneralTransfer[itrans][2], 
X->Def.EDGeneralTransfer[itrans][3],
   450     X->Def.EDParaGeneralTransfer[itrans], 
X, tmp_v0, tmp_v1);
   451   X->Large.prdct += dam_pr;
   465   double complex tmp_trans,
   467   double complex *tmp_v0,
   468   double complex *tmp_v1
   471   int mask2, state2, ierr, origin, bit2diff, Fsgn;
   472   unsigned long int mask1, state1, idim_max_buf, j, state1check, bit1diff, ioff, jreal;
   473   MPI_Status statusMPI;
   474   double complex trans, dmv, dam_pr;
   478   mask2 = (int)
X->Def.Tpow[2 * org_isite2+org_ispin2];
   479   bit2diff = mask2 - 1;
   482   state2 = origin & mask2;
   484   SgnBit((
unsigned long int) (origin & bit2diff), &Fsgn); 
   486   ierr = MPI_Sendrecv(&
X->Check.idim_max, 1, MPI_UNSIGNED_LONG, origin, 0,
   487                       &idim_max_buf,      1, MPI_UNSIGNED_LONG, origin, 0,
   488                       MPI_COMM_WORLD, &statusMPI);
   490   ierr = MPI_Sendrecv(
list_1, 
X->Check.idim_max + 1, MPI_UNSIGNED_LONG, origin, 0,
   491                       list_1buf,   idim_max_buf + 1, MPI_UNSIGNED_LONG, origin, 0,
   492                       MPI_COMM_WORLD, &statusMPI);
   494   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_max + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   495                       v1buf,       idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0, 
   496                       MPI_COMM_WORLD, &statusMPI);
   501   mask1 = 
X->Def.Tpow[2 * org_isite1 + org_ispin1];
   502   if (state2 == mask2) {
   503     trans = -(double) Fsgn * tmp_trans;
   506   else if (state2 == 0) {
   508     trans = -(double) Fsgn * conj(tmp_trans);
   509     if (
X->Large.mode == M_CORR|| 
X->Large.mode == M_CALCSPEC) {
   515   bit1diff = 
X->Def.Tpow[2 * 
X->Def.Nsite - 1] * 2 - mask1 * 2;
   518 #pragma omp parallel default(none) reduction(+:dam_pr) private(j, dmv, Fsgn, ioff, jreal, state1) \   519   firstprivate(idim_max_buf, trans, X, mask1, state1check, bit1diff, myrank) shared(list_1, list_2_1, list_2_2, list_1buf, v1buf, tmp_v1, tmp_v0)   521     if (
X->Large.mode == M_MLTPLY || 
X->Large.mode == M_CALCSPEC) {
   523       for (j = 1; j <= idim_max_buf; j++) {
   526         state1 = jreal & mask1;
   528         if (state1 == state1check) {
   529           SgnBit(jreal & bit1diff, &Fsgn);
   531             X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   533           dmv = (double)Fsgn * trans * 
v1buf[j];
   535           dam_pr += conj(tmp_v1[ioff]) * dmv;
   541       for (j = 1; j <= idim_max_buf; j++) {
   544         state1 = jreal & mask1;
   546         if (state1 == state1check) {
   547           SgnBit(jreal & bit1diff, &Fsgn);
   549             X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   555           dmv = (double)Fsgn * trans * 
v1buf[j];
   556           dam_pr += conj(tmp_v1[ioff]) * dmv;
   577   double complex tmp_trans,
   579   double complex *tmp_v0,
   580   double complex *tmp_v1,
   581   double complex *
v1buf,
   584   long unsigned int *list_2_1_target,
   585   long unsigned int *list_2_2_target
   588   int mask2, state2, ierr, origin, bit2diff, Fsgn;
   589   unsigned long int mask1, state1, idim_max_buf, j, state1check, bit1diff, ioff, jreal;
   590   MPI_Status statusMPI;
   591   double complex trans, dmv;
   595   mask2 = (int)
X->Def.Tpow[2 * org_isite2+org_ispin2];
   596   bit2diff = mask2 - 1;
   599   state2 = origin & mask2;
   601   SgnBit((
unsigned long int) (origin & bit2diff), &Fsgn); 
   603   ierr = MPI_Sendrecv(&
X->Check.idim_maxOrg, 1, MPI_UNSIGNED_LONG, origin, 0,
   604                       &idim_max_buf,         1, MPI_UNSIGNED_LONG, origin, 0,
   605                       MPI_COMM_WORLD, &statusMPI);
   607   ierr = MPI_Sendrecv(
list_1_org, 
X->Check.idim_maxOrg + 1, MPI_UNSIGNED_LONG, origin, 0,
   608                       list_1buf_org,      idim_max_buf + 1, MPI_UNSIGNED_LONG, origin, 0,
   609                       MPI_COMM_WORLD, &statusMPI);
   611   ierr = MPI_Sendrecv(tmp_v1, 
X->Check.idim_maxOrg + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   612                       v1buf,          idim_max_buf + 1, MPI_DOUBLE_COMPLEX, origin, 0,
   613                       MPI_COMM_WORLD, &statusMPI);
   618   mask1 = 
X->Def.Tpow[2 * org_isite1 + org_ispin1];
   619   if (state2 == mask2) {
   620     trans = -(double) Fsgn * tmp_trans;
   623   else if (state2 == 0) {
   625     trans = -(double) Fsgn * conj(tmp_trans);
   629   bit1diff = 
X->Def.Tpow[2 * 
X->Def.Nsite - 1] * 2 - mask1 * 2;
   631   if (
X->Large.mode == M_MLTPLY|| 
X->Large.mode == M_CALCSPEC) {
   632 #pragma omp parallel for default(none) private(j, dmv, Fsgn, ioff, jreal, state1) \   633   firstprivate(idim_max_buf, trans, X, mask1, state1check, bit1diff,list_2_1_target, list_2_2_target, list_1buf_org, list_1) shared(v1buf, tmp_v0)   634     for (j = 1; j <= idim_max_buf; j++) {
   636       state1 = jreal & mask1;
   637       if (state1 == state1check) {
   638         SgnBit(jreal & bit1diff, &Fsgn);
   639         GetOffComp(list_2_1_target, list_2_2_target, jreal ^ mask1,
   640                    X->Large.irght, 
X->Large.ilft, 
X->Large.ihfbit, &ioff);
   642           dmv = (double) Fsgn * trans * 
v1buf[j];
 void exitMPI(int errorcode)
MPI Abortation wrapper. 
double complex X_GC_child_general_hopp_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When both site1 and site2 are in the inter process region. 
long unsigned int * list_1buf
long unsigned int * list_1buf_org
double complex X_GC_child_general_hopp_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When only site2 is in the inter process region. 
void GC_child_general_hopp_MPIdouble(unsigned long int itrans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When both site1 and site2 are in the inter process region. 
double complex X_child_CisAjt_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *v1buf, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target)
Hopping term in Hubbard (Kondo) + Canonical ensemble When only site2 is in the inter process region...
void child_general_hopp_MPIdouble(unsigned long int itrans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When both site1 and site2 are in the inter proce...
long unsigned int * list_1_org
long unsigned int * list_2_1
double complex X_child_general_hopp_MPIsingle(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When only site2 is in the inter process region...
int GetOffComp(long unsigned int *_list_2_1, long unsigned int *_list_2_2, long unsigned int _ibit, const long unsigned int _irght, const long unsigned int _ilft, const long unsigned int _ihfbit, long unsigned int *_ioffComp)
function of getting off-diagonal component 
void GC_child_general_hopp_MPIsingle(unsigned long int itrans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard + GC When only site2 is in the inter process region. 
long unsigned int * list_1
long unsigned int * list_2_2
double complex X_child_CisAjt_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *v1buf, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target)
Hopping term in Hubbard + MPI When both site1 and site2 are in the inter process region. 
int myrank
Process ID, defined in InitializeMPI() 
void child_general_hopp_MPIsingle(unsigned long int itrans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When only site2 is in the inter process region...
double complex X_child_general_hopp_MPIdouble(int org_isite1, int org_ispin1, int org_isite2, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Hubbard (Kondo) + Canonical ensemble When both site1 and site2 are in the inter proce...
void SgnBit(const long unsigned int org_bit, int *sgn)
function of getting fermion sign (64 bit)