xbt_dynar_t changed_tasks = SD_simulate(-1.0);
if (xbt_dynar_is_empty(changed_tasks))
break;
- XBT_INFO("link1: bw=%.0f, lat=%f", SD_route_get_bandwidth(hosts[0], hosts[1]),
- SD_route_get_latency(hosts[0], hosts[1]));
+ XBT_INFO("link1: bw=%.0f, lat=%f", sg_host_route_bandwidth(hosts[0], hosts[1]),
+ sg_host_route_latency(hosts[0], hosts[1]));
XBT_INFO("Jupiter: speed=%.0f", sg_host_speed(hosts[0])* sg_host_get_available_speed(hosts[0]));
XBT_INFO("Tremblay: speed=%.0f", sg_host_speed(hosts[1])* sg_host_get_available_speed(hosts[1]));
if (SD_task_get_amount(parent) <= 1e-6){
redist_time= 0;
} else {
- redist_time = SD_route_get_latency(parent_host[0], host) +
- SD_task_get_amount(parent) / SD_route_get_bandwidth(parent_host[0], host);
+ redist_time = sg_host_route_latency(parent_host[0], host) +
+ SD_task_get_amount(parent) / sg_host_route_bandwidth(parent_host[0], host);
}
data_available = SD_task_get_start_time(parent) + redist_time;
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/simdag.h"
+#include "simgrid/s4u.hpp"
#include "xbt/ex.h"
#include <xbt/ex.hpp>
#include "xbt/log.h"
/* test the estimation functions */
const sg_host_t *hosts = sg_host_list();
- sg_host_t h1 = hosts[4];
- sg_host_t h2 = hosts[2];
- const char *name1 = sg_host_get_name(h1);
- const char *name2 = sg_host_get_name(h2);
+ simgrid::s4u::Host* h1 = hosts[4];
+ simgrid::s4u::Host* h2 = hosts[2];
double comp_amount1 = 2000000;
double comp_amount2 = 1000000;
double comm_amount12 = 2000000;
double comm_amount21 = 3000000;
- XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, name1, comp_amount1/sg_host_speed(h1));
- XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, name2, comp_amount2/sg_host_speed(h2));
-
- XBT_INFO("Route between %s and %s:", name1, name2);
- SD_link_t *route = SD_route_get_list(h1, h2);
- int route_size = SD_route_get_size(h1, h2);
- for (int i = 0; i < route_size; i++)
- XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(route[i]), sg_link_latency(route[i]),
- sg_link_bandwidth(route[i]));
- xbt_free(route);
- XBT_INFO("Route latency = %f, route bandwidth = %f", SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
- XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount12, name1, name2,
- SD_route_get_latency(h1, h2) + comm_amount12 / SD_route_get_bandwidth(h1, h2));
- XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount21, name2, name1,
- SD_route_get_latency(h2, h1) + comm_amount21 / SD_route_get_bandwidth(h2, h1));
+ XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, h1->cname(), comp_amount1/h1->speed());
+ XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, h2->cname(), comp_amount2/h2->speed());
+
+ XBT_INFO("Route between %s and %s:", h1->cname(), h2->cname());
+ std::vector<Link*> route;
+ double latency = 0;
+ h1->routeTo(h2, &route, &latency);
+
+ for (auto link : route)
+ XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
+ sg_link_bandwidth(link));
+
+ XBT_INFO("Route latency = %f, route bandwidth = %f", latency, sg_host_route_bandwidth(h1, h2));
+ XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount12, h1->cname(), h2->cname(),
+ sg_host_route_latency(h1, h2) + comm_amount12 / sg_host_route_bandwidth(h1, h2));
+ XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount21, h2->cname(), h1->cname(),
+ sg_host_route_latency(h2, h1) + comm_amount21 / sg_host_route_bandwidth(h2, h1));
/* creation of the tasks and their dependencies */
SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
SD_TASK_COMM_PAR_MXN_1D_BLOCK = 4 /**< @brief MxN data redistribution (1D Block distribution) */
} e_SD_task_kind_t;
-
-/************************** Workstation handling ****************************/
-/** @addtogroup SD_host_api
- *
- * A host is a place where a task can be executed.
- * A host is represented as a <em>physical resource with computing capabilities</em> and has a <em>name</em>.
- *
- * The hosts are created from the description file when you call the function SD_create_environment.
- *
- * @see sg_host_t
- * @{
- */
-XBT_PUBLIC(SD_link_t *) SD_route_get_list(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(int) SD_route_get_size(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(double) SD_route_get_latency(sg_host_t src, sg_host_t dst);
-XBT_PUBLIC(double) SD_route_get_bandwidth(sg_host_t src, sg_host_t dst);
-/** @} */
-
/************************** Task handling ************************************/
/** @defgroup SD_task_api Tasks
* @brief Functions for managing the tasks
#ifndef MAXMIN_DATATYPES_H
#define MAXMIN_DATATYPES_H
-typedef struct surf_storage *surf_storage_t;
-typedef struct surf_stat *surf_stat_t;
-
typedef struct lmm_element *lmm_element_t;
typedef struct lmm_variable *lmm_variable_t;
typedef struct lmm_constraint *lmm_constraint_t;
if (bytes_amount != nullptr)
for (int j = 0; j < host_count; j++)
if (bytes_amount[i * host_count + j] != 0)
- time += (SD_route_get_latency(host_list[i], host_list[j]) +
- bytes_amount[i * host_count + j] / SD_route_get_bandwidth(host_list[i], host_list[j]));
+ time += (sg_host_route_latency(host_list[i], host_list[j]) +
+ bytes_amount[i * host_count + j] / sg_host_route_bandwidth(host_list[i], host_list[j]));
if (time > max_time)
max_time = time;
+++ /dev/null
-/* 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 "simgrid/s4u/host.hpp"
-
-#include "simdag_private.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "surf/surf.h"
-
-/** @brief Returns the route between two workstations
- *
- * Use SD_route_get_size() to know the array size.
- *
- * \param src a host
- * \param dst another host
- * \return an array of the \ref SD_link_t composing the route
- * \see SD_route_get_size(), SD_link_t
- */
-SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
-{
- std::vector<Link*> route;
- src->routeTo(dst, &route, nullptr);
-
- int cpt=0;
- SD_link_t* list = xbt_new(SD_link_t, route.size());
- for (const auto& link : route) {
- list[cpt] = link;
- cpt++;
- }
- return list;
-}
-
-/**
- * \brief Returns the number of links on the route between two workstations
- *
- * \param src a workstation
- * \param dst another workstation
- * \return the number of links on the route between these two workstations
- * \see SD_route_get_list()
- */
-int SD_route_get_size(sg_host_t src, sg_host_t dst)
-{
- std::vector<Link*> route;
- src->routeTo(dst, &route, nullptr);
- int size = route.size();
- return size;
-}
-
-/**
- * \brief Returns the latency of the route between two workstations.
- *
- * \param src the first workstation
- * \param dst the second workstation
- * \return the latency of the route between the two workstations (in seconds)
- * \see SD_route_get_bandwidth()
- */
-double SD_route_get_latency(sg_host_t src, sg_host_t dst)
-{
- double latency = 0;
- std::vector<Link*> route;
- src->routeTo(dst, &route, &latency);
-
- return latency;
-}
-
-/**
- * \brief Returns the bandwidth of the route between two workstations,
- * i.e. the minimum link bandwidth of all between the workstations.
- *
- * \param src the first workstation
- * \param dst the second workstation
- * \return the bandwidth of the route between the two workstations (in bytes/second)
- * \see SD_route_get_latency()
- */
-double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst)
-{
- double min_bandwidth = -1.0;
-
- std::vector<Link*> route;
- src->routeTo(dst, &route, nullptr);
-
- for (const auto& link : route) {
- double bandwidth = sg_link_bandwidth(link);
- if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
- min_bandwidth = bandwidth;
- }
-
- return min_bandwidth;
-}
*/
double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
{
+ double min_bandwidth = -1.0;
+
std::vector<simgrid::s4u::Link*> vlinks;
from->routeTo(to, &vlinks, nullptr);
- double res = 0;
- for (auto link : vlinks)
- res += link->bandwidth();
- return res;
+ for (auto link : vlinks) {
+ double bandwidth = link->bandwidth();
+ if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
+ min_bandwidth = bandwidth;
+ }
+ return min_bandwidth;
}
/** @brief Displays debugging information about a host */
const char *name2 = sg_host_get_name(h2);
fprintf(stderr, "Route between %s and %s\n", name1, name2);
- SD_link_t *route = SD_route_get_list(h1, h2);
- int route_size = SD_route_get_size(h1, h2);
- fprintf(stderr, "Route size %d\n", route_size);
- for (int i = 0; i < route_size; i++)
- fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]),
- sg_link_latency(route[i]), sg_link_bandwidth(route[i]));
+ xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
+ sg_host_route(h1, h2, route);
+ fprintf(stderr, "Route size %lu\n", xbt_dynar_length(route));
+ unsigned int i;
+ SD_link_t link;
+ xbt_dynar_foreach(route, i, link)
+ fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n", sg_link_name(link),
+ sg_link_latency(link), sg_link_bandwidth(link));
fprintf(stderr, "Route latency = %f, route bandwidth = %f\n",
- SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
- xbt_free(route);
+ sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
+ xbt_dynar_free_container(&route);
}
if (!strcmp(argv[2], "FULL_LINK")) {
int list_size = sg_host_count();
sg_host_t h2 = hosts[j];
const char *name2 = sg_host_get_name(h2);
fprintf(stderr, "Route between %s and %s\n", name1, name2);
- SD_link_t *route = SD_route_get_list(h1, h2);
- int route_size = SD_route_get_size(h1, h2);
- fprintf(stderr, " Route size %d\n", route_size);
- for (int k = 0; k < route_size; k++) {
+ xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
+ sg_host_route(h1, h2, route);
+ fprintf(stderr, " Route size %lu\n", xbt_dynar_length(route));
+ unsigned int k;
+ SD_link_t link;
+ xbt_dynar_foreach(route, k, link)
fprintf(stderr, " Link %s: latency = %f, bandwidth = %f\n",
- sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k]));
- }
+ sg_link_name(link), sg_link_latency(link), sg_link_bandwidth(link));
fprintf(stderr, " Route latency = %f, route bandwidth = %f\n",
- SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
- xbt_free(route);
+ sg_host_route_latency(h1, h2), sg_host_route_bandwidth(h1, h2));
+ xbt_dynar_free_container(&route);
}
}
}
sg_host_t h1 = hosts[i];
sg_host_t h2 = hosts[j];
printf("%d\tand\t%d\t\t",i,j);
+ xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
xbt_os_cputimer_start(timer);
- SD_route_get_list(h1, h2);
+ sg_host_route(h1, h2, route);
xbt_os_cputimer_stop(timer);
+ xbt_dynar_free(&route);
+
printf("%f\n", xbt_os_timer_elapsed(timer) );
xbt_free(hosts);
src/simdag/sd_dotloader.cpp
src/simdag/sd_global.cpp
src/simdag/sd_task.cpp
- src/simdag/sd_workstation.cpp
)
set(BINDINGS_SRC