-2

I am a beginner at parallelization, can somebody help me with how to make this program parallel with OpenMP? I'm trying but won't work. The running time is always almost the same.

    {
double start = omp_get_wtime();
#pragma omp parallel for
    for (int i = 0; i < Row1; i++) {
        for (int j = 0; j < Col2; j++) {
            rslt[i][j] = 0;

            for (long long int k = 0; k < Row2; k++) {
                rslt[i][j] += firstMatrix[i][k] * secondMatrix[k][j];
            }
            //printf("%lld\t", rslt[i][j]);
        }
        //printf("\n");
    }
    double stop = omp_get_wtime();
    printf("Multiplication Time (s) %.6f\n", (stop - start));
}
Arthurke
  • 1
  • 1
  • You should certainly read the >200 previous posts on how to do a matrix multiplication with OpenMP: https://stackoverflow.com/search?q=%5Bopenmp%5D+matrix+multiplication . Not to mention there are a LOT of tutorials on this on the web... Note that your loop does not have any observable effect to the compiler can completely remove it (assuming optimization are enabled which is not mentioned). – Jérôme Richard May 16 '22 at 20:52

0 Answers0