Exemple #1
0
void zedc_sw_init(void)
{
	sw_trace("Using z_ prefixed libz.a\n");
	sw_trace("  ZLIB_VERSION %s (header version)\n", ZLIB_VERSION);
	sw_trace("  zlibVersion  %s (libz.so version)\n", z_zlibVersion());

	if (strcmp(ZLIB_VERSION, z_zlibVersion()) != 0) {
		pr_err("libz.so %s and zlib.h %s do not match!\n",
		       z_zlibVersion(), ZLIB_VERSION);
		return;
	}
}
Exemple #2
0
void zedc_sw_done(void)
{
	if (handle != NULL) {
		sw_trace("Closing software zlib\n");
		dlclose(handle);
	}
}
double clover_trlog_acc(const int id, hamiltonian_field_t * const hf) {
  monomial * mnl = &monomial_list[id];
  mnl->energy1 = 0.;
  sw_term(hf->gaugefield, mnl->kappa, mnl->c_sw); 
  /*compute the contribution from the clover trlog term */
  mnl->energy1 = -sw_trace(EO, mnl->mu);   
  if(g_proc_id == 0 && g_debug_level > 3) {
    printf("called clover_trlog_acc for id %d dH = %1.4e\n", 
	   id, mnl->energy1 - mnl->energy0);
  }
  return(mnl->energy1 - mnl->energy0);
}
void clover_trlog_heatbath(const int id, hamiltonian_field_t * const hf) {
  monomial * mnl = &monomial_list[id];
  mnl->energy0 = 0.;

  init_sw_fields();
  sw_term(hf->gaugefield, mnl->kappa, mnl->c_sw); 
  /*compute the contribution from the clover trlog term */
  mnl->energy0 = -sw_trace(EO, mnl->mu);
  if(g_proc_id == 0 && g_debug_level > 3) {
    printf("called clover_trlog_heatbath for id %d E = %e\n", id, mnl->energy0);
  }
  return;
}
void reweighting_factor(const int N, const int nstore) {
  int n = VOLUME;
  monomial * mnl;
  FILE * ofs;
  hamiltonian_field_t hf;

  hf.gaugefield = g_gauge_field;
  hf.momenta = NULL;
  hf.derivative = NULL;
  hf.update_gauge_copy = g_update_gauge_copy;

  double * data = (double*)calloc(no_monomials*N, sizeof(double));
  double * trlog = (double*)calloc(no_monomials, sizeof(double));

  // we compute the trlog part first, because they are independent of 
  // stochastic noise. This is only needed for even/odd monomials
  for(int j = 0; j < no_monomials; j++) {
    mnl = &monomial_list[j];
    if(mnl->even_odd_flag) {
      init_sw_fields();
      double c_sw = mnl->c_sw;
      if(c_sw < 0.) c_sw = 0.;

      sw_term( (const su3**) hf.gaugefield, mnl->kappa, c_sw); 
      if(mnl->type != NDDETRATIO) {
        trlog[j] = -sw_trace(0, mnl->mu);
      }
      else {
        trlog[j] = -sw_trace_nd(0, mnl->mubar, mnl->epsbar);
      }
        
      sw_term( (const su3**) hf.gaugefield, mnl->kappa2, c_sw);
      if(mnl->type != NDDETRATIO) {
        trlog[j] -= -sw_trace(0, mnl->mu2);
      }
      else {
        trlog[j] -= -sw_trace_nd(0, mnl->mubar2, mnl->epsbar2);
      }
    }
    else {
      trlog[j] = 0.;
    }
    if(g_proc_id == 0 && g_debug_level > 0) {
      printf("# monomial[%d] %s, trlog = %e\n", j, mnl->name, trlog[j]);
    }
  }

  for(int i = 0; i < N; i++) {
    if(g_proc_id == 0 && g_debug_level > 0) {
      printf("# computing reweighting factors for sample %d\n", i);
    }
    for(int j = 0; j < no_monomials; j++) {
      mnl = &monomial_list[j];
      if(mnl->type != GAUGE) {
	if(mnl->even_odd_flag) {
	  random_spinor_field_eo(mnl->pf, mnl->rngrepro, RN_GAUSS);
          mnl->energy0 = square_norm(mnl->pf, n/2, 1);
	}
	else {
          random_spinor_field_lexic(mnl->pf, mnl->rngrepro, RN_GAUSS);
          mnl->energy0 = square_norm(mnl->pf, n, 1);
        }
	if(g_proc_id == 0 && g_debug_level > 1) {
	  printf("# monomial[%d] %s, energy0 = %e\n", j, mnl->name, mnl->energy0);
	}
	if(mnl->type == NDDETRATIO) {
	  if(mnl->even_odd_flag) {
	    random_spinor_field_eo(mnl->pf2, mnl->rngrepro, RN_GAUSS);
            mnl->energy0 += square_norm(mnl->pf, n/2, 1);
	  }
	  else {
            random_spinor_field_lexic(mnl->pf, mnl->rngrepro, RN_GAUSS);
            mnl->energy0 += square_norm(mnl->pf2, n, 1);
          }
	}
      }
    }

    for(int j = 0; j < no_monomials; j++) {
      mnl = &monomial_list[j];
      if(mnl->type != GAUGE) {
	double y = mnl->accfunction(j, &hf);
	data[i*no_monomials + j] = y;
	if(g_proc_id == 0 && g_debug_level > 0) {
	  printf("# monomial[%d] %s, stochastic part: w_%d=%e exp(w_%d)=%e\n", j, mnl->name, j, j, y, exp(y));
	}
      }
    }
  }
  
  if(g_proc_id == 0) {
    char filename[50];
    sprintf(filename, "reweighting_factor.data.%.5d", nstore);
    if((ofs = fopen(filename, "w")) == NULL) {
      fatal_error("Could not open file for data output", "reweighting_factor");
    }
    else {
      for(int j = 0; j < no_monomials; j++) {
        mnl = &monomial_list[j];
        for(int i = 0; i < N; i++) {
          fprintf(ofs, "%.2d %.5d %e %e %e %e %.10e\n", j, i, mnl->kappa, mnl->kappa2, mnl->mu, mnl->mu2, data[i*no_monomials + j] + trlog[j]);
        }
      }
      fclose(ofs);
    }
  }
  free(data);
  free(trlog);
}
Exemple #6
0
void zedc_sw_done(void)
{
	sw_trace("Closing software zlib\n");
}
Exemple #7
0
/**
 * NOTE: We had different variants trying to find the right libz.so.1
 * in our system. Unfortunately this can differ for the various
 * distributions:
 *
 * RHEL7.2:
 *   $ ldconfig -p | grep libz.so.1 | cut -d' ' -f4 | head -n1
 *   /lib64/libz.so.1
 *
 * Ubuntu 15.10:
 *   $ ldconfig -p | grep libz.so.1 | cut -d' ' -f4 | head -n1
 *   /lib/powerpc64le-linux-gnu/libz.so.1
 *
 * Intel with RHEL6.7:
 *   $ ldconfig -p | grep libz.so.1 | cut -d' ' -f4 | head -n1
 *   /lib64/libz.so.1
 *
 * We are setting this via config.mk option and allow the
 * distributions to overwrite this via rpm spec file.
 *
 * NOTE: We tried loading "libz.so.1" without full path, but that
 * turned out to be dangerous. We tried to load our own lib, which was
 * leading to endless recursive calls and segfaults as results.
 */
void zedc_sw_init(void)
{
	char *error;
	const char *zlib_path = getenv("ZLIB_PATH");

	/* User has setup environment variable to find libz.so.1 */
	if (zlib_path != NULL) {
		sw_trace("Loading software zlib \"%s\"\n", zlib_path);
		dlerror();
		handle = dlopen(zlib_path, RTLD_LAZY);
		if (handle != NULL)
			goto load_syms;
	}

	/* We saw dlopen returning non NULL value in case of passing ""! */
	if (strcmp(CONFIG_ZLIB_PATH, "") == 0) {
		pr_err("  Empty CONFIG_ZLIB_PATH \"%s\"\n",
		       CONFIG_ZLIB_PATH);
		return;
	}

	/* Loading private zlib.so.1 using CONFIG_ZLIB_PATH */
	sw_trace("Loading software zlib \"%s\"\n", CONFIG_ZLIB_PATH);
	dlerror();
	handle = dlopen(CONFIG_ZLIB_PATH, RTLD_LAZY);
	if (handle == NULL) {
		pr_err("  %s\n", dlerror());
		return;
	}

load_syms:
	register_sym(zlibVersion);

	sw_trace("  ZLIB_VERSION=%s (header) zlibVersion()=%s (code)\n",
		 ZLIB_VERSION, z_zlibVersion());

	if (strcmp(ZLIB_VERSION, z_zlibVersion()) != 0) {
		pr_err("libz.so.1=%s and zlib.h=%s do not match!\n",
		       z_zlibVersion(), ZLIB_VERSION);
		return;
	}

	register_sym(deflateInit2_);
	register_sym(deflateParams);
	register_sym(deflateReset);
	register_sym(deflatePrime);
	register_sym(deflateCopy);
	register_sym(deflate);
	register_sym(deflateSetDictionary);
	register_sym(deflateSetHeader);
	register_sym(deflateEnd);

	register_sym(inflateInit2_);
	register_sym(inflateSync);
	register_sym(inflatePrime);
	register_sym(inflate);
	register_sym(inflateReset);
	register_sym(inflateReset2);
	register_sym(inflateSetDictionary);
	register_sym(inflateGetDictionary);
	register_sym(inflateGetHeader);
	register_sym(inflateEnd);

	register_sym(inflateBackInit_);
	register_sym(inflateBack);
	register_sym(inflateBackEnd);

	register_sym(gzopen);
	register_sym(gzdopen);
	register_sym(gzwrite);
	register_sym(gzread);
	register_sym(gzclose);
	register_sym(gzflush);
	register_sym(gzungetc);
	register_sym(gzeof);
	register_sym(gztell);
	register_sym(gzerror);
	register_sym(gzseek);
	register_sym(gzrewind);
	register_sym(gzputs);
	register_sym(gzputc);
	register_sym(gzgetc);
	register_sym(gzputs);
	register_sym(gzprintf);

	register_sym(compress);
	register_sym(uncompress);

	register_sym(zError);
	register_sym(zlibCompileFlags);

	register_sym(adler32);
	register_sym(adler32_combine);
	register_sym(crc32);
	register_sym(crc32_combine);


#if ZLIB_VERNUM >= 0x1280
	register_sym(gzopen64);
	register_sym(gzseek64);
	register_sym(gztell64);
	register_sym(gzoffset);
	register_sym(gzoffset64);
	register_sym(adler32_combine64);
	register_sym(crc32_combine64);
	register_sym(get_crc_table);
#endif
}