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
4d35b552
Commit
4d35b552
authored
Apr 27, 2021
by
iker_martin
Browse files
WIP - Se esta arreglando un error de memoria - Anadiendo salida de tiempos
parent
a539c1cc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Codes/IOcodes/read_ini.c
View file @
4d35b552
...
...
@@ -57,6 +57,7 @@ static int handler(void* user, const char* section, const char* name,
}
else
{
pconfig
->
phy_dist
[
act_resize
]
=
COMM_PHY_CPU
;
}
free
(
aux
);
pconfig
->
actual_resize
=
pconfig
->
actual_resize
+
1
;
// Ultimo elemento del grupo
...
...
@@ -130,11 +131,11 @@ void free_config(configuration *user_config) {
* Imprime por salida estandar toda la informacion que contiene
* la configuracion pasada como argumento
*/
void
print_config
(
configuration
*
user_config
,
int
numP
)
{
void
print_config
(
configuration
*
user_config
,
int
grp
)
{
if
(
user_config
!=
NULL
)
{
int
i
;
printf
(
"Config loaded: resizes=%d, matrix=%d, sdr=%d, adr=%d, time=%f ||
NUMP
=%d
\n
"
,
user_config
->
resizes
,
user_config
->
matrix_tam
,
user_config
->
sdr
,
user_config
->
adr
,
user_config
->
general_time
,
numP
);
printf
(
"Config loaded: resizes=%d, matrix=%d, sdr=%d, adr=%d,
aib=%d
time=%f ||
grp
=%d
\n
"
,
user_config
->
resizes
,
user_config
->
matrix_tam
,
user_config
->
sdr
,
user_config
->
adr
,
user_config
->
aib
,
user_config
->
general_time
,
grp
);
for
(
i
=
0
;
i
<
user_config
->
resizes
;
i
++
)
{
printf
(
"Resize %d: Iters=%d, Procs=%d, Factors=%f, Phy=%d
\n
"
,
i
,
user_config
->
iters
[
i
],
user_config
->
procs
[
i
],
user_config
->
factors
[
i
],
user_config
->
phy_dist
[
i
]);
...
...
@@ -143,6 +144,25 @@ void print_config(configuration *user_config, int numP) {
}
void
print_config_group
(
configuration
*
user_config
,
int
grp
)
{
if
(
user_config
!=
NULL
)
{
int
parents
,
sons
;
parents
=
sons
=
0
;
if
(
grp
>
0
)
{
parents
=
user_config
->
procs
[
grp
-
1
];
}
if
(
grp
<
user_config
->
resizes
-
1
)
{
sons
=
user_config
->
procs
[
grp
+
1
];
}
printf
(
"Config: matrix=%d, sdr=%d, adr=%d, aib=%d time=%f
\n
"
,
user_config
->
matrix_tam
,
user_config
->
sdr
,
user_config
->
adr
,
user_config
->
aib
,
user_config
->
general_time
);
printf
(
"Config Group: iters=%d, factor=%f, phy=%d, procs=%d, parents=%d, sons=%d
\n
"
,
user_config
->
iters
[
grp
],
user_config
->
factors
[
grp
],
user_config
->
phy_dist
[
grp
],
user_config
->
procs
[
grp
],
parents
,
sons
);
}
}
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ||
...
...
Codes/IOcodes/read_ini.h
View file @
4d35b552
...
...
@@ -18,7 +18,8 @@ typedef struct
configuration
*
read_ini_file
(
char
*
file_name
);
void
free_config
(
configuration
*
user_config
);
void
print_config
(
configuration
*
user_config
,
int
numP
);
void
print_config
(
configuration
*
user_config
,
int
grp
);
void
print_config_group
(
configuration
*
user_config
,
int
grp
);
// MPI Intercomm functions
void
send_config_file
(
configuration
*
config_file
,
int
root
,
MPI_Comm
intercomm
);
...
...
Codes/Main/Main.c
View file @
4d35b552
...
...
@@ -15,7 +15,7 @@ void TC(int numS);
int
start_redistribution
(
int
numS
,
MPI_Request
**
comm_req
);
int
check_redistribution
(
int
iter
,
MPI_Request
**
comm_req
);
void
iterate
(
double
*
matrix
,
int
n
);
void
iterate
(
double
*
matrix
,
int
n
,
int
async_comm
);
void
computeMatrix
(
double
*
matrix
,
int
n
);
void
initMatrix
(
double
**
matrix
,
int
n
);
...
...
@@ -34,10 +34,15 @@ typedef struct {
configuration
*
config_file
;
group_data
*
group
;
// Variables sobre resultados
//int *iters_time, *iters_type, iter_index;
int
main
(
int
argc
,
char
*
argv
[])
{
int
numP
,
myId
;
int
numP
,
myId
,
i
;
int
thread_level
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Init
_thread
(
&
argc
,
&
argv
,
MPI_THREAD_MULTIPLE
,
&
thread_level
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
numP
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
myId
);
...
...
@@ -61,17 +66,45 @@ int main(int argc, char *argv[]) {
}
}
if
(
myId
==
ROOT
)
print_config
(
config_file
,
numP
);
//iters_time = malloc(config_file->iters[group->grp] * 3 * sizeof(int));
//iters_type = malloc(config_file->iters[group->grp] * 3 * sizeof(int));
//iter_index = 0;
//if(myId== ROOT) print_config(config_file, group->grp);
int
res
=
work
();
if
(
res
)
{
// Ultimo set de procesos muestra resultados
//RESULTADOS
/*
if(myId == ROOT) {
print_config_group(config_file, group->grp);
printf("Titer: ");
for(i=0; i<iter_index; i++) {
printf("%d ", iters_time[i]);
}
printf("\nTop: ");
for(i=0; i<iter_index; i++) {
printf("%d ", iters_type[i]);
}
printf("\n");
free(iters_time);
free(iters_type);
}
*/
/*
int len;
char *name = malloc(MPI_MAX_PROCESSOR_NAME * sizeof(char));
char *version = malloc(MPI_MAX_LIBRARY_VERSION_STRING * sizeof(char));
MPI_Get_processor_name(name, &len);
MPI_Get_library_version(version, &len);
printf("P%d Nuevo GRUPO %d de %d procs en nodo %s con %s\n", myId, group->grp, numP, name, version);
*/
free_config
(
config_file
);
free
(
group
->
sync_array
);
free
(
group
->
async_array
);
free
(
group
);
MPI_Finalize
();
return
0
;
...
...
@@ -95,17 +128,19 @@ int work() {
maxiter
=
config_file
->
iters
[
group
->
grp
];
initMatrix
(
&
matrix
,
config_file
->
matrix_tam
);
state
=
MAL_COMM_UNINITIALIZED
;
for
(
iter
=
group
->
iter_start
;
iter
<
maxiter
;
iter
++
)
{
iterate
(
matrix
,
config_file
->
matrix_tam
);
iterate
(
matrix
,
config_file
->
matrix_tam
,
state
);
}
state
=
checkpoint
(
iter
,
MAL_COMM_UNINITIALIZED
,
&
async_comm
);
state
=
checkpoint
(
iter
,
state
,
&
async_comm
);
iter
=
0
;
while
(
state
==
MAL_ASYNC_PENDING
)
{
iterate
(
matrix
,
config_file
->
matrix_tam
);
iterate
(
matrix
,
config_file
->
matrix_tam
,
state
);
iter
++
;
state
=
checkpoint
(
iter
,
state
,
&
async_comm
);
}
...
...
@@ -120,7 +155,7 @@ int work() {
*
* Si hay datos asincronos a transmitir, primero se comienza a
* transmitir estos y se termina la funcion. Se tiene que comprobar con
* llamando a la función de nuevo que se han terminado de enviar
//TODO
* llamando a la función de nuevo que se han terminado de enviar
*
* Si hay ademas datos sincronos a enviar, no se envian aun.
*
...
...
@@ -193,30 +228,31 @@ int check_redistribution(int iter, MPI_Request **comm_req) {
}
else
{
req_completed
=
&
(
*
comm_req
)[
1
];
}
test_err
=
MPI_Test
(
req_completed
,
&
completed
,
MPI_STATUS_IGNORE
);
if
(
test_err
!=
MPI_SUCCESS
&&
test_err
!=
MPI_ERR_PENDING
)
{
printf
(
"P%d aborting
\n
"
,
group
->
myId
);
printf
(
"P%d aborting
-- Test Async
\n
"
,
group
->
myId
);
MPI_Abort
(
MPI_COMM_WORLD
,
test_err
);
}
MPI_Allreduce
(
&
completed
,
&
all_completed
,
1
,
MPI_INT
,
MPI_MIN
,
MPI_COMM_WORLD
);
if
(
!
all_completed
)
return
MAL_ASYNC_PENDING
;
// Continue only if asynchronous send has ended
if
(
!
all_completed
)
return
MAL_ASYNC_PENDING
;
// Continue only if asynchronous send has ended
iter_send
=
iter
;
//MPI_Barrier(MPI_COMM_WORLD); if(group->myId == ROOT){ printf("TEST 2.A0.5\n"); fflush(stdout);} //FIXME BORRAR
MPI_Bcast
(
&
iter_send
,
1
,
MPI_INT
,
rootBcast
,
group
->
children
);
if
(
config_file
->
sdr
>
0
)
{
//MPI_Barrier(MPI_COMM_WORLD); if(group->myId == ROOT){ printf("TEST 2.A0.5a\n"); fflush(stdout);} //FIXME BORRAR
if
(
config_file
->
sdr
>
0
)
{
// Realizar envio sincrono
send_sync
(
group
->
sync_array
,
config_file
->
sdr
,
group
->
myId
,
group
->
numP
,
ROOT
,
group
->
children
,
numS
);
}
if
(
config_file
->
aib
==
MAL_USE_IBARRIER
)
{
MPI_Wait
(
&
(
*
comm_req
)[
0
],
MPI_STATUS_IGNORE
);
// Indicar como completado el envio asincrono
}
free
(
*
comm_req
);
// Desconectar intercomunicador con los hijos
MPI_Comm_disconnect
(
&
(
group
->
children
));
free
(
*
comm_req
);
return
MAL_COMM_COMPLETED
;
}
...
...
@@ -259,15 +295,33 @@ void Sons_init() {
* Simula la ejecucción de una iteración de computo en la aplicación
* que dura al menos un tiempo de "time" segundos.
*/
void
iterate
(
double
*
matrix
,
int
n
)
{
void
iterate
(
double
*
matrix
,
int
n
,
int
async_comm
)
{
double
start_time
,
actual_time
;
double
time
=
config_file
->
general_time
*
config_file
->
factors
[
group
->
grp
];
int
i
,
operations
=
0
;
start_time
=
actual_time
=
MPI_Wtime
();
while
(
actual_time
-
start_time
<
time
)
{
computeMatrix
(
matrix
,
n
);
actual_time
=
MPI_Wtime
();
}
/*
if(async_comm == MAL_ASYNC_PENDING) { // Se esta realizando una redistribucion de datos asincrona
operations = iters_type[iter_index - 1];
for (i=0; i<operations; i++) {
computeMatrix(matrix, n);
actual_time = MPI_Wtime(); // Guardar tiempos
}
operations = 0;
} else { // No hay redistribucion de datos actualmente
*/
while
(
actual_time
-
start_time
<
time
)
{
computeMatrix
(
matrix
,
n
);
operations
++
;
actual_time
=
MPI_Wtime
();
// Guardar tiempos
}
//}
//iters_time[iter_index] = actual_time - start_time;
//iters_type[iter_index] = operations;
//iters_type++;
}
/*
...
...
Codes/malleability/CommDist.c
View file @
4d35b552
...
...
@@ -46,13 +46,19 @@ void malloc_comm_array(char **array, int qty, int myId, int numP) {
struct
Dist_data
dist_data
;
get_dist
(
qty
,
myId
,
numP
,
&
dist_data
);
*
array
=
malloc
(
dist_data
.
tamBl
*
sizeof
(
char
));
if
(
(
*
array
=
malloc
(
dist_data
.
tamBl
*
sizeof
(
char
)))
==
NULL
)
{
printf
(
"Memory Error (Malloc Arrays(%d))
\n
"
,
dist_data
.
tamBl
);
exit
(
1
);
}
/*
int i;
for(i=0; i<dist_data.tamBl; i++) {
(*array)[i] = '!' + i + dist_data.ini;
}
// printf("P%d Tam %d String: %s\n", myId, dist_data.tamBl, *array);
printf("P%d Tam %d String: %s\n", myId, dist_data.tamBl, *array);
*/
}
//================================================================================
...
...
@@ -287,7 +293,7 @@ void send_async_arrays(struct Dist_data dist_data, char *array, int rootBcast, i
set_counts
(
i
,
numP_child
,
dist_data
,
counts
.
counts
);
counts
.
displs
[
i
]
=
counts
.
displs
[
i
-
1
]
+
counts
.
counts
[
i
-
1
];
}
//
print_counts(dist_data, counts.counts, counts.displs, numP_child, "Padres");
print_counts
(
dist_data
,
counts
.
counts
,
counts
.
displs
,
numP_child
,
"Padres"
);
/* COMUNICACION DE DATOS */
MPI_Ialltoallv
(
array
,
counts
.
counts
,
counts
.
displs
,
MPI_CHAR
,
NULL
,
counts
.
zero_arr
,
counts
.
zero_arr
,
MPI_CHAR
,
dist_data
.
intercomm
,
comm_req
);
...
...
@@ -312,7 +318,7 @@ void recv_async_arrays(struct Dist_data dist_data, char *array, int root, int nu
set_counts
(
i
,
numP_parents
,
dist_data
,
counts
.
counts
);
counts
.
displs
[
i
]
=
counts
.
displs
[
i
-
1
]
+
counts
.
counts
[
i
-
1
];
}
//
print_counts(dist_data, counts.counts, counts.displs, numP_parents, "Hijos");
print_counts
(
dist_data
,
counts
.
counts
,
counts
.
displs
,
numP_parents
,
"Hijos"
);
/* COMUNICACION DE DATOS */
MPI_Ialltoallv
(
aux
,
counts
.
zero_arr
,
counts
.
zero_arr
,
MPI_CHAR
,
array
,
counts
.
counts
,
counts
.
displs
,
MPI_CHAR
,
dist_data
.
intercomm
,
comm_req
);
...
...
Codes/malleability/CommDist.h
View file @
4d35b552
...
...
@@ -4,7 +4,7 @@
#include <string.h>
#define MAL_COMM_COMPLETED 0
#define MAL_COMM_UNINITIALIZED
0
#define MAL_COMM_UNINITIALIZED
2
#define MAL_ASYNC_PENDING 1
#define MAL_USE_NORMAL 0
...
...
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