Commit c055d140 authored by iker_martin's avatar iker_martin
Browse files

Added debug prints and two minor bug fixes

parent 02447d0f
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
#include "distribution_methods/block_distribution.h" #include "distribution_methods/block_distribution.h"
#include "CommDist.h" #include "CommDist.h"
#include "malleabilityDataStructures.h"
//void prepare_redistribution(int qty, int myId, int numP, int numO, int is_children_group, int is_intercomm, char **recv, struct Counts *s_counts, struct Counts *r_counts); //void prepare_redistribution(int qty, int myId, int numP, int numO, int is_children_group, int is_intercomm, char **recv, struct Counts *s_counts, struct Counts *r_counts);
void prepare_redistribution(int qty, int myId, int numP, int numO, int is_children_group, int is_intercomm, int is_sync, char **recv, struct Counts *s_counts, struct Counts *r_counts); //FIXME Choose name for is_sync void prepare_redistribution(int qty, int myId, int numP, int numO, int is_children_group, int is_intercomm, int is_sync, char **recv, struct Counts *s_counts, struct Counts *r_counts); //FIXME Choose name for is_sync
...@@ -404,6 +405,9 @@ int async_communication_check(int myId, int is_children_group, int red_strategie ...@@ -404,6 +405,9 @@ int async_communication_check(int myId, int is_children_group, int red_strategie
*/ */
void async_communication_wait(int red_strategies, MPI_Comm comm, MPI_Request *requests, size_t request_qty) { void async_communication_wait(int red_strategies, MPI_Comm comm, MPI_Request *requests, size_t request_qty) {
MPI_Waitall(request_qty, requests, MPI_STATUSES_IGNORE); MPI_Waitall(request_qty, requests, MPI_STATUSES_IGNORE);
#if USE_MAL_DEBUG >= 3
DEBUG_FUNC("Targets Waitall completed", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
if(malleability_red_contains_strat(red_strategies, MALL_RED_IBARRIER, NULL)) { if(malleability_red_contains_strat(red_strategies, MALL_RED_IBARRIER, NULL)) {
MPI_Ibarrier(comm, &(requests[request_qty-1]) ); MPI_Ibarrier(comm, &(requests[request_qty-1]) );
MPI_Wait(&(requests[request_qty-1]), MPI_STATUS_IGNORE); //TODO Is it really needed? It will be ensured later MPI_Wait(&(requests[request_qty-1]), MPI_STATUS_IGNORE); //TODO Is it really needed? It will be ensured later
...@@ -573,6 +577,7 @@ void prepare_redistribution(int qty, int myId, int numP, int numO, int is_childr ...@@ -573,6 +577,7 @@ void prepare_redistribution(int qty, int myId, int numP, int numO, int is_childr
mallocCounts(r_counts, array_size+offset_ids); mallocCounts(r_counts, array_size+offset_ids);
if(is_children_group) { if(is_children_group) {
offset_ids = 0;
prepare_comm_alltoall(myId, numP, numO, qty, offset_ids, r_counts); prepare_comm_alltoall(myId, numP, numO, qty, offset_ids, r_counts);
// Obtener distribución para este hijo // Obtener distribución para este hijo
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#include "../Main/configuration.h" #include "../Main/configuration.h"
#include "../Main/Main_datatypes.h" #include "../Main/Main_datatypes.h"
#define DEBUG_FUNC(debug_string, rank, numP) printf("MaM [P%d/%d]: %s -- %s:%s:%d\n", rank, numP, debug_string, __FILE__, __func__, __LINE__)
/* --- PHYSICAL DIST STRUCTURE --- */ /* --- PHYSICAL DIST STRUCTURE --- */
struct physical_dist { struct physical_dist {
int num_cpus, num_nodes; int num_cpus, num_nodes;
......
...@@ -53,6 +53,10 @@ malleability_data_t *dist_a_data; ...@@ -53,6 +53,10 @@ malleability_data_t *dist_a_data;
int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec, char *nodelist, int num_cpus, int num_nodes) { int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_exec, char *nodelist, int num_cpus, int num_nodes) {
MPI_Comm dup_comm, thread_comm; MPI_Comm dup_comm, thread_comm;
#if USE_MAL_DEBUG
DEBUG_FUNC("Initializing MaM", myId, numP); fflush(stdout); MPI_Barrier(comm);
#endif
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));
...@@ -109,6 +113,10 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex ...@@ -109,6 +113,10 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex
//TODO Get name of each process and create real nodelist //TODO Get name of each process and create real nodelist
} }
#if USE_MAL_DEBUG
DEBUG_FUNC("MaM has been initialized correctly as parents", myId, numP); fflush(stdout); MPI_Barrier(comm);
#endif
return MALLEABILITY_NOT_CHILDREN; return MALLEABILITY_NOT_CHILDREN;
} }
...@@ -505,6 +513,10 @@ void Children_init() { ...@@ -505,6 +513,10 @@ void Children_init() {
int numP_parents, root_parents; int numP_parents, root_parents;
int is_intercomm; int is_intercomm;
#if USE_MAL_DEBUG
DEBUG_FUNC("MaM will now initialize children", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
malleability_connect_children(mall->myId, mall->numP, mall->root, mall->comm, &numP_parents, &root_parents, &(mall->intercomm)); malleability_connect_children(mall->myId, mall->numP, mall->root, mall->comm, &numP_parents, &root_parents, &(mall->intercomm));
MPI_Comm_test_inter(mall->intercomm, &is_intercomm); MPI_Comm_test_inter(mall->intercomm, &is_intercomm);
if(!is_intercomm) { // For intracommunicators, these processes will be added if(!is_intercomm) { // For intracommunicators, these processes will be added
...@@ -517,8 +529,15 @@ void Children_init() { ...@@ -517,8 +529,15 @@ 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);
#if USE_MAL_DEBUG
DEBUG_FUNC("Children have completed spawn step", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
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
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Children start asynchronous redistribution", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
#if USE_MAL_BARRIERS #if USE_MAL_BARRIERS
MPI_Barrier(mall->intercomm); MPI_Barrier(mall->intercomm);
#endif #endif
...@@ -528,9 +547,15 @@ void Children_init() { ...@@ -528,9 +547,15 @@ void Children_init() {
} else { } else {
recv_data(numP_parents, dist_a_data, MALLEABILITY_USE_ASYNCHRONOUS); recv_data(numP_parents, dist_a_data, MALLEABILITY_USE_ASYNCHRONOUS);
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Children started asynchronous redistribution", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
for(i=0; i<dist_a_data->entries; i++) { for(i=0; i<dist_a_data->entries; i++) {
async_communication_wait(mall_conf->red_strategies, mall->intercomm, dist_a_data->requests[i], dist_a_data->request_qty[i]); async_communication_wait(mall_conf->red_strategies, mall->intercomm, dist_a_data->requests[i], dist_a_data->request_qty[i]);
} }
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Children waited for all asynchronous redistributions", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
for(i=0; i<dist_a_data->entries; i++) { for(i=0; i<dist_a_data->entries; i++) {
async_communication_end(mall_conf->red_method, mall_conf->red_strategies, dist_a_data->requests[i], dist_a_data->request_qty[i], &(dist_a_data->windows[i])); async_communication_end(mall_conf->red_method, mall_conf->red_strategies, dist_a_data->requests[i], dist_a_data->request_qty[i], &(dist_a_data->windows[i]));
} }
...@@ -541,6 +566,9 @@ void Children_init() { ...@@ -541,6 +566,9 @@ void Children_init() {
#endif #endif
mall_conf->times->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
} }
#if USE_MAL_DEBUG
DEBUG_FUNC("Children have completed asynchronous data redistribution step", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
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);
if(dist_s_data->entries || rep_s_data->entries) { // Recibir datos sincronos if(dist_s_data->entries || rep_s_data->entries) { // Recibir datos sincronos
...@@ -565,6 +593,9 @@ void Children_init() { ...@@ -565,6 +593,9 @@ void Children_init() {
#endif #endif
mall_conf->times->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
} }
#if USE_MAL_DEBUG
DEBUG_FUNC("Children have completed synchronous data redistribution step", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
// Guardar los resultados de esta transmision // Guardar los resultados de esta transmision
malleability_times_broadcast(mall->root); malleability_times_broadcast(mall->root);
...@@ -577,6 +608,10 @@ void Children_init() { ...@@ -577,6 +608,10 @@ void Children_init() {
#endif #endif
mall_conf->times->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
#if USE_MAL_DEBUG
DEBUG_FUNC("MaM has been initialized correctly as children", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
} }
//======================================================|| //======================================================||
...@@ -682,6 +717,9 @@ int check_redistribution() { ...@@ -682,6 +717,9 @@ int check_redistribution() {
MPI_Request *req_completed; MPI_Request *req_completed;
MPI_Win window; MPI_Win window;
local_completed = 1; local_completed = 1;
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Originals are checking for all asynchronous redistributions", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
for(i=0; i<dist_a_data->entries; i++) { for(i=0; i<dist_a_data->entries; i++) {
req_completed = dist_a_data->requests[i]; req_completed = dist_a_data->requests[i];
...@@ -689,9 +727,15 @@ int check_redistribution() { ...@@ -689,9 +727,15 @@ int check_redistribution() {
completed = async_communication_check(mall->myId, MALLEABILITY_NOT_CHILDREN, mall_conf->red_strategies, mall->intercomm, req_completed, req_qty); completed = async_communication_check(mall->myId, MALLEABILITY_NOT_CHILDREN, mall_conf->red_strategies, mall->intercomm, req_completed, req_qty);
local_completed = local_completed && completed; local_completed = local_completed && completed;
} }
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Originals will now check a global decision", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
MPI_Allreduce(&local_completed, &all_completed, 1, MPI_INT, MPI_MIN, mall->comm); MPI_Allreduce(&local_completed, &all_completed, 1, MPI_INT, MPI_MIN, mall->comm);
if(!all_completed) return MALL_DIST_PENDING; // Continue only if asynchronous send has ended if(!all_completed) return MALL_DIST_PENDING; // Continue only if asynchronous send has ended
#if USE_MAL_DEBUG >= 2
DEBUG_FUNC("Originals sent asyncrhonous redistributions", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
#endif
for(i=0; i<dist_a_data->entries; i++) { for(i=0; i<dist_a_data->entries; i++) {
req_completed = dist_a_data->requests[i]; req_completed = dist_a_data->requests[i];
...@@ -952,3 +996,4 @@ void malleability_comms_update(MPI_Comm comm) { ...@@ -952,3 +996,4 @@ void malleability_comms_update(MPI_Comm comm) {
MPI_Comm_set_name(mall->comm, "MPI_COMM_MALL"); MPI_Comm_set_name(mall->comm, "MPI_COMM_MALL");
MPI_Comm_set_name(mall->user_comm, "MPI_COMM_MALL_USER"); MPI_Comm_set_name(mall->user_comm, "MPI_COMM_MALL_USER");
} }
...@@ -3,16 +3,22 @@ ...@@ -3,16 +3,22 @@
void def_malleability_times(MPI_Datatype *new_type); void def_malleability_times(MPI_Datatype *new_type);
void init_malleability_times() { void init_malleability_times() {
if(mall_conf->times == NULL) { #if USE_MAL_DEBUG
DEBUG_FUNC("Initializing recording structure", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(mall->comm);
#endif
mall_conf->times = (malleability_times_t *) malloc(sizeof(malleability_times_t)); mall_conf->times = (malleability_times_t *) malloc(sizeof(malleability_times_t));
if(mall_conf->times == NULL) { if(mall_conf->times == NULL) {
perror("Error al crear la estructura de tiempos interna para maleabilidad\n"); perror("Error al crear la estructura de tiempos interna para maleabilidad\n");
MPI_Abort(MPI_COMM_WORLD, -5); MPI_Abort(MPI_COMM_WORLD, -5);
} }
}
reset_malleability_times(); reset_malleability_times();
def_malleability_times(&mall_conf->times->times_type); def_malleability_times(&mall_conf->times->times_type);
#if USE_MAL_DEBUG
DEBUG_FUNC("Initialized recording structure", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(mall->comm);
#endif
} }
...@@ -24,6 +30,9 @@ void reset_malleability_times() { ...@@ -24,6 +30,9 @@ void reset_malleability_times() {
} }
void free_malleability_times() { void free_malleability_times() {
#if USE_MAL_DEBUG
DEBUG_FUNC("Freeing recording structure", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(mall->comm);
#endif
if(mall_conf->times != NULL) { if(mall_conf->times != NULL) {
if(mall_conf->times->times_type != MPI_DATATYPE_NULL) { if(mall_conf->times->times_type != MPI_DATATYPE_NULL) {
MPI_Type_free(&mall_conf->times->times_type); MPI_Type_free(&mall_conf->times->times_type);
...@@ -31,6 +40,9 @@ void free_malleability_times() { ...@@ -31,6 +40,9 @@ void free_malleability_times() {
} }
free(mall_conf->times); free(mall_conf->times);
} }
#if USE_MAL_DEBUG
DEBUG_FUNC("Freed recording structure", mall->myId, mall->numP); fflush(stdout); MPI_Barrier(mall->comm);
#endif
} }
void malleability_times_broadcast(int root) { void malleability_times_broadcast(int root) {
......
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