Commit d8139b51 authored by iker_martin's avatar iker_martin
Browse files

Matrix computation fixed

parent df17a353
......@@ -12,7 +12,8 @@
#include "../malleability/malleabilityManager.h"
#include "../malleability/malleabilityStates.h"
#define DR_MAX_SIZE 1000000000
//#define DR_MAX_SIZE 1000000000
#define DR_MAX_SIZE 600000000
int work();
double iterate(int async_comm);
......
......@@ -7,18 +7,32 @@
/*
* Realiza una multiplicación de matrices de tamaño n
*/
double computeMatrix(double *matrix, int n) { //FIXME No da tiempos repetibles
double computeMatrix(double *matrix, int n) {
int row, col;
double aux;
aux=0;
for(row=0; row<n; row++) {
for(col=0; col<n; col++) {
aux += ( (int)(matrix[row*n + col] + exp(sqrt(row*col))) % n);
aux += (int)(matrix[row*n + col] * matrix[row*n + col]);
}
}
return aux;
}
/*
double computeMatrix(double *matrix, int n) {
int row, col;
double aux;
aux=0;
for(row=0; row<n; row++) {
for(col=0; col<n; col++) {
aux += ( (int)(matrix[row*n + col] + exp(sqrt(row*col))) % n);
}
}
return aux;
}*/
double computePiSerial(int n) {
int i;
......@@ -35,24 +49,26 @@ double computePiSerial(int n) {
//MPI_Reduce(&sum, &res, 1, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
}
/*
* Init matrix
*/
void initMatrix(double **matrix, size_t n) {
size_t i, j;
double *aux = NULL;
freeMatrix(matrix);
// Init matrix
if(matrix != NULL) {
*matrix = malloc(n * n * sizeof(double));
if(*matrix == NULL) { MPI_Abort(MPI_COMM_WORLD, -1);}
aux = (double *) malloc(n * n * sizeof(double));
if(aux == NULL) { perror("Computing matrix could not be allocated"); MPI_Abort(MPI_COMM_WORLD, -1);}
for(i=0; i < n; i++) {
for(j=0; j < n; j++) {
(*matrix)[i*n + j] = i+j;
}
aux[i*n + j] = (i+j) * 1.1;
}
}
*matrix = aux;
}
......
......@@ -36,7 +36,7 @@ double init_comm_reduce_pt(group_data group, configuration *config_file, iter_st
*/
double init_stage(configuration *config_file, int stage_i, group_data group, MPI_Comm comm, int compute) {
double result = 0;
int qty = 20000;
int qty = 1000;
iter_stage_t *stage = &(config_file->stages[stage_i]);
stage->operations = qty;
......@@ -183,6 +183,7 @@ double init_matrix_pt(group_data group, configuration *config_file, iter_stage_t
t_stage = stage->t_stage * config_file->groups[group.grp].factor;
initMatrix(&(stage->double_array), config_file->granularity);
if(compute) {
if(group.myId == ROOT) {
start_time = MPI_Wtime();
......
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