Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further cleaning in this rotten realm
[simgrid.git] / src / simdag / simdag_private.h
1 /* Copyright (c) 2006-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #ifndef SIMDAG_PRIVATE_H
8 #define SIMDAG_PRIVATE_H
9
10 #include "xbt/base.h"
11 #include "xbt/dict.h"
12 #include "xbt/dynar.h"
13 #include "simgrid/simdag.h"
14 #include "surf/surf.h"
15 #include "xbt/mallocator.h"
16 #include <stdbool.h>
17
18 SG_BEGIN_DECL()
19
20 /* Global variables */
21
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 */
26
27   xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
28
29   int watch_point_reached;      /* has a task just reached a watch point? */
30
31   xbt_dynar_t initial_task_set;
32   xbt_dynar_t executable_task_set;
33   xbt_dynar_t completed_task_set;
34
35   xbt_dynar_t return_set;
36   int task_number;
37
38 } s_SD_global_t, *SD_global_t;
39
40 extern XBT_PRIVATE SD_global_t sd_global;
41
42 /* Storage */
43 typedef s_xbt_dictelm_t s_SD_storage_t;
44 typedef struct SD_storage {
45   void *data;                   /* user data */
46   const char *host;
47 } s_SD_storage_priv_t, *SD_storage_priv_t;
48
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);
51 }
52
53 /* Task */
54 typedef struct SD_task {
55   e_SD_task_state_t state;
56   void *data;                   /* user data */
57   char *name;
58   e_SD_task_kind_t kind;
59   double amount;
60   double alpha;          /* used by typed parallel tasks */
61   double remains;
62   double start_time;
63   double finish_time;
64   surf_action_t surf_action;
65   unsigned short watch_points;  /* bit field xor()ed with masks */
66
67   int marked;                   /* used to check if the task DAG has some cycle*/
68
69   /* dependencies */
70   xbt_dynar_t tasks_before;
71   xbt_dynar_t tasks_after;
72   int unsatisfied_dependencies;
73   unsigned int is_not_ready;
74
75   /* scheduling parameters (only exist in state SD_SCHEDULED) */
76   int host_count;
77   sg_host_t *host_list;
78   double *flops_amount;
79   double *bytes_amount;
80   double rate;
81
82   long long int counter;        /* task unique identifier for instrumentation */
83   char *category;               /* sd task category for instrumentation */
84 } s_SD_task_t;
85
86 /* Task dependencies */
87 typedef struct SD_dependency {
88   char *name;
89   void *data;
90   SD_task_t src;
91   SD_task_t dst;
92   /* src must be finished before dst can start */
93 } s_SD_dependency_t, *SD_dependency_t;
94
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);
100
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);
105
106 /* Functions to test if the task is in a given state. */
107
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)
110 {
111   return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
112 }
113
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);
117
118 SG_END_DECL()
119
120 #endif