Esempio n. 1
0
int main( int argc, char **argv ){
  int prompt;
  char *filexml;
  
  initialize_machine(&argc,&argv);

  /* Remap standard I/O if needed */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
  
  g_sync();
  /* set up */
  prompt = setup();

  /* loop over input sets */
  while( readin(prompt) == 0){
    
    node0_printf("BEGIN\n");
#ifdef CHECK_INVERT
    
    check_ks_invert( srcfile, srcflag, F_OFFSET(phi), 
		     ansfile, ansflag, F_OFFSET(xxx), 
		     F_OFFSET(g_rand), mass);
    
#else
#ifndef HAVE_QIO
BOMB Checking the fermion force requires QIO compilation
#endif
    
    check_fermion_force( srcfile, srcflag, F_OFFSET(xxx), 
			 ansfile, ansflag, mass);
    node0_printf("Done checking fermion force\n");
#endif
    
    /* save lattice if requested */
    if( saveflag != FORGET ){
      rephase( OFF );
      node0_printf("Saving the lattice\n");
      save_lattice( saveflag, savefile, NULL );
      rephase( ON );
    }
    
#ifdef FN
    /* save longlinks if requested */
    if (savelongflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the long links\n");
      save_color_matrix_scidac_from_field( savelongfile, filexml, 
         "Long links", QIO_SINGLEFILE, get_lnglinks(get_fm_links(fn_links)[0]), 4);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the longlinks.  Recompile with QIO\n");
#endif
    }
    
    /* save fatlinks if requested */
    if (savefatflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the fat links\n");
      save_color_matrix_scidac_from_field( savefatfile, filexml, 
	   "Fat links", QIO_SINGLEFILE, get_fatlinks(get_fm_links(fn_links)[0]), 4);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the fatlinks.  Recompile with QIO\n");
#endif
    }
#endif
    
  }
  node0_printf("RUNNING COMPLETED\n");
  return 0;
}
Esempio n. 2
0
/* The QIO file is closed after writing the lattice */
gauge_file *save_scidac(char *filename, int volfmt, int serpar, int ildgstyle,
			char *stringLFN){
  QIO_Layout layout;
  QIO_Filesystem fs;
  QIO_Writer *outfile;
  int status;
  field_offset src = F_OFFSET(link[0]);
  gauge_file *gf;
  char *info;
  QIO_String *filexml;
  QIO_String *recxml;
  char default_file_xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><title>MILC ILDG archival gauge configuration</title>";

  QIO_verbose(QIO_VERB_OFF);

  /* Build the layout structure */
  build_qio_layout(&layout);

  /* Define the I/O system */
  build_qio_filesystem(&fs);

  /* Make a dummy gauge file structure for MILC use */
  gf = setup_output_gauge_file();

  /* Set the filename in the gauge_file structure */
  gf->filename = filename;

  /* Open file for writing */
  filexml = QIO_string_create();
  QIO_string_set(filexml, default_file_xml);
  outfile = open_scidac_output(filename, volfmt, serpar, ildgstyle, 
			       stringLFN, &layout, &fs, filexml);
  if(outfile == NULL)terminate(1);
  QIO_string_destroy(filexml);

  /* Create the QCDML string for this configuration */
  info = create_QCDML();
  recxml = QIO_string_create();
  QIO_string_set(recxml, info);

  /* Write the lattice field */
  status = write_F3_M_from_site(outfile, recxml, src, LATDIM);
  if(status)terminate(1);

  /* Discard for now */
  QIO_string_destroy(recxml);
  
  /* Write information */
  if(volfmt == QIO_SINGLEFILE){
    node0_printf("Saved gauge configuration serially to binary file %s\n",
		 filename);
  }
  else if(volfmt == QIO_MULTIFILE){
    node0_printf("Saved gauge configuration as multifile to binary file %s\n",
	   filename);
  }
  else if(volfmt == QIO_PARTFILE){
    node0_printf("Saved gauge configuration in partition format to binary file %s\n",
	   filename);
  }

  node0_printf("Time stamp %s\n",gf->header->time_stamp);
  node0_printf("Checksums %x %x\n",
	       QIO_get_writer_last_checksuma(outfile),
	       QIO_get_writer_last_checksumb(outfile));

  /* Close the file */
  QIO_close_write(outfile);

  free_QCDML(info);
  return gf;
}
Esempio n. 3
0
int main( int argc, char **argv ){
  int prompt;
  char *filexml;
  
  initialize_machine(&argc,&argv);

  /* Remap standard I/O if needed */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);
  
  g_sync();
  /* set up */
  prompt = setup();

  /* loop over input sets */
  while( readin(prompt) == 0){
    
    if(prompt == 2)continue;
    
    node0_printf("BEGIN\n");
#ifdef CHECK_INVERT
    
    check_ks_invert( par_buf.srcfile[0], srcflag, par_buf.ansfile, par_buf.ansflag, 
		     par_buf.nmass, par_buf.ksp, par_buf.qic);
    
#else
#ifndef HAVE_QIO
    BOMB Checking the fermion force requires QIO compilation;
#endif
    
    check_fermion_force( par_buf.srcfile, srcflag, par_buf.ansfile[0], 
			 par_buf.ansflag[0], par_buf.nmass, par_buf.ksp);
    node0_printf("Done checking fermion force\n");
#endif
    
    /* save lattice if requested */
    if( saveflag != FORGET ){
      rephase( OFF );
      node0_printf("Saving the lattice\n");
      save_lattice( saveflag, savefile, NULL );
      rephase( ON );
    }
    
#ifdef FN
    /* save longlinks if requested */
    if (savelongflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the long links\n");
      save_color_matrix_scidac_from_field( savelongfile, filexml, 
		   "Long links", QIO_SINGLEFILE, 
		   get_lnglinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      /* REMOVE NEXT STATEMENT */
      //      save_color_matrix_scidac_from_field( "lngback.scidac", filexml, 
      //		   "Long back links", QIO_SINGLEFILE, 
      //                   get_lngbacklinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the longlinks.  Recompile with QIO\n");
#endif
    }
    
    /* save fatlinks if requested */
    if (savefatflag != FORGET ){
#ifdef HAVE_QIO
      filexml = create_QCDML();
      node0_printf("Saving the fat links\n");
      save_color_matrix_scidac_from_field( savefatfile, filexml, 
            "Fat links", QIO_SINGLEFILE, 
	    get_fatlinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      /* REMOVE NEXT STATEMENT */
      //      save_color_matrix_scidac_from_field( "fatback.scidac", filexml, 
      //	   "Fat back links", QIO_SINGLEFILE, 
      //	    get_fatbacklinks(get_fm_links(fn_links)[0]), 4, PRECISION);
      free_QCDML(filexml);
#else
      printf("ERROR: Can't save the fatlinks.  Recompile with QIO\n");
#endif
    }
#endif
    
  }
  node0_printf("RUNNING COMPLETED\n");

#ifndef CHECK_INVERT

#ifdef HISQ_SVD_COUNTER
  printf("hisq_svd_counter = %d\n", hisq_svd_counter);
#endif
  
#ifdef HISQ_FORCE_FILTER_COUNTER
  printf("hisq_force_filter_counter = %d\n", hisq_force_filter_counter);
#endif

#endif

  return 0;
}
Esempio n. 4
0
int update()  {
  int step, iters=0;
  int n;
  Real final_rsq;
#ifdef HMC_ALGORITHM
  double startaction,endaction,d_action();
  Real xrandom;
#endif
  imp_ferm_links_t** fn;

    /* refresh the momenta */
    ranmom();

    /* In this application, the number of naik terms is 1 or 2 only */
    n = fermion_links_get_n_naiks(fn_links);

    /* do "steps" microcanonical steps"  */
    for(step=1; step <= steps; step++){
 
#ifdef PHI_ALGORITHM
        /* generate a pseudofermion configuration only at start*/
	/* also clear xxx, since zero is our best guess for the solution
	   with a new random phi field. */
     	if(step==1){
	  restore_fermion_links_from_site(fn_links, PRECISION);
	  fn = get_fm_links(fn_links);
	  clear_latvec( F_OFFSET(xxx1), EVENANDODD );
	  grsource_imp( F_OFFSET(phi1), mass1, EVEN, fn[0]);
	  clear_latvec( F_OFFSET(xxx2), EVENANDODD );
	  grsource_imp( F_OFFSET(phi2), mass2, EVEN, fn[n-1]);
	}

#ifdef HMC_ALGORITHM
        /* find action */
        /* do conjugate gradient to get (Madj M)inverse * phi */
        if(step==1){
            /* do conjugate gradient to get (Madj M)inverse * phi */
	  restore_fermion_links_from_site(fn_links, PRECISION);
	  fn = get_fm_links(fn_links);
	    iters += ks_congrad( F_OFFSET(phi1), F_OFFSET(xxx1), mass1,
				 niter, nrestart, rsqmin, PRECISION, EVEN, 
				 &final_rsq, fn[0]);
	  restore_fermion_links_from_site(fn_links, PRECISION);
	  fn = get_fm_links(fn_links);
	    iters += ks_congrad( F_OFFSET(phi2), F_OFFSET(xxx2), mass2,
				 niter, nrestart, rsqmin, PRECISION, EVEN, 
				 &final_rsq, fn[n-1]);

     	    startaction=d_action();
            /* copy link field to old_link */
	    gauge_field_copy( F_OFFSET(link[0]), F_OFFSET(old_link[0]));
        }
#endif

	/* update U's to middle of interval */
     	update_u(0.5*epsilon);

#else /* "R" algorithm */
       	/* first update the U's to special time interval */
        /* and generate a pseudofermion configuration */
	/* probably makes most sense if nflavors1 >= nflavors2 */

       	update_u(epsilon*(0.5-nflavors1/8.0));
	clear_latvec( F_OFFSET(xxx1), EVENANDODD );
	restore_fermion_links_from_site(fn_links, PRECISION);
	fn = get_fm_links(fn_links);
     	grsource_imp( F_OFFSET(phi1), mass1, EVEN, fn[0]);

       	update_u(epsilon*((nflavors1-nflavors2)/8.0));
	clear_latvec( F_OFFSET(xxx2), EVENANDODD );
	restore_fermion_links_from_site(fn_links, PRECISION);
	fn = get_fm_links(fn_links);
     	grsource_imp( F_OFFSET(phi2), mass2, EVEN, fn[n-1]);

	/* update U's to middle of interval */
     	update_u(epsilon*nflavors2/8.0);
#endif

        /* do conjugate gradient to get (Madj M)inverse * phi */
	restore_fermion_links_from_site(fn_links, PRECISION);
	fn = get_fm_links(fn_links);
	if(n == 2){
	  iters += ks_congrad( F_OFFSET(phi1), F_OFFSET(xxx1), mass1,
		       niter, nrestart, rsqmin, PRECISION, EVEN, &final_rsq, fn[0] );
	  iters += ks_congrad( F_OFFSET(phi2), F_OFFSET(xxx2), mass2,
		       niter, nrestart, rsqmin, PRECISION, EVEN, &final_rsq, fn[1] );
	} else {
	iters += ks_congrad_two_src( F_OFFSET(phi1), F_OFFSET(phi2),
				     F_OFFSET(xxx1), F_OFFSET(xxx2),
				     mass1, mass2, niter, nrestart, rsqmin, 
				     PRECISION, EVEN, &final_rsq,
				     fn[0]);
	}

	dslash_site( F_OFFSET(xxx1), F_OFFSET(xxx1), ODD, fn[0]);
	dslash_site( F_OFFSET(xxx2), F_OFFSET(xxx2), ODD, fn[n-1]);
	/* now update H by full time interval */
    	update_h(epsilon);

#if 0
#ifdef HAVE_QIO
	{
	  char *filexml;
	  char recxml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><title>Test fermion force field</title>";
	  char ansfile[128];
	  char rootname[] = "fermion_force_dump";

	  /* Do this at the specified interval */
	  if(step%3 == 1){
	    
	    /* Construct a file name */
	    sprintf(ansfile,"%s%02d",rootname,step);
	    /* Dump the computed fermion force from the site structure */
	    filexml = create_QCDML();
	    save_color_matrix_scidac_from_site(ansfile, filexml, 
		       recxml, QIO_PARTFILE,  F_OFFSET(mom[0]), 4, PRECISION);
	    free_QCDML(filexml);
	  }
	}
#endif
#endif

    	/* update U's by half time step to get to even time */
    	update_u(epsilon*0.5);

        /* reunitarize the gauge field */
	rephase( OFF );
        reunitarize();
	rephase( ON );

    }	/* end loop over microcanonical steps */

#ifdef HMC_ALGORITHM
    /* find action */
    /* do conjugate gradient to get (Madj M)inverse * phi */
    restore_fermion_links_from_site(fn_links, PRECISION);
    fn = get_fm_links(fn_links);
    iters += ks_congrad( F_OFFSET(phi1), F_OFFSET(xxx1), mass1,
			 niter, nrestart, rsqmin, PRECISION, EVEN, 
			 &final_rsq, fn[0]);
    iters += ks_congrad( F_OFFSET(phi2), F_OFFSET(xxx2), mass2,
			 niter, nrestart, rsqmin, PRECISION, EVEN, 
			 &final_rsq, fn[n-1]);
    endaction=d_action();
    /* decide whether to accept, if not, copy old link field back */
    /* careful - must generate only one random number for whole lattice */
    if(this_node==0)xrandom = myrand(&node_prn);
    broadcast_float(&xrandom);
    if( exp( (double)(startaction-endaction) ) < xrandom ){
	if(steps > 0)
	    gauge_field_copy( F_OFFSET(old_link[0]), F_OFFSET(link[0]) );
#ifdef FN
	invalidate_fermion_links(fn_links);
#endif
	node0_printf("REJECT: delta S = %e\n", (double)(endaction-startaction));
    }
    else {
	node0_printf("ACCEPT: delta S = %e\n", (double)(endaction-startaction));
    }
#endif

    if(steps > 0)return (iters/steps);
    else return(-99);
}