HΦ  3.2.0
mltplyMPIHubbard.c
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifdef MPI
20 #include "mpi.h"
21 #endif
22 #include "Common.h"
23 #include "bitcalc.h"
24 #include "wrapperMPI.h"
25 #include "mltplyCommon.h"
26 #include "mltplyMPIHubbard.h"
33 (
34  unsigned long int itrans,
35  struct BindStruct *X,
36  double complex *tmp_v0,
37  double complex *tmp_v1
38 ){
39 #ifdef MPI
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;
46 #endif
47 }/*void GC_child_general_hopp_MPIdouble*/
55  int org_isite1,
56  int org_ispin1,
57  int org_isite2,
58  int org_ispin2,
59  double complex tmp_trans,
60  struct BindStruct *X,
61  double complex *tmp_v0,
62  double complex *tmp_v1
63 ) {
64 #ifdef MPI
65  int mask1, mask2, state1, state2, ierr, origin, bitdiff, Fsgn;
66  unsigned long int idim_max_buf, j;
67  MPI_Status statusMPI;
68  double complex trans, dmv, dam_pr;
69 
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);
75 
76  state1 = origin & mask1;
77  state2 = origin & mask2;
78 
79  SgnBit((unsigned long int) (origin & bitdiff), &Fsgn); // Fermion sign
80 
81  if (state1 == 0 && state2 == mask2) {
82  trans = -(double)Fsgn * tmp_trans;
83  }/*if (state1 == 0 && state2 == mask2)*/
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;
87  }/*if (state1 == mask1 && state2 == 0)*/
88  else return 0.0;
89 
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);
93  if (ierr != 0) exitMPI(-1);
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);
97  if (ierr != 0) exitMPI(-1);
98 
99  dam_pr = 0.0;
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)
102  {
103  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
104 #pragma omp for
105  for (j = 1; j <= idim_max_buf; j++) {
106  dmv = trans * v1buf[j];
107  tmp_v0[j] += dmv;
108  dam_pr += conj(tmp_v1[j]) * dmv;
109  }/*for (j = 1; j <= idim_max_buf; j++)*/
110  }/*if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC)*/
111  else {
112 #pragma omp for
113  for (j = 1; j <= idim_max_buf; j++) {
114  dmv = trans * v1buf[j];
115  dam_pr += conj(tmp_v1[j]) * dmv;
116  }/*for (j = 1; j <= idim_max_buf; j++)*/
117  }
118  }/*End of parallel region*/
119  return (dam_pr);
120 #else
121  return 0.0;
122 #endif
123 }/*void GC_child_general_hopp_MPIdouble*/
131  int org_isite1,
132  int org_ispin1,
133  int org_isite2,
134  int org_ispin2,
135  double complex tmp_trans,
136  struct BindStruct *X,
137  double complex *tmp_v0,
138  double complex *tmp_v1,
139  double complex *v1buf,
140  long unsigned int *list_1_org,
141  long unsigned int *list_1buf_org,
142  long unsigned int *list_2_1_target,
143  long unsigned int *list_2_2_target
144 ) {
145 #ifdef MPI
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;
150 
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);
156 
157  state1 = origin & mask1;
158  state2 = origin & mask2;
159 
160  SgnBit((unsigned long int) (origin & bitdiff), &Fsgn); // Fermion sign
161 
162  if (state1 == 0 && state2 == mask2) {
163  trans = -(double) Fsgn * tmp_trans;
164  }/*if (state1 == 0 && state2 == mask2)*/
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) {
168  trans = 0;
169  }
170  }/*if (state1 == mask1 && state2 == 0)*/
171  else return 0;
172 
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);
176  if (ierr != 0) exitMPI(-1);
177 
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);
181  if (ierr != 0) exitMPI(-1);
182 
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);
186  if (ierr != 0) exitMPI(-1);
187 
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];
194  GetOffComp(list_2_1_target, list_2_2_target, list_1buf_org[j],
195  X->Large.irght, X->Large.ilft, X->Large.ihfbit, &ioff);
196  tmp_v0[ioff] += dmv;
197  }/*for (j = 1; j <= idim_max_buf; j++)*/
198  }/*if (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC)*/
199  else return 0.0;
200 
201  return 1.0;
202 #else
203  return 0.0;
204 #endif
205 }/*void child_CisAjt_MPIdouble*/
212  unsigned long int itrans,
213  struct BindStruct *X,
214  double complex *tmp_v0,
215  double complex *tmp_v1
216 ){
217 #ifdef MPI
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;
224 #endif
225 }/*void GC_child_general_hopp_MPIsingle*/
234  int org_isite1,
235  int org_ispin1,
236  int org_isite2,
237  int org_ispin2,
238  double complex tmp_trans,
239  struct BindStruct *X,
240  double complex *tmp_v0,
241  double complex *tmp_v1
242 ) {
243 #ifdef MPI
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;
248  /*
249  Prepare index in the inter PE
250  */
251  mask2 = (int) X->Def.Tpow[2 * org_isite2 + org_ispin2];
252  bit2diff = mask2 - 1;
253  origin = myrank ^ mask2;
254  state2 = origin & mask2;
255 
256  SgnBit((unsigned long int) (origin & bit2diff), &Fsgn); // Fermion sign
257 
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);
261  if (ierr != 0) exitMPI(-1);
262 
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);
266  if (ierr != 0) exitMPI(-1);
267 
268  /*
269  Index in the intra PE
270  */
271  mask1 = X->Def.Tpow[2 * org_isite1 + org_ispin1];
272 
273  if (state2 == mask2) {
274  trans = -(double) Fsgn * tmp_trans;
275  state1check = 0;
276  }/*if (state2 == mask2)*/
277  else if (state2 == 0) {
278  state1check = mask1;
279  trans = -(double) Fsgn * conj(tmp_trans);
280  if (X->Large.mode == M_CORR|| X->Large.mode == M_CALCSPEC) trans = 0;
281  }/*if (state2 != mask2)*/
282  else return 0;
283 
284  bit1diff = X->Def.Tpow[2 * X->Def.Nsite - 1] * 2 - mask1 * 2;
285 
286  dam_pr = 0.0;
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)
289  {
290  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
291 #pragma omp for
292  for (j = 0; j < idim_max_buf; j++) {
293 
294  state1 = j & mask1;
295 
296  if (state1 == state1check) {
297 
298  SgnBit(j & bit1diff, &Fsgn);
299  ioff = j ^ mask1;
300 
301  dmv = (double)Fsgn * trans * v1buf[j + 1];
302  tmp_v0[ioff + 1] += dmv;
303  dam_pr += conj(tmp_v1[ioff + 1]) * dmv;
304  }/*if (state1 == state1check)*/
305  }/*for (j = 0; j < idim_max_buf; j++)*/
306  }/*if (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC)*/
307  else {
308 #pragma omp for
309  for (j = 0; j < idim_max_buf; j++) {
310 
311  state1 = j & mask1;
312 
313  if (state1 == state1check) {
314 
315  SgnBit(j & bit1diff, &Fsgn);
316  ioff = j ^ mask1;
317 
318  dmv = (double)Fsgn * trans * v1buf[j + 1];
319  dam_pr += conj(tmp_v1[ioff + 1]) * dmv;
320  }/*for (j = 0; j < idim_max_buf; j++)*/
321  }/*for (j = 0; j < idim_max_buf; j++)*/
322  }/*if (! (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC))*/
323  }/*End of parallel region*/
324  return (dam_pr);
325 #else
326  return 0.0;
327 #endif
328 }/*void GC_child_general_hopp_MPIsingle*/
335  unsigned long int itrans,
336  struct BindStruct *X,
337  double complex *tmp_v0,
338  double complex *tmp_v1
339 ){
340 #ifdef MPI
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;
347 #endif
348 }/*void child_general_hopp_MPIdouble*/
356  int org_isite1,
357  int org_ispin1,
358  int org_isite2,
359  int org_ispin2,
360  double complex tmp_trans,
361  struct BindStruct *X,
362  double complex *tmp_v0,
363  double complex *tmp_v1
364 ) {
365 #ifdef MPI
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;
370 
371  mask1 = (int) X->Def.Tpow[2 * org_isite1 + org_ispin1];
372  mask2 = (int) X->Def.Tpow[2 * org_isite2 + org_ispin2];
373 
374  if (mask2 > mask1) bitdiff = mask2 - mask1 * 2;
375  else bitdiff = mask1 - mask2 * 2;
376  origin = myrank ^ (mask1 + mask2);
377 
378  state1 = origin & mask1;
379  state2 = origin & mask2;
380 
381  SgnBit((unsigned long int) (origin & bitdiff), &Fsgn); // Fermion sign
382 
383  if (state1 == 0 && state2 == mask2) {
384  trans = -(double) Fsgn * tmp_trans;
385  }
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;
389  }
390  else return 0;
391 
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);
395  if (ierr != 0) exitMPI(-1);
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);
399  if (ierr != 0) exitMPI(-1);
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);
403  if (ierr != 0) exitMPI(-1);
404 
405  dam_pr = 0.0;
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)
408  {
409  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
410 #pragma omp for
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];
415  tmp_v0[ioff] += dmv;
416  dam_pr += conj(tmp_v1[ioff]) * dmv;
417  }/*for (j = 1; j <= idim_max_buf; j++)*/
418  }/*if (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC)*/
419  else {
420 #pragma omp for
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;
426  }/*for (j = 1; j <= idim_max_buf; j++)*/
427  }/*for (j = 1; j <= idim_max_buf; j++)*/
428  }/*End of parallel region*/
429  return (dam_pr);
430 #else
431  return 0.0;
432 #endif
433 }/*void child_general_hopp_MPIdouble*/
440  unsigned long int itrans,
441  struct BindStruct *X,
442  double complex *tmp_v0,
443  double complex *tmp_v1
444 ){
445 #ifdef MPI
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;
452 #endif
453 }/*void child_general_hopp_MPIsingle*/
461  int org_isite1,
462  int org_ispin1,
463  int org_isite2,
464  int org_ispin2,
465  double complex tmp_trans,
466  struct BindStruct *X,
467  double complex *tmp_v0,
468  double complex *tmp_v1
469 ) {
470 #ifdef MPI
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;
475  /*
476  Prepare index in the inter PE
477  */
478  mask2 = (int)X->Def.Tpow[2 * org_isite2+org_ispin2];
479  bit2diff = mask2 - 1;
480  origin = myrank ^ mask2;
481 
482  state2 = origin & mask2;
483 
484  SgnBit((unsigned long int) (origin & bit2diff), &Fsgn); // Fermion sign
485 
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);
489  if (ierr != 0) exitMPI(-1);
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);
493  if (ierr != 0) exitMPI(-1);
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);
497  if (ierr != 0) exitMPI(-1);
498  /*
499  Index in the intra PE
500  */
501  mask1 = X->Def.Tpow[2 * org_isite1 + org_ispin1];
502  if (state2 == mask2) {
503  trans = -(double) Fsgn * tmp_trans;
504  state1check = 0;
505  }
506  else if (state2 == 0) {
507  state1check = mask1;
508  trans = -(double) Fsgn * conj(tmp_trans);
509  if (X->Large.mode == M_CORR|| X->Large.mode == M_CALCSPEC) {
510  trans = 0;
511  }
512  }
513  else return 0;
514 
515  bit1diff = X->Def.Tpow[2 * X->Def.Nsite - 1] * 2 - mask1 * 2;
516 
517  dam_pr = 0.0;
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)
520  {
521  if (X->Large.mode == M_MLTPLY || X->Large.mode == M_CALCSPEC) {
522 #pragma omp for
523  for (j = 1; j <= idim_max_buf; j++) {
524 
525  jreal = list_1buf[j];
526  state1 = jreal & mask1;
527 
528  if (state1 == state1check) {
529  SgnBit(jreal & bit1diff, &Fsgn);
530  GetOffComp(list_2_1, list_2_2, jreal ^ mask1,
531  X->Large.irght, X->Large.ilft, X->Large.ihfbit, &ioff);
532 
533  dmv = (double)Fsgn * trans * v1buf[j];
534  tmp_v0[ioff] += dmv;
535  dam_pr += conj(tmp_v1[ioff]) * dmv;
536  }/*if (state1 == state1check)*/
537  }/*for (j = 1; j <= idim_max_buf; j++)*/
538  }/*if (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC)*/
539  else {
540 #pragma omp for
541  for (j = 1; j <= idim_max_buf; j++) {
542 
543  jreal = list_1buf[j];
544  state1 = jreal & mask1;
545 
546  if (state1 == state1check) {
547  SgnBit(jreal & bit1diff, &Fsgn);
548  GetOffComp(list_2_1, list_2_2, jreal ^ mask1,
549  X->Large.irght, X->Large.ilft, X->Large.ihfbit, &ioff);
550 /*
551  if(X->Large.mode==M_CORR){
552  printf("DEBUG: myrank=%d, org=%d, bit=%d, iexchg=%d, ioff=%d, list_1=%d\n", myrank, jreal, state1, jreal ^ mask1, ioff, list_1[ioff]);
553  }
554 */
555  dmv = (double)Fsgn * trans * v1buf[j];
556  dam_pr += conj(tmp_v1[ioff]) * dmv;
557  }/*if (state1 == state1check)*/
558  }/*for (j = 1; j <= idim_max_buf; j++)*/
559  }/*if (! (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC))*/
560  }/*End of parallel region*/
561  return (dam_pr);
562 #else
563  return 0.0;
564 #endif
565 }/*double complex child_general_hopp_MPIsingle*/
573  int org_isite1,
574  int org_ispin1,
575  int org_isite2,
576  int org_ispin2,
577  double complex tmp_trans,
578  struct BindStruct *X,
579  double complex *tmp_v0,
580  double complex *tmp_v1,
581  double complex *v1buf,
582  long unsigned int *list_1_org,
583  long unsigned int *list_1buf_org,
584  long unsigned int *list_2_1_target,
585  long unsigned int *list_2_2_target
586 ){
587 #ifdef MPI
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;
592  /*
593  Prepare index in the inter PE
594  */
595  mask2 = (int)X->Def.Tpow[2 * org_isite2+org_ispin2];
596  bit2diff = mask2 - 1;
597  origin = myrank ^ mask2;
598 
599  state2 = origin & mask2;
600 
601  SgnBit((unsigned long int) (origin & bit2diff), &Fsgn); // Fermion sign
602 
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);
606  if (ierr != 0) exitMPI(-1);
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);
610  if (ierr != 0) exitMPI(-1);
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);
614  if (ierr != 0) exitMPI(-1);
615  /*
616  Index in the intra PE
617  */
618  mask1 = X->Def.Tpow[2 * org_isite1 + org_ispin1];
619  if (state2 == mask2) {
620  trans = -(double) Fsgn * tmp_trans;
621  state1check = 0;
622  }
623  else if (state2 == 0) {
624  state1check = mask1;
625  trans = -(double) Fsgn * conj(tmp_trans);
626  }
627  else return 0;
628 
629  bit1diff = X->Def.Tpow[2 * X->Def.Nsite - 1] * 2 - mask1 * 2;
630 
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++) {
635  jreal = list_1buf_org[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);
641  if(ioff !=0){
642  dmv = (double) Fsgn * trans * v1buf[j];
643  tmp_v0[ioff] += dmv;
644  }/*if(ioff !=0)*/
645  }/*if (state1 == state1check)*/
646  }/*for (j = 1; j <= idim_max_buf; j++)*/
647  }/*if (X->Large.mode == M_MLTPLY|| X->Large.mode == M_CALCSPEC)*/
648  else return 0;
649 
650  return 1;
651 #else
652  return 0.0;
653 #endif
654 }/*double complex child_general_hopp_MPIsingle*/
void exitMPI(int errorcode)
MPI Abortation wrapper.
Definition: wrapperMPI.c:86
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
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 ihfbit
Used for Ogata-Lin ???
Definition: struct.h:345
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
double complex prdct
The expectation value of the energy.
Definition: struct.h:314
long unsigned int * list_1buf
Definition: global.h:48
struct LargeList Large
Variables for Matrix-Vector product.
Definition: struct.h:412
int ** EDGeneralTransfer
Index of transfer integrals for calculation. malloc in setmem_def(). Data Format [DefineList::NTransf...
Definition: struct.h:110
int mode
multiply or expectation value.
Definition: struct.h:330
long unsigned int * list_1buf_org
Definition: global.h:54
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...
Bind.
Definition: struct.h:409
unsigned long int idim_maxOrg
The local Hilbert-space dimention of original state for the spectrum.
Definition: struct.h:305
unsigned int Nsite
Number of sites in the INTRA process region.
Definition: struct.h:56
double complex * EDParaGeneralTransfer
Value of general transfer integrals by a def file. malloc in setmem_def(). Data Format [DefineList::N...
Definition: struct.h:116
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 * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
Definition: struct.h:90
long unsigned int ilft
Used for Ogata-Lin ???
Definition: struct.h:344
long unsigned int * list_1_org
Definition: global.h:53
long unsigned int * list_2_1
Definition: global.h:49
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
Definition: bitcalc.c:195
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
Definition: global.h:47
long unsigned int * list_2_2
Definition: global.h:50
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.
struct EDMainCalStruct X
Definition: struct.h:432
long unsigned int irght
Used for Ogata-Lin ???
Definition: struct.h:343
int myrank
Process ID, defined in InitializeMPI()
Definition: global.h:163
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...
double complex * v1buf
Definition: global.h:37
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
void SgnBit(const long unsigned int org_bit, int *sgn)
function of getting fermion sign (64 bit)
Definition: bitcalc.c:339