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
MAM_BICGSTAB
Commits
9b3fed07
Commit
9b3fed07
authored
Mar 22, 2024
by
iker_martin
Browse files
First working version for Ethernet network. Found bug around MPICH+OFI for function MPI_Probe.
parent
cf2459d8
Changes
5
Show whitespace changes
Inline
Side-by-side
BiCGStab_Iker/BiCGStab.c
View file @
9b3fed07
...
@@ -187,7 +187,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
...
@@ -187,7 +187,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
n
=
size
;
n_dist
=
sizeR
;
maxiter
=
16
*
size
;
rec_iter
=
maxiter
/
2
;
umbral
=
1.0e-8
;
n
=
size
;
n_dist
=
sizeR
;
maxiter
=
16
*
size
;
rec_iter
=
maxiter
/
2
;
umbral
=
1.0e-8
;
myId
=
computeData
->
myId
;
myId
=
computeData
->
myId
;
state
=
-
1
;
state
=
-
1
;
reconfigure
=
0
;
rec_iter
=
1
;
reconfigure
=
0
;
rec_iter
=
1
;
maxiter
=
100
;
while
((
computeData
->
iter
<
maxiter
)
&&
(
computeData
->
tol
>
umbral
))
{
while
((
computeData
->
iter
<
maxiter
)
&&
(
computeData
->
tol
>
umbral
))
{
...
@@ -290,7 +290,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
...
@@ -290,7 +290,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
computeData
->
iter
++
;
computeData
->
iter
++
;
if
(
computeData
->
iter
==
rec_iter
)
{
reconfigure
=
1
;}
if
(
computeData
->
iter
==
rec_iter
)
{
reconfigure
=
1
;}
if
(
reconfigure
)
{
if
(
reconfigure
)
{
//
dump(computeData);
//
dump(computeData);
MAM_Checkpoint
(
&
state
,
MAM_CHECK_COMPLETION
,
user_func
,
(
void
*
)
user_data
);
MAM_Checkpoint
(
&
state
,
MAM_CHECK_COMPLETION
,
user_func
,
(
void
*
)
user_data
);
if
(
state
==
MAM_COMPLETED
)
{
if
(
state
==
MAM_COMPLETED
)
{
reconfigure
=
0
;
reconfigure
=
0
;
...
@@ -298,7 +298,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
...
@@ -298,7 +298,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
targets_update
(
computeData
,
user_data
);
targets_update
(
computeData
,
user_data
);
sizeR
=
computeData
->
matL
.
dim1
;
sizeR
=
computeData
->
matL
.
dim1
;
n_dist
=
sizeR
;
n_dist
=
sizeR
;
//
dump(computeData);
//
dump(computeData);
}
}
}
}
}
}
...
@@ -335,6 +335,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
...
@@ -335,6 +335,7 @@ void BiCGStab_compute (Compute_data *computeData, user_redist_t *user_data) {
void
BiCGStab_free
(
Compute_data
*
computeData
)
{
void
BiCGStab_free
(
Compute_data
*
computeData
)
{
RemoveDoubles
(
&
computeData
->
x
);
RemoveDoubles
(
&
computeData
->
b
);
RemoveDoubles
(
&
computeData
->
aux
);
RemoveDoubles
(
&
computeData
->
s
);
RemoveDoubles
(
&
computeData
->
aux
);
RemoveDoubles
(
&
computeData
->
s
);
RemoveDoubles
(
&
computeData
->
q
);
RemoveDoubles
(
&
computeData
->
r
);
RemoveDoubles
(
&
computeData
->
q
);
RemoveDoubles
(
&
computeData
->
r
);
RemoveDoubles
(
&
computeData
->
p
);
RemoveDoubles
(
&
computeData
->
r0
);
RemoveDoubles
(
&
computeData
->
y
);
RemoveDoubles
(
&
computeData
->
p
);
RemoveDoubles
(
&
computeData
->
r0
);
RemoveDoubles
(
&
computeData
->
y
);
...
@@ -346,8 +347,6 @@ void BiCGStab_free (Compute_data *computeData) {
...
@@ -346,8 +347,6 @@ void BiCGStab_free (Compute_data *computeData) {
RemoveDoubles
(
&
computeData
->
res_err
);
RemoveDoubles
(
&
computeData
->
x_exact
);
RemoveDoubles
(
&
computeData
->
res_err
);
RemoveDoubles
(
&
computeData
->
x_exact
);
#endif
#endif
RemoveDoubles
(
&
computeData
->
x
);
RemoveDoubles
(
&
computeData
->
b
);
RemoveInts
(
&
computeData
->
sizes
);
RemoveInts
(
&
computeData
->
dspls
);
RemoveInts
(
&
computeData
->
sizes
);
RemoveInts
(
&
computeData
->
dspls
);
RemoveInts
(
&
computeData
->
vlen
);
RemoveInts
(
&
computeData
->
vlen
);
if
(
computeData
->
isOriginal
)
{
if
(
computeData
->
isOriginal
)
{
...
@@ -366,7 +365,8 @@ int main (int argc, char **argv) {
...
@@ -366,7 +365,8 @@ int main (int argc, char **argv) {
int
index
=
0
,
indexL
=
0
;
int
index
=
0
,
indexL
=
0
;
SparseMatrix
mat
=
{
0
,
0
,
NULL
,
NULL
,
NULL
},
sym
=
{
0
,
0
,
NULL
,
NULL
,
NULL
};
SparseMatrix
mat
=
{
0
,
0
,
NULL
,
NULL
,
NULL
},
sym
=
{
0
,
0
,
NULL
,
NULL
,
NULL
};
int
root
=
0
,
myId
,
nProcs
,
isTarget
,
numTarget
,
req
;
int
root
=
0
,
myId
,
nProcs
;
int
isTarget
,
numTarget
,
req
,
initNumP
;
int
dimL
,
dspL
,
*
vdimL
=
NULL
,
*
vdspL
=
NULL
;
int
dimL
,
dspL
,
*
vdimL
=
NULL
,
*
vdspL
=
NULL
;
SparseMatrix
matL
=
{
0
,
0
,
NULL
,
NULL
,
NULL
};
SparseMatrix
matL
=
{
0
,
0
,
NULL
,
NULL
,
NULL
};
double
*
sol1L
=
NULL
,
*
sol2L
=
NULL
;
double
*
sol1L
=
NULL
,
*
sol2L
=
NULL
;
...
@@ -391,6 +391,7 @@ int main (int argc, char **argv) {
...
@@ -391,6 +391,7 @@ int main (int argc, char **argv) {
computeData
.
myId
=
myId
;
computeData
.
myId
=
myId
;
computeData
.
numP
=
nProcs
;
computeData
.
numP
=
nProcs
;
computeData
.
comm
=
MPI_COMM_WORLD
;
computeData
.
comm
=
MPI_COMM_WORLD
;
initNumP
=
computeData
.
numP
;
user_data
=
empty_user_data
;
user_data
=
empty_user_data
;
user_data
.
comm
=
computeData
.
comm
;
user_data
.
comm
=
computeData
.
comm
;
...
@@ -400,7 +401,7 @@ int main (int argc, char **argv) {
...
@@ -400,7 +401,7 @@ int main (int argc, char **argv) {
if
(
isTarget
)
{
if
(
isTarget
)
{
targets_update
(
&
computeData
,
&
user_data
);
targets_update
(
&
computeData
,
&
user_data
);
computeData
.
isOriginal
=
0
;
computeData
.
isOriginal
=
0
;
//
dump(&computeData);
//
dump(&computeData);
}
else
{
}
else
{
/***************************************/
/***************************************/
if
(
argc
==
4
)
{
if
(
argc
==
4
)
{
...
@@ -414,7 +415,7 @@ int main (int argc, char **argv) {
...
@@ -414,7 +415,7 @@ int main (int argc, char **argv) {
}
}
/***************************************/
/***************************************/
printf
(
"A
\n
"
);
//
printf ("A\n");
CreateInts
(
&
vdimL
,
nProcs
);
CreateInts
(
&
vdspL
,
nProcs
);
CreateInts
(
&
vdimL
,
nProcs
);
CreateInts
(
&
vdspL
,
nProcs
);
if
(
mat_from_file
)
{
if
(
mat_from_file
)
{
if
(
myId
==
root
)
{
if
(
myId
==
root
)
{
...
@@ -431,7 +432,7 @@ int main (int argc, char **argv) {
...
@@ -431,7 +432,7 @@ int main (int argc, char **argv) {
RemoveSparseMatrix
(
&
mat
);
RemoveSparseMatrix
(
&
mat
);
RemoveSparseMatrix
(
&
sym
);
RemoveSparseMatrix
(
&
sym
);
}
}
printf
(
"B
\n
"
);
//
printf ("B\n");
}
}
else
{
else
{
dim
=
size_param
*
size_param
*
size_param
;
dim
=
size_param
*
size_param
*
size_param
;
...
@@ -466,7 +467,7 @@ int main (int argc, char **argv) {
...
@@ -466,7 +467,7 @@ int main (int argc, char **argv) {
/***************************************/
/***************************************/
printf
(
"C
\n
"
);
//
printf ("C\n");
beta
=
1
.
0
/
sqrt
(
dim
);
beta
=
1
.
0
/
sqrt
(
dim
);
if
(
mat_from_file
)
{
if
(
mat_from_file
)
{
...
@@ -486,11 +487,11 @@ int main (int argc, char **argv) {
...
@@ -486,11 +487,11 @@ int main (int argc, char **argv) {
}
}
}
}
printf
(
"D
\n
"
);
//
printf ("D\n");
// MPI_Scatterv (sol2, vdimL, vdspL, MPI_DOUBLE, sol2L, dimL, MPI_DOUBLE, root, MPI_COMM_WORLD); //FIXME It does not seem to do anything
// MPI_Scatterv (sol2, vdimL, vdspL, MPI_DOUBLE, sol2L, dimL, MPI_DOUBLE, root, MPI_COMM_WORLD); //FIXME It does not seem to do anything
printf
(
"E
\n
"
);
//
printf ("E\n");
computeData
.
sizes
=
vdimL
;
computeData
.
sizes
=
vdimL
;
computeData
.
my_size
=
dimL
;
computeData
.
my_size
=
dimL
;
computeData
.
dspls
=
vdspL
;
computeData
.
dspls
=
vdspL
;
...
@@ -529,16 +530,22 @@ int main (int argc, char **argv) {
...
@@ -529,16 +530,22 @@ int main (int argc, char **argv) {
// }
// }
beta
=
sqrt
(
beta
);
beta
=
sqrt
(
beta
);
if
(
computeData
.
myId
==
0
)
if
(
computeData
.
myId
==
0
)
{
printf
(
"Error: %20.10e
\n
"
,
beta
);
printf
(
"Error: %20.10e
\n
"
,
beta
);
print_global_results
(
computeData
.
t1
);
}
/***************************************/
/***************************************/
// Freeing memory
// Freeing memory
BiCGStab_free
(
&
computeData
);
BiCGStab_free
(
&
computeData
);
RemoveDoubles
(
&
sol2
);
RemoveDoubles
(
&
sol2
);
MAM_Finalize
();
if
(
initNumP
>
numTarget
&&
computeData
.
myId
==
0
)
{
MPI_Abort
(
MPI_COMM_WORLD
,
-
100
);
}
if
(
computeData
.
comm
!=
MPI_COMM_WORLD
&&
computeData
.
comm
!=
MPI_COMM_NULL
)
MPI_Comm_free
(
&
(
computeData
.
comm
));
if
(
computeData
.
comm
!=
MPI_COMM_WORLD
&&
computeData
.
comm
!=
MPI_COMM_NULL
)
MPI_Comm_free
(
&
(
computeData
.
comm
));
MAM_Finalize
();
MPI_Finalize
();
MPI_Finalize
();
return
0
;
return
0
;
...
...
BiCGStab_Iker/ToolsMAM.c
View file @
9b3fed07
...
@@ -277,6 +277,6 @@ void print_global_results(double start_time) {
...
@@ -277,6 +277,6 @@ void print_global_results(double start_time) {
printf
(
"T_spawn: %lf"
,
sp_time
);
printf
(
"T_spawn: %lf"
,
sp_time
);
printf
(
"
\n
T_SR: %lf"
,
sy_time
);
printf
(
"
\n
T_SR: %lf"
,
sy_time
);
printf
(
"
\n
T_AR: %lf"
,
asy_time
);
printf
(
"
\n
T_AR: %lf"
,
asy_time
);
printf
(
"
\n
T_Malleability: %lf"
,
mall_time
);
printf
(
"
\n
T_Malleability: %lf
\n
"
,
mall_time
);
printf
(
"
\n
T_total: %lf
\n
"
,
global_time
);
//
printf("T_total: %lf\n", global_time);
}
}
BiCGStab_Iker/ToolsMAM.h
View file @
9b3fed07
...
@@ -30,5 +30,6 @@ static const user_redist_t empty_user_data = {
...
@@ -30,5 +30,6 @@ static const user_redist_t empty_user_data = {
extern
void
targets_distribution
(
mam_user_reconf_t
user_reconf
,
user_redist_t
*
user_data
);
extern
void
targets_distribution
(
mam_user_reconf_t
user_reconf
,
user_redist_t
*
user_data
);
//extern void targets_distribution_synch(mam_user_reconf_t user_reconf, user_redist_t *user_data);
//extern void targets_distribution_synch(mam_user_reconf_t user_reconf, user_redist_t *user_data);
extern
void
print_global_results
(
double
start_time
);
#endif
#endif
BiCGStab_Iker/ToolsMPI.c
View file @
9b3fed07
...
@@ -154,13 +154,13 @@ int ComputeSprMatrixRecvWeights (int prc_src, int dimL, MPI_Comm comm) {
...
@@ -154,13 +154,13 @@ int ComputeSprMatrixRecvWeights (int prc_src, int dimL, MPI_Comm comm) {
int
tam
,
tam_int
,
tam_double
,
tam_ub
;
int
tam
,
tam_int
,
tam_double
,
tam_ub
;
MPI_Status
sta
;
MPI_Status
sta
;
// Definition of sizes
// Definition of sizes
MPI_Type_size
(
MPI_INT
,
&
tam_int
);
MPI_Type_size
(
MPI_INT
,
&
tam_int
);
MPI_Type_size
(
MPI_DOUBLE
,
&
tam_double
);
MPI_Type_size
(
MPI_DOUBLE
,
&
tam_double
);
MPI_Type_size
(
MPI_UB
,
&
tam_ub
);
MPI_Type_size
(
MPI_UB
,
&
tam_ub
);
MPI_Probe
(
prc_src
,
Tag_Send_Packet_Matrix_To_Leaf
,
comm
,
&
sta
);
MPI_Probe
(
prc_src
,
Tag_Send_Packet_Matrix_To_Leaf
,
comm
,
&
sta
);
MPI_Get_count
(
&
sta
,
MPI_BYTE
,
&
tam
);
MPI_Get_count
(
&
sta
,
MPI_BYTE
,
&
tam
);
// Return the number of nonzeros included in a packet
// Return the number of nonzeros included in a packet
return
(
tam
-
(
dimL
*
tam_int
+
tam_ub
))
/
(
tam_int
+
tam_double
);
return
(
tam
-
(
dimL
*
tam_int
+
tam_ub
))
/
(
tam_int
+
tam_double
);
}
}
...
@@ -175,7 +175,7 @@ int DistributeMatrix (SparseMatrix spr, int index, ptr_SparseMatrix sprL, int in
...
@@ -175,7 +175,7 @@ int DistributeMatrix (SparseMatrix spr, int index, ptr_SparseMatrix sprL, int in
// Getiing the parameter of the communicator
// Getiing the parameter of the communicator
MPI_Comm_rank
(
comm
,
&
myId
);
MPI_Comm_size
(
comm
,
&
nProcs
);
MPI_Comm_rank
(
comm
,
&
myId
);
MPI_Comm_size
(
comm
,
&
nProcs
);
// Broadcasting the matrix dimension
// Broadcasting the matrix dimension
MPI_Bcast
(
&
dim
,
1
,
MPI_INT
,
root
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
dim
,
1
,
MPI_INT
,
root
,
comm
);
// Calculating the vectors of sizes (vdimL) and displacements (vdspl)
// Calculating the vectors of sizes (vdimL) and displacements (vdspl)
divL
=
(
dim
/
nProcs
);
rstL
=
(
dim
%
nProcs
);
divL
=
(
dim
/
nProcs
);
rstL
=
(
dim
%
nProcs
);
...
...
BiCGStab_Iker/makefile
View file @
9b3fed07
...
@@ -23,8 +23,7 @@
...
@@ -23,8 +23,7 @@
# ============================================================
# ============================================================
DIR
=
/home/martini/mam_bicgstab
DIR
=
/home/martini/mam_bicgstab
APP
=
malleability/build
APP
=
malleability/build
MAMFLAGS
=
-I
$(DIR)
/malleability
-L
$(DIR)
/
$(APP)
-lmam
MAMFLAGS
=
-I
$(DIR)
/malleability
-L
$(DIR)
/
$(APP)
-Wl
,-rpath
=
$(DIR)
/
$(APP)
-lmam
#-Wl,-rpath=$(DIR)/$(APP)
CC
=
mpicc
CC
=
mpicc
CFLAGS
=
-std
=
c++11
-mavx
-fabi-version
=
0
-Wall
-fopenmp
-I
.
-I
${MKLROOT}
/include
-I
${HOME}
/libs
CFLAGS
=
-std
=
c++11
-mavx
-fabi-version
=
0
-Wall
-fopenmp
-I
.
-I
${MKLROOT}
/include
-I
${HOME}
/libs
...
...
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