Commit f5fe619d authored by iker_martin's avatar iker_martin
Browse files

Results structure is no longer needed by MaM and has a separated structure for...

Results structure is no longer needed by MaM and has a separated structure for this purpose. Merge Shrink has a related problem with results to solve
parent 594957a2
...@@ -5,97 +5,17 @@ ...@@ -5,97 +5,17 @@
#define RESULTS_EXTRA_SIZE 100 #define RESULTS_EXTRA_SIZE 100
void def_results_type(results_data *results, int resizes, MPI_Datatype *results_type);
void compute_max(results_data *results, double *computed_array, int myId, int root, MPI_Comm comm); void compute_max(results_data *results, double *computed_array, int myId, int root, MPI_Comm comm);
void compute_mean(results_data *results, double *computed_array, int myId, int numP, int root, MPI_Comm comm); void compute_mean(results_data *results, double *computed_array, int myId, int numP, int root, MPI_Comm comm);
void compute_median(results_data *results, double *computed_array, size_t *used_ids, int myId, int numP, int root, MPI_Comm comm); void compute_median(results_data *results, double *computed_array, size_t *used_ids, int myId, int numP, int root, MPI_Comm comm);
void match_median(results_data *results, double *computed_array, size_t *used_ids, int myId, int numP, int root, MPI_Comm comm); void match_median(results_data *results, double *computed_array, size_t *used_ids, int myId, int numP, int root, MPI_Comm comm);
//======================================================||
//======================================================||
//================MPI RESULTS FUNCTIONS=================||
//======================================================||
//======================================================||
/*
* Comunica una estructura de resultados a todos los procesos del comunicador
* a traves de un tipo derivado.
*
* Si se llama con un intercommunicador, el grupo de procesos que envia los datos
* tiene que indicar en el proceso raiz el valor "MPI_ROOT" para "root" y el resto
* de ese grupo el valor "MPI_PROC_NULL". Los procesos del otro grupo tienen que
* indicar el Id del proceso raiz que ha puesto "MPI_ROOT".
*/
void comm_results(results_data *results, int root, size_t resizes, MPI_Comm intercomm) {
MPI_Datatype results_type;
// Obtener un tipo derivado para enviar todos los
// datos escalares con una sola comunicacion
def_results_type(results, resizes, &results_type);
MPI_Bcast(results, 1, results_type, root, intercomm);
//Liberar tipos derivados
MPI_Type_free(&results_type);
}
/*
* Define un tipo derivado de MPI para mandar los tiempos
* con una sola comunicacion.
*
* En concreto son tres escalares y dos vectores de tamaño "resizes"
*/
void def_results_type(results_data *results, int resizes, MPI_Datatype *results_type) {
int i, counts = 7;
int blocklengths[] = {1, 1, 1, 1, 1, 1, 1};
MPI_Aint displs[counts], dir;
MPI_Datatype types[counts];
// Rellenar vector types
types[0] = types[1] = types[2] = types[3] = types[4] = types[5] = types[6] = MPI_DOUBLE;
blocklengths[2] = blocklengths[3] = blocklengths[4] = blocklengths[5] = blocklengths[6] = resizes;
// Rellenar vector displs
MPI_Get_address(results, &dir);
MPI_Get_address(&(results->exec_start), &displs[0]);
MPI_Get_address(&(results->wasted_time), &displs[1]);
MPI_Get_address(results->sync_time, &displs[2]);
MPI_Get_address(results->async_time, &displs[3]);
MPI_Get_address(results->spawn_real_time, &displs[4]);
MPI_Get_address(results->spawn_time, &displs[5]);
MPI_Get_address(results->malleability_time, &displs[6]);
for(i=0;i<counts;i++) displs[i] -= dir;
MPI_Type_create_struct(counts, blocklengths, displs, types, results_type);
MPI_Type_commit(results_type);
}
//======================================================|| //======================================================||
//======================================================|| //======================================================||
//================SET RESULTS FUNCTIONS=================|| //================SET RESULTS FUNCTIONS=================||
//======================================================|| //======================================================||
//======================================================|| //======================================================||
/*
* Guarda los resultados respecto a la redistribución de datos
* tras una reconfiguración. A llamar por los hijos tras
* terminar la redistribución y obtener la configuración.
*/
void set_results_post_reconfig(results_data *results, int grp, int sdr, int adr) {
if(sdr) { // Si no hay datos sincronos, el tiempo es 0
results->sync_time[grp-1] = results->sync_end - results->sync_time[grp-1];
} else {
results->sync_time[grp-1] = 0;
}
if(adr) { // Si no hay datos asincronos, el tiempo es 0
results->async_time[grp-1] = results->async_end - results->async_time[grp-1];
} else {
results->async_time[grp-1] = 0;
}
results->malleability_time[grp-1] = results->malleability_end - results->malleability_time[grp-1];
}
/* /*
* Pone el indice del siguiente elemento a escribir a 0 para los vectores * Pone el indice del siguiente elemento a escribir a 0 para los vectores
* que tengan que ver con las iteraciones. * que tengan que ver con las iteraciones.
......
...@@ -22,9 +22,6 @@ typedef struct { ...@@ -22,9 +22,6 @@ typedef struct {
double wasted_time; // Time spent recalculating iter stages double wasted_time; // Time spent recalculating iter stages
} results_data; } results_data;
void comm_results(results_data *results, int root, size_t resizes, MPI_Comm intercomm);
void set_results_post_reconfig(results_data *results, int grp, int sdr, int adr);
void reset_results_index(results_data *results); void reset_results_index(results_data *results);
void compute_results_iter(results_data *results, int myId, int numP, int root, size_t n_stages, int capture_method, MPI_Comm comm); void compute_results_iter(results_data *results, int myId, int numP, int root, size_t n_stages, int capture_method, MPI_Comm comm);
......
...@@ -69,7 +69,6 @@ int main(int argc, char *argv[]) { ...@@ -69,7 +69,6 @@ int main(int argc, char *argv[]) {
set_benchmark_grp(group->grp); set_benchmark_grp(group->grp);
set_benchmark_configuration(config_file); set_benchmark_configuration(config_file);
set_benchmark_results(results);
if(config_file->n_groups > 1) { if(config_file->n_groups > 1) {
set_malleability_configuration(config_file->groups[group->grp+1].sm, config_file->groups[group->grp+1].ss, set_malleability_configuration(config_file->groups[group->grp+1].sm, config_file->groups[group->grp+1].ss,
...@@ -79,6 +78,7 @@ int main(int argc, char *argv[]) { ...@@ -79,6 +78,7 @@ int main(int argc, char *argv[]) {
malleability_add_data(&(group->grp), 1, MAL_INT, 1, 1); malleability_add_data(&(group->grp), 1, MAL_INT, 1, 1);
malleability_add_data(&run_id, 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); malleability_add_data(&(group->iter_start), 1, MAL_INT, 1, 1);
//malleability_add_data(&(results->exec_start), 1, MAL_DOUBLE, 1, 1);
if(config_file->sdr) { if(config_file->sdr) {
for(i=0; i<group->sync_data_groups; i++) { for(i=0; i<group->sync_data_groups; i++) {
...@@ -98,7 +98,6 @@ int main(int argc, char *argv[]) { ...@@ -98,7 +98,6 @@ 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);
// 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
...@@ -113,6 +112,9 @@ int main(int argc, char *argv[]) { ...@@ -113,6 +112,9 @@ int main(int argc, char *argv[]) {
malleability_get_data(&value, 2, 1, 1); malleability_get_data(&value, 2, 1, 1);
group->iter_start = *((int *)value); group->iter_start = *((int *)value);
//malleability_get_data(&value, 3, 1, 1);
//results->exec_start = *((double *)value);
if(config_file->sdr) { if(config_file->sdr) {
malleability_get_entries(&entries, 0, 1); malleability_get_entries(&entries, 0, 1);
group->sync_array = (char **) malloc(entries * sizeof(char *)); group->sync_array = (char **) malloc(entries * sizeof(char *));
...@@ -131,7 +133,8 @@ int main(int argc, char *argv[]) { ...@@ -131,7 +133,8 @@ int main(int argc, char *argv[]) {
} }
group->grp = group->grp + 1; group->grp = group->grp + 1;
realloc_results_iters(results, config_file->n_stages, config_file->groups[group->grp].iters); results = malloc(sizeof(results_data));
init_results_data(results, config_file->n_resizes, config_file->n_stages, config_file->groups[group->grp].iters);
} }
// //
...@@ -148,7 +151,7 @@ int main(int argc, char *argv[]) { ...@@ -148,7 +151,7 @@ int main(int argc, char *argv[]) {
if(group->grp != 0) { if(group->grp != 0) {
obtain_op_times(0); //Obtener los nuevos valores de tiempo para el computo obtain_op_times(0); //Obtener los nuevos valores de tiempo para el computo
set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr); malleability_retrieve_times(&results->spawn_time[group->grp - 1], &results->sync_time[group->grp - 1], &results->async_time[group->grp - 1], &results->malleability_time[group->grp - 1]);
} }
if(config_file->n_groups != group->grp + 1) { //TODO Llevar a otra funcion if(config_file->n_groups != group->grp + 1) { //TODO Llevar a otra funcion
...@@ -158,6 +161,7 @@ int main(int argc, char *argv[]) { ...@@ -158,6 +161,7 @@ int main(int argc, char *argv[]) {
if(group->grp != 0) { if(group->grp != 0) {
malleability_modify_data(&(group->grp), 0, 1, MAL_INT, 1, 1); malleability_modify_data(&(group->grp), 0, 1, MAL_INT, 1, 1);
malleability_modify_data(&(group->iter_start), 2, 1, MAL_INT, 1, 1);
} }
} }
......
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
*/ */
#include <mpi.h> #include <mpi.h>
/* --- SPAWN STRUCTURES --- */ //FIXME Remove both includes
#include "../Main/configuration.h"
#include "../Main/Main_datatypes.h"
/* --- PHYSICAL DIST STRUCTURE --- */
struct physical_dist { struct physical_dist {
int num_cpus, num_nodes; int num_cpus, num_nodes;
char *nodelist; char *nodelist;
...@@ -14,6 +18,7 @@ struct physical_dist { ...@@ -14,6 +18,7 @@ struct physical_dist {
int dist_type, info_type; int dist_type, info_type;
}; };
/* --- SPAWN STRUCTURE --- */
typedef struct { typedef struct {
int myId, root, root_parents; int myId, root, root_parents;
int spawn_qty, initial_qty, target_qty; int spawn_qty, initial_qty, target_qty;
...@@ -27,4 +32,44 @@ typedef struct { ...@@ -27,4 +32,44 @@ typedef struct {
MPI_Comm comm, returned_comm; MPI_Comm comm, returned_comm;
} Spawn_data; } Spawn_data;
/* --- TIME CAPTURE STRUCTURE --- */
typedef struct {
// Spawn, Sync and Async time
double spawn_start, spawn_time;
double sync_start, sync_end;
double async_start, async_end;
double malleability_start, malleability_end;
MPI_Datatype times_type;
} malleability_times_t;
/* --- GLOBAL STRUCTURES --- */
typedef struct {
int spawn_method;
int spawn_dist;
int spawn_strategies;
int red_method;
int red_strategies;
int grp;
malleability_times_t *times;
configuration *config_file;
} malleability_config_t;
typedef struct { //FIXME numC_spawned no se esta usando
int myId, numP, numC, numC_spawned, root, root_parents;
pthread_t async_thread;
MPI_Comm comm, thread_comm;
MPI_Comm intercomm;
MPI_Comm user_comm;
int dup_user_comm;
char *name_exec, *nodelist;
int num_cpus, num_nodes, nodelist_len;
} malleability_t;
/* --- VARIABLES --- */
malleability_config_t *mall_conf;
malleability_t *mall;
#endif #endif
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "malleabilityDataStructures.h" #include "malleabilityDataStructures.h"
#include "malleabilityTypes.h" #include "malleabilityTypes.h"
#include "malleabilityZombies.h" #include "malleabilityZombies.h"
#include "malleabilityTimes.h"
#include "spawn_methods/GenericSpawn.h" #include "spawn_methods/GenericSpawn.h"
#include "CommDist.h" #include "CommDist.h"
...@@ -32,35 +33,8 @@ void* thread_async_work(); ...@@ -32,35 +33,8 @@ void* thread_async_work();
void print_comms_state(); void print_comms_state();
void malleability_comms_update(MPI_Comm comm); void malleability_comms_update(MPI_Comm comm);
typedef struct {
int spawn_method;
int spawn_dist;
int spawn_strategies;
int red_method;
int red_strategies;
int grp;
configuration *config_file;
results_data *results;
} malleability_config_t;
typedef struct { //FIXME numC_spawned no se esta usando
int myId, numP, numC, numC_spawned, root, root_parents;
pthread_t async_thread;
MPI_Comm comm, thread_comm;
MPI_Comm intercomm;
MPI_Comm user_comm;
int dup_user_comm;
char *name_exec, *nodelist;
int num_cpus, num_nodes, nodelist_len;
} malleability_t;
int state = MALL_UNRESERVED; //FIXME Mover a otro lado int state = MALL_UNRESERVED; //FIXME Mover a otro lado
malleability_config_t *mall_conf;
malleability_t *mall;
malleability_data_t *rep_s_data; malleability_data_t *rep_s_data;
malleability_data_t *dist_s_data; malleability_data_t *dist_s_data;
malleability_data_t *rep_a_data; malleability_data_t *rep_a_data;
...@@ -81,6 +55,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex ...@@ -81,6 +55,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex
mall_conf = (malleability_config_t *) malloc(sizeof(malleability_config_t)); mall_conf = (malleability_config_t *) malloc(sizeof(malleability_config_t));
mall = (malleability_t *) malloc(sizeof(malleability_t)); mall = (malleability_t *) malloc(sizeof(malleability_t));
rep_s_data = (malleability_data_t *) malloc(sizeof(malleability_data_t)); rep_s_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
dist_s_data = (malleability_data_t *) malloc(sizeof(malleability_data_t)); dist_s_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
rep_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t)); rep_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
...@@ -112,6 +87,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex ...@@ -112,6 +87,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex
state = MALL_NOT_STARTED; state = MALL_NOT_STARTED;
zombies_service_init(); zombies_service_init();
init_malleability_times();
// Si son el primer grupo de procesos, obtienen los datos de los padres // Si son el primer grupo de procesos, obtienen los datos de los padres
MPI_Comm_get_parent(&(mall->intercomm)); MPI_Comm_get_parent(&(mall->intercomm));
...@@ -147,6 +123,7 @@ void free_malleability() { ...@@ -147,6 +123,7 @@ void free_malleability() {
free(dist_s_data); free(dist_s_data);
free(dist_a_data); free(dist_a_data);
free_malleability_times();
if(mall->comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->comm)); if(mall->comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->comm));
if(mall->thread_comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->thread_comm)); if(mall->thread_comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->thread_comm));
free(mall); free(mall);
...@@ -181,9 +158,10 @@ int malleability_checkpoint() { ...@@ -181,9 +158,10 @@ int malleability_checkpoint() {
case MALL_UNRESERVED: case MALL_UNRESERVED:
break; break;
case MALL_NOT_STARTED: case MALL_NOT_STARTED:
reset_malleability_times();
// Comprobar si se tiene que realizar un redimensionado // Comprobar si se tiene que realizar un redimensionado
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->malleability_time[mall_conf->grp] = MPI_Wtime(); mall_conf->times->malleability_start = MPI_Wtime();
//if(CHECK_RMS()) {return MALL_DENIED;} //if(CHECK_RMS()) {return MALL_DENIED;}
state = spawn_step(); state = spawn_step();
...@@ -198,8 +176,7 @@ int malleability_checkpoint() { ...@@ -198,8 +176,7 @@ int malleability_checkpoint() {
state = check_spawn_state(&(mall->intercomm), mall->comm, &end_real_time); state = check_spawn_state(&(mall->intercomm), mall->comm, &end_real_time);
if (state == MALL_SPAWN_COMPLETED || state == MALL_SPAWN_ADAPTED) { if (state == MALL_SPAWN_COMPLETED || state == MALL_SPAWN_ADAPTED) {
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_time[mall_conf->grp] = MPI_Wtime() - mall_conf->results->spawn_start; mall_conf->times->spawn_time = MPI_Wtime() - mall_conf->times->malleability_start;
mall_conf->results->spawn_real_time[mall_conf->grp] = end_real_time - mall_conf->results->spawn_start;
malleability_checkpoint(); malleability_checkpoint();
} }
...@@ -224,13 +201,13 @@ int malleability_checkpoint() { ...@@ -224,13 +201,13 @@ int malleability_checkpoint() {
case MALL_SPAWN_ADAPT_PENDING: case MALL_SPAWN_ADAPT_PENDING:
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_start = MPI_Wtime(); mall_conf->times->spawn_start = MPI_Wtime();
unset_spawn_postpone_flag(state); unset_spawn_postpone_flag(state);
state = check_spawn_state(&(mall->intercomm), mall->comm, &end_real_time); state = check_spawn_state(&(mall->intercomm), mall->comm, &end_real_time);
if(!malleability_spawn_contains_strat(mall_conf->spawn_strategies, MALL_SPAWN_PTHREAD, NULL)) { if(!malleability_spawn_contains_strat(mall_conf->spawn_strategies, MALL_SPAWN_PTHREAD, NULL)) {
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_time[mall_conf->grp] = MPI_Wtime() - mall_conf->results->spawn_start; mall_conf->times->spawn_time = MPI_Wtime() - mall_conf->times->malleability_start;
malleability_checkpoint(); malleability_checkpoint();
} }
break; break;
...@@ -242,7 +219,7 @@ int malleability_checkpoint() { ...@@ -242,7 +219,7 @@ int malleability_checkpoint() {
case MALL_DIST_COMPLETED: //TODO No es esto muy feo? case MALL_DIST_COMPLETED: //TODO No es esto muy feo?
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->malleability_end = MPI_Wtime(); mall_conf->times->malleability_end = MPI_Wtime();
state = MALL_COMPLETED; state = MALL_COMPLETED;
break; break;
} }
...@@ -263,12 +240,8 @@ void get_benchmark_configuration(configuration **config_file) { ...@@ -263,12 +240,8 @@ void get_benchmark_configuration(configuration **config_file) {
*config_file = mall_conf->config_file; *config_file = mall_conf->config_file;
} }
void set_benchmark_results(results_data *results) { void malleability_retrieve_times(double *sp_time, double *sy_time, double *asy_time, double *mall_time) {
mall_conf->results = results; malleability_I_retrieve_times(sp_time, sy_time, asy_time, mall_time);
}
void get_benchmark_results(results_data **results) {
*results = mall_conf->results;
} }
//------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------
...@@ -527,9 +500,6 @@ void Children_init() { ...@@ -527,9 +500,6 @@ void Children_init() {
MPI_Bcast(&(mall_conf->red_method), 1, MPI_INT, root_parents, mall->intercomm); MPI_Bcast(&(mall_conf->red_method), 1, MPI_INT, root_parents, mall->intercomm);
MPI_Bcast(&(mall_conf->red_strategies), 1, MPI_INT, root_parents, mall->intercomm); MPI_Bcast(&(mall_conf->red_strategies), 1, MPI_INT, root_parents, mall->intercomm);
mall_conf->results = (results_data *) malloc(sizeof(results_data));
init_results_data(mall_conf->results, mall_conf->config_file->n_resizes, mall_conf->config_file->n_stages, RESULTS_INIT_DATA_QTY);
comm_data_info(rep_a_data, dist_a_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm); comm_data_info(rep_a_data, dist_a_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
if(dist_a_data->entries || rep_a_data->entries) { // Recibir datos asincronos if(dist_a_data->entries || rep_a_data->entries) { // Recibir datos asincronos
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
...@@ -548,7 +518,7 @@ void Children_init() { ...@@ -548,7 +518,7 @@ void Children_init() {
} }
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
mall_conf->results->async_end= MPI_Wtime(); // Obtener timestamp de cuando termina comm asincrona mall_conf->times->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); comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
...@@ -568,17 +538,17 @@ void Children_init() { ...@@ -568,17 +538,17 @@ void Children_init() {
MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], datatype, root_parents, mall->intercomm); MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], datatype, root_parents, mall->intercomm);
} }
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
mall_conf->results->sync_end = MPI_Wtime(); // Obtener timestamp de cuando termina comm sincrona mall_conf->times->sync_end = MPI_Wtime(); // Obtener timestamp de cuando termina comm sincrona
} }
// Guardar los resultados de esta transmision // Guardar los resultados de esta transmision
comm_results(mall_conf->results, mall->root, mall_conf->config_file->n_resizes, mall->intercomm); malleability_times_broadcast(mall->root);
if(!is_intercomm) { if(!is_intercomm) {
malleability_comms_update(mall->intercomm); malleability_comms_update(mall->intercomm);
} }
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->malleability_end = MPI_Wtime(); // Obtener timestamp de cuando termina maleabilidad mall_conf->times->malleability_end = MPI_Wtime(); // Obtener timestamp de cuando termina maleabilidad
MPI_Comm_disconnect(&(mall->intercomm)); //FIXME Error en OpenMPI + Merge MPI_Comm_disconnect(&(mall->intercomm)); //FIXME Error en OpenMPI + Merge
} }
...@@ -594,13 +564,13 @@ void Children_init() { ...@@ -594,13 +564,13 @@ void Children_init() {
*/ */
int spawn_step(){ int spawn_step(){
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_start = MPI_Wtime(); mall_conf->times->spawn_start = MPI_Wtime();
state = init_spawn(mall->name_exec, mall->num_cpus, mall->num_nodes, mall->nodelist, mall->myId, mall->numP, mall->numC, mall->root, mall_conf->spawn_dist, mall_conf->spawn_method, mall_conf->spawn_strategies, mall->thread_comm, &(mall->intercomm)); state = init_spawn(mall->name_exec, mall->num_cpus, mall->num_nodes, mall->nodelist, mall->myId, mall->numP, mall->numC, mall->root, mall_conf->spawn_dist, mall_conf->spawn_method, mall_conf->spawn_strategies, mall->thread_comm, &(mall->intercomm));
if(!malleability_spawn_contains_strat(mall_conf->spawn_strategies, MALL_SPAWN_PTHREAD, NULL)) { if(!malleability_spawn_contains_strat(mall_conf->spawn_strategies, MALL_SPAWN_PTHREAD, NULL)) {
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_time[mall_conf->grp] = MPI_Wtime() - mall_conf->results->spawn_start; mall_conf->times->spawn_time = MPI_Wtime() - mall_conf->times->malleability_start;
} }
return state; return state;
} }
...@@ -647,7 +617,7 @@ int start_redistribution() { ...@@ -647,7 +617,7 @@ int start_redistribution() {
if(dist_a_data->entries || rep_a_data->entries) { // Enviar datos asincronos if(dist_a_data->entries || rep_a_data->entries) { // Enviar datos asincronos
//FIXME No se envian los datos replicados (rep_a_data) //FIXME No se envian los datos replicados (rep_a_data)
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
mall_conf->results->async_time[mall_conf->grp] = MPI_Wtime(); mall_conf->times->async_start = MPI_Wtime();
if(malleability_red_contains_strat(mall_conf->red_strategies, MALL_RED_THREAD, NULL)) { if(malleability_red_contains_strat(mall_conf->red_strategies, MALL_RED_THREAD, NULL)) {
return thread_creation(); return thread_creation();
} else { } else {
...@@ -699,7 +669,7 @@ int check_redistribution() { ...@@ -699,7 +669,7 @@ int check_redistribution() {
MPI_Comm_test_inter(mall->intercomm, &is_intercomm); MPI_Comm_test_inter(mall->intercomm, &is_intercomm);
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
if(!is_intercomm) mall_conf->results->async_end = MPI_Wtime(); // Merge method only if(!is_intercomm) mall_conf->times->async_end = MPI_Wtime(); // Merge method only
return end_redistribution(); return end_redistribution();
} }
...@@ -726,7 +696,7 @@ int end_redistribution() { ...@@ -726,7 +696,7 @@ int end_redistribution() {
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
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
mall_conf->results->sync_time[mall_conf->grp] = MPI_Wtime(); mall_conf->times->sync_start = MPI_Wtime();
send_data(mall->numC, dist_s_data, MALLEABILITY_USE_SYNCHRONOUS); send_data(mall->numC, dist_s_data, MALLEABILITY_USE_SYNCHRONOUS);
// TODO Crear funcion especifica y anyadir para Asinc // TODO Crear funcion especifica y anyadir para Asinc
...@@ -741,10 +711,10 @@ int end_redistribution() { ...@@ -741,10 +711,10 @@ int end_redistribution() {
MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], datatype, rootBcast, mall->intercomm); MPI_Bcast(rep_s_data->arrays[i], rep_s_data->qty[i], datatype, rootBcast, mall->intercomm);
} }
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
if(!is_intercomm) mall_conf->results->sync_end = MPI_Wtime(); // Merge method only if(!is_intercomm) mall_conf->times->sync_end = MPI_Wtime(); // Merge method only
} }
comm_results(mall_conf->results, rootBcast, mall_conf->config_file->n_resizes, mall->intercomm); malleability_times_broadcast(rootBcast);
local_state = MALL_DIST_COMPLETED; local_state = MALL_DIST_COMPLETED;
if(!is_intercomm) { // Merge Spawn if(!is_intercomm) { // Merge Spawn
...@@ -771,8 +741,9 @@ int shrink_redistribution() { ...@@ -771,8 +741,9 @@ int shrink_redistribution() {
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
double time_extra = MPI_Wtime(); double time_extra = MPI_Wtime();
//TODO Create new state before collecting zombies. Processes can perform tasks before that. Then call again Malleability to commit the change //TODO Create Commit function. Processes can perform tasks before that. Then call again Malleability to commit the change
zombies_collect_suspended(mall->user_comm, mall->myId, mall->numP, mall->numC, mall->root, (void *) mall_conf->results, mall_conf->config_file->n_stages, mall_conf->config_file->capture_method); MPI_Abort(MPI_COMM_WORLD, -20); // (void *) mall_conf->results
zombies_collect_suspended(mall->user_comm, mall->myId, mall->numP, mall->numC, mall->root, NULL, mall_conf->config_file->n_stages, mall_conf->config_file->capture_method);
if(mall->myId < mall->numC) { if(mall->myId < mall->numC) {
if(mall->thread_comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->thread_comm)); //FIXME Modificar a que se pida pro el usuario el cambio y se llama a comms_update if(mall->thread_comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->thread_comm)); //FIXME Modificar a que se pida pro el usuario el cambio y se llama a comms_update
...@@ -788,10 +759,7 @@ int shrink_redistribution() { ...@@ -788,10 +759,7 @@ int shrink_redistribution() {
MPI_Comm_free(&(mall->intercomm)); MPI_Comm_free(&(mall->intercomm));
//MPI_Barrier(mall->comm); //MPI_Barrier(mall->comm);
mall_conf->results->spawn_time[mall_conf->grp] += MPI_Wtime() - time_extra; mall_conf->times->spawn_time += MPI_Wtime() - time_extra;
if(malleability_spawn_contains_strat(mall_conf->spawn_strategies,MALL_SPAWN_PTHREAD, NULL)) {
mall_conf->results->spawn_real_time[mall_conf->grp] += MPI_Wtime() - time_extra;
}
return MALL_DIST_COMPLETED; return MALL_DIST_COMPLETED;
} else { } else {
return MALL_ZOMBIE; return MALL_ZOMBIE;
...@@ -885,7 +853,7 @@ int thread_check() { ...@@ -885,7 +853,7 @@ int thread_check() {
} }
MPI_Comm_test_inter(mall->intercomm, &is_intercomm); MPI_Comm_test_inter(mall->intercomm, &is_intercomm);
//MPI_Barrier(mall->intercomm); //MPI_Barrier(mall->intercomm);
if(!is_intercomm) mall_conf->results->async_end = MPI_Wtime(); // Merge method only if(!is_intercomm) mall_conf->times->async_end = MPI_Wtime(); // Merge method only
return end_redistribution(); return end_redistribution();
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <mpi.h> #include <mpi.h>
#include "../IOcodes/results.h"
#include "../Main/configuration.h" #include "../Main/configuration.h"
#include "../Main/Main_datatypes.h" #include "../Main/Main_datatypes.h"
#include "malleabilityStates.h" #include "malleabilityStates.h"
...@@ -29,7 +28,6 @@ void malleability_get_data(void **data, size_t index, int is_replicated, int is_ ...@@ -29,7 +28,6 @@ void malleability_get_data(void **data, size_t index, int is_replicated, int is_
void set_benchmark_configuration(configuration *config_file); void set_benchmark_configuration(configuration *config_file);
void get_benchmark_configuration(configuration **config_file); void get_benchmark_configuration(configuration **config_file);
void set_benchmark_results(results_data *results); void malleability_retrieve_times(double *sp_time, double *sy_time, double *asy_time, double *mall_time);
void get_benchmark_results(results_data **results);
#endif #endif
#include "malleabilityTimes.h"
void def_malleability_times(MPI_Datatype *new_type);
void init_malleability_times() {
if(mall_conf->times == NULL) {
mall_conf->times = (malleability_times_t *) malloc(sizeof(malleability_times_t));
if(mall_conf->times == NULL) {
perror("Error al crear la estructura de tiempos interna para maleabilidad\n");
MPI_Abort(MPI_COMM_WORLD, -5);
}
}
reset_malleability_times();
def_malleability_times(&mall_conf->times->times_type);
}
void reset_malleability_times() {
malleability_times_t *times = mall_conf->times;
times->spawn_start = 0; times->sync_start = 0; times->async_start = 0; times->malleability_start = 0;
times->sync_end = 0; times->async_end = 0; times->malleability_end = 0;
times->spawn_time = 0;
}
void free_malleability_times() {
if(mall_conf->times != NULL) {
if(mall_conf->times->times_type != MPI_DATATYPE_NULL) {
MPI_Type_free(&mall_conf->times->times_type);
mall_conf->times->times_type = MPI_DATATYPE_NULL;
}
free(mall_conf->times);
}
}
void malleability_times_broadcast(int root) {
malleability_times_t *times = mall_conf->times;
MPI_Bcast(mall_conf->times, 1, times->times_type, root, mall->intercomm);
}
void malleability_I_retrieve_times(double *sp_time, double *sy_time, double *asy_time, double *mall_time) {
malleability_times_t *times = mall_conf->times;
*sp_time = times->spawn_time;
*sy_time = times->sync_end - times->sync_start;
*asy_time = times->async_end - times->async_start;
*mall_time = times->malleability_end - times->malleability_start;
}
void def_malleability_times(MPI_Datatype *new_type) {
int i, counts = 4;
int blocklengths[counts];
MPI_Aint displs[counts], dir;
MPI_Datatype types[counts];
blocklengths[0] = blocklengths[1] = blocklengths[2] = blocklengths[3] = 1;
types[0] = types[1] = types[2] = types[3] = MPI_DOUBLE;
// Se pasa el vector a traves de la direccion de "mall_conf"
// Rellenar vector displs
MPI_Get_address(mall_conf->times, &dir);
// Obtener direccion base
MPI_Get_address(&(mall_conf->times->spawn_time), &displs[0]);
MPI_Get_address(&(mall_conf->times->sync_start), &displs[1]);
MPI_Get_address(&(mall_conf->times->async_start), &displs[2]);
MPI_Get_address(&(mall_conf->times->malleability_start), &displs[3]);
for(i=0;i<counts;i++) displs[i] -= dir;
MPI_Type_create_struct(counts, blocklengths, displs, types, new_type);
MPI_Type_commit(new_type);
}
#ifndef MALLEABILITY_TIMES_H
#define MALLEABILITY_TIMES_H
#include <mpi.h>
#include "malleabilityDataStructures.h"
void init_malleability_times();
void reset_malleability_times();
void free_malleability_times();
void malleability_times_broadcast(int root);
void malleability_I_retrieve_times(double *sp_time, double *sy_time, double *asy_time, double *mall_time);
#endif
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