Esempio n. 1
0
int func_a(int pa)
{                                     // *** 36
  int rv=0;
  TEMPO(7, 500*TIMEBASE, pa, rv);     // 38
  if (pa==1) 
    { 
      rv += func_f(1);
      TEMPO(8, 500*TIMEBASE, pa, rv); // 42
      rv += func_f(1);
    }
  TEMPO(6, 500*TIMEBASE, pa, rv);     // 45
  return rv;
}
Esempio n. 2
0
unsigned int *generate_scale_table(unsigned int nbands, scale_t scale)
{
	unsigned int *out;
	forward_t func_f;
	reverse_t func_r;
	float sc_max;
	float sc_min;
	float sc_step;
	float i;
	int j;

	if(scale < 0 || scale >= MAX_SCALE)
	      return NULL;
	if(nbands < 2)
	      return NULL;

	/* Technically nbands can be anything, but it is nice to have sanity bounds on
	 * input parameters */
	if(nbands > 20000)
	      return NULL;

	out = calloc(nbands, sizeof(unsigned int));
	if(!out)
	      return NULL;

	func_f = forward[scale];
	func_r = reverse[scale];

	sc_max = func_r(MAX_FREQ);
	sc_min = func_r(MIN_FREQ);
	sc_step = (sc_max - sc_min) / (float)(nbands);

	for(i = sc_min + sc_step, j = 0; i <= sc_max + sc_step && j < nbands; i += sc_step, j++) {
		out[j] = func_f(i);
	}

	return out;
}
Esempio n. 3
0
static void solve(double* density, double& time)
{
	PREV_DENSITY = new double[XY_LEN];
	for (int j = 0; j < OY_LEN + 1; j++)
	{
		for (int i = 0; i < OX_LEN_1; i++)
		{
			PREV_DENSITY[OX_LEN_1 * j + i] = analytical_solution(0, OX[i], OY[j]);
		}
	}

	int i = 0, j = 0, tl = 0;
	double timeStart = 0, timeEnd=0;
#ifdef _OPENMP
	// printf("OPENMP THREADS COUNT = %d\n", omp_get_max_threads());
	long count = 0;
	// dummy parallel section to get all threads running
	#pragma omp parallel private(i,j)
	{
		_InterlockedIncrement(&count);
	}
#endif

#ifdef _OPENMP
//	printf("OPENMP timer function is used!\n");
	timeStart = omp_get_wtime();
#else
//	printf("Standart timer function is used!\n");
	StartTimer();
#endif
	fflush(stdout);
	for (tl = 1; tl <= TIME_STEP_CNT; tl++)
	{
		PREV_TIME = TIME;
		TIME = TAU * tl;
		for (int k = 0; k <= OX_LEN; k++)
		{
			density[k] = analytical_solution(OX[k], BB, TIME);
			density[OX_LEN_1 * OY_LEN + k] = analytical_solution(OX[k], UB, TIME);
		}
		for (int u = 0; u <= OY_LEN; u++)
		{
			density[OX_LEN_1 * u] = analytical_solution(LB, OY[u], TIME);
			density[OX_LEN_1 * u + OX_LEN] = analytical_solution(RB, OY[u], TIME);
		}
#ifdef _OPENMP
	#pragma omp parallel for collapse(2) private(i, j)
#endif
		for (j = 1; j < OY_LEN; ++j)
		{
			for (i = 1; i < OX_LEN; ++i)
			{
				density[OX_LEN_1 * j + i] = integrate(i, j);
				density[OX_LEN_1 * j + i] += TAU * func_f(B, TIME, UB, BB, LB, RB, OX[i], OY[j]);
			}
		}
		memcpy(PREV_DENSITY, density, XY_LEN * sizeof(double));// заменить на быструю версию из agnerasmlib
	}
#ifdef _OPENMP
	timeEnd = omp_get_wtime();
	time = (timeEnd-timeStart);
//	printf("time %f s.\n", time);
#else
	time = GetTimer()/1000;
//	printf("time %f s.\n", time/1000);
#endif
	delete [] PREV_DENSITY;
}
Esempio n. 4
0
int func_set(const gsl_vector *params, void *data, gsl_vector *yvals, gsl_matrix *jacobian)
{
    func_f(params, data, yvals);
    func_df(params, data, jacobian);
    return GSL_SUCCESS;
}