コード例 #1
0
ファイル: doitf.c プロジェクト: syntheticpp/benchfft
void setup(struct problem *p)
{
     int n, zero = 0;

     BENCH_ASSERT(can_do(p));

     switch (p->rank) {
     case 1:
	  {
	       n = p->n[0];

	       if (p->kind == PROBLEM_COMPLEX) {
		    /*
		     * example code says that wsave consists of 3 * n
		     * locations, but the code dumps core for n == 4
		     */
		    WSAVE = bench_malloc((3 * n + 4) * sizeof(bench_real));
		    if (SINGLE_PRECISION)
			 CFFT1D(p->in, &n, &zero, WSAVE);
		    else
			 ZFFT1D(p->in, &n, &zero, WSAVE);
	       } else {
		    WSAVE = bench_malloc((4 * n) * sizeof(bench_real));

		    if (p->sign == -1) {
			 if (SINGLE_PRECISION)
			      SCFFT1D(p->in, &n, &zero, WSAVE);
			 else
			      DZFFT1D(p->in, &n, &zero, WSAVE);
		    } else {
			 if (SINGLE_PRECISION)
			      CSFFT1D(p->in, &n, &zero, WSAVE);
			 else
			      ZDFFT1D(p->in, &n, &zero, WSAVE);
		    }
	       }
	       break;
	  }
     case 2:
	  /* nothing to do */
	  break;
     default:
	  BENCH_ASSERT(0);
     }
}
コード例 #2
0
ファイル: transform_cnt.c プロジェクト: Tang-QingYu/PINY
void convert_pimd_force_cent(
                CLATOMS_INFO *clatoms_info, CLATOMS_POS *clatoms_pos,
                CLATOMS_TRAN *clatoms_tran )

/*==========================================================================*/
{/*begin routine*/
/*======================================================================*/
/*           Local variable declarations                                */

  int ip,ipart,iopt,ierr,npp,incl,n,incn,np2,iii;
  int np2p1,ip2m1, ip2m2;
  int pi_beads = clatoms_info->pi_beads;
  int natm_tot = clatoms_info->natm_tot;
  int myatm_start = clatoms_info->myatm_start;
  int myatm_end = clatoms_info->myatm_end;
  int ifound;
  int one1,one2,one3,one4,one5,one6;
  int nwork;
  int lwork1,lwork2;
  int init;
  double sfact;
  double *x_c,*y_c,*z_c,anorm;
  int ip_ind,ip_ind1,ip_ind2;
  int sign,lda;

/*==========================================================================*/
/* I) Assign local pointers */

  np2  = pi_beads/2;
  x_c = clatoms_tran->x_trans;
  y_c = clatoms_tran->y_trans;
  z_c = clatoms_tran->z_trans;

/*==========================================================================*/
/* II) Get mode forces */

  if(pi_beads!=1){
   for(ipart=myatm_start;ipart<=myatm_end;ipart++){
    for(ip=1;ip<=pi_beads;ip++){
     ip_ind = 2*ip-1;
     x_c[ip_ind]   = clatoms_pos[ip].fx[ipart];
     y_c[ip_ind]   = clatoms_pos[ip].fy[ipart];
     z_c[ip_ind]   = clatoms_pos[ip].fz[ipart];
    }/*endfor*/
   for(ip=1;ip<=pi_beads;ip++){
    ip_ind = 2*ip;
    x_c[ip_ind] = 0.0;
    y_c[ip_ind] = 0.0;
    z_c[ip_ind] = 0.0;
   }/*endfor*/
/* i) transform to normal mode forces */
   ifound = 0;    
#ifdef HP_VECLIB
   ifound = 1;    
   iopt = -1;
   ierr  = 0;
   npp = pi_beads;
   incl = 1;
   n = 1;
   incn = 1;
   ZFFTS(&x_c[1],&npp,&incl,&n,&incn,&iopt,&ierr);
   ZFFTS(&y_c[1],&npp,&incl,&n,&incn,&iopt,&ierr);
   ZFFTS(&z_c[1],&npp,&incl,&n,&incn,&iopt,&ierr);
   anorm = (double)(pi_beads);
   for(ip=1;ip<=2*pi_beads;ip++){
     x_c[ip] *= anorm;
     y_c[ip] *= anorm;
     z_c[ip] *= anorm;
   }/*endfor*/
#endif
#ifdef SGI_COMPLIB
    ifound = 1;   
    sign   = 1;
    npp    = pi_beads;
    n      = 1;
    incl   = 1;
    lda    = 1;
    ZFFT1D(&sign,&npp,&(x_c[1]),&incl,&(clatoms_tran->work[1]));
    ZFFT1D(&sign,&npp,&(y_c[1]),&incl,&(clatoms_tran->work[1]));
    ZFFT1D(&sign,&npp,&(z_c[1]),&incl,&(clatoms_tran->work[1]));
#endif
#ifdef IBM_ESSL
    ifound=1;
    init=0;
    one1=one2=one3=one4=one5=one6=1;
    lwork1=lwork2=clatoms_tran->nwork;
    anorm = 1.0;
    sign = -1;
    DCFT(&init,&(x_c[1]),&one1,&one2,&(x_c[1]),
         &one3,&one4,&pi_beads,&one5,&sign,&anorm,&(clatoms_tran->work3[1]),
         &lwork1,&(clatoms_tran->work4[1]),&lwork2);
    DCFT(&init,&(y_c[1]),&one1,&one2,&(y_c[1]),
         &one3,&one4,&pi_beads,&one5,&sign,&anorm,&(clatoms_tran->work3[1]),
         &lwork1,&(clatoms_tran->work4[1]),&lwork2);
    DCFT(&init,&(z_c[1]),&one1,&one2,&(z_c[1]),
         &one3,&one4,&pi_beads,&one5,&sign,&anorm,&(clatoms_tran->work3[1]),
         &lwork1,&(clatoms_tran->work4[1]),&lwork2);
#endif
#ifdef C90
    ifound = 1;   
    sign   = 1;
    npp = pi_beads;
    n = 1;
    incl = 1;
    lda = 1;
    CFFT99(&x_c[1],&(clatoms_tran->work[1]),&(clatoms_tran->work2[1]),
           &(clatoms_tran->ifax[1]),&incl,&lda,&pi_beads,&n,&sign);
    CFFT99(&y_c[1],&(clatoms_tran->work[1]),&(clatoms_tran->work2[1]),
           &(clatoms_tran->ifax[1]),&incl,&lda,&pi_beads,&n,&sign);
    CFFT99(&z_c[1],&(clatoms_tran->work[1]),&(clatoms_tran->work2[1]),
           &(clatoms_tran->ifax[1]),&incl,&lda,&pi_beads,&n,&sign);
#endif
    if(ifound==0){
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      printf("Centroid transformation not implemented on your platform\n");
      printf("Contact Technical support: \n");
      printf("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
      fflush(stdout);
      exit(1);
    }/*endif*/
/* ii) put the forces in the correct vectors */
     clatoms_pos[1].fx[ipart] = x_c[1];
     clatoms_pos[1].fy[ipart] = y_c[1];
     clatoms_pos[1].fz[ipart] = z_c[1];
     clatoms_pos[pi_beads].fx[ipart] = x_c[(pi_beads+1)];
     clatoms_pos[pi_beads].fy[ipart] = y_c[(pi_beads+1)];
     clatoms_pos[pi_beads].fz[ipart] = z_c[(pi_beads+1)];
     for(ip=2;ip<=np2;ip++){
      ip_ind2 = 2*ip - 2;
      ip_ind1 = 2*ip - 1;
      clatoms_pos[ip_ind2].fx[ipart] = x_c[ip_ind1]*2.0;
      clatoms_pos[ip_ind2].fy[ipart] = y_c[ip_ind1]*2.0;
      clatoms_pos[ip_ind2].fz[ipart] = z_c[ip_ind1]*2.0;
     }/*endfor*/
     for(ip=2;ip<=np2;ip++){
      ip_ind1 = 2*ip - 1;
      ip_ind2 = 2*ip;
      clatoms_pos[ip_ind1].fx[ipart] = x_c[ip_ind2]*2.0;
      clatoms_pos[ip_ind1].fy[ipart] = y_c[ip_ind2]*2.0;
      clatoms_pos[ip_ind1].fz[ipart] = z_c[ip_ind2]*2.0;
     }/*endfor*/
    }/*endfor:ipart*/
  }/*endif*/
#ifdef DEBUG
  printf("DEBUGGING FORCE TRANSFORM\n");
  for(ip=4;ip<=pi_beads;ip+=4){
    printf("pos[%d].fx[1]=%g\n",ip,clatoms_pos[ip].fx[myatm_start]);
    printf("pos[%d].fy[1]=%g\n",ip,clatoms_pos[ip].fy[myatm_start]);
    printf("pos[%d].fz[1]=%g\n",ip,clatoms_pos[ip].fz[myatm_start]);
  }/*endfor*/
  for(ip=4;ip<=pi_beads;ip+=4){
    printf("pos[%d].fx[%d]=%g\n",ip,natm_tot,clatoms_pos[ip].fx[myatm_end]);
    printf("pos[%d].fy[%d]=%g\n",ip,natm_tot,clatoms_pos[ip].fy[myatm_end]);
    printf("pos[%d].fz[%d]=%g\n",ip,natm_tot,clatoms_pos[ip].fz[myatm_end]);
  }/*endfor*/
  printf("Enter an integer: ");scanf("%d",&ip);
#endif

/*--------------------------------------------------------------------------*/
}/*end routine*/
コード例 #3
0
ファイル: doitf.c プロジェクト: syntheticpp/benchfft
void doit(int iter, struct problem *p)
{
     int i;
     int sign = p->sign;

     switch (p->rank) {
     case 1:{
	       int n = p->n[0];
	       void *wsave = WSAVE;

	       if (p->kind == PROBLEM_COMPLEX) {
		    bench_real *pin = p->in;

		    if (SINGLE_PRECISION) {
			 for (i = 0; i < iter; ++i) {
			      CFFT1D(pin, &n, &sign, wsave);
			 }
		    } else {
			 for (i = 0; i < iter; ++i) {
			      ZFFT1D(pin, &n, &sign, wsave);
			 }
		    }
	       } else {
		    bench_real *pin = p->in;

		    if (sign == -1) {
			 if (SINGLE_PRECISION)
			      for (i = 0; i < iter; ++i) {
				   SCFFT1D(pin, &n, &sign, WSAVE);
			      } 
			 else
			      for (i = 0; i < iter; ++i) {
				   DZFFT1D(pin, &n, &sign, WSAVE);
			      }
		    } else {
			 if (SINGLE_PRECISION)
			      for (i = 0; i < iter; ++i) {
				   CSFFT1D(pin, &n, &sign, WSAVE);
			      } 
			 else
			      for (i = 0; i < iter; ++i) {
				   ZDFFT1D(pin, &n, &sign, WSAVE);
			      }
		    }
	       }
	       break;
	  }
     case 2:{
	       int n = p->n[0];
	       int m = p->n[1];
	       bench_real *pin = p->in;

	       if (p->kind == PROBLEM_COMPLEX) {
		    if (SINGLE_PRECISION) {
			 for (i = 0; i < iter; ++i) {
			      CFFT2D(pin, &m, &n, &sign);
			 }
		    } else {
			 for (i = 0; i < iter; ++i) {
			      ZFFT2D(pin, &m, &n, &sign);
			 }
		    }
	       } else {
		    if (sign == -1) {
			 if (SINGLE_PRECISION)
			      for (i = 0; i < iter; ++i) {
				   SCFFT2D(pin, &m, &n);
			      }
			 else
			      for (i = 0; i < iter; ++i) {
				   DZFFT2D(pin, &m, &n);
			      }
		    } else {
			 if (SINGLE_PRECISION)
			      for (i = 0; i < iter; ++i) {
				   CSFFT2D(pin, &m, &n);
			 } else
			      for (i = 0; i < iter; ++i) {
				   ZDFFT2D(pin, &m, &n);
			      }
		    }
	       }
	  }

     }
}