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 sg_host_t *host_list; /* array of workstations, created only if
24 necessary in sg_host_list() */
25 SD_link_t *link_list; /* array of links */
27 xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
29 int watch_point_reached; /* has a task just reached a watch point? */
31 xbt_dynar_t initial_task_set;
32 xbt_dynar_t executable_task_set;
33 xbt_dynar_t completed_task_set;
35 xbt_dynar_t return_set;
38 } s_SD_global_t, *SD_global_t;
40 extern XBT_PRIVATE SD_global_t sd_global;
43 typedef s_xbt_dictelm_t s_SD_storage_t;
44 typedef struct SD_storage {
45 void *data; /* user data */
47 } s_SD_storage_priv_t, *SD_storage_priv_t;
49 static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){
50 return (SD_storage_priv_t)xbt_lib_get_level(storage, SD_STORAGE_LEVEL);
54 typedef struct SD_task {
55 e_SD_task_state_t state;
56 void *data; /* user data */
58 e_SD_task_kind_t kind;
60 double alpha; /* used by typed parallel tasks */
64 surf_action_t surf_action;
65 unsigned short watch_points; /* bit field xor()ed with masks */
67 int marked; /* used to check if the task DAG has some cycle*/
70 xbt_dynar_t tasks_before;
71 xbt_dynar_t tasks_after;
72 int unsatisfied_dependencies;
73 unsigned int is_not_ready;
75 /* scheduling parameters (only exist in state SD_SCHEDULED) */
82 long long int counter; /* task unique identifier for instrumentation */
83 char *category; /* sd task category for instrumentation */
86 /* Task dependencies */
87 typedef struct SD_dependency {
92 /* src must be finished before dst can start */
93 } s_SD_dependency_t, *SD_dependency_t;
95 /* SimDag private functions */
96 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
97 XBT_PRIVATE void SD_task_run(SD_task_t task);
98 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
99 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
101 /* Task mallocator functions */
102 XBT_PRIVATE void* SD_task_new_f(void);
103 XBT_PRIVATE void SD_task_recycle_f(void *t);
104 XBT_PRIVATE void SD_task_free_f(void *t);
106 /* Functions to test if the task is in a given state. */
108 /* Returns whether the given task is scheduled or runnable. */
109 static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
111 return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
114 /********** Storage **********/
115 XBT_PRIVATE SD_storage_t __SD_storage_create(void *surf_storage, void *data);
116 XBT_PRIVATE void __SD_storage_destroy(void *storage);