1 /* Copyright (c) 2006-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMDAG_PRIVATE_H
8 #define SIMDAG_PRIVATE_H
12 #include "xbt/dynar.h"
13 #include "simgrid/simdag.h"
14 #include "surf/surf.h"
15 #include "xbt/mallocator.h"
20 /* Global variables */
22 typedef struct SD_global {
23 SD_workstation_t *workstation_list; /* array of workstations, created only if
24 necessary in SD_workstation_get_list */
25 SD_link_t *link_list; /* array of links */
26 SD_link_t *recyclable_route; /* array returned by SD_route_get_list
27 and mallocated only once */
29 xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
31 int watch_point_reached; /* has a task just reached a watch point? */
33 xbt_dynar_t initial_task_set;
34 xbt_dynar_t executable_task_set;
35 xbt_dynar_t completed_task_set;
37 xbt_dynar_t return_set;
40 } s_SD_global_t, *SD_global_t;
42 extern XBT_PRIVATE SD_global_t sd_global;
45 typedef s_xbt_dictelm_t s_SD_workstation_t;
48 typedef s_xbt_dictelm_t s_SD_storage_t;
49 typedef struct SD_storage {
50 void *data; /* user data */
52 } s_SD_storage_priv_t, *SD_storage_priv_t;
54 static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){
55 return (SD_storage_priv_t)xbt_lib_get_level(storage, SD_STORAGE_LEVEL);
59 typedef struct SD_task {
60 e_SD_task_state_t state;
61 void *data; /* user data */
63 e_SD_task_kind_t kind;
65 double alpha; /* used by typed parallel tasks */
69 surf_action_t surf_action;
70 unsigned short watch_points; /* bit field xor()ed with masks */
72 int marked; /* used to check if the task DAG has some cycle*/
75 xbt_dynar_t tasks_before;
76 xbt_dynar_t tasks_after;
77 int unsatisfied_dependencies;
78 unsigned int is_not_ready;
80 /* scheduling parameters (only exist in state SD_SCHEDULED) */
82 SD_workstation_t *workstation_list; /* surf workstations */
87 long long int counter; /* task unique identifier for instrumentation */
88 char *category; /* sd task category for instrumentation */
91 /* Task dependencies */
92 typedef struct SD_dependency {
97 /* src must be finished before dst can start */
98 } s_SD_dependency_t, *SD_dependency_t;
100 /* SimDag private functions */
101 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
102 XBT_PRIVATE void SD_task_run(SD_task_t task);
103 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
104 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
106 /* Task mallocator functions */
107 XBT_PRIVATE void* SD_task_new_f(void);
108 XBT_PRIVATE void SD_task_recycle_f(void *t);
109 XBT_PRIVATE void SD_task_free_f(void *t);
111 /* Functions to test if the task is in a given state. */
113 /* Returns whether the given task is scheduled or runnable. */
114 static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
116 return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
119 /********** Storage **********/
120 XBT_PRIVATE SD_storage_t __SD_storage_create(void *surf_storage, void *data);
121 XBT_PRIVATE void __SD_storage_destroy(void *storage);
123 /********** Tracing **********/
124 /* declaration of instrumentation functions from sd_task_instr.c */
125 XBT_PRIVATE void TRACE_sd_task_create(SD_task_t task);
126 XBT_PRIVATE void TRACE_sd_task_execute_start(SD_task_t task);
127 XBT_PRIVATE void TRACE_sd_task_execute_end(SD_task_t task);
128 XBT_PRIVATE void TRACE_sd_task_destroy(SD_task_t task);