From 974fdcf1a70f588b4d700da5f927c1c318d2fe01 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 20 Feb 2020 13:31:21 +0100 Subject: [PATCH] convert io-file-remote --- MANIFEST.in | 6 +- examples/c/CMakeLists.txt | 5 +- examples/c/io-file-remote/io-file-remote.c | 84 +++++++++++++++++++ examples/c/io-file-remote/io-file-remote.tesh | 43 ++++++++++ .../c/io-file-remote/io-file-remote_d.xml | 19 +++++ teshsuite/msg/CMakeLists.txt | 5 +- teshsuite/msg/io-file-remote/io-file-remote.c | 84 ------------------- .../msg/io-file-remote/io-file-remote.tesh | 64 -------------- .../msg/io-file-remote/io-file-remote_d.xml | 24 ------ 9 files changed, 154 insertions(+), 180 deletions(-) create mode 100644 examples/c/io-file-remote/io-file-remote.c create mode 100644 examples/c/io-file-remote/io-file-remote.tesh create mode 100644 examples/c/io-file-remote/io-file-remote_d.xml delete mode 100644 teshsuite/msg/io-file-remote/io-file-remote.c delete mode 100644 teshsuite/msg/io-file-remote/io-file-remote.tesh delete mode 100644 teshsuite/msg/io-file-remote/io-file-remote_d.xml diff --git a/MANIFEST.in b/MANIFEST.in index 341ecaa392..00f45c14dc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -61,6 +61,9 @@ include examples/c/exec-dvfs/exec-dvfs.c include examples/c/exec-dvfs/exec-dvfs.tesh include examples/c/io-disk-raw/io-disk-raw.c include examples/c/io-disk-raw/io-disk-raw.tesh +include examples/c/io-file-remote/io-file-remote.c +include examples/c/io-file-remote/io-file-remote.tesh +include examples/c/io-file-remote/io-file-remote_d.xml include examples/c/plugin-hostload/plugin-hostload.c include examples/c/plugin-hostload/plugin-hostload.tesh include examples/deprecated/java/app/bittorrent/Common.java @@ -656,9 +659,6 @@ include teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp include teshsuite/msg/host_on_off_processes/host_on_off_processes.tesh include teshsuite/msg/host_on_off_recv/host_on_off_recv.c include teshsuite/msg/host_on_off_recv/host_on_off_recv.tesh -include teshsuite/msg/io-file-remote/io-file-remote.c -include teshsuite/msg/io-file-remote/io-file-remote.tesh -include teshsuite/msg/io-file-remote/io-file-remote_d.xml include teshsuite/msg/io-file/io-file.c include teshsuite/msg/io-file/io-file.tesh include teshsuite/msg/platform-properties/platform-properties.c diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 226cb61eb1..0ce31d8c58 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -8,7 +8,7 @@ foreach(x cloud-capping cloud-simple exec-dvfs energy-exec - io-disk-raw + io-disk-raw io-file-remote plugin-hostload) add_executable (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c) target_link_libraries(${x}-c simgrid) @@ -47,6 +47,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-cr ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/async-waitall_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/io-file-remote_d.xml PARENT_SCOPE) foreach(x @@ -56,7 +57,7 @@ foreach(x cloud-capping cloud-simple exec-dvfs energy-exec - io-disk-raw + io-disk-raw io-file-remote plugin-hostload) ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x} diff --git a/examples/c/io-file-remote/io-file-remote.c b/examples/c/io-file-remote/io-file-remote.c new file mode 100644 index 0000000000..f10c86be92 --- /dev/null +++ b/examples/c/io-file-remote/io-file-remote.c @@ -0,0 +1,84 @@ +/* Copyright (c) 2014-2020. 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/actor.h" +#include "simgrid/disk.h" +#include "simgrid/engine.h" +#include "simgrid/host.h" +#include + +#include "xbt/asserts.h" +#include "xbt/log.h" + +#define INMEGA (1024 * 1024) + +XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example"); + +static void host(int argc, char* argv[]) +{ + sg_file_t file = sg_file_open(argv[1], NULL); + const char* filename = sg_file_get_name(file); + XBT_INFO("Opened file '%s'", filename); + sg_file_dump(file); + + XBT_INFO("Try to write %llu MiB to '%s'", sg_file_get_size(file) / 1024, filename); + sg_size_t write = sg_file_write(file, sg_file_get_size(file) * 1024); + XBT_INFO("Have written %llu MiB to '%s'.", write / (1024 * 1024), filename); + + if (argc > 4) { + if (atoi(argv[4]) != 0) { + XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, sg_file_get_size(file), sg_host_self_get_name(), + argv[2]); + sg_file_rmove(file, sg_host_by_name(argv[2]), argv[3]); + } else { + XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, sg_file_get_size(file), sg_host_self_get_name(), + argv[2]); + sg_file_rcopy(file, sg_host_by_name(argv[2]), argv[3]); + } + } + sg_file_close(file); +} + +int main(int argc, char** argv) +{ + + simgrid_init(&argc, argv); + sg_storage_file_system_init(); + simgrid_load_platform(argv[1]); + + simgrid_register_function("host", host); + simgrid_load_deployment(argv[2]); + + size_t host_count = sg_host_count(); + sg_host_t* hosts = sg_host_list(); + + for (long i = 0; i < host_count; i++) { + unsigned int disk_count; + sg_disk_t* disks; + sg_host_disks(hosts[i], &disk_count, &disks); + for (unsigned int j = 0; j < disk_count; j++) + XBT_INFO("Init: %s: %llu/%llu MiB used/free on '%s@%s'", sg_host_get_name(hosts[i]), + sg_disk_get_size_used(disks[j]) / INMEGA, sg_disk_get_size_free(disks[j]) / INMEGA, + sg_disk_name(disks[j]), sg_host_get_name(sg_disk_get_host(disks[j]))); + free(disks); + } + + simgrid_run(); + + for (long i = 0; i < host_count; i++) { + unsigned int disk_count; + sg_disk_t* disks; + sg_host_disks(hosts[i], &disk_count, &disks); + for (unsigned int j = 0; j < disk_count; j++) + XBT_INFO("End: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(disks[j]) / INMEGA, + sg_disk_get_size_free(disks[j]) / INMEGA, sg_disk_name(disks[j]), sg_host_get_name(hosts[i])); + free(disks); + } + + free(hosts); + + XBT_INFO("Simulation time %g", simgrid_get_clock()); + return 0; +} diff --git a/examples/c/io-file-remote/io-file-remote.tesh b/examples/c/io-file-remote/io-file-remote.tesh new file mode 100644 index 0000000000..dc136c53ed --- /dev/null +++ b/examples/c/io-file-remote/io-file-remote.tesh @@ -0,0 +1,43 @@ +#!/usr/bin/env tesh + +$ ${bindir:=.}/io-file-remote-c ${platfdir}/hosts_with_disks.xml io-file-remote_d.xml "--log=root.fmt:[%10.6r]%e(%i@%5h)%e%m%n" +> [ 0.000000] (0@ ) Init: alice: 12/511987 MiB used/free on 'Disk1@alice' +> [ 0.000000] (0@ ) Init: bob: 35/511964 MiB used/free on 'Disk1@bob' +> [ 0.000000] (0@ ) Init: bob: 0/512000 MiB used/free on 'Disk2@bob' +> [ 0.000000] (0@ ) Init: carl: 35/511964 MiB used/free on 'Disk1@bob' +> [ 0.000000] (1@alice) Opened file '/include/surf/simgrid_dtd.h' +> [ 0.000000] (1@alice) File Descriptor information: +> Full path: '/include/surf/simgrid_dtd.h' +> Size: 23583 +> Mount point: '/' +> Disk Id: 'Disk1' +> Host Id: 'alice' +> File Descriptor Id: 0 +> [ 0.000000] (1@alice) Try to write 23 MiB to '/include/surf/simgrid_dtd.h' +> [ 0.000000] (2@ bob) Opened file '/scratch/doc/simgrid/examples/platforms/g5k.xml' +> [ 0.000000] (2@ bob) File Descriptor information: +> Full path: '/scratch/doc/simgrid/examples/platforms/g5k.xml' +> Size: 17028 +> Mount point: '/scratch' +> Disk Id: 'Disk1' +> Host Id: 'bob' +> File Descriptor Id: 0 +> [ 0.000000] (2@ bob) Try to write 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml' +> [ 0.000000] (3@ carl) Opened file '/scratch/include/surf/simgrid_dtd.h' +> [ 0.000000] (3@ carl) File Descriptor information: +> Full path: '/scratch/include/surf/simgrid_dtd.h' +> Size: 23583 +> Mount point: '/scratch' +> Disk Id: 'Disk1' +> Host Id: 'bob' +> File Descriptor Id: 0 +> [ 0.000000] (3@ carl) Try to write 23 MiB to '/scratch/include/surf/simgrid_dtd.h' +> [ 0.301862] (1@alice) Have written 23 MiB to '/include/surf/simgrid_dtd.h'. +> [ 0.301862] (1@alice) Move '/include/surf/simgrid_dtd.h' (of size 24148992) from 'alice' to 'bob' +> [ 0.660757] (2@ bob) Have written 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml'. +> [ 0.660757] (2@ bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice' +> [ 1.234522] (3@ carl) Have written 23 MiB to '/scratch/include/surf/simgrid_dtd.h'. +> [ 1.643366] (0@ ) End: 29/511970 MiB used/free on 'Disk1@alice' +> [ 1.643366] (0@ ) End: 97/511902 MiB used/free on 'Disk1@bob' +> [ 1.643366] (0@ ) End: 0/512000 MiB used/free on 'Disk2@bob' +> [ 1.643366] (0@ ) Simulation time 1.64337 diff --git a/examples/c/io-file-remote/io-file-remote_d.xml b/examples/c/io-file-remote/io-file-remote_d.xml new file mode 100644 index 0000000000..d14901b8fb --- /dev/null +++ b/examples/c/io-file-remote/io-file-remote_d.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index f153e0475b..e94cf44b5c 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -4,7 +4,7 @@ foreach(x async-wait get_sender host_on_off host_on_off_recv process-lifetime energy-ptask platform-properties - io-file io-file-remote + io-file task-priority trace_integration) if(enable_msg) @@ -50,7 +50,6 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/ap ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/io-file-remote_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/platform-properties_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/baseline_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/kill_d.xml @@ -80,7 +79,7 @@ if(enable_msg) task_destroy_cancel task_listen_from task_progress process-lifetime energy-ptask - io-file io-file-remote + io-file platform-properties task-priority trace_integration) diff --git a/teshsuite/msg/io-file-remote/io-file-remote.c b/teshsuite/msg/io-file-remote/io-file-remote.c deleted file mode 100644 index 3456513fc8..0000000000 --- a/teshsuite/msg/io-file-remote/io-file-remote.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2014-2020. 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 - -#include /* sscanf */ - -#define INMEGA (1024 * 1024) - -XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example"); - -static int host(int argc, char* argv[]) -{ - msg_file_t file = MSG_file_open(argv[1], NULL); - const char* filename = MSG_file_get_name(file); - XBT_INFO("Opened file '%s'", filename); - MSG_file_dump(file); - - XBT_INFO("Try to read %llu from '%s'", MSG_file_get_size(file), filename); - sg_size_t read = MSG_file_read(file, MSG_file_get_size(file)); - XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu", read, filename, MSG_file_tell(file)); - XBT_INFO("Seek back to the beginning of the stream..."); - MSG_file_seek(file, 0, SEEK_SET); - XBT_INFO("Offset is now at: %llu", MSG_file_tell(file)); - - MSG_file_close(file); - - if (argc > 5) { - file = MSG_file_open(argv[2], NULL); - filename = MSG_file_get_name(file); - XBT_INFO("Opened file '%s'", filename); - XBT_INFO("Try to write %llu MiB to '%s'", MSG_file_get_size(file) / 1024, filename); - sg_size_t write = MSG_file_write(file, MSG_file_get_size(file) * 1024); - XBT_INFO("Have written %llu bytes to '%s'.", write, filename); - - const_sg_host_t src = MSG_host_self(); - msg_host_t dest = MSG_host_by_name(argv[3]); - if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) { - XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src), - argv[3]); - MSG_file_rmove(file, dest, argv[4]); - } else { - XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src), - argv[3]); - MSG_file_rcopy(file, dest, argv[4]); - } - MSG_file_close(file); - } - - return 0; -} - -int main(int argc, char** argv) -{ - unsigned int cur; - const_sg_storage_t st; - - MSG_init(&argc, argv); - MSG_storage_file_system_init(); - - MSG_create_environment(argv[1]); - MSG_function_register("host", host); - MSG_launch_application(argv[2]); - - xbt_dynar_t storages = MSG_storages_as_dynar(); - xbt_dynar_foreach (storages, cur, st) { - XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", MSG_storage_get_used_size(st) / INMEGA, - MSG_storage_get_free_size(st) / INMEGA, MSG_storage_get_name(st)); - } - - int res = MSG_main(); - - xbt_dynar_foreach (storages, cur, st) { - XBT_INFO("End: %llu/%llu MiB used/free on '%s'", MSG_storage_get_used_size(st) / INMEGA, - MSG_storage_get_free_size(st) / INMEGA, MSG_storage_get_name(st)); - } - xbt_dynar_free(&storages); - - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res != MSG_OK; -} diff --git a/teshsuite/msg/io-file-remote/io-file-remote.tesh b/teshsuite/msg/io-file-remote/io-file-remote.tesh deleted file mode 100644 index 30c9a47145..0000000000 --- a/teshsuite/msg/io-file-remote/io-file-remote.tesh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/io-file-remote ${platfdir:=.}/storage/remote_io.xml ${srcdir:=.}/io-file-remote_d.xml "--log=root.fmt:[%10.6r]%e(%i@%5h)%e%m%n" -> [ 0.000000] (0@ ) Init: 12/476824 MiB used/free on 'Disk1' -> [ 0.000000] (0@ ) Init: 35/476801 MiB used/free on 'Disk2' -> [ 0.000000] (1@alice) Opened file '/tmp/doc/simgrid/examples/msg/chord/chord10k.xml' -> [ 0.000000] (1@alice) File Descriptor information: -> Full path: '/tmp/doc/simgrid/examples/msg/chord/chord10k.xml' -> Size: 1624671 -> Mount point: '/tmp' -> Storage Id: 'Disk2' -> Storage Type: 'SATA-II_HDD' -> File Descriptor Id: 0 -> [ 0.000000] (1@alice) Try to read 1624671 from '/tmp/doc/simgrid/examples/msg/chord/chord10k.xml' -> [ 0.000000] (2@ bob) Opened file '/scratch/lib/libsimgrid.so.3.6.2' -> [ 0.000000] (2@ bob) File Descriptor information: -> Full path: '/scratch/lib/libsimgrid.so.3.6.2' -> Size: 12710497 -> Mount point: '/scratch' -> Storage Id: 'Disk1' -> Storage Type: 'SATA-II_HDD' -> File Descriptor Id: 0 -> [ 0.000000] (2@ bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2' -> [ 0.000000] (3@ carl) Opened file '/scratch/lib/libsimgrid.so.3.6.2' -> [ 0.000000] (3@ carl) File Descriptor information: -> Full path: '/scratch/lib/libsimgrid.so.3.6.2' -> Size: 12710497 -> Mount point: '/scratch' -> Storage Id: 'Disk1' -> Storage Type: 'SATA-II_HDD' -> File Descriptor Id: 0 -> [ 0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2' -> [ 0.000000] (4@ dave) Opened file '/tmp/doc/simgrid/examples/simdag/dax/Montage_50.xml' -> [ 0.000000] (4@ dave) File Descriptor information: -> Full path: '/tmp/doc/simgrid/examples/simdag/dax/Montage_50.xml' -> Size: 48868 -> Mount point: '/tmp' -> Storage Id: 'Disk2' -> Storage Type: 'SATA-II_HDD' -> File Descriptor Id: 0 -> [ 0.000000] (4@ dave) Try to read 48868 from '/tmp/doc/simgrid/examples/simdag/dax/Montage_50.xml' -> [ 0.001062] (4@ dave) Have read 48868 from '/tmp/doc/simgrid/examples/simdag/dax/Montage_50.xml'. Offset is now at: 48868 -> [ 0.001062] (4@ dave) Seek back to the beginning of the stream... -> [ 0.001062] (4@ dave) Offset is now at: 0 -> [ 0.001062] (4@ dave) Opened file '/tmp/doc/simgrid/examples/simdag/scheduling/Montage_25.xml' -> [ 0.001062] (4@ dave) Try to write 22 MiB to '/tmp/doc/simgrid/examples/simdag/scheduling/Montage_25.xml' -> [ 0.050039] (1@alice) Have read 1624671 from '/tmp/doc/simgrid/examples/msg/chord/chord10k.xml'. Offset is now at: 1624671 -> [ 0.050039] (1@alice) Seek back to the beginning of the stream... -> [ 0.050039] (1@alice) Offset is now at: 0 -> [ 0.276315] (3@ carl) Have read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'. Offset is now at: 12710497 -> [ 0.276315] (3@ carl) Seek back to the beginning of the stream... -> [ 0.276315] (3@ carl) Offset is now at: 0 -> [ 0.387036] (2@ bob) Have read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'. Offset is now at: 12710497 -> [ 0.387036] (2@ bob) Seek back to the beginning of the stream... -> [ 0.387036] (2@ bob) Offset is now at: 0 -> [ 0.387036] (2@ bob) Opened file '/scratch/doc/simgrid/examples/platforms/g5k.xml' -> [ 0.387036] (2@ bob) Try to write 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml' -> [ 0.391211] (4@ dave) Have written 23641088 bytes to '/tmp/doc/simgrid/examples/simdag/scheduling/Montage_25.xml'. -> [ 0.391211] (4@ dave) Move '/tmp/doc/simgrid/examples/simdag/scheduling/Montage_25.xml' (of size 23641088) from 'dave' to 'carl' -> [ 0.819921] (2@ bob) Have written 17436672 bytes to '/scratch/doc/simgrid/examples/platforms/g5k.xml'. -> [ 0.819921] (2@ bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice' -> [ 1.598229] (0@ ) End: 51/476785 MiB used/free on 'Disk1' -> [ 1.598229] (0@ ) End: 51/476785 MiB used/free on 'Disk2' -> [ 1.598229] (0@ ) Simulation time 1.59823 diff --git a/teshsuite/msg/io-file-remote/io-file-remote_d.xml b/teshsuite/msg/io-file-remote/io-file-remote_d.xml deleted file mode 100644 index 1200d95db8..0000000000 --- a/teshsuite/msg/io-file-remote/io-file-remote_d.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -- 2.20.1