From: Frederic Suter Date: Sun, 26 Mar 2017 11:11:21 +0000 (+0200) Subject: conversion++ X-Git-Tag: v3.16~449 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e0b5312ebe2965016e89714370d85535c017c982 conversion++ --- diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 0c1823154b..28cdd2cf51 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,5 +1,5 @@ # C examples -foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async +foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async storage_client_server trace_integration) add_executable (${x} ${x}/${x}.c) target_link_libraries(${x} simgrid) @@ -34,7 +34,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE) -foreach(x concurrent_rw get_sender host_on_off host_on_off_processes host_on_off_recv host_on_off_wait listen_async +foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv host_on_off_wait listen_async storage_client_server task_destroy_cancel trace_integration) ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh) endforeach() diff --git a/teshsuite/msg/concurrent_rw/concurrent_rw.c b/teshsuite/msg/concurrent_rw/concurrent_rw.c deleted file mode 100644 index 9231629261..0000000000 --- a/teshsuite/msg/concurrent_rw/concurrent_rw.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2008-2010, 2012-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 "simgrid/msg.h" -#include - -#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml" - -XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); - -static int host(int argc, char *argv[]) -{ - char name[2048]; - int id = MSG_process_self_PID(); - snprintf(name,2048,"%s%i", FILENAME1, id); - msg_file_t file = MSG_file_open(name, NULL); - XBT_INFO("process %d is writing!", id); - MSG_file_write(file, 3000000); - XBT_INFO("process %d goes to sleep for %d seconds", id, id); - MSG_process_sleep(id); - XBT_INFO("process %d is writing again!", id); - MSG_file_write(file, 3000000); - XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id); - MSG_process_sleep(6-id); - XBT_INFO("process %d is reading!", id); - MSG_file_seek(file, 0, SEEK_SET); - MSG_file_read(file, 3000000); - XBT_INFO("process %d goes to sleep for %d seconds", id, id); - MSG_process_sleep(id); - XBT_INFO("process %d is reading again!", id); - MSG_file_seek(file, 0, SEEK_SET); - MSG_file_read(file, 3000000); - - XBT_INFO("process %d => Size of %s: %llu", id, MSG_file_get_name(file), MSG_file_get_size(file)); - MSG_file_close(file); - - return 0; -} - -int main(int argc, char **argv) -{ - MSG_init(&argc, argv); - MSG_create_environment(argv[1]); - - MSG_function_register("host", host); - for(int i = 0 ; i < 5; i++){ - MSG_process_create("bob", host, NULL, MSG_host_by_name(xbt_strdup("bob"))); - } - - int res = MSG_main(); - XBT_INFO("Simulation time %g", MSG_get_clock()); - - return res != MSG_OK; -} diff --git a/teshsuite/msg/concurrent_rw/concurrent_rw.tesh b/teshsuite/msg/concurrent_rw/concurrent_rw.tesh deleted file mode 100644 index 2d837c54dc..0000000000 --- a/teshsuite/msg/concurrent_rw/concurrent_rw.tesh +++ /dev/null @@ -1,42 +0,0 @@ -$ ./concurrent_rw$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:bob@bob) process 1 is writing! -> [ 0.000000] (2:bob@bob) process 2 is writing! -> [ 0.000000] (3:bob@bob) process 3 is writing! -> [ 0.000000] (4:bob@bob) process 4 is writing! -> [ 0.000000] (5:bob@bob) process 5 is writing! -> [ 0.500000] (1:bob@bob) process 1 goes to sleep for 1 seconds -> [ 0.500000] (2:bob@bob) process 2 goes to sleep for 2 seconds -> [ 0.500000] (3:bob@bob) process 3 goes to sleep for 3 seconds -> [ 0.500000] (4:bob@bob) process 4 goes to sleep for 4 seconds -> [ 0.500000] (5:bob@bob) process 5 goes to sleep for 5 seconds -> [ 1.500000] (1:bob@bob) process 1 is writing again! -> [ 1.600000] (1:bob@bob) process 1 goes to sleep for 5 seconds -> [ 2.500000] (2:bob@bob) process 2 is writing again! -> [ 2.600000] (2:bob@bob) process 2 goes to sleep for 4 seconds -> [ 3.500000] (3:bob@bob) process 3 is writing again! -> [ 3.600000] (3:bob@bob) process 3 goes to sleep for 3 seconds -> [ 4.500000] (4:bob@bob) process 4 is writing again! -> [ 4.600000] (4:bob@bob) process 4 goes to sleep for 2 seconds -> [ 5.500000] (5:bob@bob) process 5 is writing again! -> [ 5.600000] (5:bob@bob) process 5 goes to sleep for 1 seconds -> [ 6.600000] (4:bob@bob) process 4 is reading! -> [ 6.600000] (5:bob@bob) process 5 is reading! -> [ 6.600000] (1:bob@bob) process 1 is reading! -> [ 6.600000] (2:bob@bob) process 2 is reading! -> [ 6.600000] (3:bob@bob) process 3 is reading! -> [ 6.750000] (4:bob@bob) process 4 goes to sleep for 4 seconds -> [ 6.750000] (5:bob@bob) process 5 goes to sleep for 5 seconds -> [ 6.750000] (1:bob@bob) process 1 goes to sleep for 1 seconds -> [ 6.750000] (2:bob@bob) process 2 goes to sleep for 2 seconds -> [ 6.750000] (3:bob@bob) process 3 goes to sleep for 3 seconds -> [ 7.750000] (1:bob@bob) process 1 is reading again! -> [ 7.780000] (1:bob@bob) process 1 => Size of /home/doc/simgrid/examples/platforms/g5k.xml1: 6000000 -> [ 8.750000] (2:bob@bob) process 2 is reading again! -> [ 8.780000] (2:bob@bob) process 2 => Size of /home/doc/simgrid/examples/platforms/g5k.xml2: 6000000 -> [ 9.750000] (3:bob@bob) process 3 is reading again! -> [ 9.780000] (3:bob@bob) process 3 => Size of /home/doc/simgrid/examples/platforms/g5k.xml3: 6000000 -> [ 10.750000] (4:bob@bob) process 4 is reading again! -> [ 10.780000] (4:bob@bob) process 4 => Size of /home/doc/simgrid/examples/platforms/g5k.xml4: 6000000 -> [ 11.750000] (5:bob@bob) process 5 is reading again! -> [ 11.780000] (5:bob@bob) process 5 => Size of /home/doc/simgrid/examples/platforms/g5k.xml5: 6000000 -> [ 11.780000] (0:maestro@) Simulation time 11.78 diff --git a/teshsuite/s4u/CMakeLists.txt b/teshsuite/s4u/CMakeLists.txt index d2dce9ca90..12c25fe335 100644 --- a/teshsuite/s4u/CMakeLists.txt +++ b/teshsuite/s4u/CMakeLists.txt @@ -1,4 +1,4 @@ -foreach(x actor pid) +foreach(x actor concurrent_rw pid) add_executable (${x} ${x}/${x}.cpp) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) @@ -11,6 +11,6 @@ set(teshsuite_src ${teshsuite_src} PARENT_SCOPE) set(tesh_files ${tesh_files} PARENT_SCOPE) set(xml_files ${xml_files} PARENT_SCOPE) -foreach(x actor pid) +foreach(x actor concurrent_rw pid) ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh) endforeach() diff --git a/teshsuite/s4u/concurrent_rw/concurrent_rw.cpp b/teshsuite/s4u/concurrent_rw/concurrent_rw.cpp new file mode 100644 index 0000000000..82a0ca894c --- /dev/null +++ b/teshsuite/s4u/concurrent_rw/concurrent_rw.cpp @@ -0,0 +1,54 @@ +/* Copyright (c) 2008-2010, 2012-2015, 2017. 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 "simgrid/s4u.hpp" +#include + +#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml" + +XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test"); + +static void host() +{ + char name[2048]; + int id = simgrid::s4u::this_actor::pid(); + snprintf(name, 2048, "%s%i", FILENAME1, id); + simgrid::s4u::File* file = new simgrid::s4u::File(name, NULL); + XBT_INFO("process %d is writing!", id); + file->write(3000000); + XBT_INFO("process %d goes to sleep for %d seconds", id, id); + simgrid::s4u::this_actor::sleep_for(id); + XBT_INFO("process %d is writing again!", id); + file->write(3000000); + XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id); + simgrid::s4u::this_actor::sleep_for(6 - id); + XBT_INFO("process %d is reading!", id); + file->seek(0); + file->read(3000000); + XBT_INFO("process %d goes to sleep for %d seconds", id, id); + simgrid::s4u::this_actor::sleep_for(id); + XBT_INFO("process %d is reading again!", id); + file->seek(0); + file->read(3000000); + + XBT_INFO("process %d => Size of %s: %llu", id, name, file->size()); + // Close the file + delete file; +} + +int main(int argc, char** argv) +{ + simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv); + e->loadPlatform(argv[1]); + + for (int i = 0; i < 5; i++) + simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("bob"), host); + + e->run(); + XBT_INFO("Simulation time %g", e->getClock()); + + return 0; +} diff --git a/teshsuite/s4u/concurrent_rw/concurrent_rw.tesh b/teshsuite/s4u/concurrent_rw/concurrent_rw.tesh new file mode 100644 index 0000000000..8be078fe9c --- /dev/null +++ b/teshsuite/s4u/concurrent_rw/concurrent_rw.tesh @@ -0,0 +1,42 @@ +$ ./concurrent_rw$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +> [ 0.000000] (host@bob) process 1 is writing! +> [ 0.000000] (host@bob) process 2 is writing! +> [ 0.000000] (host@bob) process 3 is writing! +> [ 0.000000] (host@bob) process 4 is writing! +> [ 0.000000] (host@bob) process 5 is writing! +> [ 0.500000] (host@bob) process 1 goes to sleep for 1 seconds +> [ 0.500000] (host@bob) process 2 goes to sleep for 2 seconds +> [ 0.500000] (host@bob) process 3 goes to sleep for 3 seconds +> [ 0.500000] (host@bob) process 4 goes to sleep for 4 seconds +> [ 0.500000] (host@bob) process 5 goes to sleep for 5 seconds +> [ 1.500000] (host@bob) process 1 is writing again! +> [ 1.600000] (host@bob) process 1 goes to sleep for 5 seconds +> [ 2.500000] (host@bob) process 2 is writing again! +> [ 2.600000] (host@bob) process 2 goes to sleep for 4 seconds +> [ 3.500000] (host@bob) process 3 is writing again! +> [ 3.600000] (host@bob) process 3 goes to sleep for 3 seconds +> [ 4.500000] (host@bob) process 4 is writing again! +> [ 4.600000] (host@bob) process 4 goes to sleep for 2 seconds +> [ 5.500000] (host@bob) process 5 is writing again! +> [ 5.600000] (host@bob) process 5 goes to sleep for 1 seconds +> [ 6.600000] (host@bob) process 4 is reading! +> [ 6.600000] (host@bob) process 5 is reading! +> [ 6.600000] (host@bob) process 1 is reading! +> [ 6.600000] (host@bob) process 2 is reading! +> [ 6.600000] (host@bob) process 3 is reading! +> [ 6.750000] (host@bob) process 4 goes to sleep for 4 seconds +> [ 6.750000] (host@bob) process 5 goes to sleep for 5 seconds +> [ 6.750000] (host@bob) process 1 goes to sleep for 1 seconds +> [ 6.750000] (host@bob) process 2 goes to sleep for 2 seconds +> [ 6.750000] (host@bob) process 3 goes to sleep for 3 seconds +> [ 7.750000] (host@bob) process 1 is reading again! +> [ 7.780000] (host@bob) process 1 => Size of /home/doc/simgrid/examples/platforms/g5k.xml1: 6000000 +> [ 8.750000] (host@bob) process 2 is reading again! +> [ 8.780000] (host@bob) process 2 => Size of /home/doc/simgrid/examples/platforms/g5k.xml2: 6000000 +> [ 9.750000] (host@bob) process 3 is reading again! +> [ 9.780000] (host@bob) process 3 => Size of /home/doc/simgrid/examples/platforms/g5k.xml3: 6000000 +> [ 10.750000] (host@bob) process 4 is reading again! +> [ 10.780000] (host@bob) process 4 => Size of /home/doc/simgrid/examples/platforms/g5k.xml4: 6000000 +> [ 11.750000] (host@bob) process 5 is reading again! +> [ 11.780000] (host@bob) process 5 => Size of /home/doc/simgrid/examples/platforms/g5k.xml5: 6000000 +> [ 11.780000] (maestro@) Simulation time 11.78