How do I apply loop tiling?

234 Views Asked by At

I am trying to apply code tiling but I dont really understand it, I had seen things about inner loop but I dont have any inner loops. Can anyone explain it to me? I am using the gcc compiler.

  
  #pragma omp parallel for reduction (+:outputBins)
  for (int i = 0; i < inputData.numDataPoints; i++) { 
    // Transforming from cylindrical to Cartesian coordinates:
    const FTYPE x = inputData.r[i]*COS(inputData.phi[i]);
    const FTYPE y = inputData.r[i]*SIN(inputData.phi[i]);

    // Calculating the bin numbers for these coordinates:
    const int iX = int((x - xMin)*binsPerUnitX);
    const int iY = int((y - yMin)*binsPerUnitY);

    // Incrementing the appropriate bin in the counter
    ++outputBins[iX][iY];
  }
}
/// I tried this, but doent do re correct thing because it messes with paralelization
  const int N = 20000;
  
  #pragma omp parallel for reduction (+:outputBins)
  for (int j=0; j < inputData.numDataPoints; j+=N){

    for (int i = j; i < (j+N); i++) { 
      // Transforming from cylindrical to Cartesian coordinates:
      const FTYPE x = inputData.r[j]*COS(inputData.phi[j]);
      const FTYPE y = inputData.r[j]*SIN(inputData.phi[j]);

      // Calculating the bin numbers for these coordinates:
      const int iX = int((x - xMin)*binsPerUnitX);
      const int iY = int((y - yMin)*binsPerUnitY);

      // Incrementing the appropriate bin in the counter
      ++outputBins[iX][iY];
    }
  }

0

There are 0 best solutions below