Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dead code
[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   xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
24
25   int watch_point_reached;      /* has a task just reached a watch point? */
26
27   xbt_dynar_t initial_task_set;
28   xbt_dynar_t executable_task_set;
29   xbt_dynar_t completed_task_set;
30
31   xbt_dynar_t return_set;
32   int task_number;
33
34 } s_SD_global_t, *SD_global_t;
35
36 extern XBT_PRIVATE SD_global_t sd_global;
37
38 /* Storage */
39 typedef s_xbt_dictelm_t s_SD_storage_t;
40 typedef struct SD_storage {
41   void *data;                   /* user data */
42   const char *host;
43 } s_SD_storage_priv_t, *SD_storage_priv_t;
44
45 static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){
46   return (SD_storage_priv_t)xbt_lib_get_level(storage, SD_STORAGE_LEVEL);
47 }
48
49 /* Task */
50 typedef struct SD_task {
51   e_SD_task_state_t state;
52   void *data;                   /* user data */
53   char *name;
54   e_SD_task_kind_t kind;
55   double amount;
56   double alpha;          /* used by typed parallel tasks */
57   double remains;
58   double start_time;
59   double finish_time;
60   surf_action_t surf_action;
61   unsigned short watch_points;  /* bit field xor()ed with masks */
62
63   int marked;                   /* used to check if the task DAG has some cycle*/
64
65   /* dependencies */
66   xbt_dynar_t tasks_before;
67   xbt_dynar_t tasks_after;
68   int unsatisfied_dependencies;
69   unsigned int is_not_ready;
70
71   /* scheduling parameters (only exist in state SD_SCHEDULED) */
72   int host_count;
73   sg_host_t *host_list;
74   double *flops_amount;
75   double *bytes_amount;
76   double rate;
77
78   long long int counter;        /* task unique identifier for instrumentation */
79   char *category;               /* sd task category for instrumentation */
80 } s_SD_task_t;
81
82 /* Task dependencies */
83 typedef struct SD_dependency {
84   char *name;
85   void *data;
86   SD_task_t src;
87   SD_task_t dst;
88   /* src must be finished before dst can start */
89 } s_SD_dependency_t, *SD_dependency_t;
90
91 /* SimDag private functions */
92 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
93 XBT_PRIVATE void SD_task_run(SD_task_t task);
94 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
95 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
96
97 /* Task mallocator functions */
98 XBT_PRIVATE void* SD_task_new_f(void);
99 XBT_PRIVATE void SD_task_recycle_f(void *t);
100 XBT_PRIVATE void SD_task_free_f(void *t);
101
102 /* Functions to test if the task is in a given state. */
103
104 /* Returns whether the given task is scheduled or runnable. */
105 static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
106 {
107   return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
108 }
109
110 /********** Storage **********/
111 XBT_PRIVATE SD_storage_t __SD_storage_create(void *surf_storage, void *data);
112 XBT_PRIVATE void __SD_storage_destroy(void *storage);
113
114 SG_END_DECL()
115
116 #endif