0

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];
    }
  }

dreamcrash
  • 47,137
  • 25
  • 94
  • 117
ControlMet
  • 26
  • 4
  • Please specify what exactly you mean by "loop tiling". What is the problem with the first version? OpenMP should automatically distribute the loop to the threads in "tiles" (assuming static scheduling). If you have a loop nest, you may want to tile in more than one dimension, if this optimizes cache locality. But in your case that isn't needed, as you observed yourself. – paleonix Dec 13 '20 at 01:45
  • I alredy did it, I refered how to apply blocking I was kind of lost, ty for the help :D – ControlMet Dec 14 '20 at 12:48
  • You are streaming 1-D input data. Little to no point in applying tiling here, especially if the coordinates are randomly distributed. – Hristo Iliev Dec 14 '20 at 16:22
  • Okei, ty, I can apply unroll and jam right? – ControlMet Dec 18 '20 at 10:03

0 Answers0