Ejemplo n.º 1
0
/* Updates the momenta: equation 16 of Gottlieb */
void update_momenta(int * mnllist, double step, const int no, 
		    hamiltonian_field_t * const hf) {

#ifdef OMP
#pragma omp parallel for
#endif
  for(int i = 0; i < (VOLUMEPLUSRAND + g_dbw2rand);i++) { 
    for(int mu=0;mu<4;mu++) { 
      _zero_su3adj(hf->derivative[i][mu]);
    }
  }
  
  for(int k = 0; k < no; k++) {
    if(monomial_list[ mnllist[k] ].derivativefunction != NULL) {
      monomial_list[ mnllist[k] ].derivativefunction(mnllist[k], hf);
    }
  }
  
#ifdef MPI
  xchange_deri(hf->derivative);
#endif
    
#ifdef OMP
#pragma omp parallel for
#endif
  for(int i = 0; i < VOLUME; i++) {
    for(int mu = 0; mu < 4; mu++) {
      /* the minus comes from an extra minus in trace_lambda */
      _su3adj_minus_const_times_su3adj(hf->momenta[i][mu], step, hf->derivative[i][mu]); 
    }
  }

  return;
}
Ejemplo n.º 2
0
void monitor_forces(hamiltonian_field_t * const hf) {

  for(int id = 0; id < no_monomials; id++) {
    if(monomial_list[ id ].derivativefunction != NULL) {
#ifdef TM_USE_OMP
#pragma omp parallel for
#endif
      for(int i = 0; i < (VOLUMEPLUSRAND + g_dbw2rand);i++) { 
	for(int mu=0;mu<4;mu++) { 
	  _zero_su3adj(hf->derivative[i][mu]);
	}
      }
      
      monomial_list[ id ].derivativefunction(id, hf);
      
#ifdef TM_USE_MPI
      xchange_deri(hf->derivative);
#endif
      
      double sum = 0., max = 0., sum2;
#ifdef TM_USE_OMP
#pragma omp parallel private(sum2)
      {
	int thread_num = omp_get_thread_num();
	g_omp_acc_re[thread_num] = 0.;
#pragma omp for reduction(+ : sum) nowait
#endif
	for(int i = 0; i < VOLUME; i++) {
	  for(int mu = 0; mu < 4; mu++) {
	    sum2 = _su3adj_square_norm(hf->derivative[i][mu]); 
	    sum += sum2;
#ifdef TM_USE_OMP
	    if(sum2 > g_omp_acc_re[thread_num]) g_omp_acc_re[thread_num] = sum2;
#else
	    if(sum2 > max) max = sum2;
#endif
	  }
	}
#ifdef TM_USE_OMP
      } /* OMP closing brace */
      max = g_omp_acc_re[0];
      for( int i = 1; i < omp_num_threads; i++) {
	if(g_omp_acc_re[i] > max) max = g_omp_acc_re[i];
      }
#endif
      
      // output for force monitoring
#ifdef TM_USE_MPI
      MPI_Reduce(&sum, &sum2, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
      sum = sum2;
      MPI_Reduce(&max, &sum2, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
      max = sum2;
#endif
      if(g_proc_id == 0) {
	printf("# squared force for monomial %s on timescale %d: aver: %1.8e max: %1.8e\n", 
	       monomial_list[ id ].name,
	       monomial_list[ id ].timescale,
	       sum/((double)(VOLUME*g_nproc))/4., max);
	fflush(stdout);
      }
    }
  } 
  return;
}