*/
void SIMIX_host_destroy(void *h)
{
- smx_host_priv_t host = (smx_host_priv_t) h;
+ smx_host_priv_t host = static_cast<smx_host_priv_t>(h);
xbt_assert((host != nullptr), "Invalid parameters");
void _SIMIX_host_free_process_arg(void *data)
{
- smx_process_arg_t arg = *(smx_process_arg_t*)data;
+ smx_process_arg_t arg = *(static_cast<smx_process_arg_t*>(data));
delete arg;
}
/**
XBT_DEBUG("Restarting Process %s(%s) right now", arg->name.c_str(), arg->hostname);
if (simix_global->create_process_function) {
- simix_global->create_process_function(arg->name.c_str(),
- arg->code,
- nullptr,
- arg->hostname,
- arg->kill_time,
- arg->properties,
- arg->auto_restart,
- nullptr);
+ simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->hostname, arg->kill_time,
+ arg->properties, arg->auto_restart, nullptr);
} else {
- simcall_process_create(arg->name.c_str(),
- arg->code,
- nullptr,
- arg->hostname,
- arg->kill_time,
- arg->properties,
+ simcall_process_create(arg->name.c_str(), arg->code, nullptr, arg->hostname, arg->kill_time, arg->properties,
arg->auto_restart);
}
}
xbt_dynar_reset(process_list);
}
-smx_synchro_t simcall_HANDLER_execution_start(smx_simcall_t simcall,
- const char* name, double flops_amount, double priority, double bound, unsigned long affinity_mask) {
+smx_synchro_t simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount,
+ double priority, double bound, unsigned long affinity_mask) {
return SIMIX_execution_start(simcall->issuer, name,flops_amount,priority,bound,affinity_mask);
}
-smx_synchro_t SIMIX_execution_start(smx_process_t issuer, const char *name,
- double flops_amount, double priority, double bound, unsigned long affinity_mask){
+
+smx_synchro_t SIMIX_execution_start(smx_process_t issuer, const char *name, double flops_amount, double priority,
+ double bound, unsigned long affinity_mask){
/* alloc structures and initialize */
simgrid::simix::Exec *exec = new simgrid::simix::Exec(name, issuer->host);
exec->surf_exec->setData(exec);
exec->surf_exec->setPriority(priority);
- if (bound != 0)
+ if (bound > 0)
static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
if (affinity_mask != 0) {
return exec;
}
-smx_synchro_t SIMIX_execution_parallel_start(const char *name,
- int host_nb, sg_host_t *host_list,
- double *flops_amount, double *bytes_amount,
- double amount, double rate){
-
- sg_host_t *host_list_cpy = nullptr;
- int i;
+smx_synchro_t SIMIX_execution_parallel_start(const char *name, int host_nb, sg_host_t *host_list, double *flops_amount,
+ double *bytes_amount, double amount, double rate){
/* alloc structures and initialize */
simgrid::simix::Exec *exec = new simgrid::simix::Exec(name, nullptr);
/* set surf's synchro */
- host_list_cpy = xbt_new0(sg_host_t, host_nb);
- for (i = 0; i < host_nb; i++)
+ 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];
/* Check that we are not mixing VMs and PMs in the parallel task */
simgrid::surf::HostImpl *host = host_list[0]->extension<simgrid::surf::HostImpl>();
bool is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host));
- for (i = 1; i < host_nb; i++) {
+ for (int i = 1; i < host_nb; i++) {
bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host_list[i]->extension<simgrid::surf::HostImpl>()));
xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
}
void SIMIX_set_category(smx_synchro_t synchro, const char *category)
{
- if (synchro->state != SIMIX_RUNNING) return;
+ if (synchro->state != SIMIX_RUNNING)
+ return;
simgrid::simix::Exec *exec = dynamic_cast<simgrid::simix::Exec *>(synchro);
if (exec != nullptr) {
*
* \return The SIMIX process
*/
-smx_process_t SIMIX_process_self(void)
+smx_process_t SIMIX_process_self()
{
smx_context_t self_context = SIMIX_context_self();
- return self_context ? self_context->process() : nullptr;
+ return (self_context != nullptr) ? self_context->process() : nullptr;
}
/**
xbt_os_mutex_acquire(simix_global->mutex);
/* cancel non-blocking communications */
- smx_synchro_t synchro;
- while ((synchro = (smx_synchro_t) xbt_fifo_pop(process->comms))) {
+ smx_synchro_t synchro = static_cast<smx_synchro_t>(xbt_fifo_pop(process->comms));
+ while (synchro != nullptr) {
simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
/* make sure no one will finish the comm after this process is destroyed,
} else {
xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro);
}
+ synchro = static_cast<smx_synchro_t>(xbt_fifo_pop(process->comms));
}
XBT_DEBUG("%p should not be run anymore",process);
* Should be called some time to time to free the memory allocated for processes
* that have finished (or killed).
*/
-void SIMIX_process_empty_trash(void)
+void SIMIX_process_empty_trash()
{
smx_process_t process = nullptr;
process->ppid = SIMIX_process_get_PID(parent_process);
/* SMPI process have their own data segment and
each other inherit from their father */
- #if HAVE_SMPI
+#if HAVE_SMPI
if(smpi_privatize_global_variables){
if(parent_process->pid != 0){
SIMIX_segment_index_set(process, parent_process->segment_index);
SIMIX_segment_index_set(process, process->pid - 1);
}
}
- #endif
+#endif
}
/* Process data for auto-restart */
return process;
}
-void SIMIX_process_detach(void)
+void SIMIX_process_detach()
{
auto context = dynamic_cast<simgrid::simix::AttachContext*>(SIMIX_context_self());
if (!context)
* The two lists are swapped so, be careful when using them before and after a
* call to this function.
*/
-void SIMIX_process_runall(void)
+void SIMIX_process_runall()
{
SIMIX_context_runall();
xbt_fifo_remove(process->comms, process->waiting_synchro);
comm->cancel();
- // Remove first occurence of &process->simcall:
+ // Remove first occurrence of &process->simcall:
auto i = boost::range::find(
process->waiting_synchro->simcalls,
&process->simcall);
XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
}
-
}
/** @brief Ask another process to raise the given exception
{
process->new_host = dest;
}
-void SIMIX_process_change_host(smx_process_t process,
- sg_host_t dest)
+void SIMIX_process_change_host(smx_process_t process, sg_host_t dest)
{
xbt_assert((process != nullptr), "Invalid parameters");
xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
XBT_OUT();
}
-int SIMIX_process_get_maxpid(void) {
+int SIMIX_process_get_maxpid() {
return simix_process_maxpid;
}
-int SIMIX_process_count(void)
+int SIMIX_process_count()
{
return xbt_swag_size(simix_global->process_list);
}
/* needs to be public and without simcall because it is called
by exceptions and logging events */
-const char* SIMIX_process_self_get_name(void) {
+const char* SIMIX_process_self_get_name() {
smx_process_t process = SIMIX_process_self();
if (process == nullptr || process == simix_global->maestro_process)
/**
* \brief Returns the list of processes to run.
*/
-xbt_dynar_t SIMIX_process_get_runnable(void)
+xbt_dynar_t SIMIX_process_get_runnable()
{
return simix_global->process_to_run;
}
{
smx_process_t proc;
xbt_swag_foreach(proc, simix_global->process_list) {
- if (proc->pid == (unsigned long) PID)
+ if (proc->pid == static_cast<unsigned long> (PID))
return proc;
}
return nullptr;
}
-/** @brief returns a dynar containg all currently existing processes */
-xbt_dynar_t SIMIX_processes_as_dynar(void) {
+/** @brief returns a dynar containing all currently existing processes */
+xbt_dynar_t SIMIX_processes_as_dynar() {
smx_process_t proc;
xbt_dynar_t res = xbt_dynar_new(sizeof(smx_process_t),nullptr);
xbt_swag_foreach(proc, simix_global->process_list) {
return res;
}
-
void SIMIX_process_on_exit_runall(smx_process_t process) {
s_smx_process_exit_fun_t exit_fun;
- smx_process_exit_status_t exit_status = (process->context->iwannadie) ?
- SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
+ smx_process_exit_status_t exit_status = (process->context->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
while (!xbt_dynar_is_empty(process->on_exit)) {
exit_fun = xbt_dynar_pop_as(process->on_exit,s_smx_process_exit_fun_t);
(exit_fun.fun)((void*)exit_status, exit_fun.arg);
}
/** @brief Restart a process, starting it again from the beginning. */
smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) {
- XBT_DEBUG("Restarting process %s on %s",
- process->name.c_str(), sg_host_get_name(process->host));
+ XBT_DEBUG("Restarting process %s on %s", process->name.c_str(), sg_host_get_name(process->host));
//retrieve the arguments of the old process
//FIXME: Factorize this with SIMIX_host_add_auto_restart_process ?
//start the new process
if (simix_global->create_process_function)
- return simix_global->create_process_function(
- arg.name.c_str(), std::move(arg.code), arg.data,
- arg.hostname, arg.kill_time,
- arg.properties, arg.auto_restart,
- nullptr);
+ return simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.hostname,
+ arg.kill_time, arg.properties, arg.auto_restart, nullptr);
else
- return simcall_process_create(
- arg.name.c_str(), std::move(arg.code), arg.data,
- arg.hostname, arg.kill_time,
+ return simcall_process_create(arg.name.c_str(), std::move(arg.code), arg.data, arg.hostname, arg.kill_time,
arg.properties, arg.auto_restart);
}
name = "";
smx_process_t self = SIMIX_process_self();
return simgrid::simix::kernelImmediate([&] {
- return SIMIX_process_create(name,
- std::move(code), data, hostname,
- kill_time, properties, auto_restart,
- self);
+ return SIMIX_process_create(name, std::move(code), data, hostname, kill_time, properties, auto_restart, self);
});
}