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

Start commenting some lines

Co-authored-by: Caterina Gazzotti <gazzotti.caterina@gmail.com>
Co-authored-by: Fabio Zanichelli <274956@studenti.unimore.it>
This commit is contained in:
Steffo 2022-11-11 16:47:48 +00:00 committed by GitHub
parent 5bbe60d482
commit 46dedaef45
Signed by: github
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,8 +24,11 @@ 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
for (i = 0; i < ny; i++) 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
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;
@ -39,6 +42,8 @@ static void print_array(int nx,
{ {
int i; int i;
// Cannot optimize this: prints have to be dependent on each other to make sense!
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
{ {
fprintf(stderr, DATA_PRINTF_MODIFIER, y[i]); fprintf(stderr, DATA_PRINTF_MODIFIER, y[i]);
@ -58,11 +63,18 @@ static void kernel_atax(int nx, int ny,
{ {
int i, j; int i, j;
// TODO: Optimizable loop, no dependencies
for (i = 0; i < _PB_NY; i++) for (i = 0; i < _PB_NY; i++)
y[i] = 0; y[i] = 0;
// TODO: Optimizable loop, no dependencies
// actually tmp[i] could be a local variable
for (i = 0; i < _PB_NX; i++)
tmp[i] = 0;
// TODO: what do we do here?
for (i = 0; i < _PB_NX; i++) for (i = 0; i < _PB_NX; i++)
{ {
tmp[i] = 0;
for (j = 0; j < _PB_NY; j++) for (j = 0; j < _PB_NY; j++)
tmp[i] = tmp[i] + A[i][j] * x[j]; tmp[i] = tmp[i] + A[i][j] * x[j];
for (j = 0; j < _PB_NY; j++) for (j = 0; j < _PB_NY; j++)