Commit 1b43c2cb authored by iker_martin's avatar iker_martin
Browse files

Minor changes before executing.

parent d5d7427a
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <string.h> #include <string.h>
#include "../malleability/malleabilityManager.h" #include "../malleability/malleabilityManager.h"
#include<unistd.h> #include <unistd.h>
//#define ONLY_SYM 0 //#define ONLY_SYM 0
#define ROOT 0 #define ROOT 0
...@@ -124,6 +124,7 @@ int main (int argc, char *argv[]) { ...@@ -124,6 +124,7 @@ int main (int argc, char *argv[]) {
terminate = compute(&computeData, &dist_data, sm); terminate = compute(&computeData, &dist_data, sm);
if(terminate) { if(terminate) {
update_dist_data(&dist_data);
MPI_Barrier(dist_data.comm); MPI_Barrier(dist_data.comm);
if(dist_data.myId == ROOT) { if(dist_data.myId == ROOT) {
print_global_results(); print_global_results();
...@@ -134,6 +135,9 @@ int main (int argc, char *argv[]) { ...@@ -134,6 +135,9 @@ int main (int argc, char *argv[]) {
// End of CG // End of CG
free_malleability(); free_malleability();
free_computeData(&computeData, 1); free_computeData(&computeData, 1);
if(sm && numP > num_children && dist_data.myId == 0) {
MPI_Abort(MPI_COMM_WORLD, -100);
}
MPI_Finalize(); MPI_Finalize();
} }
...@@ -383,12 +387,12 @@ void pre_compute(Compute_data *computeData, struct Dist_data dist_data, double * ...@@ -383,12 +387,12 @@ void pre_compute(Compute_data *computeData, struct Dist_data dist_data, double *
#else #else
ProdSparseMatrixVector (computeData->subm, full_vec, computeData->z); // z += A * full_x ProdSparseMatrixVector (computeData->subm, full_vec, computeData->z); // z += A * full_x
#endif #endif
dcopy (&(dist_data.tamBl), subsol, &IONE, computeData->res, &IONE); // res = b rcopy (&(dist_data.tamBl), subsol, &IONE, computeData->res, &IONE); // res = b
daxpy (&(dist_data.tamBl), &DMONE, computeData->z, &IONE, computeData->res, &IONE); // res -= z raxpy (&(dist_data.tamBl), &DMONE, computeData->z, &IONE, computeData->res, &IONE); // res -= z
//dcopy (&(computeData.subm.dim1), computeData.res, &IONE, &(computeData.d+computeData.displs_rows[myId]), &IONE); // d_full = res //rcopy (&(computeData.subm.dim1), computeData.res, &IONE, &(computeData.d+computeData.displs_rows[myId]), &IONE); // d_full = res
MPI_Allgatherv(computeData->res, dist_data.tamBl, MPI_DOUBLE, computeData->d_full, computeData->dist_rows, computeData->displs_rows, MPI_DOUBLE, MPI_COMM_WORLD); MPI_Allgatherv(computeData->res, dist_data.tamBl, MPI_DOUBLE, computeData->d_full, computeData->dist_rows, computeData->displs_rows, MPI_DOUBLE, MPI_COMM_WORLD);
dcopy (&(dist_data.tamBl), &(computeData->d_full[dist_data.ini]), &IONE, computeData->d, &IONE); // d = d_full[ini] to d_full[ini+tamBl] rcopy (&(dist_data.tamBl), &(computeData->d_full[dist_data.ini]), &IONE, computeData->d, &IONE); // d = d_full[ini] to d_full[ini+tamBl]
computeData->beta = ddot (&(dist_data.tamBl), computeData->res, &IONE, computeData->res, &IONE); // beta = res' * res computeData->beta = rdot (&(dist_data.tamBl), computeData->res, &IONE, computeData->res, &IONE); // beta = res' * res
MPI_Allreduce(MPI_IN_PLACE, &computeData->beta, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(MPI_IN_PLACE, &computeData->beta, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
computeData->tol = sqrt (computeData->beta); // tol = sqrt(beta) = norm (res) computeData->tol = sqrt (computeData->beta); // tol = sqrt(beta) = norm (res)
} }
...@@ -408,25 +412,24 @@ int compute(Compute_data *computeData, struct Dist_data *dist_data, int sm) { ...@@ -408,25 +412,24 @@ int compute(Compute_data *computeData, struct Dist_data *dist_data, int sm) {
while ((computeData->iter < computeData->maxiter) && (computeData->tol > computeData->umbral)) { while ((computeData->iter < computeData->maxiter) && (computeData->tol > computeData->umbral)) {
//TODO Hacer un estudio de los valores escalares para la iteración 501
// COMPUTATION // COMPUTATION
#ifdef ONLY_SYM #ifdef ONLY_SYM
ProdSymSparseMatrixVector (computeData->subm, computeData->d_full, computeData->z); // z += A * d_full ProdSymSparseMatrixVector (computeData->subm, computeData->d_full, computeData->z); // z += A * d_full
#else #else
ProdSparseMatrixVector (computeData->subm, computeData->d_full, computeData->z); // z += A * d_full ProdSparseMatrixVector (computeData->subm, computeData->d_full, computeData->z); // z += A * d_full
#endif #endif
computeData->rho = ddot (&(dist_data->tamBl), computeData->d, &IONE, computeData->z, &IONE); // rho = (d * z) computeData->rho = rdot (&(dist_data->tamBl), computeData->d, &IONE, computeData->z, &IONE); // rho = (d * z)
MPI_Allreduce(MPI_IN_PLACE, &computeData->rho, 1, MPI_DOUBLE, MPI_SUM, dist_data->comm); // Reduce(rho, SUM) MPI_Allreduce(MPI_IN_PLACE, &computeData->rho, 1, MPI_DOUBLE, MPI_SUM, dist_data->comm); // Reduce(rho, SUM)
computeData->rho = computeData->beta / computeData->rho; // rho = beta / aux computeData->rho = computeData->beta / computeData->rho; // rho = beta / aux
daxpy (&(dist_data->tamBl), &computeData->rho, computeData->d, &IONE, computeData->vec, &IONE); // x += rho * d raxpy (&(dist_data->tamBl), &computeData->rho, computeData->d, &IONE, computeData->vec, &IONE); // x += rho * d
computeData->rho = -computeData->rho; computeData->rho = -computeData->rho;
daxpy (&(dist_data->tamBl), &computeData->rho, computeData->z, &IONE, computeData->res, &IONE); // res -= rho * z raxpy (&(dist_data->tamBl), &computeData->rho, computeData->z, &IONE, computeData->res, &IONE); // res -= rho * z
computeData->alpha = computeData->beta; // alpha = beta computeData->alpha = computeData->beta; // alpha = beta
computeData->beta = ddot (&(dist_data->tamBl), computeData->res, &IONE, computeData->res, &IONE); // beta = res' * res computeData->beta = rdot (&(dist_data->tamBl), computeData->res, &IONE, computeData->res, &IONE); // beta = res' * res
MPI_Allreduce(MPI_IN_PLACE, &computeData->beta, 1, MPI_DOUBLE, MPI_SUM, dist_data->comm); // Reduce(beta, SUM) MPI_Allreduce(MPI_IN_PLACE, &computeData->beta, 1, MPI_DOUBLE, MPI_SUM, dist_data->comm); // Reduce(beta, SUM)
computeData->alpha = computeData->beta / computeData->alpha; // alpha = beta / alpha computeData->alpha = computeData->beta / computeData->alpha; // alpha = beta / alpha
dscal (&(dist_data->tamBl), &computeData->alpha, computeData->d, &IONE); // d = alpha * d rscal (&(dist_data->tamBl), &computeData->alpha, computeData->d, &IONE); // d = alpha * d
daxpy (&(dist_data->tamBl), &DONE, computeData->res, &IONE, computeData->d, &IONE); // d += res raxpy (&(dist_data->tamBl), &DONE, computeData->res, &IONE, computeData->d, &IONE); // d += res
MPI_Allgatherv(computeData->d, dist_data->tamBl, MPI_DOUBLE, computeData->d_full, MPI_Allgatherv(computeData->d, dist_data->tamBl, MPI_DOUBLE, computeData->d_full,
computeData->dist_rows, computeData->displs_rows, MPI_DOUBLE, dist_data->comm); // d_full = Gather(d) computeData->dist_rows, computeData->displs_rows, MPI_DOUBLE, dist_data->comm); // d_full = Gather(d)
...@@ -668,7 +671,7 @@ void dist_new(struct Dist_data *dist_data, Compute_data *computeData) { ...@@ -668,7 +671,7 @@ void dist_new(struct Dist_data *dist_data, Compute_data *computeData) {
get_dist(computeData->n, dist_data->myId, dist_data->numP, dist_data); get_dist(computeData->n, dist_data->myId, dist_data->numP, dist_data);
get_rows_dist(computeData, dist_data->numP, computeData->n); get_rows_dist(computeData, dist_data->numP, computeData->n);
CreateDoubles(&computeData->d, dist_data->tamBl); CreateDoubles(&computeData->d, dist_data->tamBl);
dcopy (&(dist_data->tamBl), &(computeData->d_full[dist_data->ini]), &IONE, computeData->d, &IONE); // d = d_full[ini] to d_full[ini+tamBl] rcopy (&(dist_data->tamBl), &(computeData->d_full[dist_data->ini]), &IONE, computeData->d, &IONE); // d = d_full[ini] to d_full[ini+tamBl]
malleability_get_entries(&entries, 0, 0); //Get if there is any asynch data to recover malleability_get_entries(&entries, 0, 0); //Get if there is any asynch data to recover
if(entries) { is_synch=0; entry=0; } if(entries) { is_synch=0; entry=0; }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "distribution_methods/block_distribution.h" #include "distribution_methods/block_distribution.h"
#include "CommDist.h" #include "CommDist.h"
void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO, int is_children_group, int is_intercomm, void **recv, struct Counts *s_counts, struct Counts *r_counts); void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO, int is_children_group, int is_intercomm, int is_sync, void **recv, struct Counts *s_counts, struct Counts *r_counts);
void check_requests(struct Counts s_counts, struct Counts r_counts, MPI_Request **requests, size_t *request_qty); void check_requests(struct Counts s_counts, struct Counts r_counts, MPI_Request **requests, size_t *request_qty);
void sync_point2point(void *send, void *recv, int mal_type, int is_intercomm, int myId, struct Counts s_counts, struct Counts r_counts, MPI_Comm comm); void sync_point2point(void *send, void *recv, int mal_type, int is_intercomm, int myId, struct Counts s_counts, struct Counts r_counts, MPI_Comm comm);
...@@ -76,13 +76,13 @@ int sync_communication(void *send, void **recv, int qty, int mal_type, int depen ...@@ -76,13 +76,13 @@ int sync_communication(void *send, void **recv, int qty, int mal_type, int depen
/* PREPARE COMMUNICATION */ /* PREPARE COMMUNICATION */
MPI_Comm_test_inter(comm, &is_intercomm); MPI_Comm_test_inter(comm, &is_intercomm);
prepare_redistribution(qty, mal_type, myId, numP, numO, is_children_group, is_intercomm, recv, &s_counts, &r_counts); prepare_redistribution(qty, mal_type, myId, numP, numO, is_children_group, is_intercomm, 1, recv, &s_counts, &r_counts);
/*
if(is_intercomm) { if(is_intercomm) {
MPI_Intercomm_merge(comm, is_children_group, &aux_comm); MPI_Intercomm_merge(comm, is_children_group, &aux_comm);
aux_comm_used = 1; aux_comm_used = 1;
} } else { aux_comm = comm; }
*/
if(mal_type == MAL_INT) { if(mal_type == MAL_INT) {
datatype = MPI_INT; datatype = MPI_INT;
} else if(mal_type == MAL_DOUBLE) { } else if(mal_type == MAL_DOUBLE) {
...@@ -112,11 +112,11 @@ int sync_communication(void *send, void **recv, int qty, int mal_type, int depen ...@@ -112,11 +112,11 @@ int sync_communication(void *send, void **recv, int qty, int mal_type, int depen
/* PERFORM COMMUNICATION */ /* PERFORM COMMUNICATION */
switch(red_method) { switch(red_method) {
case MALL_RED_POINT: case MALL_RED_POINT:
sync_point2point(send, *recv, mal_type, is_intercomm, myId, s_counts, r_counts, comm); sync_point2point(send, *recv, mal_type, is_intercomm, myId, s_counts, r_counts, aux_comm);
break; break;
case MALL_RED_BASELINE: case MALL_RED_BASELINE:
default: default:
MPI_Alltoallv(send, s_counts.counts, s_counts.displs, datatype, *recv, r_counts.counts, r_counts.displs, datatype, comm); MPI_Alltoallv(send, s_counts.counts, s_counts.displs, datatype, *recv, r_counts.counts, r_counts.displs, datatype, aux_comm);
break; break;
} }
...@@ -253,7 +253,7 @@ int async_communication(void *send, void **recv, int qty, int mal_type, int depe ...@@ -253,7 +253,7 @@ int async_communication(void *send, void **recv, int qty, int mal_type, int depe
/* PREPARE COMMUNICATION */ /* PREPARE COMMUNICATION */
MPI_Comm_test_inter(comm, &is_intercomm); MPI_Comm_test_inter(comm, &is_intercomm);
prepare_redistribution(qty, mal_type, myId, numP, numO, is_children_group, is_intercomm, recv, &s_counts, &r_counts); prepare_redistribution(qty, mal_type, myId, numP, numO, is_children_group, is_intercomm, 0, recv, &s_counts, &r_counts);
check_requests(s_counts, r_counts, requests, request_qty); check_requests(s_counts, r_counts, requests, request_qty);
if(mal_type == MAL_INT) { if(mal_type == MAL_INT) {
...@@ -394,7 +394,7 @@ void async_point2point(void *send, void *recv, int mal_type, struct Counts s_cou ...@@ -394,7 +394,7 @@ void async_point2point(void *send, void *recv, int mal_type, struct Counts s_cou
* - r_counts (OUT): Struct where is indicated how many elements receives this process from other processes in the previous group. * - r_counts (OUT): Struct where is indicated how many elements receives this process from other processes in the previous group.
* *
*/ */
void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO, int is_children_group, int is_intercomm, void **recv, struct Counts *s_counts, struct Counts *r_counts) { void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO, int is_children_group, int is_intercomm, int is_sync, void **recv, struct Counts *s_counts, struct Counts *r_counts) {
int array_size = numO; int array_size = numO;
int offset_ids = 0; int offset_ids = 0;
size_t datasize; size_t datasize;
...@@ -411,8 +411,8 @@ void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO, ...@@ -411,8 +411,8 @@ void prepare_redistribution(int qty, int mal_type, int myId, int numP, int numO,
MPI_Abort(MPI_COMM_WORLD, -1); MPI_Abort(MPI_COMM_WORLD, -1);
} }
if(is_intercomm) { if(is_intercomm && is_sync) {
//offset_ids = numP; //FIXME Modify only if active? offset_ids = numP; //FIXME Modify only if active?
} else { } else {
array_size = numP > numO ? numP : numO; array_size = numP > numO ? numP : numO;
} }
......
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