-/* pmm - parallel matrix multiplication "double diffusion" */
+/* pmm - double broadcast parallel matrix multiplication */
-/* Copyright (c) 2006-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/matrix.h"
#include "xbt/xbt_os_time.h"
-/** @addtogroup MSG_examples
- *
- * - <b>pmm/msg_pmm.c</b>: Parallel Matrix Multiplication is a little application. This is something that most MPI
- * developers have written during their class, here implemented using MSG instead of MPI.
- */
-
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pmm, "Messages specific for this msg example");
/* This example should always be executed using a deployment of GRID_SIZE * GRID_SIZE nodes. */
{
char my_mbox[MAILBOX_NAME_SIZE];
node_job_t myjob, jobs[GRID_NUM_NODES];
- xbt_matrix_t A, B, C, sA, sB, sC;
+ xbt_matrix_t A = NULL;
+ xbt_matrix_t B = NULL;
+ xbt_matrix_t C = NULL;
result_t result;
xbt_assert(argc != 1, "Wrong number of arguments for this node");
/* Initialize the node's data-structures */
int myid = xbt_str_parse_int(argv[1], "Invalid ID received as first node parameter: %s");
snprintf(my_mbox, MAILBOX_NAME_SIZE - 1, "%d", myid);
- sC = xbt_matrix_double_new_zeros(NODE_MATRIX_SIZE, NODE_MATRIX_SIZE);
+ xbt_matrix_t sC = xbt_matrix_double_new_zeros(NODE_MATRIX_SIZE, NODE_MATRIX_SIZE);
- if(myid == 0){
+ if (myid == 0){
/* Create the matrices to multiply and one to store the result */
A = xbt_matrix_double_new_id(MATRIX_SIZE, MATRIX_SIZE);
B = xbt_matrix_double_new_seq(MATRIX_SIZE, MATRIX_SIZE);
broadcast_jobs(jobs + 1);
} else {
- A = B = C = NULL; /* Avoid warning at compilation */
myjob = wait_job(myid);
}
/* Multiplication main-loop */
XBT_VERB("Start Multiplication's Main-loop");
for (int k=0; k < GRID_SIZE; k++){
+ xbt_matrix_t sA;
+ xbt_matrix_t sB;
+
if(k == myjob->col){
XBT_VERB("Broadcast sA(%d,%d) to row %d", myjob->row, k, myjob->row);
broadcast_matrix(myjob->A, NEIGHBOURS_COUNT, myjob->nodes_in_row);
static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs)
{
- int row = 0, col = 0;
+ int row = 0;
+ int col = 0;
for (int node = 0; node < GRID_NUM_NODES; node++){
XBT_VERB("Create job %d", node);