• [^] # Re: Est-ce le cache CPU ?

    Posté par (site web personnel) . En réponse au message étudier le fonctionnement du cache. Évalué à 1.

    Bon, alors voila le code en question (uniquement le coeur de la boucle incriminée)... les tableaux sont une classe qui stocke les données 2D dans un vecteur 1D (colonnes écrites les unes à la suite des autres). Les tabelaux font typiquement ~100*100 cellules sauf le tableau vf qui lui fait 100*100*100*100 pour l'exemple cité.


    // variables needed to optimize the computational speed
    const double lw_radius2=lw_radius*lw_radius;
    const double z_shoot=z[i_shoot][j_shoot];
    const double t_snow_shoot=t_snowold[i_shoot][j_shoot];

    // every grid cell receives radiation from the chosen one with coordinates (a,b)
    for ( int j = 0; j < dimy; j++ ) {
    for ( int i = 0; i < dimx; i++ ) {
    const double bx = (double)(i_shoot - i) * cellsize; // bx = dx (m) going from (i_shoot,j_shoot) to (i,j)
    const double by = (double)(j_shoot - j) * cellsize; // by = dy (m) going from (i_shoot,j_shoot) to (i,j)
    const double bz = z_shoot - z[i][j]; // bz = dz (m) going from (i_shoot,j_shoot) to (i,j)

    // distance between the surfaces
    const double dist2 = ( (bx * bx) + (by * by) + (bz * bz) );

    // the longwave radiation will only be emitted if the radius is lower than
    // a preassumed radius (lw_radius) -> changeable in: lw_t(a,b) * lw_radius
    //please note that it also excludes the current shooting cell itself!
    if ( dist2 <= lw_radius2 && dist2>0.) {
    const int ij = j * dimx + i;
    const int ab = j_shoot * dimx + i_shoot;
    vf[0][0] = vf[ij][ab];

    // formulation of the long-wave radiation coming from the terrain:
    const double rad = ( 0.000009886 * (pow( 0.5 * log(dist2),1.07 )) * (meteo2D[i][j].ta - t_snow_shoot)
    + 0.000003456 * meteo2D[i][j].ta + 0.0001452 * t_snow_shoot - 0.0304 )
    * vf[0][0] * 10000. * PI;

    // the received amount is added to the total radiation at ij
    lwi[i][j] += rad;

    // the next ('shooting') grid cell with the most unshot radiation is selected
    // taking into account an air column reduction factor,
    // the actual (slope) area size, emittable longwave radiation
    // and the sum of total terrain view factor
    if ( lw_t[i][j] * vf_t[i][j] > diffmax_lw ) {
    diffmax_lw = lw_t[i][j] * vf_t[i][j];
    *e = i;
    *f = j;
    }
    s++;
    } // end of if only for distances lower than lw_radius

    // stopping criterion : Delta B^(k) * Sum_j(Fij) * A
    eps_stern += fabs( lw_t[i][j] * vf_t[i][j] );
    } // end of for i loop
    } // end of for j loop

    // set the emitted 'shot' radiation at that cell to zero, but in contrast to the
    // shortwave radiation exchange taking into account multiple reflections here
    // every grid cell emitts only once
    lw_t[i_shoot][j_shoot] = 0.;


    Bien sur, cela ne compile pas, il manque plein de choses, etc mais le code complet est volumineux.

    Mathias