GRAS_DEFINE_TYPE(s_matrix,
struct s_matrix {
+ int lines;
int rows;
- int cols;
- double *ctn GRAS_ANNOTE(size, rows*cols);
+ double *ctn GRAS_ANNOTE(size, lines*rows);
};)
typedef struct s_matrix matrix_t;
/* 7. Prepare and send the request to the server */
- request[0].rows=request[0].cols=request[1].rows=request[1].cols=MATSIZE;
+ request[0].lines=request[0].rows=request[1].lines=request[1].rows=MATSIZE;
request[0].ctn=xbt_malloc0(sizeof(double)*MATSIZE*MATSIZE);
request[1].ctn=xbt_malloc0(sizeof(double)*MATSIZE*MATSIZE);
void mat_dump(matrix_t *mat, const char* name) {
int i,j;
- printf(">>> Matrix %s dump (%d x %d)\n",name,mat->rows,mat->cols);
- for (i=0; i<mat->rows; i++) {
+ printf(">>> Matrix %s dump (%d x %d)\n",name,mat->lines,mat->rows);
+ for (i=0; i<mat->lines; i++) {
printf(" ");
- for (j=0; j<mat->cols; j++)
- printf(" %.2f",mat->ctn[i*mat->cols + j]);
+ for (j=0; j<mat->rows; j++)
+ printf(" %.2f",mat->ctn[i*mat->rows + j]);
printf("\n");
}
printf("<<< end_of_matrix %s dump\n",name);
int i,j,k;
/* 2. Make some room to return the result */
- result.rows = data[0].rows;
- result.cols = data[1].cols;
- result.ctn = xbt_malloc0(sizeof(double) * result.rows * result.cols);
+ result.lines = data[0].lines;
+ result.rows = data[1].rows;
+ result.ctn = xbt_malloc0(sizeof(double) * result.lines * result.rows);
/* 3. Do the computation */
- for (i=0; i<result.rows; i++)
- for (j=0; j<result.cols; j++)
- for (k=0; k<data[1].rows; k++)
- result.ctn[i*result.cols + j] += data[0].ctn[i*result.cols +k] *data[1].ctn[k*result.cols +j];
+ for (i=0; i<result.lines; i++)
+ for (j=0; j<result.rows; j++)
+ for (k=0; k<data[1].lines; k++)
+ result.ctn[i*result.rows + j] += data[0].ctn[i*result.rows +k] *data[1].ctn[k*result.rows +j];
/* 4. Send it back as payload of a pong message to the expeditor */
gras_msg_send(expeditor, gras_msgtype_by_name("answer"), &result);