/********************************* Task **************************************/
struct s_simdata_task_t {
- ~s_simdata_task_t() { delete[] this->host_list; /* parallel tasks only */ }
+ ~s_simdata_task_t()
+ {
+ /* parallel tasks only */
+ delete[] this->host_list;
+ /* flops_parallel_amount and bytes_parallel_amount are automatically deleted in ~L07Action */
+ }
void setUsed();
void setNotUsed() { this->isused = false; }
/* Simulator Data specific to parallel tasks */
simdata->host_nb = host_nb;
simdata->host_list = new sg_host_t[host_nb];
- simdata->flops_parallel_amount = flops_amount;
- simdata->bytes_parallel_amount = bytes_amount;
-
std::copy_n(host_list, host_nb, simdata->host_list);
+ if (flops_amount != nullptr) {
+ simdata->flops_parallel_amount = new double[host_nb];
+ std::copy_n(flops_amount, host_nb, simdata->flops_parallel_amount);
+ }
+ if (bytes_amount != nullptr) {
+ simdata->bytes_parallel_amount = new double[host_nb * host_nb];
+ std::copy_n(bytes_amount, host_nb * host_nb, simdata->bytes_parallel_amount);
+ }
return task;
}
-/* Copyright (c) 2006-2016. The SimGrid Team.
+/* Copyright (c) 2006-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "simdag_private.hpp"
#include "src/surf/HostImpl.hpp"
#include "src/surf/surf_interface.hpp"
+#include <algorithm>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_task, sd, "Logging specific to SimDag (task)");
/* Copy the elements of the task into the action */
int host_nb = task->allocation->size();
- sg_host_t *hosts = xbt_new(sg_host_t, host_nb);
- int i =0;
- for (auto const& host : *task->allocation) {
- hosts[i] = host;
- i++;
- }
+ sg_host_t* hosts = new sg_host_t[host_nb];
+ std::copy_n(task->allocation->begin(), host_nb, hosts);
- double *flops_amount = xbt_new0(double, host_nb);
- double *bytes_amount = xbt_new0(double, host_nb * host_nb);
+ double* flops_amount = new double[host_nb]();
+ double* bytes_amount = new double[host_nb * host_nb]();
if(task->flops_amount)
- memcpy(flops_amount, task->flops_amount, sizeof(double) * host_nb);
+ std::copy_n(task->flops_amount, host_nb, flops_amount);
if(task->bytes_amount)
- memcpy(bytes_amount, task->bytes_amount, sizeof(double) * host_nb * host_nb);
+ std::copy_n(task->bytes_amount, host_nb * host_nb, bytes_amount);
task->surf_action = surf_host_model->executeParallelTask(host_nb, hosts, flops_amount, bytes_amount, task->rate);
#include "src/plugins/vm/VirtualMachineImpl.hpp"
#include "src/surf/surf_interface.hpp"
#include "xbt/ex.hpp"
+#include <algorithm>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts");
simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, nullptr));
/* set surf's synchro */
- sg_host_t *host_list_cpy = xbt_new0(sg_host_t, host_nb);
- for (int i = 0; i < host_nb; i++)
- host_list_cpy[i] = host_list[i];
+ sg_host_t* host_list_cpy = new sg_host_t[host_nb];
+ std::copy_n(host_list, host_nb, host_list_cpy);
/* Check that we are not mixing VMs and PMs in the parallel task */
bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[0]));
xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider "
"using the ptask model");
}
- } else
+ } else {
xbt_die(
"This model only accepts one of the following. You should consider using the ptask model for the other cases.\n"
" - execution with one host only and no communication\n"
" - Self-comms with one host only\n"
" - Communications with two hosts and no computation");
- xbt_free(host_list);
+ }
+ delete[] host_list;
+ delete[] flops_amount;
+ delete[] bytes_amount;
return action;
}
this->setCost(1.0);
this->setRemains(0.0);
}
- xbt_free(host_list);
+ delete[] host_list;
}
Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
- sg_host_t*host_list = xbt_new0(sg_host_t, 2);
- double *flops_amount = xbt_new0(double, 2);
- double *bytes_amount = xbt_new0(double, 4);
+ sg_host_t* host_list = new sg_host_t[2]();
+ double* flops_amount = new double[2]();
+ double* bytes_amount = new double[4]();
host_list[0] = src;
host_list[1] = dst;
Action *CpuL07::execution_start(double size)
{
- sg_host_t*host_list = xbt_new0(sg_host_t, 1);
- double *flops_amount = xbt_new0(double, 1);
+ sg_host_t* host_list = new sg_host_t[1]();
+ double* flops_amount = new double[1]();
host_list[0] = getHost();
flops_amount[0] = size;
L07Action::~L07Action(){
delete hostList_;
- free(communicationAmount_);
- free(computationAmount_);
+ delete[] communicationAmount_;
+ delete[] computationAmount_;
}
void L07Action::updateBound()