Commit e5b80639 authored by iker_martin's avatar iker_martin
Browse files

Version funcional sin comunicacion de datos distribuidos. Se tiene que...

Version funcional sin comunicacion de datos distribuidos. Se tiene que comprobar tambien la creacion de procesos en segundo plano
parent 9516eb5c
......@@ -46,7 +46,6 @@ typedef struct {
int argc;
int numS; // Cantidad de procesos hijos
//int commAsync; FIXME REMOVE
MPI_Comm children, parents;
char *compute_comm_array;
......@@ -54,62 +53,37 @@ typedef struct {
char *sync_array, *async_array;
} group_data;
/*
typedef struct {
int myId, numP, numS, adr;
MPI_Comm children;
char *sync_array;
} thread_data;
*/
configuration *config_file;
group_data *group;
results_data *results;
int run_id = 0; // Utilizado para diferenciar más fácilmente ejecuciones en el análisis
//pthread_t async_thread; // TODO Cambiar de sitio?
int main(int argc, char *argv[]) {
int numP, myId, res;
int req;
int im_child;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &req);
MPI_Comm_size(MPI_COMM_WORLD, &numP);
MPI_Comm_rank(MPI_COMM_WORLD, &myId);
MPI_Comm delete; //FIXME DEBUGGING
MPI_Comm_get_parent(&delete);
if(delete != MPI_COMM_NULL ) {
printf("Hijos salen\n");
MPI_Finalize();
return 0;
}
if(req != MPI_THREAD_MULTIPLE) {
printf("No se ha obtenido la configuración de hilos necesaria\nSolicitada %d -- Devuelta %d\n", req, MPI_THREAD_MULTIPLE);
}
init_group_struct(argv, argc, myId, numP);
init_malleability(myId, numP, ROOT, MPI_COMM_WORLD, argv[0]); //FIXME Cambiar el uso de MPI_COMM_WORLD?
MPI_Comm_get_parent(&(group->parents)); //FIXME No usar esto
if(group->parents != MPI_COMM_NULL ) {
group->grp++;
MPI_Comm_disconnect(&(group->parents)); //FIXME Volver a poner cuando se arregle MAIN.c
}
im_child = init_malleability(myId, numP, ROOT, MPI_COMM_WORLD, argv[0]);
if(group->grp == 0) {
if(!im_child) {
init_application();
set_benchmark_grp(group->grp);
set_benchmark_configuration(config_file);
set_benchmark_results(results);
MPI_Barrier(MPI_COMM_WORLD);
results->exec_start = MPI_Wtime();
} else {
// TODO Que habría que hacer aqui?
get_benchmark_configuration(&config_file); //No se obtiene bien el archivo
get_benchmark_results(&results); //No se obtiene bien el archivo
set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr);
......@@ -117,12 +91,32 @@ int main(int argc, char *argv[]) {
if(config_file->comm_tam) {
group->compute_comm_array = malloc(config_file->comm_tam * sizeof(char));
}
int entries;
void *value = NULL;
malleability_get_entries(&entries, 1, 1);
malleability_get_data(&value, 0, 1, 1);
group->grp = *((int *)value);
free(value);
malleability_get_data(&value, 1, 1, 1);
run_id = *((int *)value);
free(value);
group->grp = group->grp + 1;
set_benchmark_grp(group->grp);
}
if(config_file->resizes != group->grp + 1) {
if(config_file->resizes != group->grp + 1) {
int spawn_type = COMM_SPAWN_SERIAL; // TODO Pasar a CONFIG
set_malleability_configuration(spawn_type, config_file->phy_dist[group->grp+1], -1, config_file->aib, -1);
set_children_number(config_file->procs[group->grp+1]); // TODO TO BE DEPRECATED
if(group->grp == 0) {
malleability_add_data(&(group->grp), 1, MAL_INT, 1, 1);
malleability_add_data(&run_id, 1, MAL_INT, 1, 1);
}
}
res = work();
......@@ -132,9 +126,9 @@ int main(int argc, char *argv[]) {
results->exec_time = MPI_Wtime() - results->exec_start;
}
//print_final_results(); // Pasado este punto ya no pueden escribir los procesos
print_final_results(); // Pasado este punto ya no pueden escribir los procesos
MPI_Finalize();
//free_application_data();
free_application_data();
return 0;
}
......@@ -169,9 +163,6 @@ int work() {
if(config_file->iters[group->grp] == iter && config_file->resizes != group->grp + 1)
state = malleability_checkpoint();
MPI_Finalize();
exit(0);
iter = 0;
while(state == MAL_DIST_PENDING || state == MAL_SPAWN_PENDING) {
iterate(matrix, config_file->matrix_tam, state);
......@@ -297,7 +288,6 @@ void init_group_struct(char *argv[], int argc, int myId, int numP) {
group->numP = numP;
group->grp = 0;
group->iter_start = 0;
//group->commAsync = MAL_COMM_UN; FIXME REMOVE
group->argc = argc;
group->argv = argv;
}
......@@ -372,7 +362,7 @@ void free_application_data() {
if(group->grp == 0) { //FIXME Revisar porque cuando es diferente a 0 no funciona
free_results_data(results);
//free(results);
free(results);
}
free(group);
......
......@@ -114,7 +114,7 @@ int check_slurm_comm(int myId, int root, int numP, MPI_Comm *child) { // TODO Bo
if(slurm_data->type_creation == COMM_SPAWN_PTHREAD) {
MPI_Allreduce(&commSlurm, &state, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
MPI_Allreduce(&commSlurm, &state, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); // FIXME No usar MPI_COMM_WORLD
if(state != MAL_SPAWN_COMPLETED) return state; // Continue only if asynchronous process creation has ended
......@@ -215,6 +215,7 @@ void processes_dist(char *argv, int numP_childs, int type) {
MPI_Info_create(&(slurm_data->info));
MPI_Info_set(slurm_data->info, "hosts", hostfile);
free(hostfile);
free(procs_array);
// Free JOB INFO
......
......@@ -56,8 +56,10 @@ malleability_data_t *dist_s_data;
malleability_data_t *rep_a_data;
malleability_data_t *dist_a_data;
void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec) {
/*
* TODO HACER
*/
int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec) {
MPI_Comm dup_comm, thread_comm;
mall_conf = (malleability_config_t *) malloc(sizeof(malleability_config_t));
......@@ -67,15 +69,14 @@ void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_e
rep_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
dist_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
//MPI_Comm_dup(comm, &dup_comm);
//MPI_Comm_dup(comm, &thread_comm);
mall->comm = comm;
MPI_Comm_dup(comm, &dup_comm);
MPI_Comm_dup(comm, &thread_comm);
mall->myId = myId;
mall->numP = numP;
mall->root = root;
//mall->comm = dup_comm;
//mall->comm = thread_comm; // TODO Refactor -- Crear solo si es necesario?
mall->comm = dup_comm;
mall->comm = thread_comm; // TODO Refactor -- Crear solo si es necesario?
mall->name_exec = name_exec;
rep_s_data->entries = 0;
......@@ -89,7 +90,9 @@ void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_e
MPI_Comm_get_parent(&(mall->intercomm));
if(mall->intercomm != MPI_COMM_NULL ) {
Children_init();
return MALLEABILITY_CHILDREN;
}
return MALLEABILITY_NOT_CHILDREN;
}
void free_malleability() {
......@@ -134,7 +137,6 @@ int malleability_checkpoint() {
//if(CHECK_RMS()) {return MAL_DENIED;}
state = spawn_step();
return MAL_DIST_COMPLETED;
if (state == MAL_SPAWN_COMPLETED){
state = start_redistribution();
......@@ -169,7 +171,7 @@ void set_benchmark_configuration(configuration *config_file) {
mall_conf->config_file = config_file;
}
void get_benchmark_configuration(configuration **config_file) { //FIXME Revisar posible error de memoria
void get_benchmark_configuration(configuration **config_file) {
*config_file = mall_conf->config_file;
}
......@@ -177,7 +179,7 @@ void set_benchmark_results(results_data *results) {
mall_conf->results = results;
}
void get_benchmark_results(results_data **results) { //FIXME Revisar posible error de memoria
void get_benchmark_results(results_data **results) {
*results = mall_conf->results;
}
//-------------------------------------------------------------------------------------------------------------
......@@ -260,7 +262,7 @@ void malleability_get_entries(int *entries, int is_replicated, int is_constant){
* Es tarea del usuario saber el tipo de esos datos.
* TODO Refactor a que sea automatico
*/
void malleability_get_data(void *data, int index, int is_replicated, int is_constant) {
void malleability_get_data(void **data, int index, int is_replicated, int is_constant) {
malleability_data_t *data_struct;
if(is_constant) {
......@@ -277,7 +279,7 @@ void malleability_get_data(void *data, int index, int is_replicated, int is_cons
}
}
data = (void *) data_struct->arrays[index];
*data = data_struct->arrays[index];
}
......@@ -349,12 +351,9 @@ void recv_data(int numP_parents, malleability_data_t *data_struct, int is_asynch
void Children_init() {
/* FIXME
* grp -- a constante replicado || TODO Acordarse de sumar 1
* run_id -- a constante replicado
* iter_start -- a constante replicado || TODO Setear valor segun adr==0
*/
int numP_parents, root_parents, i;
//int *aux;
MPI_Bcast(&root_parents, 1, MPI_INT, MALLEABILITY_ROOT, mall->intercomm);
MPI_Bcast(&numP_parents, 1, MPI_INT, root_parents, mall->intercomm);
......@@ -365,7 +364,6 @@ void Children_init() {
if(dist_a_data->entries || rep_a_data->entries) { // Recibir datos asincronos
printf("HIJOS NO ASYNC\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
comm_data_info(rep_a_data, dist_a_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
if(mall_conf->comm_type == MAL_USE_NORMAL || mall_conf->comm_type == MAL_USE_IBARRIER || mall_conf->comm_type == MAL_USE_POINT) {
......@@ -377,9 +375,8 @@ void Children_init() {
mall_conf->results->async_end= MPI_Wtime(); // Obtener timestamp de cuando termina comm asincrona
}
comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
if(dist_s_data->entries || rep_s_data->entries) { // Recibir datos sincronos
printf("HIJOS NO SYNC\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
recv_data(numP_parents, dist_s_data, 0);
mall_conf->results->sync_end = MPI_Wtime(); // Obtener timestamp de cuando termina comm sincrona
......@@ -387,9 +384,7 @@ void Children_init() {
// TODO Crear funcion especifica y anyadir para Asinc
// TODO Tener en cuenta el tipo y qty
for(i=0; i<rep_s_data->entries; i++) {
//aux = (int *) rep_s_data->arrays[i]; //TODO Comprobar que realmente es un int
MPI_Bcast(rep_s_data->arrays[i], 1, MPI_INT, root_parents, mall->intercomm);
//rep_s_data->arrays[i] = (void *) aux;
MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], MPI_INT, root_parents, mall->intercomm);
}
}
......@@ -397,7 +392,7 @@ void Children_init() {
// Guardar los resultados de esta transmision
recv_results(mall_conf->results, mall->root, mall_conf->config_file->resizes, mall->intercomm);
//MPI_Comm_disconnect(&(mall->intercomm)); //FIXME Volver a poner cuando se arregle MAIN.c
MPI_Comm_disconnect(&(mall->intercomm));
}
//======================================================||
......@@ -528,8 +523,7 @@ int end_redistribution() {
// TODO Crear funcion especifica y anyadir para Asinc
// TODO Tener en cuenta el tipo y qty
for(i=0; i<rep_s_data->entries; i++) {
//aux = (int *) rep_s_data->arrays[i]; //TODO Comprobar que realmente es un int
MPI_Bcast(rep_s_data->arrays[i], 1, MPI_INT, rootBcast, mall->intercomm);
MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], MPI_INT, rootBcast, mall->intercomm);
}
}
......
......@@ -8,7 +8,7 @@
#include "../IOcodes/results.h"
#include "malleabilityStates.h"
void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec);
int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec);
void free_malleability();
int malleability_checkpoint();
void set_benchmark_grp(int grp);
......@@ -18,7 +18,7 @@ void set_children_number(int numC); // TODO TO BE DEPRECATED
void malleability_add_data(void *data, int total_qty, int type, int is_replicated, int is_constant);
void malleability_get_entries(int *entries, int is_replicated, int is_constant);
void malleability_get_data(void *data, int index, int is_replicated, int is_constant);
void malleability_get_data(void **data, int index, int is_replicated, int is_constant);
void set_benchmark_configuration(configuration *config_file);
void get_benchmark_configuration(configuration **config_file);
......
......@@ -18,3 +18,8 @@
#define MAL_USE_IBARRIER 1
#define MAL_USE_POINT 2
#define MAL_USE_THREAD 3
#define MAL_INT 0
#define MAL_CHAR 1
......@@ -49,7 +49,7 @@ void add_data(void *data, int total_qty, int type, int request_qty, malleability
* unicamente.
*/
void comm_data_info(malleability_data_t *data_struct_rep, malleability_data_t *data_struct_dist, int is_children_group, int myId, int root, MPI_Comm intercomm) {
int rootBcast = MPI_PROC_NULL;
int i, rootBcast = MPI_PROC_NULL;
MPI_Datatype entries_type, struct_type;
if(is_children_group) {
......@@ -63,12 +63,24 @@ void comm_data_info(malleability_data_t *data_struct_rep, malleability_data_t *d
MPI_Bcast(&(data_struct_rep->entries), 1, entries_type, rootBcast, intercomm);
if(is_children_group) {
if(data_struct_rep->entries == 0) init_malleability_data_struct(data_struct_rep, data_struct_rep->entries);
if(data_struct_dist->entries == 0) init_malleability_data_struct(data_struct_dist, data_struct_dist->entries);
if(data_struct_rep->entries != 0) init_malleability_data_struct(data_struct_rep, data_struct_rep->entries);
if(data_struct_dist->entries != 0) init_malleability_data_struct(data_struct_dist, data_struct_dist->entries);
}
def_malleability_qty_type(data_struct_dist, data_struct_rep, &struct_type);
MPI_Bcast(&data_struct_rep, 1, struct_type, rootBcast, intercomm);
MPI_Bcast(MPI_BOTTOM, 1, struct_type, rootBcast, intercomm); //FIXME Doy error
if(is_children_group) {
//data_struct->requests[data_struct->entries] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request)); FIXME Crear los requests?
//data_struct->requests[data_struct->entries][i] = MPI_REQUEST_NULL;
for(i=0; i < data_struct_rep->entries; i++) {
data_struct_rep->arrays[i] = (void *) malloc(data_struct_rep->qty[i] * sizeof(int)); //TODO Tener en cuenta que no siempre es int
}
for(i=0; i < data_struct_dist->entries; i++) {
data_struct_dist->arrays[i] = (void *) malloc(data_struct_dist->qty[i] * sizeof(int)); //TODO Tener en cuenta que no siempre es int
}
}
MPI_Type_free(&entries_type);
MPI_Type_free(&struct_type);
......@@ -129,7 +141,8 @@ void free_malleability_data_struct(malleability_data_t *data_struct) {
max = data_struct->entries;
if(max != 0) {
for(i=0; i<max; i++) {
free(data_struct->requests[i]);
//free(data_struct->arrays[i]); //FIXME Valores alojados con 1 elemento no se liberan?
//free(data_struct->requests[i]); //TODO Plantear como crearlos
}
free(data_struct->qty);
......@@ -168,26 +181,22 @@ void def_malleability_entries(malleability_data_t *data_struct_rep, malleability
* de datos de dos estructuras de descripcion de datos.
* El vector de "requests" no es enviado ya que solo es necesario
* en los padres.
* TODO Refactor?
*/
void def_malleability_qty_type(malleability_data_t *data_struct_rep, malleability_data_t *data_struct_dist, MPI_Datatype *new_type) {
int i, counts = 4;
int counts = 4;
int blocklengths[counts];
MPI_Aint displs[counts], dir;
MPI_Aint displs[counts];
MPI_Datatype types[counts];
types[0] = types[1] = types[2] = types[3] = MPI_INT;
blocklengths[0] = blocklengths[1] = data_struct_rep->entries;
blocklengths[2] = blocklengths[3] = data_struct_dist->entries;
// Obtener direccion base
MPI_Get_address(data_struct_rep, &dir);
MPI_Get_address(&(data_struct_rep->qty), &displs[0]);
MPI_Get_address(&(data_struct_rep->types), &displs[1]);
MPI_Get_address(&(data_struct_dist->qty), &displs[2]);
MPI_Get_address(&(data_struct_dist->types), &displs[3]);
for(i=0;i<counts;i++) displs[i] -= dir;
MPI_Get_address((data_struct_rep->qty), &displs[0]);
MPI_Get_address((data_struct_rep->types), &displs[1]);
MPI_Get_address((data_struct_dist->qty), &displs[2]);
MPI_Get_address((data_struct_dist->types), &displs[3]);
MPI_Type_create_struct(counts, blocklengths, displs, types, new_type);
MPI_Type_commit(new_type);
......
......@@ -6,8 +6,6 @@
#include "malleabilityStates.h"
#define MALLEABILITY_INIT_DATA_QTY 100
#define MAL_INT 0
#define MAL_CHAR 1
typedef struct {
int entries; // Indica numero de vectores a comunicar (replicated data)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment