コード例 #1
0
ファイル: basic6.c プロジェクト: rosacris/simgrid
int main(int argc, char **argv)
{
  double comm_cost[] = { 0.0, 0.0, 0.0, 0.0 };
  double comp_cost[] = { 1.0 };
  SD_task_t taskA, taskB;
  xbt_dynar_t ret;

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  taskA = SD_task_create("Task A", NULL, 1.0);
  taskB = SD_task_create("Task B", NULL, 1.0);

  SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost,
                   comm_cost, -1.0);
  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost,
                   comm_cost, -1.0);

  ret = SD_simulate(-1.0);
  xbt_dynar_free(&ret);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #2
0
ファイル: basic6.c プロジェクト: Julio-Anjos/simgrid
int main(int argc, char **argv)
{
  double comm_cost[] = { 0.0, 0.0, 0.0, 0.0 };
  double comp_cost[] = { 1.0 };
  SD_task_t taskA, taskB;
  xbt_dynar_t ret;

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  taskA = SD_task_create("Task A", NULL, 1.0);
  taskB = SD_task_create("Task B", NULL, 1.0);

  SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost,
                   comm_cost, -1.0);
  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost,
                   comm_cost, -1.0);

  ret = SD_simulate(-1.0);
  xbt_assert(xbt_dynar_length(ret) == 2,
      "I was expecting the terminaison of 2 tasks, but I got %lu instead",
      xbt_dynar_length(ret));
  xbt_dynar_free(&ret);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #3
0
int main(int argc, char **argv)
{
  double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 };
  double no_cost[] = { 0.0, 0.0 };

  SD_task_t task[TASK_NUM];

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t root = SD_task_create("Root", NULL, 1.0);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(root, 1, hosts, no_cost, no_cost, -1.0);

  for (int i = 0; i < TASK_NUM; i++) {
    task[i] = SD_task_create("Comm", NULL, 1.0);
    SD_task_schedule(task[i], 2, hosts, no_cost, communication_amount, -1.0);
    SD_task_dependency_add(NULL, NULL, root, task[i]);
  }
  xbt_free(hosts);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  for (int i = 0; i < TASK_NUM; i++) {
    SD_task_destroy(task[i]);
  }
  SD_task_destroy(root);

  SD_exit();
  return 0;
}
コード例 #4
0
ファイル: comm-p2p-latency-3.c プロジェクト: R7R8/simgrid
int main(int argc, char **argv)
{
  double communication_amount1[] = { 0.0, 1.0, 0.0, 0.0 };
  double communication_amount2[] = { 0.0, 0.0, 1.0, 0.0 };
  double no_cost1[] = { 0.0 };
  double no_cost[] = { 0.0, 0.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t root = SD_task_create("Root", NULL, 1.0);
  SD_task_t task1 = SD_task_create("Comm 1", NULL, 1.0);
  SD_task_t task2 = SD_task_create("Comm 2", NULL, 1.0);

  SD_task_schedule(root, 1, sg_host_list(), no_cost1, no_cost1, -1.0);
  SD_task_schedule(task1, 2, sg_host_list(), no_cost, communication_amount1, -1.0);
  SD_task_schedule(task2, 2, sg_host_list(), no_cost, communication_amount2, -1.0);

  SD_task_dependency_add(NULL, NULL, root, task1);
  SD_task_dependency_add(NULL, NULL, root, task2);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(root);
  SD_task_destroy(task1);
  SD_task_destroy(task2);

  SD_exit();
  return 0;
}
コード例 #5
0
ファイル: incomplete.c プロジェクト: Shurakai/SimGrid
/* SimDag Incomplete Test
 * Scenario:
 *   - Create a bunch of tasks
 *   - schedule only a subset of them (init, A and D)
 *   - run the simulation
 *   - Verify that we detect which tasks are not scheduled and show their state.
 * The scheduled task A sends 1GB. Simulation time should be
 *          1e9/1.25e8 + 1e-4 = 8.0001 seconds
 * Task D is scheduled but depends on unscheduled task C.
 */
int main(int argc, char **argv)
{

  SD_task_t taskInit;
  SD_task_t taskA, taskB, taskC, taskD;
  xbt_dynar_t ret;

  const SD_workstation_t *workstation;

  double communication_amount1 = 1e9;
  double no_cost = 0.0;

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  taskInit = SD_task_create("Init", NULL, 1.0);
  taskA = SD_task_create("Task A", NULL, 1.0);
  taskB = SD_task_create("Task B", NULL, 1.0);
  taskC = SD_task_create("Task C", NULL, 1.0);
  taskD = SD_task_create("Task D", NULL, 1.0);


  /* scheduling parameters */

  workstation = SD_workstation_get_list();

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskInit, taskB);
  SD_task_dependency_add(NULL, NULL, taskC, taskD);

  /* let's launch the simulation! */
  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost,
                   &no_cost, -1.0);
  SD_task_schedule(taskA, 1, &workstation[0], &no_cost,
                     &communication_amount1, -1.0);
  SD_task_schedule(taskD, 1, &workstation[0], &no_cost,
                     &communication_amount1, -1.0);


  ret = SD_simulate(-1.);
  xbt_dynar_free(&ret);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);
  SD_task_destroy(taskInit);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #6
0
ファイル: basic5.c プロジェクト: Julio-Anjos/simgrid
/* Basic SimDag Test 5
 * Scenario:
 *   - Create a no-op Init task
 *   - Create two tasks: send 100kB and compute 10Mflops
 *   - Schedule them concurrently
 * The two tasks should overlap smoothly as they use different resources.
 * Simulated time should be:
 *          MAX(1e5/(1.25e8), 1e7/4e9) = MAX(.0009, .0025) = 0.0025 seconds
 */
int main(int argc, char **argv)
{

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit;
  SD_task_t taskA;
  SD_task_t taskB;
  xbt_dynar_t ret;

  /* scheduling parameters */

  double no_cost[] = { 0., 0., 0., 0. };
  double amount[] = { 0., 100000., 0., 0. };
  double comput[] = { 10000000. };

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  taskInit = SD_task_create("Task Init", NULL, 1.0);
  taskA = SD_task_create("Task A", NULL, 1.0);
  taskB = SD_task_create("Task B", NULL, 1.0);

  /* let's launch the simulation! */
  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost,
                   no_cost, -1.0);
  SD_task_schedule(taskA, 2, SD_workstation_get_list(), no_cost, amount,
                   -1.0);
  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comput, no_cost,
                   -1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskInit, taskB);

  ret = SD_simulate(-1.0);
  xbt_dynar_free(&ret);
  SD_task_destroy(taskInit);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #7
0
ファイル: test_comp_only_par.c プロジェクト: Shurakai/SimGrid
int main(int argc, char **argv)
{

  double time;
  double comm_amount[] = { 0.0, 0.0, 0.0, 0.0 };
  double comp_cost[] = { 1.0, 1.0 };

  SD_task_t task;
  xbt_dynar_t ret;

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  task = SD_task_create("partask", NULL, 1.0);
  SD_task_schedule(task, 2, SD_workstation_get_list(), comp_cost,
                   comm_amount, -1.0);

  ret = SD_simulate(-1.0);
  xbt_dynar_free(&ret);

  time = SD_get_clock();

  printf("%g\n", time);
  fflush(stdout);

  SD_task_destroy(task);

  SD_exit();

  return 0;
}
コード例 #8
0
ファイル: sd_task.cpp プロジェクト: dindon-sournois/simgrid
/** @brief create a complex data redistribution task that can then be  auto-scheduled
 *
 * Auto-scheduling mean that the task can be used with SD_task_schedulev(). 
 * This allows to specify the task costs at creation, and decouple them from the scheduling process where you just
 * specify which resource should communicate.
 *
 * A data redistribution can be scheduled on any number of host.
 * The assumed distribution is a 1D block distribution. Each host owns the same share of the \see amount.
 * To be auto-scheduled, \see SD_task_distribute_comm_mxn_1d_block has to be  called first.
 * \param name the name of the task (can be \c nullptr)
 * \param data the user data you want to associate with the task (can be \c nullptr)
 * \param amount amount of data to redistribute by the task
 * \return the new task
 */
SD_task_t SD_task_create_comm_par_mxn_1d_block(const char *name, void *data, double amount)
{
  SD_task_t res = SD_task_create(name, data, amount);
  res->host_list=nullptr;
  res->kind = SD_TASK_COMM_PAR_MXN_1D_BLOCK;

  return res;
}
コード例 #9
0
ファイル: sd_task.cpp プロジェクト: dindon-sournois/simgrid
static inline SD_task_t SD_task_create_sized(const char *name, void *data, double amount, int ws_count)
{
  SD_task_t task = SD_task_create(name, data, amount);
  task->bytes_amount = xbt_new0(double, ws_count * ws_count);
  task->flops_amount = xbt_new0(double, ws_count);
  task->host_count = ws_count;
  task->host_list = xbt_new0(sg_host_t, ws_count);
  return task;
}
コード例 #10
0
ファイル: incomplete.c プロジェクト: simgrid/simgrid
/* SimDag Incomplete Test
 * Scenario:
 *   - Create a bunch of tasks
 *   - schedule only a subset of them (init, A and D)
 *   - run the simulation
 *   - Verify that we detect which tasks are not scheduled and show their state.
 * The scheduled task A sends 1GB. Simulation time should be
 *          1e9/1.25e8 + 1e-4 = 8.0001 seconds
 * Task D is scheduled but depends on unscheduled task C.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double communication_amount1 = 1e9;
  double no_cost = 0.0;

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
  SD_task_t taskB = SD_task_create("Task B", NULL, 1.0);
  SD_task_t taskC = SD_task_create("Task C", NULL, 1.0);
  SD_task_t taskD = SD_task_create("Task D", NULL, 1.0);

  SD_task_dependency_add(taskInit, taskA);
  SD_task_dependency_add(taskInit, taskB);
  SD_task_dependency_add(taskC, taskD);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(taskInit, 1, hosts, &no_cost, &no_cost, -1.0);
  SD_task_schedule(taskA, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);
  SD_task_schedule(taskD, 1, &hosts[0], &no_cost, &communication_amount1, -1.0);
  xbt_free(hosts);

  /* let's launch the simulation! */
  SD_simulate(-1.);

  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);
  SD_task_destroy(taskInit);

  XBT_INFO("Simulation time: %f", SD_get_clock());


  return 0;
}
コード例 #11
0
ファイル: sd_task.cpp プロジェクト: dindon-sournois/simgrid
/** @brief create a parallel computation task that can then be auto-scheduled
 *
 * Auto-scheduling mean that the task can be used with SD_task_schedulev(). This allows to specify the task costs at
 * creation, and decouple them from the scheduling process where you just specify which resource should deliver the
 * mandatory power.
 *
 * A parallel computation can be scheduled on any number of host.
 * The underlying speedup model is Amdahl's law.
 * To be auto-scheduled, \see SD_task_distribute_comp_amdahl has to be called first.
 * \param name the name of the task (can be \c nullptr)
 * \param data the user data you want to associate with the task (can be \c nullptr)
 * \param flops_amount amount of compute work to be done by the task
 * \param alpha purely serial fraction of the work to be done (in [0.;1.[)
 * \return the new task
 */
SD_task_t SD_task_create_comp_par_amdahl(const char *name, void *data, double flops_amount, double alpha)
{
  xbt_assert(alpha < 1. && alpha >= 0., "Invalid parameter: alpha must be in [0.;1.[");

  SD_task_t res = SD_task_create(name, data, flops_amount);
  res->alpha = alpha;
  res->kind = SD_TASK_COMP_PAR_AMDAHL;

  return res;
}
コード例 #12
0
ファイル: test_reinit_costs.c プロジェクト: Shurakai/SimGrid
static SD_task_t create_empty_cost_root()
{
  double no_cost[] = { 0.0 };
  SD_task_t root;

  root = SD_task_create("Root", NULL, 1.0);
  SD_task_schedule(root, 1, SD_workstation_get_list(), no_cost, no_cost,
                   -1.0);

  return root;
}
コード例 #13
0
ファイル: test_reinit_costs.c プロジェクト: Shurakai/SimGrid
static SD_task_t create_root_with_costs()
{
  double comp_cost[] = { 0.0, 0.0 };
  double comm_cost[] = { 0.0, 1.0, 0.0, 0.0 };
  SD_task_t root;

  root = SD_task_create("Root", NULL, 1.0);
  SD_task_schedule(root, 2, SD_workstation_get_list(), comp_cost,
                   comm_cost, -1.0);

  return root;
}
コード例 #14
0
ファイル: basic0.c プロジェクト: fabienchaix/simgrid
/* Basic SimDag Test 0
 * Scenario:
 *   - Create a no-op Init task
 *   - Create two communication tasks: 100MB and 1B
 *   - Schedule them concurrently on the two hosts of the platform
 * The two communications occur simultaneously but one is so short that it has no impact on the other.
 * Simulated time should be:
 *          1e8/1.25e8 + 1e-4 = 0.8001 seconds
 * This corresponds to paying latency once and having the full bandwidth for the big message.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double communication_amount1[] = { 0, 1e8, 0, 0 };
  double communication_amount2[] = { 0, 1, 0, 0 };
  const double no_cost[] = { 0.0, 0.0 };

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task Comm 1", NULL, 1.0);
  SD_task_t taskB = SD_task_create("Task Comm 2", NULL, 1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskInit, taskB);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
  SD_task_schedule(taskA, 2, hosts, no_cost, communication_amount1, -1.0);
  SD_task_schedule(taskB, 2, hosts, no_cost, communication_amount2, -1.0);
  xbt_free(hosts);

  /* let's launch the simulation! */
  SD_simulate(-1.0);
  SD_task_destroy(taskInit);
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #15
0
ファイル: basic4.c プロジェクト: fabienchaix/simgrid
/* Basic SimDag Test 4
 * Scenario:
 *   - Create a chain of tasks (Init, A, Fin)
 *   - Have a 1B communication between two no-op tasks.
 * Verify that the tasks are actually simulated in the right order.
 * The simulated time should be equal to the network latency: 0.0001 seconds.
 */
int main(int argc, char **argv)
{
  /* scheduling parameters */
  double no_cost[] = { 0., 0., 0., 0. };
  double amount[] = { 0., 1., 0., 0. };

  /* SD initialization */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of the tasks and their dependencies */
  SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0);
  SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
  SD_task_t taskFin = SD_task_create("Task Fin", NULL, 1.0);

  SD_task_dependency_add(NULL, NULL, taskInit, taskA);
  SD_task_dependency_add(NULL, NULL, taskA, taskFin);

  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
  SD_task_schedule(taskA, 2, hosts, no_cost, amount, -1.0);
  SD_task_schedule(taskFin, 1, hosts, no_cost, no_cost, -1.0);
  xbt_free(hosts);

  /* let's launch the simulation! */
  SD_simulate(-1.0);
  SD_task_destroy(taskInit);
  SD_task_destroy(taskA);
  SD_task_destroy(taskFin);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  SD_exit();
  return 0;
}
コード例 #16
0
ファイル: comm-p2p-latency-1.c プロジェクト: R7R8/simgrid
/*
 * simple latency test
 * send one byte from 0 to 1 
 * 
 * this is a test for multiple platforms
 * see tesh file for expected output
 */
int main(int argc, char **argv)
{
  double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 };
  const double no_cost[] = { 0.0, 0.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t task = SD_task_create("Comm 1", NULL, 1.0);

  SD_task_schedule(task, 2, sg_host_list(), no_cost, communication_amount, -1.0);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(task);

  SD_exit();
  return 0;
}
コード例 #17
0
ファイル: comp-only-seq.c プロジェクト: fabienchaix/simgrid
int main(int argc, char **argv)
{

  double comm_amount[] = { 0.0 };
  double comp_cost[] = { 1.0 };

  SD_init(&argc, argv);
  SD_create_environment(argv[1]);

  SD_task_t task = SD_task_create("seqtask", NULL, 1.0);
  sg_host_t *hosts = sg_host_list();
  SD_task_schedule(task, 1, hosts, comp_cost, comm_amount, -1.0);
  xbt_free(hosts);

  SD_simulate(-1.0);

  printf("%g\n", SD_get_clock());
  fflush(stdout);

  SD_task_destroy(task);

  SD_exit();
  return 0;
}
コード例 #18
0
ファイル: sd_test.cpp プロジェクト: fabienchaix/simgrid
int main(int argc, char **argv)
{
  sg_host_t host_list[2];
  double computation_amount[2];
  double communication_amount[4] = { 0 };

  /* initialization of SD */
  SD_init(&argc, argv);

  xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
  SD_create_environment(argv[1]);

  /* test the estimation functions */
  const sg_host_t *hosts = sg_host_list();
  sg_host_t h1 = hosts[0];
  sg_host_t h2 = hosts[1];
  const char *name1 = sg_host_get_name(h1);
  const char *name2 = sg_host_get_name(h2);
  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));

  /* creation of the tasks and their dependencies */
  SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
  SD_task_t taskB = SD_task_create("Task B", NULL, 40.0);
  SD_task_t taskC = SD_task_create("Task C", NULL, 30.0);
  SD_task_t taskD = SD_task_create("Task D", NULL, 60.0);

  /* try to attach and retrieve user data to a task */
  SD_task_set_data(taskA, static_cast<void*>(&comp_amount1));
  if (fabs(comp_amount1 - (*(static_cast<double*>(SD_task_get_data(taskA))))) > 1e-12)
      XBT_ERROR("User data was corrupted by a simple set/get");

  SD_task_dependency_add(NULL, NULL, taskB, taskA);
  SD_task_dependency_add(NULL, NULL, taskC, taskA);
  SD_task_dependency_add(NULL, NULL, taskD, taskB);
  SD_task_dependency_add(NULL, NULL, taskD, taskC);
  SD_task_dependency_add(NULL, NULL, taskB, taskC);

  try {
    SD_task_dependency_add(NULL, NULL, taskA, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Hey, I can add a dependency between Task A and Task A!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;                  /* this is a serious error */
  }

  try {
    SD_task_dependency_add(NULL, NULL, taskB, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Oh oh, I can add an already existing dependency!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  try {
    SD_task_dependency_remove(taskA, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Dude, I can remove an unknown dependency!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  try {
    SD_task_dependency_remove(taskC, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Wow, I can remove a dependency between Task C and itself!");
  } catch (xbt_ex& ex) {
    if (ex.category != arg_error)
      throw;
  }

  /* if everything is ok, no exception is forwarded or rethrown by main() */

  /* watch points */
  SD_task_watch(taskD, SD_DONE);
  SD_task_watch(taskB, SD_DONE);
  SD_task_unwatch(taskD, SD_DONE);

  /* scheduling parameters */
  host_list[0] = h1;
  host_list[1] = h2;
  computation_amount[0] = comp_amount1;
  computation_amount[1] = comp_amount2;

  communication_amount[1] = comm_amount12;
  communication_amount[2] = comm_amount21;

  /* estimated time */
  SD_task_t task = taskD;
  XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), SD_task_get_execution_time(task, 2, host_list,
           computation_amount, communication_amount));

  SD_task_schedule(taskA, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskB, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1);
  SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);

  std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
  for (auto task: *changed_tasks){
    XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
          SD_task_get_start_time(task), SD_task_get_finish_time(task));
  }

  XBT_DEBUG("Destroying tasks...");
  SD_task_destroy(taskA);
  SD_task_destroy(taskB);
  SD_task_destroy(taskC);
  SD_task_destroy(taskD);

  XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
  SD_exit();
  return 0;
}
コード例 #19
0
ファイル: sd_test.c プロジェクト: FlorianPO/simgrid
int main(int argc, char **argv)
{
  int i;
  unsigned int ctr;
  const char *platform_file;
  const SD_workstation_t *workstations;
  const char *name1;
  const char *name2;
  double computation_amount1;
  double computation_amount2;
  double communication_amount12;
  double communication_amount21;
  const SD_link_t *route;
  int route_size;
  SD_task_t task, taskA, taskB, taskC, taskD, checkB, checkD;
  xbt_dynar_t changed_tasks;
  xbt_ex_t ex;
  const int workstation_number = 2;
  SD_workstation_t workstation_list[2];
  double computation_amount[2];
  double communication_amount[4] = { 0 };
  double rate = -1.0;
  SD_workstation_t w1, w2;

  /* initialization of SD */
  SD_init(&argc, argv);

  /*  xbt_log_control_set("sd.thres=debug"); */

  if (argc < 2) {
    XBT_INFO("Usage: %s platform_file", argv[0]);
    XBT_INFO("example: %s sd_platform.xml", argv[0]);
    exit(1);
  }

  /* creation of the environment */
  platform_file = argv[1];
  SD_create_environment(platform_file);

  /* test the estimation functions */
  workstations = SD_workstation_get_list();
  w1 = workstations[0];
  w2 = workstations[1];
  SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS);
  name1 = SD_workstation_get_name(w1);
  name2 = SD_workstation_get_name(w2);
  computation_amount1 = 2000000;
  computation_amount2 = 1000000;
  communication_amount12 = 2000000;
  communication_amount21 = 3000000;
  XBT_INFO("Computation time for %f flops on %s: %f", computation_amount1,
        name1, SD_workstation_get_computation_time(w1,
                                                   computation_amount1));
  XBT_INFO("Computation time for %f flops on %s: %f", computation_amount2,
        name2, SD_workstation_get_computation_time(w2,
                                                   computation_amount2));

  XBT_INFO("Route between %s and %s:", name1, name2);
  route = SD_route_get_list(w1, w2);
  route_size = SD_route_get_size(w1, w2);
  for (i = 0; i < route_size; i++) {
    XBT_INFO("   Link %s: latency = %f, bandwidth = %f",
          SD_link_get_name(route[i]),
          SD_link_get_current_latency(route[i]),
          SD_link_get_current_bandwidth(route[i]));
  }
  XBT_INFO("Route latency = %f, route bandwidth = %f",
        SD_route_get_current_latency(w1, w2),
        SD_route_get_current_bandwidth(w1, w2));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f",
        communication_amount12, name1, name2,
        SD_route_get_communication_time(w1, w2, communication_amount12));
  XBT_INFO("Communication time for %f bytes between %s and %s: %f",
        communication_amount21, name2, name1,
        SD_route_get_communication_time(w2, w1, communication_amount21));

  /* creation of the tasks and their dependencies */
  taskA = SD_task_create("Task A", NULL, 10.0);
  taskB = SD_task_create("Task B", NULL, 40.0);
  taskC = SD_task_create("Task C", NULL, 30.0);
  taskD = SD_task_create("Task D", NULL, 60.0);

  /* try to attach and retrieve user data to a task */
  SD_task_set_data(taskA, (void*) &computation_amount1);
  if (computation_amount1 != (*((double*) SD_task_get_data(taskA))))
      XBT_ERROR("User data was corrupted by a simple set/get");

  SD_task_dependency_add(NULL, NULL, taskB, taskA);
  SD_task_dependency_add(NULL, NULL, taskC, taskA);
  SD_task_dependency_add(NULL, NULL, taskD, taskB);
  SD_task_dependency_add(NULL, NULL, taskD, taskC);
  /*  SD_task_dependency_add(NULL, NULL, taskA, taskD); /\* deadlock */



  TRY {
    SD_task_dependency_add(NULL, NULL, taskA, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Hey, I can add a dependency between Task A and Task A!");
  }
  CATCH(ex) {
    if (ex.category != arg_error)
      RETHROW;                  /* this is a serious error */
    xbt_ex_free(ex);
  }

  TRY {
    SD_task_dependency_add(NULL, NULL, taskB, taskA);   /* shouldn't work and must raise an exception */
    xbt_die("Oh oh, I can add an already existing dependency!");
  }
  CATCH(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }

  TRY {
    SD_task_dependency_remove(taskA, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Dude, I can remove an unknown dependency!");
  }
  CATCH(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }

  TRY {
    SD_task_dependency_remove(taskC, taskC);    /* shouldn't work and must raise an exception */
    xbt_die("Wow, I can remove a dependency between Task C and itself!");
  }
  CATCH(ex) {
    if (ex.category != arg_error)
      RETHROW;
    xbt_ex_free(ex);
  }


  /* if everything is ok, no exception is forwarded or rethrown by main() */

  /* watch points */
  SD_task_watch(taskD, SD_DONE);
  SD_task_watch(taskB, SD_DONE);
  SD_task_unwatch(taskD, SD_DONE);


  /* scheduling parameters */
  workstation_list[0] = w1;
  workstation_list[1] = w2;
  computation_amount[0] = computation_amount1;
  computation_amount[1] = computation_amount2;

  communication_amount[1] = communication_amount12;
  communication_amount[2] = communication_amount21;

  /* estimated time */
  task = taskD;
  XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task),
        SD_task_get_execution_time(task, workstation_number,
                                   workstation_list, computation_amount,
                                   communication_amount));

  /* let's launch the simulation! */

  SD_task_schedule(taskA, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskB, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskC, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);
  SD_task_schedule(taskD, workstation_number, workstation_list,
                   computation_amount, communication_amount, rate);

  changed_tasks = SD_simulate(-1.0);
  xbt_dynar_foreach(changed_tasks, ctr, task) {
    XBT_INFO("Task '%s' start time: %f, finish time: %f",
          SD_task_get_name(task),
          SD_task_get_start_time(task), SD_task_get_finish_time(task));
  }
コード例 #20
0
ファイル: sd_fail.c プロジェクト: fabienchaix/simgrid
int main(int argc, char **argv)
{
  double computation_amount[1];
  double communication_amount[2] = { 0 };
  sg_host_t hosts[1];

  /* initialization of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  SD_create_environment(argv[1]);

  /* creation of a single task that will poorly fail when the workstation will stop */
  XBT_INFO("First test: COMP_SEQ task");
  SD_task_t task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
  SD_task_watch(task, SD_FAILED);
  SD_task_watch(task, SD_DONE);

  XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task));

  SD_task_schedulel(task, 1, sg_host_by_name("Faulty Host"));

  xbt_dynar_t tasks = SD_simulate(-1.0);
  xbt_dynar_free(&tasks);

  SD_task_dump(task);

  XBT_INFO("Task '%s' has failed. %.f flops remain to be done", SD_task_get_name(task),
           SD_task_get_remaining_amount(task));

  XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", SD_task_get_name(task));
  SD_task_unschedule(task);
  SD_task_schedulel(task, 1, sg_host_by_name("Safe Host"));

  XBT_INFO("Run the simulation again");
  tasks = SD_simulate(-1.0);
  xbt_dynar_free(&tasks);

  SD_task_dump(task);
  XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task),
           SD_task_get_finish_time(task));

  SD_task_destroy(task);
  task=NULL;

  XBT_INFO("Second test: NON TYPED task");

  task = SD_task_create("Poor parallel task", NULL, 2e10);
  SD_task_watch(task, SD_FAILED);
  SD_task_watch(task, SD_DONE);

  computation_amount[0] = 2e10;

  XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task));

  hosts[0] = sg_host_by_name("Faulty Host");
  SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1);

  tasks = SD_simulate(-1.0);
  xbt_dynar_free(&tasks);

  SD_task_dump(task);

  XBT_INFO("Task '%s' has failed. %.f flops remain to be done", SD_task_get_name(task),
            SD_task_get_remaining_amount(task));

  XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", SD_task_get_name(task));
  SD_task_unschedule(task);

  hosts[0] = sg_host_by_name("Safe Host");

  SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1);

  XBT_INFO("Run the simulation again");
  tasks = SD_simulate(-1.0);
  xbt_dynar_free(&tasks);

  SD_task_dump(task);
  XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task),
           SD_task_get_finish_time(task));

  SD_task_destroy(task);
  SD_exit();
  return 0;
}
コード例 #21
0
ファイル: sd_test2.c プロジェクト: cemsbr/simgrid
int main(int argc, char **argv)
{
  int i, j;
  xbt_dynar_t changed_tasks;
  int n_hosts;
  const SD_workstation_t *hosts;
  SD_task_t taskInit;
  SD_task_t PtoPComm1;
  SD_task_t PtoPComm2;
  SD_task_t ParComp_wocomm;
  SD_task_t IntraRedist;
  SD_task_t ParComp_wcomm1;
  SD_task_t InterRedist;
  SD_task_t taskFinal;
  SD_task_t ParComp_wcomm2;
  SD_workstation_t PtoPcomm1_hosts[2];
  SD_workstation_t PtoPcomm2_hosts[2];
  double PtoPcomm1_table[] = { 0, 12500000, 0, 0 };     /* 100Mb */
  double PtoPcomm2_table[] = { 0, 1250000, 0, 0 };      /* 10Mb */
  double ParComp_wocomm_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 };      /* 1 Gflop per Proc */
  double *ParComp_wocomm_table;
  SD_workstation_t ParComp_wocomm_hosts[5];
  double *IntraRedist_cost;
  double *IntraRedist_table;
  SD_workstation_t IntraRedist_hosts[5];
  double ParComp_wcomm1_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 };      /* 1 Gflop per Proc */
  double *ParComp_wcomm1_table;
  SD_workstation_t ParComp_wcomm1_hosts[5];
  double *InterRedist_cost;
  double *InterRedist_table;
  double ParComp_wcomm2_cost[] = { 1e+8, 1e+8, 1e+8, 1e+8, 1e+8 };      /* 1 Gflop per Proc (0.02sec duration) */
  SD_workstation_t ParComp_wcomm2_hosts[5];
  double final_cost = 5e+9;
  double *ParComp_wcomm2_table;

  /* initialisation of SD */
  SD_init(&argc, argv);

  /* creation of the environment */
  if (strstr(argv[1],".xml"))
    SD_create_environment(argv[1]);
  else
    xbt_die("Unsupported platform description style (not XML): %s",
            argv[1]);

  /* getting platform infos */
  n_hosts = SD_workstation_get_number();
  hosts = SD_workstation_get_list();

  /* sorting hosts by hostname */
  qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t),
        nameCompareHosts);

  /* creation of the tasks */
  taskInit = SD_task_create("Initial", NULL, 1.0);
  PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
  PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
  ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
  IntraRedist = SD_task_create("intra redist", NULL, 1.0);
  ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
  InterRedist = SD_task_create("inter redist", NULL, 1.0);
  taskFinal = SD_task_create("Final", NULL, 1.0);
  ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);


  /* creation of the dependencies */
  SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
  SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2);
  SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm);
  SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist);
  SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1);
  SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist);
  SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2);
  SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal);
  SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal);


  /* scheduling parameters */

  /* large point-to-point communication (0.1 sec duration) */
  PtoPcomm1_hosts[0] = hosts[0];
  PtoPcomm1_hosts[1] = hosts[1];

  /* small point-to-point communication (0.01 sec duration) */
  PtoPcomm2_hosts[0] = hosts[0];
  PtoPcomm2_hosts[1] = hosts[2];

  /* parallel task without intra communications (1 sec duration) */
  ParComp_wocomm_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wocomm_hosts[i] = hosts[i];
  }

  /* redistribution within a cluster (small latencies) */
  /* each host send (4*2.5Mb =) 10Mb */
  /* bandwidth is shared between 5 flows (0.05sec duration) */
  IntraRedist_cost = xbt_new0(double, 5);
  IntraRedist_table = xbt_new0(double, 25);
  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        IntraRedist_table[i * 5 + j] = 0.;
      else
        IntraRedist_table[i * 5 + j] = 312500.; /* 2.5Mb */
    }
  }

  for (i = 0; i < 5; i++) {
    IntraRedist_hosts[i] = hosts[i];
  }

  /* parallel task with intra communications */
  /* Computation domination (1 sec duration) */
  ParComp_wcomm1_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wcomm1_hosts[i] = hosts[i];
  }

  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        ParComp_wcomm1_table[i * 5 + j] = 0.;
      else
        ParComp_wcomm1_table[i * 5 + j] = 312500.;      /* 2.5Mb */
    }
  }

  /* inter cluster redistribution (big latency on the backbone) */
  /* (0.5sec duration without latency impact) */
  InterRedist_cost = xbt_new0(double, 10);
  InterRedist_table = xbt_new0(double, 100);
  for (i = 0; i < 5; i++) {
    InterRedist_table[i * 10 + i + 5] = 1250000.;       /* 10Mb */
  }

  /* parallel task with intra communications */
  /* Communication domination (0.1 sec duration) */

  ParComp_wcomm2_table = xbt_new0(double, 25);

  for (i = 0; i < 5; i++) {
    ParComp_wcomm2_hosts[i] = hosts[i + 5];
  }

  for (i = 0; i < 5; i++) {
    for (j = 0; j < 5; j++) {
      if (i == j)
        ParComp_wcomm2_table[i * 5 + j] = 0.;
      else
        ParComp_wcomm2_table[i * 5 + j] = 625000.;      /* 5Mb */
    }
  }

  /* Sequential task */


  /* scheduling the tasks */
  SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST,
                   -1.0);
  SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST,
                   PtoPcomm1_table, -1.0);
  SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST,
                   PtoPcomm2_table, -1.0);
  SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts,
                   ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
  SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost,
                   IntraRedist_table, -1.0);
  SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts,
                   ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0);
  SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost,
                   InterRedist_table, -1.0);
  SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts,
                   ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
  SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost,
                   SD_SCHED_NO_COST, -1.0);

  /* let's launch the simulation! */
  changed_tasks = SD_simulate(-1.0);

  XBT_INFO("Simulation time: %f", SD_get_clock());

  xbt_dynar_free_container(&changed_tasks);

  free(ParComp_wocomm_table);
  free(IntraRedist_cost);
  free(IntraRedist_table);
  free(ParComp_wcomm1_table);
  free(InterRedist_cost);
  free(InterRedist_table);
  free(ParComp_wcomm2_table);

  SD_task_destroy(taskInit);
  SD_task_destroy(PtoPComm1);
  SD_task_destroy(PtoPComm2);
  SD_task_destroy(ParComp_wocomm);
  SD_task_destroy(IntraRedist);
  SD_task_destroy(ParComp_wcomm1);
  SD_task_destroy(InterRedist);
  SD_task_destroy(ParComp_wcomm2);
  SD_task_destroy(taskFinal);

  SD_exit();
  return 0;
}