Commit 8542201a authored by iker_martin's avatar iker_martin
Browse files

Finalizada implementacion de regresion lineal con todas las colectivas

parent dae36bb8
...@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) { ...@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
if(res==1) { // Se ha llegado al final de la aplicacion if(res==1) { // Se ha llegado al final de la aplicacion
MPI_Barrier(comm); // TODO Posible error al utilizar SHRINK MPI_Barrier(comm); // TODO Posible error al utilizar SHRINK
results->exec_time = MPI_Wtime() - results->exec_start - result->wasted_time; results->exec_time = MPI_Wtime() - results->exec_start - results->wasted_time;
} }
print_final_results(); // Pasado este punto ya no pueden escribir los procesos print_final_results(); // Pasado este punto ya no pueden escribir los procesos
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <math.h> #include <math.h>
#include <mpi.h> #include <mpi.h>
#include "Main_datatypes.h" #include "Main_datatypes.h"
#include "../malleability/distribution_methods/block_distribution.h"
#include "linear_reg.h" #include "linear_reg.h"
...@@ -113,35 +114,91 @@ void lr_times_bcast(int myId, int numP, int root, MPI_Comm comm, int loop_iters, ...@@ -113,35 +114,91 @@ void lr_times_bcast(int myId, int numP, int root, MPI_Comm comm, int loop_iters,
* Obtains an array of times to perform an "Allgatherv" * Obtains an array of times to perform an "Allgatherv"
* operation depending on a predifined set of number of bytes. * operation depending on a predifined set of number of bytes.
*/ */
/*
void lr_times_allgatherv(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times) { void lr_times_allgatherv(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times) {
int i, j, n; int i, j, n;
int *counts, *displs;
double start_time; double start_time;
char *aux = NULL; char *aux = NULL, *aux_full = NULL;
struct Dist_data dist_data;
struct Counts counts;
for(i=0; i<LR_ARRAY_TAM; i++) {
n = LR_bytes_array[i];
prepare_comm_allgatherv(numP, n, &counts);
get_block_dist(n, myId, numP, &dist_data);
aux = malloc(dist_data.tamBl * sizeof(char));
aux_full = malloc(n * sizeof(char));
for(j=0; j<loop_iters; j++) {
MPI_Barrier(comm);
start_time = MPI_Wtime();
MPI_Allgatherv(aux, dist_data.tamBl, MPI_CHAR, aux_full, counts.counts, counts.displs, MPI_CHAR, comm);
times[i*loop_iters+j] = MPI_Wtime() - start_time;
}
counts = calloc(numP,sizeof(int)); freeCounts(&counts);
displs = calloc(numP,sizeof(int)); free(aux);
free(aux_full);
aux_full = NULL;
aux = NULL;
}
}
/*
* Obtains an array of times to perform an "Reduce"
* operation depending on a predifined set of number of bytes.
*/
void lr_times_reduce(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times) {
int i, j, n;
double start_time;
char *aux = NULL, *aux_full = NULL;
for(i=0; i<LR_ARRAY_TAM; i++) { for(i=0; i<LR_ARRAY_TAM; i++) {
n = LR_bytes_array[i]; n = LR_bytes_array[i];
aux = malloc( * sizeof(char));
aux = malloc(n * sizeof(char));
aux_full = malloc(n * sizeof(char)); aux_full = malloc(n * sizeof(char));
for(j=0; j<loop_iters; j++) { for(j=0; j<loop_iters; j++) {
MPI_Barrier(comm); MPI_Barrier(comm);
start_time = MPI_Wtime(); start_time = MPI_Wtime();
MPI_Allgatherv(aux, stage_data.my_bytes, MPI_CHAR, aux_full, counts, displs, MPI_CHAR, comm); MPI_Reduce(aux, aux_full, n, MPI_CHAR, MPI_MAX, root, comm);
times[i*loop_iters+j] = MPI_Wtime() - start_time; times[i*loop_iters+j] = MPI_Wtime() - start_time;
} }
free(aux);
free(aux_full);
aux_full = NULL;
aux = NULL;
}
}
/*
* Obtains an array of times to perform an "Allreduce"
* operation depending on a predifined set of number of bytes.
*/
void lr_times_allreduce(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times) {
int i, j, n;
double start_time;
char *aux = NULL, *aux_full = NULL;
for(i=0; i<LR_ARRAY_TAM; i++) {
n = LR_bytes_array[i];
aux = malloc(n * sizeof(char));
aux_full = malloc(n * sizeof(char));
for(j=0; j<loop_iters; j++) {
MPI_Barrier(comm);
start_time = MPI_Wtime();
MPI_Allreduce(aux, aux_full, n, MPI_CHAR, MPI_MAX, comm);
times[i*loop_iters+j] = MPI_Wtime() - start_time;
}
free(aux); free(aux);
free(aux_full); free(aux_full);
aux_full = NULL; aux_full = NULL;
aux = NULL; aux = NULL;
} }
free(counts);
free(displs);
} }
*/
...@@ -14,5 +14,8 @@ void lr_calc_Y(double slope, double intercept, double x_value, int *y_result); ...@@ -14,5 +14,8 @@ void lr_calc_Y(double slope, double intercept, double x_value, int *y_result);
void lr_compute(int loop_iters, double *bytes, double *times, double *slope, double *intercept); void lr_compute(int loop_iters, double *bytes, double *times, double *slope, double *intercept);
void lr_times_bcast(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times); void lr_times_bcast(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times);
void lr_times_allgatherv(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times);
void lr_times_reduce(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times);
void lr_times_allreduce(int myId, int numP, int root, MPI_Comm comm, int loop_iters, double *times);
#endif #endif
...@@ -225,10 +225,13 @@ void linear_regression_stage(iter_stage_t *stage, group_data group, MPI_Comm com ...@@ -225,10 +225,13 @@ void linear_regression_stage(iter_stage_t *stage, group_data group, MPI_Comm com
lr_times_bcast(group.myId, group.numP, ROOT, comm, loop_iters, times); lr_times_bcast(group.myId, group.numP, ROOT, comm, loop_iters, times);
break; break;
case COMP_ALLGATHER: case COMP_ALLGATHER:
lr_times_allgatherv(group.myId, group.numP, ROOT, comm, loop_iters, times);
break; break;
case COMP_REDUCE: case COMP_REDUCE:
lr_times_reduce(group.myId, group.numP, ROOT, comm, loop_iters, times);
break; break;
case COMP_ALLREDUCE: case COMP_ALLREDUCE:
lr_times_allreduce(group.myId, group.numP, ROOT, comm, loop_iters, times);
break; break;
default: default:
return; return;
......
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