Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some small optimizations
[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/dynar.h"
12 #include "simgrid/simdag.h"
13 #include "surf/surf.h"
14 #include "xbt/mallocator.h"
15 #include <stdbool.h>
16
17 SG_BEGIN_DECL()
18
19 /* Global variables */
20
21 typedef struct SD_global {
22   xbt_mallocator_t task_mallocator; /* to not remalloc new tasks */
23
24   int watch_point_reached;      /* has a task just reached a watch point? */
25
26   xbt_dynar_t initial_task_set;
27   xbt_dynar_t executable_task_set;
28   xbt_dynar_t completed_task_set;
29
30   xbt_dynar_t return_set;
31
32 } s_SD_global_t, *SD_global_t;
33
34 extern XBT_PRIVATE SD_global_t sd_global;
35
36 /* Task */
37 typedef struct SD_task {
38   e_SD_task_state_t state;
39   void *data;                   /* user data */
40   char *name;
41   e_SD_task_kind_t kind;
42   double amount;
43   double alpha;          /* used by typed parallel tasks */
44   double remains;
45   double start_time;
46   double finish_time;
47   surf_action_t surf_action;
48   unsigned short watch_points;  /* bit field xor()ed with masks */
49
50   int marked;                   /* used to check if the task DAG has some cycle*/
51
52   /* dependencies */
53   xbt_dynar_t tasks_before;
54   xbt_dynar_t tasks_after;
55   int unsatisfied_dependencies;
56   unsigned int is_not_ready;
57
58   /* scheduling parameters (only exist in state SD_SCHEDULED) */
59   int host_count;
60   sg_host_t *host_list;
61   double *flops_amount;
62   double *bytes_amount;
63   double rate;
64
65   long long int counter;        /* task unique identifier for instrumentation */
66   char *category;               /* sd task category for instrumentation */
67 } s_SD_task_t;
68
69 /* Task dependencies */
70 typedef struct SD_dependency {
71   char *name;
72   void *data;
73   SD_task_t src;
74   SD_task_t dst;
75   /* src must be finished before dst can start */
76 } s_SD_dependency_t, *SD_dependency_t;
77
78 /* SimDag private functions */
79 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
80 XBT_PRIVATE void SD_task_run(SD_task_t task);
81 XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
82 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
83
84 /* Task mallocator functions */
85 XBT_PRIVATE void* SD_task_new_f(void);
86 XBT_PRIVATE void SD_task_recycle_f(void *t);
87 XBT_PRIVATE void SD_task_free_f(void *t);
88
89 SG_END_DECL()
90 #endif