Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iker Martín Álvarez
Proteo
Commits
d8139b51
Commit
d8139b51
authored
Nov 30, 2023
by
iker_martin
Browse files
Matrix computation fixed
parent
df17a353
Changes
3
Hide whitespace changes
Inline
Side-by-side
Codes/Main/Main.c
View file @
d8139b51
...
...
@@ -12,7 +12,8 @@
#include "../malleability/malleabilityManager.h"
#include "../malleability/malleabilityStates.h"
#define DR_MAX_SIZE 1000000000
//#define DR_MAX_SIZE 1000000000
#define DR_MAX_SIZE 600000000
int
work
();
double
iterate
(
int
async_comm
);
...
...
Codes/Main/computing_func.c
View file @
d8139b51
...
...
@@ -7,18 +7,32 @@
/*
* Realiza una multiplicación de matrices de tamaño n
*/
double
computeMatrix
(
double
*
matrix
,
int
n
)
{
//FIXME No da tiempos repetibles
double
computeMatrix
(
double
*
matrix
,
int
n
)
{
int
row
,
col
;
double
aux
;
aux
=
0
;
for
(
row
=
0
;
row
<
n
;
row
++
)
{
for
(
col
=
0
;
col
<
n
;
col
++
)
{
aux
+=
(
(
int
)(
matrix
[
row
*
n
+
col
]
+
exp
(
sqrt
(
row
*
col
)))
%
n
);
aux
+=
(
int
)(
matrix
[
row
*
n
+
col
]
*
matrix
[
row
*
n
+
col
]
);
}
}
return
aux
;
}
/*
double computeMatrix(double *matrix, int n) {
int row, col;
double aux;
aux=0;
for(row=0; row<n; row++) {
for(col=0; col<n; col++) {
aux += ( (int)(matrix[row*n + col] + exp(sqrt(row*col))) % n);
}
}
return aux;
}*/
double
computePiSerial
(
int
n
)
{
int
i
;
...
...
@@ -35,24 +49,26 @@ double computePiSerial(int n) {
//MPI_Reduce(&sum, &res, 1, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
}
/*
* Init matrix
*/
void
initMatrix
(
double
**
matrix
,
size_t
n
)
{
size_t
i
,
j
;
double
*
aux
=
NULL
;
freeMatrix
(
matrix
);
// Init matrix
if
(
matri
x
!
=
NULL
)
{
*
matrix
=
malloc
(
n
*
n
*
sizeof
(
double
)
);
if
(
*
matrix
==
NULL
)
{
MPI_Abort
(
MPI_COMM_WORLD
,
-
1
);}
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
(
*
matrix
)[
i
*
n
+
j
]
=
i
+
j
;
}
au
x
=
(
double
*
)
malloc
(
n
*
n
*
sizeof
(
double
));
if
(
aux
==
NULL
)
{
perror
(
"Computing matrix could not be allocated"
);
MPI_Abort
(
MPI_COMM_WORLD
,
-
1
);
}
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
aux
[
i
*
n
+
j
]
=
(
i
+
j
)
*
1
.
1
;
}
}
*
matrix
=
aux
;
}
...
...
Codes/Main/process_stage.c
View file @
d8139b51
...
...
@@ -36,7 +36,7 @@ double init_comm_reduce_pt(group_data group, configuration *config_file, iter_st
*/
double
init_stage
(
configuration
*
config_file
,
int
stage_i
,
group_data
group
,
MPI_Comm
comm
,
int
compute
)
{
double
result
=
0
;
int
qty
=
20
000
;
int
qty
=
1
000
;
iter_stage_t
*
stage
=
&
(
config_file
->
stages
[
stage_i
]);
stage
->
operations
=
qty
;
...
...
@@ -183,6 +183,7 @@ double init_matrix_pt(group_data group, configuration *config_file, iter_stage_t
t_stage
=
stage
->
t_stage
*
config_file
->
groups
[
group
.
grp
].
factor
;
initMatrix
(
&
(
stage
->
double_array
),
config_file
->
granularity
);
if
(
compute
)
{
if
(
group
.
myId
==
ROOT
)
{
start_time
=
MPI_Wtime
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment