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
Malleable_CG
Commits
e4e11cf5
Commit
e4e11cf5
authored
Sep 20, 2023
by
iker_martin
Browse files
Minor bugfix when freeing memory.
parent
9100320b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Main/ConjugateGradient.c
View file @
e4e11cf5
...
...
@@ -50,14 +50,14 @@ void get_rows_dist(Compute_data *computeData, int numP, int n);
void
mat_alloc
(
Compute_data
*
computeData
,
SparseMatrix
mat
,
struct
Dist_data
dist_data
);
void
computeSolution
(
Compute_data
computeData
,
double
**
subsol
,
SparseMatrix
mat
,
int
myId
,
double
**
full_vec
);
void
pre_compute
(
Compute_data
*
computeData
,
struct
Dist_data
dist_data
,
double
*
subsol
,
double
*
full_vec
);
int
compute
(
Compute_data
*
computeData
,
struct
Dist_data
*
dist_data
,
char
*
argv
[]
);
int
compute
(
Compute_data
*
computeData
,
struct
Dist_data
*
dist_data
);
void
free_computeData
(
Compute_data
*
computeData
);
//===================================MALLEABILITY FUNCTIONS====================================================
int
n_check
=
30
;
int
dist_old
(
struct
Dist_data
*
dist_data
,
Compute_data
*
computeData
,
char
*
argv
[],
int
type_dist
);
int
dist_old
(
struct
Dist_data
*
dist_data
,
Compute_data
*
computeData
,
int
num_children
,
int
sm
,
int
ss
,
int
rm
,
int
rs
);
void
send_matrix
(
struct
Dist_data
dist_data
,
Compute_data
computeData
,
int
rootBcast
,
int
numP_child
,
int
idI
,
int
idE
,
int
*
sendcounts
,
int
*
recvcounts
,
int
*
sdispls
,
int
*
rdispls
);
...
...
@@ -76,9 +76,12 @@ int main (int argc, char *argv[]) {
char
*
nodelist
=
NULL
;
Compute_data
computeData
;
computeData
.
z
=
NULL
;
computeData
.
d_full
=
NULL
,
computeData
.
d
=
NULL
;
computeData
.
vec
=
NULL
;
computeData
.
res
=
NULL
;
computeData
.
dist_elem
=
NULL
;
computeData
.
displs_elem
=
NULL
;
computeData
.
dist_rows
=
NULL
;
computeData
.
displs_rows
=
NULL
;
computeData
.
subm
.
vptr
=
NULL
;
computeData
.
vlen
=
NULL
;
int
numP
,
myId
,
num_children
=
0
;
struct
Dist_data
dist_data
;
...
...
@@ -93,6 +96,7 @@ int main (int argc, char *argv[]) {
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
numP
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
myId
);
printf
(
"Nuevo set %d/%d
\n
"
,
myId
,
numP
);
dist_data
.
myId
=
myId
;
dist_data
.
numP
=
numP
;
dist_data
.
comm
=
MPI_COMM_WORLD
;
...
...
@@ -101,14 +105,15 @@ int main (int argc, char *argv[]) {
if
(
!
new_group
)
{
//First set of processes
init_app
(
&
computeData
,
&
dist_data
,
argv
);
dist_old
(
&
dist_data
,
&
computeData
,
num_children
,
0
,
1
,
0
,
1
);
}
else
{
dist_new
(
&
dist_data
,
&
computeData
);
}
// Esta variable se envia a los hijos para que conozcan cuantos padres tienen
dist_data
.
numP_parents
=
numP
;
terminate
=
compute
(
&
computeData
,
&
dist_data
,
argv
);
if
(
computeData
.
iter
==
0
)
{
terminate
=
compute
(
&
computeData
,
&
dist_data
);
}
terminate
=
1
;
if
(
myId
==
ROOT
&&
terminate
)
{
printf
(
"End(%d) --> (%d,%20.10e)
\n
"
,
computeData
.
n
,
computeData
.
iter
,
computeData
.
tol
);
...
...
@@ -380,7 +385,7 @@ void pre_compute(Compute_data *computeData, struct Dist_data dist_data, double *
/*
* Bucle de computo principal
*/
int
compute
(
Compute_data
*
computeData
,
struct
Dist_data
*
dist_data
,
char
*
argv
[]
)
{
int
compute
(
Compute_data
*
computeData
,
struct
Dist_data
*
dist_data
)
{
int
IZERO
=
0
,
IONE
=
1
;
double
DONE
=
1
.
0
,
DMONE
=
-
1
.
0
,
DZERO
=
0
.
0
;
...
...
@@ -391,7 +396,7 @@ int compute(Compute_data *computeData, struct Dist_data *dist_data, char *argv[]
while
((
computeData
->
iter
<
computeData
->
maxiter
)
&&
(
computeData
->
tol
>
computeData
->
umbral
))
{
//while (computeData->tol > computeData->umbral) {
//
malleability_checkpoint();
if
(
computeData
->
iter
==
3
)
{
malleability_checkpoint
();
}
// if(dist_data->myId == ROOT) printf ("(%d,%20.10e)\n", computeData->iter, computeData->tol);
...
...
@@ -427,17 +432,36 @@ int compute(Compute_data *computeData, struct Dist_data *dist_data, char *argv[]
void
free_computeData
(
Compute_data
*
computeData
)
{
if
(
computeData
->
res
!=
NULL
)
{
RemoveDoubles
(
&
computeData
->
res
);
}
if
(
computeData
->
z
!=
NULL
)
{
RemoveDoubles
(
&
computeData
->
z
);
}
if
(
computeData
->
d
!=
NULL
)
{
RemoveDoubles
(
&
computeData
->
d
);
}
if
(
computeData
->
vec
!=
NULL
)
{
RemoveDoubles
(
&
computeData
->
vec
);
}
RemoveDoubles
(
&
computeData
->
d_full
);
if
(
computeData
->
d_full
!=
NULL
)
{
RemoveDoubles
(
&
computeData
->
d_full
);
}
if
(
computeData
->
subm
.
vptr
!=
NULL
)
{
RemoveSparseMatrix2
(
&
computeData
->
subm
);
}
if
(
computeData
->
dist_rows
!=
NULL
)
{
RemoveInts
(
&
computeData
->
dist_rows
);
}
if
(
computeData
->
displs_rows
!=
NULL
)
{
RemoveInts
(
&
computeData
->
displs_rows
);
}
if
(
computeData
->
vlen
!=
NULL
)
{
RemoveInts
(
&
computeData
->
vlen
);
}
}
/*
...
...
@@ -465,15 +489,16 @@ void free_computeData(Compute_data *computeData) {
/*
*/
int
dist_old
(
struct
Dist_data
*
dist_data
,
Compute_data
*
computeData
,
char
*
argv
[],
int
type_dist
)
{
int
i
;
//set_malleability_configuration(sm, ss, phy_dist, rm, rs);
//set_children_number(numC);
int
dist_old
(
struct
Dist_data
*
dist_data
,
Compute_data
*
computeData
,
int
num_children
,
int
sm
,
int
ss
,
int
rm
,
int
rs
)
{
int
phy_dist
=
2
;
set_malleability_configuration
(
sm
,
ss
,
phy_dist
,
rm
,
rs
);
set_children_number
(
num_children
);
malleability_add_data
(
&
(
computeData
->
iter
),
1
,
MAL_INT
,
1
,
1
);
malleability_add_data
(
&
(
computeData
->
tol
),
1
,
MAL_DOUBLE
,
1
,
1
);
malleability_add_data
(
&
(
computeData
->
beta
),
1
,
MAL_DOUBLE
,
1
,
1
);
malleability_add_data
(
&
(
computeData
->
umbral
),
1
,
MAL_DOUBLE
,
1
,
1
);
//
malleability_add_data(&(computeData->tol), 1, MAL_DOUBLE, 1, 1);
//
malleability_add_data(&(computeData->beta), 1, MAL_DOUBLE, 1, 1);
//
malleability_add_data(&(computeData->umbral), 1, MAL_DOUBLE, 1, 1);
/*
malleability_add_data(&(computeData->vec), computeData->n, MAL_DOUBLE, 0, 1);
malleability_add_data(&(computeData->res), computeData->n, MAL_DOUBLE, 0, 1);
malleability_add_data(&(computeData->z), computeData->n, MAL_DOUBLE, 0, 1);
...
...
@@ -482,6 +507,7 @@ int dist_old(struct Dist_data *dist_data, Compute_data *computeData, char *argv[
malleability_add_data(&(computeData->vlen), computeData->n, MAL_INT, 1, 1); //FIXME Ultimo valor puede sere asinc
malleability_add_data(&(computeData->subm.vpos), computeData->n, MAL_INT, 1, 1);
malleability_add_data(&(computeData->subm.vval), computeData->n, MAL_DOUBLE, 1, 1);
*/
}
/*
...
...
@@ -538,13 +564,14 @@ void dist_new(struct Dist_data *dist_data, Compute_data *computeData) {
void
*
value
=
NULL
;
malleability_get_data
(
&
value
,
0
,
1
,
1
);
computeData
->
iter
=
*
((
int
*
)
value
);
malleability_get_data
(
&
value
,
1
,
1
,
1
);
/*
malleability_get_data(&value, 1, 1, 1);
computeData->tol = *((double *)value);
malleability_get_data(&value, 2, 1, 1);
computeData->beta = *((double *)value);
malleability_get_data(&value, 3, 1, 1);
computeData->umbral = *((double *)value);
*/
/*
malleability_get_data(&value, 0, 0, 1);
computeData->vec = ((double *)value);
malleability_get_data(&value, 1, 0, 1);
...
...
@@ -561,6 +588,7 @@ void dist_new(struct Dist_data *dist_data, Compute_data *computeData) {
malleability_get_data(&value, 7, 1, 1);
computeData->subm.vval = ((double *)value);
TransformLengthtoHeader(computeData->subm.vptr, computeData->subm.dim1); // De vlen a vptr
*/
}
/*
...
...
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