X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/14b05fb84012709086290492445a2154c69b673b..9fa16e4064e1789bb1c56e0862ec6e03194a959c:/examples/msg/pmm/msg_pmm.c diff --git a/examples/msg/pmm/msg_pmm.c b/examples/msg/pmm/msg_pmm.c index ba8a65c1c4..6a0e8a9aac 100644 --- a/examples/msg/pmm/msg_pmm.c +++ b/examples/msg/pmm/msg_pmm.c @@ -1,11 +1,12 @@ /* pmm - parallel matrix multiplication "double diffusion" */ -/* Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011. The SimGrid Team. +/* Copyright (c) 2006-2015. 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 "msg/msg.h" + +#include "simgrid/msg.h" #include "xbt/matrix.h" #include "xbt/log.h" @@ -28,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pmm, /* This example should always be executed using a deployment of * GRID_SIZE * GRID_SIZE nodes. */ #define GRID_SIZE 3 /* Modify to adjust the grid's size */ -#define NODE_MATRIX_SIZE 300 /* Ammount of work done by each node*/ +#define NODE_MATRIX_SIZE 300 /* Amount of work done by each node*/ #define GRID_NUM_NODES GRID_SIZE * GRID_SIZE #define MATRIX_SIZE NODE_MATRIX_SIZE * GRID_SIZE @@ -63,7 +64,6 @@ static node_job_t wait_job(int selfid); static void broadcast_matrix(xbt_matrix_t M, int num_nodes, int *nodes); static void get_sub_matrix(xbt_matrix_t *sM, int selfid); static void receive_results(result_t *results); -static void task_cleanup(void *arg); int node(int argc, char **argv) { @@ -216,8 +216,8 @@ static node_job_t wait_job(int selfid) msg_error_t err; snprintf(self_mbox, MAILBOX_NAME_SIZE - 1, "%d", selfid); err = MSG_task_receive(&task, self_mbox); - if (err != MSG_OK) - xbt_die("Error while receiving from %s (%d)", self_mbox, (int)err); + xbt_assert(err == MSG_OK, "Error while receiving from %s (%d)", + self_mbox, (int)err); job = (node_job_t)MSG_task_get_data(task); MSG_task_destroy(task); XBT_VERB("Got Job (%d,%d)", job->row, job->col); @@ -236,7 +236,7 @@ static void broadcast_matrix(xbt_matrix_t M, int num_nodes, int *nodes) snprintf(node_mbox, MAILBOX_NAME_SIZE - 1, "%d", nodes[node]); sM = xbt_matrix_new_sub(M, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, NULL); task = MSG_task_create("sub-matrix", 100, 100, sM); - MSG_task_dsend(task, node_mbox, task_cleanup); + MSG_task_dsend(task, node_mbox, NULL); XBT_DEBUG("sub-matrix sent to %s", node_mbox); } @@ -258,20 +258,13 @@ static void get_sub_matrix(xbt_matrix_t *sM, int selfid) MSG_task_destroy(task); } -static void task_cleanup(void *arg){ - msg_task_t task = (msg_task_t)arg; - xbt_matrix_t m = (xbt_matrix_t)MSG_task_get_data(task); - xbt_matrix_free(m); - MSG_task_destroy(task); -} - /** * \brief Main function. */ int main(int argc, char *argv[]) { #ifdef BENCH_THIS_CODE - xbt_os_timer_t timer = xbt_os_timer_new(); + xbt_os_cputimer_t timer = xbt_os_timer_new(); #endif MSG_init(&argc, argv); @@ -286,18 +279,15 @@ int main(int argc, char *argv[]) MSG_launch_application(application_file); #ifdef BENCH_THIS_CODE - xbt_os_timer_start(timer); + xbt_os_cputimer_start(timer); #endif msg_error_t res = MSG_main(); #ifdef BENCH_THIS_CODE - xbt_os_timer_stop(timer); + xbt_os_cputimer_stop(timer); #endif XBT_CRITICAL("Simulated time: %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs)