Commit edc48a8e authored by iker_martin's avatar iker_martin
Browse files

Hotfix - Now is possible to perform multiple reconfigurations. IO results need...

Hotfix - Now is possible to perform multiple reconfigurations. IO results need a refactor to show all results.
parent 09e30d3b
...@@ -44,7 +44,6 @@ int main(int argc, char *argv[]) { ...@@ -44,7 +44,6 @@ int main(int argc, char *argv[]) {
num_cpus = 20; //FIXME NUMERO MAGICO //TODO Usar openMP para obtener el valor con un pragma num_cpus = 20; //FIXME NUMERO MAGICO //TODO Usar openMP para obtener el valor con un pragma
if (argc >= 5) { if (argc >= 5) {
nodelist = argv[3]; nodelist = argv[3];
//nodelist_len = strlen(nodelist);
num_nodes = atoi(argv[4]); num_nodes = atoi(argv[4]);
num_cpus = num_nodes * num_cpus; num_cpus = num_nodes * num_cpus;
} }
...@@ -68,6 +67,11 @@ int main(int argc, char *argv[]) { ...@@ -68,6 +67,11 @@ int main(int argc, char *argv[]) {
set_benchmark_configuration(config_file); set_benchmark_configuration(config_file);
set_benchmark_results(results); set_benchmark_results(results);
malleability_add_data(&(group->grp), 1, MAL_INT, 1, 1);
malleability_add_data(&run_id, 1, MAL_INT, 1, 1);
malleability_add_data(&(group->iter_start), 1, MAL_INT, 1, 1);
MPI_Barrier(comm); MPI_Barrier(comm);
results->exec_start = MPI_Wtime(); results->exec_start = MPI_Wtime();
} else { //Init hijos } else { //Init hijos
...@@ -75,34 +79,20 @@ int main(int argc, char *argv[]) { ...@@ -75,34 +79,20 @@ int main(int argc, char *argv[]) {
get_malleability_user_comm(&comm); get_malleability_user_comm(&comm);
get_benchmark_configuration(&config_file); get_benchmark_configuration(&config_file);
get_benchmark_results(&results); get_benchmark_results(&results);
set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr); //TODO Cambio al añadir nueva redistribucion
// TODO Refactor - Que sea una unica funcion // TODO Refactor - Que sea una unica funcion
// Obtiene las variables que van a utilizar los hijos // Obtiene las variables que van a utilizar los hijos
void *value = NULL; void *value = NULL;
malleability_get_data(&value, 0, 1, 1); malleability_get_data(&value, 0, 1, 1);
group->grp = *((int *)value); group->grp = *((int *)value);
free(value);
malleability_get_data(&value, 1, 1, 1); malleability_get_data(&value, 1, 1, 1);
run_id = *((int *)value); run_id = *((int *)value);
free(value);
malleability_get_data(&value, 2, 1, 1); malleability_get_data(&value, 2, 1, 1);
group->iter_start = *((int *)value); group->iter_start = *((int *)value);
free(value);
//FIXME Eliminar cuando se utilice SLURM
/*
malleability_get_data(&value, 4, 1, 1);
num_nodes = *((int *)value);
free(value);
malleability_get_data(&value, 5, 1, 1);
nodelist = (char *)value;
//free(value);
nodelist_len = strlen(nodelist);
*/
set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr); //TODO Cambio al añadir nueva redistribucion
group->grp = group->grp + 1; group->grp = group->grp + 1;
} }
...@@ -111,7 +101,6 @@ int main(int argc, char *argv[]) { ...@@ -111,7 +101,6 @@ int main(int argc, char *argv[]) {
// //
group->grp = group->grp - 1; // TODO REFACTOR??? group->grp = group->grp - 1; // TODO REFACTOR???
do { do {
group->grp = group->grp + 1; group->grp = group->grp + 1;
set_benchmark_grp(group->grp); set_benchmark_grp(group->grp);
if(group->grp != 0) { if(group->grp != 0) {
...@@ -123,14 +112,8 @@ int main(int argc, char *argv[]) { ...@@ -123,14 +112,8 @@ int main(int argc, char *argv[]) {
config_file->groups[group->grp+1].phy_dist, config_file->groups[group->grp+1].at, -1); config_file->groups[group->grp+1].phy_dist, config_file->groups[group->grp+1].at, -1);
set_children_number(config_file->groups[group->grp+1].procs); // TODO TO BE DEPRECATED set_children_number(config_file->groups[group->grp+1].procs); // TODO TO BE DEPRECATED
if(group->grp == 0) { if(group->grp != 0) {
malleability_add_data(&(group->grp), 1, MAL_INT, 1, 1); malleability_modify_data(&(group->grp), 0, 1, MAL_INT, 1, 1);
malleability_add_data(&run_id, 1, MAL_INT, 1, 1);
malleability_add_data(&(group->iter_start), 1, MAL_INT, 1, 1);
//FIXME Eliminar cuando se utilice SLURM
//malleability_add_data(&num_nodes, 1, MAL_INT, 1, 1);
//malleability_add_data(&nodelist, nodelist_len, MAL_CHAR, 1, 1);
} }
} }
...@@ -166,7 +149,6 @@ int main(int argc, char *argv[]) { ...@@ -166,7 +149,6 @@ int main(int argc, char *argv[]) {
free_application_data(); //FIXME Error al liberar memoria de SDR/ADR free_application_data(); //FIXME Error al liberar memoria de SDR/ADR
MPI_Finalize(); MPI_Finalize();
return 0; return 0;
} }
......
...@@ -133,82 +133,6 @@ double process_stage(configuration config_file, iter_stage_t stage, group_data g ...@@ -133,82 +133,6 @@ double process_stage(configuration config_file, iter_stage_t stage, group_data g
return result; return result;
} }
// Se realizan varios tests de latencia al
// mandar un único dato de tipo CHAR a los procesos impares
// desde el par inmediatamente anterior. Tras esto, los impares
// vuelven a enviar el dato al proceso par.
//
// Devuelve la latencia del sistema.
double latency(int myId, int numP, MPI_Comm comm) {
int i, loop_count = 100;
double start_time, stop_time, time;
char aux;
aux = '0';
MPI_Barrier(comm);
start_time = MPI_Wtime();
if(myId == ROOT) {
for(i=0; i<loop_count; i++){
MPI_Send(&aux, 0, MPI_CHAR, numP-1, 99, comm);
}
MPI_Recv(&aux, 0, MPI_CHAR, numP-1, 99, comm, MPI_STATUS_IGNORE);
} else if(myId+1 == numP) {
for(i=0; i<loop_count; i++){
MPI_Recv(&aux, 0, MPI_CHAR, ROOT, 99, comm, MPI_STATUS_IGNORE);
}
MPI_Send(&aux, 0, MPI_CHAR, ROOT, 99, comm);
}
MPI_Barrier(comm);
stop_time = MPI_Wtime();
time = (stop_time - start_time) / loop_count;
MPI_Bcast(&time, 1, MPI_DOUBLE, ROOT, comm);
return time;
}
// Se realizan varios tests de ancho de banda
// al mandar N datos a los procesos impares desde el
// par inmediatamente anterior. Tras esto, los impares
// vuelven a enviar los N datos al proceso par.
//
// Devuelve el tiempo necesario para realizar las pruebas
double bandwidth(int myId, int numP, MPI_Comm comm, double latency, int n) {
int i, loop_count = 100;
double start_time, stop_time, bw, time;
char *aux;
size_t n_bytes;
n_bytes = n * sizeof(char);
aux = malloc(n_bytes);
time = 0;
MPI_Barrier(comm);
start_time = MPI_Wtime();
if(myId == ROOT) {
for(i=0; i<loop_count; i++){
MPI_Send(aux, n, MPI_CHAR, numP-1, 99, comm);
}
MPI_Recv(aux, 0, MPI_CHAR, numP-1, 99, comm, MPI_STATUS_IGNORE);
} else if(myId+1 == numP) {
for(i=0; i<loop_count; i++){
MPI_Recv(aux, n, MPI_CHAR, ROOT, 99, comm, MPI_STATUS_IGNORE);
}
MPI_Send(aux, 0, MPI_CHAR, ROOT, 99, comm);
}
MPI_Barrier(comm);
stop_time = MPI_Wtime();
time = (stop_time - start_time) / loop_count;
bw = n_bytes / (time - latency);
MPI_Bcast(&bw, 1, MPI_DOUBLE, ROOT, comm);
free(aux);
return bw;
}
/* /*
* ======================================================================================== * ========================================================================================
* ======================================================================================== * ========================================================================================
...@@ -248,6 +172,8 @@ double init_matrix_pt(group_data group, configuration *config_file, iter_stage_t ...@@ -248,6 +172,8 @@ double init_matrix_pt(group_data group, configuration *config_file, iter_stage_t
stage->operations = ceil(t_stage / stage->t_op); stage->operations = ceil(t_stage / stage->t_op);
} }
MPI_Bcast(&(stage->operations), 1, MPI_INT, ROOT, comm); MPI_Bcast(&(stage->operations), 1, MPI_INT, ROOT, comm);
} else {
stage->operations = ceil(t_stage / stage->t_op);
} }
return result; return result;
...@@ -266,6 +192,8 @@ double init_pi_pt(group_data group, configuration *config_file, iter_stage_t *st ...@@ -266,6 +192,8 @@ double init_pi_pt(group_data group, configuration *config_file, iter_stage_t *st
stage->operations = ceil(t_stage / stage->t_op); stage->operations = ceil(t_stage / stage->t_op);
} }
MPI_Bcast(&(stage->operations), 1, MPI_INT, ROOT, comm); MPI_Bcast(&(stage->operations), 1, MPI_INT, ROOT, comm);
} else {
stage->operations = ceil(t_stage / stage->t_op);
} }
return result; return result;
......
...@@ -325,6 +325,40 @@ void malleability_add_data(void *data, size_t total_qty, int type, int is_replic ...@@ -325,6 +325,40 @@ void malleability_add_data(void *data, size_t total_qty, int type, int is_replic
} }
} }
/*
* Modifica en la estructura concreta de datos elegida en el indice "index"
* con el set de datos "data" de un total de "total_qty" elementos.
*
* Los datos variables se tienen que modificar cuando quieran ser mandados, no antes
*
* Mas informacion en la funcion "modify_data".
*/
void malleability_modify_data(void *data, size_t index, size_t total_qty, int type, int is_replicated, int is_constant) {
if(is_constant) {
if(is_replicated) {
modify_data(data, index, total_qty, type, 0, rep_s_data); //FIXME Numero magico
} else {
modify_data(data, index, total_qty, type, 0, dist_s_data); //FIXME Numero magico
}
} else {
if(is_replicated) {
modify_data(data, index, total_qty, type, 0, rep_a_data); //FIXME Numero magico || UN request?
} else {
size_t total_reqs = 0;
if(mall_conf->comm_type == MAL_USE_NORMAL) {
total_reqs = 1;
} else if(mall_conf->comm_type == MAL_USE_IBARRIER) {
total_reqs = 2;
} else if(mall_conf->comm_type == MAL_USE_POINT) {
total_reqs = mall->numC;
}
modify_data(data, index, total_qty, type, total_reqs, dist_a_data); //FIXME Numero magico
}
}
}
/* /*
* Devuelve el numero de entradas para la estructura de descripcion de * Devuelve el numero de entradas para la estructura de descripcion de
* datos elegida. * datos elegida.
...@@ -647,7 +681,6 @@ int end_redistribution() { ...@@ -647,7 +681,6 @@ int end_redistribution() {
rootBcast = mall->root; rootBcast = mall->root;
} }
comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_NOT_CHILDREN, mall->myId, mall->root, mall->intercomm); comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_NOT_CHILDREN, mall->myId, mall->root, mall->intercomm);
if(dist_s_data->entries || rep_s_data->entries) { // Enviar datos sincronos if(dist_s_data->entries || rep_s_data->entries) { // Enviar datos sincronos
send_data(mall->numC, dist_s_data, MALLEABILITY_USE_SYNCHRONOUS); send_data(mall->numC, dist_s_data, MALLEABILITY_USE_SYNCHRONOUS);
......
...@@ -23,6 +23,7 @@ void set_children_number(int numC); // TODO TO BE DEPRECATED ...@@ -23,6 +23,7 @@ void set_children_number(int numC); // TODO TO BE DEPRECATED
void get_malleability_user_comm(MPI_Comm *comm); void get_malleability_user_comm(MPI_Comm *comm);
void malleability_add_data(void *data, size_t total_qty, int type, int is_replicated, int is_constant); void malleability_add_data(void *data, size_t total_qty, int type, int is_replicated, int is_constant);
void malleability_modify_data(void *data, size_t index, size_t total_qty, int type, int is_replicated, int is_constant);
void malleability_get_entries(size_t *entries, int is_replicated, int is_constant); void malleability_get_entries(size_t *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);
......
...@@ -33,13 +33,43 @@ void add_data(void *data, size_t total_qty, int type, size_t request_qty, mallea ...@@ -33,13 +33,43 @@ void add_data(void *data, size_t total_qty, int type, size_t request_qty, mallea
data_struct->types[data_struct->entries] = type; data_struct->types[data_struct->entries] = type;
data_struct->arrays[data_struct->entries] = data; data_struct->arrays[data_struct->entries] = data;
data_struct->requests[data_struct->entries] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request)); if(request_qty) {
for(i=0; i < request_qty; i++) { data_struct->requests[data_struct->entries] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request));
data_struct->requests[data_struct->entries][i] = MPI_REQUEST_NULL; for(i=0; i < request_qty; i++) {
data_struct->requests[data_struct->entries][i] = MPI_REQUEST_NULL;
}
} }
data_struct->entries+=1; data_struct->entries+=1;
} }
/*
* Modifica en la estructura de datos a comunicar con los hijos
* un set de datos de un total "total_qty" distribuido entre
* todos los padres. La nueva serie "data" solo representa los datos
* que tiene este padre.
*/
void modify_data(void *data, size_t index, size_t total_qty, int type, size_t request_qty, malleability_data_t *data_struct) {
size_t i;
if(data_struct->entries < index) { // Index does not exist
return;
}
if(data_struct->requests[index] != NULL) {
//free(data_struct->requests[index]); TODO Error when trying to free
data_struct->requests[index] = NULL;
}
data_struct->qty[index] = total_qty;
data_struct->types[index] = type;
data_struct->arrays[index] = data;
if(request_qty) {
data_struct->requests[index] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request));
for(i=0; i < request_qty; i++) {
data_struct->requests[index][i] = MPI_REQUEST_NULL;
}
}
}
/* /*
* Comunicar desde los padres a los hijos las estructuras de datos sincronas o asincronas * Comunicar desde los padres a los hijos las estructuras de datos sincronas o asincronas
...@@ -71,11 +101,14 @@ void comm_data_info(malleability_data_t *data_struct_rep, malleability_data_t *d ...@@ -71,11 +101,14 @@ void comm_data_info(malleability_data_t *data_struct_rep, malleability_data_t *d
} }
def_malleability_qty_type(data_struct_dist, data_struct_rep, &struct_type); def_malleability_qty_type(data_struct_dist, data_struct_rep, &struct_type);
MPI_Bcast(MPI_BOTTOM, 1, struct_type, rootBcast, intercomm); //FIXME Doy error MPI_Bcast(MPI_BOTTOM, 1, struct_type, rootBcast, intercomm);
if(is_children_group) { 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; size_t request_qty = 1; // TODO Obtener desde la funcion
data_struct_rep->requests[data_struct_rep->entries] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request));
data_struct_dist->requests[data_struct_dist->entries] = (MPI_Request *) malloc(request_qty * sizeof(MPI_Request));
*/
for(i=0; i < data_struct_rep->entries; i++) { 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 data_struct_rep->arrays[i] = (void *) malloc(data_struct_rep->qty[i] * sizeof(int)); //TODO Tener en cuenta que no siempre es int
......
...@@ -25,6 +25,7 @@ typedef struct { ...@@ -25,6 +25,7 @@ typedef struct {
} malleability_data_t; } malleability_data_t;
void add_data(void *data, size_t total_qty, int type, size_t request_qty, malleability_data_t *data_struct); void add_data(void *data, size_t total_qty, int type, size_t request_qty, malleability_data_t *data_struct);
void modify_data(void *data, size_t index, size_t total_qty, int type, size_t request_qty, malleability_data_t *data_struct);
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); 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);
void free_malleability_data_struct(malleability_data_t *data_struct); void free_malleability_data_struct(malleability_data_t *data_struct);
......
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