Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4a1bdff10beb0ec2d9b584f0b20c0ae2d56a86f1
[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 /* Task */
39 typedef struct SD_task {
40   e_SD_task_state_t state;
41   void *data;                   /* user data */
42   char *name;
43   e_SD_task_kind_t kind;
44   double amount;
45   double alpha;          /* used by typed parallel tasks */
46   double remains;
47   double start_time;
48   double finish_time;
49   surf_action_t surf_action;
50   unsigned short watch_points;  /* bit field xor()ed with masks */
51
52   int marked;                   /* used to check if the task DAG has some cycle*/
53
54   /* dependencies */
55   xbt_dynar_t tasks_before;
56   xbt_dynar_t tasks_after;
57   int unsatisfied_dependencies;
58   unsigned int is_not_ready;
59
60   /* scheduling parameters (only exist in state SD_SCHEDULED) */
61   int host_count;
62   sg_host_t *host_list;
63   double *flops_amount;
64   double *bytes_amount;
65   double rate;
66
67   long long int counter;        /* task unique identifier for instrumentation */
68   char *category;               /* sd task category for instrumentation */
69 } s_SD_task_t;
70
71 /* Task dependencies */
72 typedef struct SD_dependency {
73   char *name;
74   void *data;
75   SD_task_t src;
76   SD_task_t dst;
77   /* src must be finished before dst can start */
78 } s_SD_dependency_t, *SD_dependency_t;
79
80 /* SimDag private functions */
81 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
82 XBT_PRIVATE void SD_task_run(SD_task_t task);
83 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
84 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
85
86 /* Task mallocator functions */
87 XBT_PRIVATE void* SD_task_new_f(void);
88 XBT_PRIVATE void SD_task_recycle_f(void *t);
89 XBT_PRIVATE void SD_task_free_f(void *t);
90
91 /* Functions to test if the task is in a given state. */
92
93 /* Returns whether the given task is scheduled or runnable. */
94 static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
95 {
96   return task->state == SD_SCHEDULED || task->state == SD_RUNNABLE;
97 }
98
99 SG_END_DECL()
100
101 #endif