sw/benchmarks/src/ocean.c
/* perform half-injection to next coarsest level                */
perform half-injection to next coarsest level
perform half - injection to next coarsest level
void rescal(percore_data_t *percore, long k)
{
    int i, j;
    int ihi = 1 << (k);
    int jhi = 1 << ((percore->params.log2_nprocs&1)+k);
    int i_off = percore->rownum*ihi;
    int j_off = percore->colnum*jhi;
    double **q = percore->q[k];
    double **rhs = percore->rhs[k];
    double **coarse = percore->rhs[k-1];
    double *col = percore->one_col;
    double *row = percore->one_row;
    bool border_n = percore->border_n;
    bool border_w = percore->border_w;
    double coeff_k1 = 1.0 / ((1 << (k + ((percore->params.log2_nprocs+1)>>1)))+1);
    double factor = multig_factor(percore, k);
    double wi1 = 0.5 * (1+i_off) * coeff_k1;
    double wj1 = (1+j_off) * coeff_k1;
    coarse[1][1] = calc_rhs(border_n || border_w, rhs, q, factor, 
        wi1, wj1,
        1, 1,
        col[0],
        col[1],
        row[0],
        row[1]);
    for(j=2; j<=jhi; j++) {
        double wj = (j+j_off) * coeff_k1;
        coarse[1][j] = calc_rhs(border_n, rhs, q, factor, 
            wi1, wj, 
            1, j,
            q[2*1-2][2*j-3],
            q[2*1][2*j-3],
            row[j-1],
            row[j]);
    }
    for(i=2; i<=ihi; i++) {
        double wi = 0.5 * (i+i_off) * coeff_k1;
        coarse[i][1] = calc_rhs(border_w, rhs, q, factor,
            wi, wj1,
            i, 1,
            col[i-1],
            col[i],
            q[2*i-3][2*1-2],
            q[2*i-3][2*1]);
    }
    for(i=2; i<=ihi; i++) {
        double wi = 0.5 * (i+i_off) * coeff_k1;
	for(j=2; j<=jhi; j++) {
    	    double wj = (j+j_off) * coeff_k1;
	    coarse[i][j] = calc_rhs(false, rhs, q, factor, wi, wj, i, j,
        	q[2*i-2][2*j-3],
        	q[2*i][2*j-3],
        	q[2*i-3][2*j-2],
    		q[2*i-3][2*j]);
	}
    }
}
void rescal ( percore_data_t * percore , long k ) { int i , j ; int ihi = 1 << ( k ) ; int jhi = 1 << ( ( percore -> params . log2_nprocs & 1 ) + k ) ; int i_off = percore -> rownum * ihi ; int j_off = percore -> colnum * jhi ; double * * q = percore -> q [ k ] ; double * * rhs = percore -> rhs [ k ] ; double * * coarse = percore -> rhs [ k - 1 ] ; double * col = percore -> one_col ; double * row = percore -> one_row ; bool border_n = percore -> border_n ; bool border_w = percore -> border_w ; double coeff_k1 = 1.0 / ( ( 1 << ( k + ( ( percore -> params . log2_nprocs + 1 ) >> 1 ) ) ) + 1 ) ; double factor = multig_factor ( percore , k ) ; double wi1 = 0.5 * ( 1 + i_off ) * coeff_k1 ; double wj1 = ( 1 + j_off ) * coeff_k1 ; coarse [ 1 ] [ 1 ] = calc_rhs ( border_n || border_w , rhs , q , factor , wi1 , wj1 , 1 , 1 , col [ 0 ] , col [ 1 ] , row [ 0 ] , row [ 1 ] ) ; for ( j = 2 ; j <= jhi ; j ++ ) { double wj = ( j + j_off ) * coeff_k1 ; coarse [ 1 ] [ j ] = calc_rhs ( border_n , rhs , q , factor , wi1 , wj , 1 , j , q [ 2 * 1 - 2 ] [ 2 * j - 3 ] , q [ 2 * 1 ] [ 2 * j - 3 ] , row [ j - 1 ] , row [ j ] ) ; } for ( i = 2 ; i <= ihi ; i ++ ) { double wi = 0.5 * ( i + i_off ) * coeff_k1 ; coarse [ i ] [ 1 ] = calc_rhs ( border_w , rhs , q , factor , wi , wj1 , i , 1 , col [ i - 1 ] , col [ i ] , q [ 2 * i - 3 ] [ 2 * 1 - 2 ] , q [ 2 * i - 3 ] [ 2 * 1 ] ) ; } for ( i = 2 ; i <= ihi ; i ++ ) { double wi = 0.5 * ( i + i_off ) * coeff_k1 ; for ( j = 2 ; j <= jhi ; j ++ ) { double wj = ( j + j_off ) * coeff_k1 ; coarse [ i ] [ j ] = calc_rhs ( false , rhs , q , factor , wi , wj , i , j , q [ 2 * i - 2 ] [ 2 * j - 3 ] , q [ 2 * i ] [ 2 * j - 3 ] , q [ 2 * i - 3 ] [ 2 * j - 2 ] , q [ 2 * i - 3 ] [ 2 * j ] ) ; } } }
perform half-injection to next coarsest level
perform half - injection to next coarsest level
// i=1 j=1 // i=1 // j=1