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

init_array: Do not optimize, costs are greater than benefits

This commit is contained in:
Steffo 2022-11-15 19:46:23 +01:00
parent 7ae893d977
commit f48d351890
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -24,11 +24,14 @@ static void init_array(int nx, int ny,
{ {
int i, j; int i, j;
// TODO: Optimizable loop, every task has no dependencies on the other ones // Parallelizing this causes a slowdown, as the cost of context-switches is greater than the cost of inlline execution
for (i = 0; i < ny; i++) // #pragma omp parallel for num_threads(SOMETHING) schedule(static)
for (i = 0; i < ny; i++) {
x[i] = i * M_PI; x[i] = i * M_PI;
}
// TODO: Optimizable loop, every task has no dependencies on the other ones // Same here, but many times more
// #pragma omp parallel for num_threads(SOMETHING) 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;