From: cristianrosa Date: Thu, 27 Jan 2011 11:00:18 +0000 (+0000) Subject: Add MSG's parallel_contexts example. X-Git-Tag: v3.6_beta2~413 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0967cf4cf43137b6e0ec47bdc60baa51c07c0b73 Add MSG's parallel_contexts example. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9516 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 864e231433..ecf5d2ecd6 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -55,6 +55,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/trace) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/icomms) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/chord) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_contexts) if(HAVE_MC) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/mc) diff --git a/examples/msg/parallel_contexts/CMakeLists.txt b/examples/msg/parallel_contexts/CMakeLists.txt new file mode 100644 index 0000000000..b66dfb4a23 --- /dev/null +++ b/examples/msg/parallel_contexts/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6) + +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(pcontexts "pcontexts.c") + +### Add definitions for compile +if(WIN32) +target_link_libraries(pcontexts simgrid ) +else(WIN32) +target_link_libraries(pcontexts simgrid m ) +endif(WIN32) diff --git a/examples/msg/parallel_contexts/deployment_pcontexts_2.xml b/examples/msg/parallel_contexts/deployment_pcontexts_2.xml new file mode 100644 index 0000000000..61e4653084 --- /dev/null +++ b/examples/msg/parallel_contexts/deployment_pcontexts_2.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/examples/msg/parallel_contexts/deployment_pcontexts_4.xml b/examples/msg/parallel_contexts/deployment_pcontexts_4.xml new file mode 100644 index 0000000000..3fc123311f --- /dev/null +++ b/examples/msg/parallel_contexts/deployment_pcontexts_4.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/examples/msg/parallel_contexts/pcontexts.c b/examples/msg/parallel_contexts/pcontexts.c new file mode 100644 index 0000000000..39fef0c26e --- /dev/null +++ b/examples/msg/parallel_contexts/pcontexts.c @@ -0,0 +1,72 @@ +#include +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, + "Messages specific for this msg example"); +#define MAX_ITER 200000 +#define WORK 100000 + +int node(int argc, char **argv); +MSG_error_t test_all(const char *, const char *); +int main(int argc, char *argv[]); + +int node(int argc, char** argv) +{ + int i,j; + m_task_t task; + + for(i=0; i < MAX_ITER; i++){ + task = MSG_task_create("test", 100000000, 1, NULL); + + for(j=0; j < WORK; j++); + + MSG_task_execute(task); + INFO0("Task successfully executed"); + MSG_task_destroy(task); + } + + return 0; +} + +/** Test function */ +MSG_error_t test_all(const char *platform_file, + const char *application_file) +{ + MSG_error_t res = MSG_OK; + + /* MSG_config("workstation/model","KCCFLN05"); */ + { /* Simulation setting */ + MSG_set_channel_number(0); + MSG_create_environment(platform_file); + } + { /* Application deployment */ + MSG_function_register("node", node); + MSG_launch_application(application_file); + } + res = MSG_main(); + + INFO1("Simulation time %g", MSG_get_clock()); + return res; +} /* end_of_test_all */ + + +/** Main function */ +int main(int argc, char *argv[]) +{ + MSG_error_t res = MSG_OK; + + MSG_global_init(&argc, argv); + if (argc < 3) { + printf("Usage: %s platform_file deployment_file\n", argv[0]); + printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); + exit(1); + } + res = test_all(argv[1], argv[2]); + MSG_clean(); + + if (res == MSG_OK) + return 0; + else + return 1; +} /* end_of_main */ diff --git a/examples/msg/parallel_contexts/pcontexts_platform.xml b/examples/msg/parallel_contexts/pcontexts_platform.xml new file mode 100644 index 0000000000..0e5118caf9 --- /dev/null +++ b/examples/msg/parallel_contexts/pcontexts_platform.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +