1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2024-11-23 00:24:23 +00:00

init_array: Parallelize the second loop

The performance hit is gone?

0.0437s → 0.0342s
This commit is contained in:
Steffo 2022-11-17 01:54:13 +01:00
parent 9dc24a3367
commit a23fd895e9
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -31,7 +31,7 @@ static void init_array(int nx, int ny,
} }
/// Initialize the `A` matrix with [something?] /// Initialize the `A` matrix with [something?]
// Using 4 threads here slows everything down: why? #pragma omp parallel for num_threads(THREAD_COUNT) schedule(static)
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
A[i][j] = ((DATA_TYPE)i * (j + 1)) / nx; A[i][j] = ((DATA_TYPE)i * (j + 1)) / nx;