#include "xbt/log.h"
#include "simgrid/link.h"
#include "simgrid/host.h"
-
SG_BEGIN_DECL()
/** @brief Link opaque datatype
/** @brief Task states
@ingroup SD_task_api */
typedef enum {
- SD_NOT_SCHEDULED = 0, /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
- SD_SCHEDULABLE = 0x0001, /**< @brief A task becomes SD_SCHEDULABLE as soon as its dependencies are satisfied */
- SD_SCHEDULED = 0x0002, /**< @brief A task becomes SD_SCHEDULED when you call function
+ SD_NOT_SCHEDULED = 0x0001, /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
+ SD_SCHEDULABLE = 0x0002, /**< @brief A task becomes SD_SCHEDULABLE as soon as its dependencies are satisfied */
+ SD_SCHEDULED = 0x0004, /**< @brief A task becomes SD_SCHEDULED when you call function
SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
- SD_RUNNABLE = 0x0004, /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
- SD_RUNNING = 0x0008, /**< @brief An SD_RUNNABLE task becomes SD_RUNNING when it is launched. */
- SD_DONE = 0x0010, /**< @brief The task is successfully finished. */
- SD_FAILED = 0x0020 /**< @brief A problem occurred during the execution of the task. */
+ SD_RUNNABLE = 0x0008, /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
+ SD_RUNNING = 0x0010, /**< @brief An SD_RUNNABLE task becomes SD_RUNNING when it is launched. */
+ SD_DONE = 0x0020, /**< @brief The task is successfully finished. */
+ SD_FAILED = 0x0040 /**< @brief A problem occurred during the execution of the task. */
} e_SD_task_state_t;
/** @brief Task kinds
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
*
SD_global_t sd_global = nullptr;
+/**
+ * \brief helper for pretty printing of task state
+ * \param state the state of a task
+ * \return the equivalent as a readable string
+ */
+const char *__get_state_name(e_SD_task_state_t state){
+ std::string state_names[7] = { "not scheduled", "schedulable", "scheduled", "runnable","running", "done", "failed" };
+ return state_names[(int)log2(state)].data();
+}
+
/**
* \brief Initializes SD internal data
*
sd_global = xbt_new(s_SD_global_t, 1);
sd_global->watch_point_reached = false;
-
sd_global->initial_tasks = new std::set<SD_task_t>();
sd_global->runnable_tasks = new std::set<SD_task_t>();
sd_global->completed_tasks = new std::set<SD_task_t>();
if (!sd_global->watch_point_reached && how_long < 0 && !sd_global->initial_tasks->empty()) {
XBT_WARN("Simulation is finished but %zu tasks are still not done", sd_global->initial_tasks->size());
- static const char* state_names[] =
- { "SD_NOT_SCHEDULED", "SD_SCHEDULABLE", "SD_SCHEDULED", "SD_RUNNABLE", "SD_RUNNING", "SD_DONE","SD_FAILED" };
for (auto t : *sd_global->initial_tasks)
- XBT_WARN("%s is in %s state", SD_task_get_name(t), state_names[SD_task_get_state(t)]);
+ XBT_WARN("%s is in %s state", SD_task_get_name(t), __get_state_name(SD_task_get_state(t)));
}
XBT_DEBUG("elapsed_time = %f, total_time = %f, watch_point_reached = %d",
jedule_sd_cleanup();
jedule_sd_exit();
#endif
-
delete sd_global->initial_tasks;
delete sd_global->runnable_tasks;
delete sd_global->completed_tasks;
void SD_task_dump(SD_task_t task)
{
XBT_INFO("Displaying task %s", SD_task_get_name(task));
- char *statename = bprintf("%s%s%s%s%s%s%s",
- (task->state == SD_NOT_SCHEDULED ? " not scheduled" : ""),
- (task->state == SD_SCHEDULABLE ? " schedulable" : ""),
- (task->state == SD_SCHEDULED ? " scheduled" : ""),
- (task->state == SD_RUNNABLE ? " runnable" : " not runnable"),
- (task->state == SD_RUNNING ? " running" : ""),
- (task->state == SD_DONE ? " done" : ""),
- (task->state == SD_FAILED ? " failed" : ""));
- XBT_INFO(" - state:%s", statename);
- free(statename);
+ if (task->state == SD_RUNNABLE)
+ XBT_INFO(" - state: runnable");
+ else if (task->state < SD_RUNNABLE)
+ XBT_INFO(" - state: %s not runnable", __get_state_name(task->state));
+ else
+ XBT_INFO(" - state: not runnable %s", __get_state_name(task->state));
if (task->kind != 0) {
switch (task->kind) {
#ifndef SIMDAG_PRIVATE_H
#define SIMDAG_PRIVATE_H
#include <set>
+#include <string>
#include <vector>
#include "xbt/dynar.h"
#include "simgrid/simdag.h"
typedef struct SD_global {
bool watch_point_reached; /* has a task just reached a watch point? */
-
std::set<SD_task_t> *initial_tasks;
std::set<SD_task_t> *runnable_tasks;
std::set<SD_task_t> *completed_tasks;
XBT_PRIVATE void SD_task_run(SD_task_t task);
XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
+XBT_PRIVATE const char *__get_state_name(e_SD_task_state_t state);
SG_END_DECL()
#endif
$ ${bindir:=.}/incomplete ../../../examples/platforms/two_hosts_platform_shared.xml "--log=root.fmt:[%10.6r]%e%m%n"
> [ 0.000000] Switching to the L07 model to handle parallel tasks.
> [ 8.000100] Simulation is finished but 3 tasks are still not done
-> [ 8.000100] Task D is in SD_SCHEDULED state
-> [ 8.000100] Task C is in SD_NOT_SCHEDULED state
-> [ 8.000100] Task B is in SD_SCHEDULABLE state
+> [ 8.000100] Task D is in scheduled state
+> [ 8.000100] Task C is in not scheduled state
+> [ 8.000100] Task B is in schedulable state
> [ 8.000100] Simulation time: 8.000100