My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
dfg.h
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
27 #ifndef DFG_H_
28 #define DFG_H_
29 
30 #include <stdio.h>
31 #include <pthread.h>
32 #include <arpa/inet.h>
33 
34 // Putting these up here helps deal with circular dependency warnings
35 struct dfg_config;
36 struct dfg_vertex;
37 
39 #define MAX_MSU 512
40 
42 #define MAIN_THREAD_ID 0
43 
45 #define MAX_RUNTIMES 16
46 
47 #define MAX_THREADS 32
48 
49 #define MAX_ROUTES 64
50 
51 #define MAX_ROUTE_ENDPOINTS 256
52 
53 #define MAX_INIT_DATA_LEN 64
54 
55 #define MAX_MSU_NAME_LEN 32
56 
57 #define MAX_MSU_TYPES 32
58 
59 #define MAX_APP_NAME_LENGTH 64
60 
61 #define MAX_MSU_PER_THREAD 8
62 
66 struct msu_init_data {
68 };
69 
73 struct dfg_runtime {
74  int id;
76  int port;
77  int n_cores;
84  int n_routes;
85  // todo: uint64_t dram;
86  // todo: struct cut *current_alloc;
87  // todo: uint64_t io_network_bw;
88 };
89 
95 };
96 
101 enum thread_mode str_to_thread_mode(char *mode);
102 
104 struct dfg_thread {
105  int id;
108  int n_msus;
110  // todo: int utilization; //sum(msu.wcet / msu.deadline)
111 };
112 
118  struct dfg_thread *thread;
120  int n_routes;
121  // ???: Should `routes` really be located in this structure?
122 
123  // todo: float dedline;
124 };
125 
134 };
135 
143  struct dfg_msu *msu;
144 };
145 
152 struct dfg_route {
153  int id;
158 };
159 
165 };
170 enum blocking_mode str_to_blocking_mode(char *mode_str);
171 
172 // Forward declaration; defined below
173 struct dfg_dependency;
174 
176 struct dfg_msu_type {
177  int id;
189  int cloneable;
193 };
194 
200 };
201 
204  struct dfg_msu_type *type;
206 };
207 
209 #define ENTRY_VERTEX_TYPE 0x01
210 
211 #define EXIT_VERTEX_TYPE 0x02
212 
213 uint8_t str_to_vertex_type(char *type_str);
214 
216 struct dfg_msu {
217  int id;
221  struct dfg_msu_type *type;
226  // todo: struct dfg_profiling profiling;
227 };
228 
230 struct db_info {
232  int port;
233  char name[16];
234  char user[16];
235  char pwd[16];
236 };
237 
239 struct dedos_dfg {
240  char application_name[64];
245  struct db_info db;
246 
251 
253  struct dfg_msu *msus[MAX_MSU];
255  int n_msus;
256 
261 
262  // todo: float application_deadline;
263 };
264 
269 void set_dfg(struct dedos_dfg *dfg);
270 
272 struct db_info *get_db_info();
274 int get_dfg_n_runtimes();
276 struct dfg_runtime *get_dfg_runtime(unsigned int id);
278 struct dfg_msu_type *get_dfg_msu_type(unsigned int id);
280 struct dfg_route *get_dfg_route(unsigned int id);
282 struct dfg_route *get_dfg_rt_route_by_type(struct dfg_runtime *rt, struct dfg_msu_type *route_type);
284 struct dfg_route *get_dfg_msu_route_by_type(struct dfg_msu *msu, struct dfg_msu_type *route_type);
286 struct dfg_msu *get_dfg_msu(unsigned int id);
288 struct dfg_thread *get_dfg_thread(struct dfg_runtime *rt, unsigned int id);
290 struct dfg_route_endpoint *get_dfg_route_endpoint(struct dfg_route *route, unsigned int msu_id);
291 
293 int msu_has_route(struct dfg_msu *msu, struct dfg_route *route);
295 struct dfg_msu *msu_type_on_runtime(struct dfg_runtime *rt, struct dfg_msu_type *type);
296 
298 struct dfg_msu *copy_dfg_msu(struct dfg_msu *input);
300 struct dfg_msu *init_dfg_msu(unsigned int id, struct dfg_msu_type *type, uint8_t vertex_type,
301  enum blocking_mode mode, struct msu_init_data *init_data);
303 int free_dfg_msu(struct dfg_msu *input);
304 
306 int schedule_dfg_msu(struct dfg_msu *msu, unsigned int runtime_id, unsigned int thread_id);
308 int unschedule_dfg_msu(struct dfg_msu *msu);
309 
311 struct dfg_route *create_dfg_route(unsigned int id, struct dfg_msu_type *type,
312  unsigned int runtime_id);
314 int delete_dfg_route(struct dfg_route *route);
315 
317 int add_dfg_route_to_msu(struct dfg_route *route, struct dfg_msu *msu);
318 // TODO: del_dfg_route_from_msu()
319 
322  struct dfg_route *route);
327  uint32_t new_key);
328 
330 struct dfg_thread * create_dfg_thread(struct dfg_runtime *rt, int thread_id,
331  enum thread_mode mode);
332 
334 void free_dfg(struct dedos_dfg *dfg);
335 
336 #endif //DFG_H_
int schedule_dfg_msu(struct dfg_msu *msu, unsigned int runtime_id, unsigned int thread_id)
Places the given MSU on the correct runtime and thread.
Definition: dfg.c:261
int unschedule_dfg_msu(struct dfg_msu *msu)
Removes the given MSU from its runtime and thread.
Definition: dfg.c:339
struct dfg_route_endpoint * get_dfg_route_endpoint(struct dfg_route *route, unsigned int msu_id)
Returns the endpoint within the given route which has the specified MSU ID.
Definition: dfg.c:112
int n_routes
The routes that an MSU can send to.
Definition: dfg.h:120
MSUs which must be present for another MSU to be cloned.
Definition: dfg.h:203
int n_msus
The number of MSUs in dedos_dfg::msus.
Definition: dfg.h:255
enum thread_mode mode
Pinned/unpinned mode for the thread.
Definition: dfg.h:106
uint32_t ip
IP of the node on which the runtime is running.
Definition: dfg.h:75
enum blocking_mode str_to_blocking_mode(char *mode_str)
Converts a string of blocking/non-blocking to the correct enumerator.
Definition: dfg.c:150
struct dfg_msu_type * type
The MSU type which must be present.
Definition: dfg.h:204
thread_mode
Identifies if a thread is pinned to a core or able to be scheduled on any core.
Definition: dfg.h:91
#define MAX_MSU_TYPES
The maximum number of different MSU types that may be present in the DFG.
Definition: dfg.h:57
struct dfg_msu_type * get_dfg_msu_type(unsigned int id)
Returns the MSU type with the given ID.
Definition: dfg.c:68
int global_ctl_port
Port of the global controller.
Definition: dfg.h:242
int n_msus
Number of MSUs placed on the thread.
Definition: dfg.h:108
struct dfg_scheduling scheduling
Information about where an MSU is scheduled.
Definition: dfg.h:225
struct dfg_route * routes[64]
Routes located on this runtime.
Definition: dfg.h:83
int get_dfg_n_runtimes()
Returns the number of registered runtime.
Definition: dfg.c:60
#define MAX_THREADS
The maximum number of threads that may be present on a runtime.
Definition: dfg.h:47
struct dfg_msu * instances[512]
Each instance of this MSU type.
Definition: dfg.h:186
uint32_t global_ctl_ip
IP address of the global controller.
Definition: dfg.h:241
int n_cores
Number of cores on the runtime node.
Definition: dfg.h:77
int msu_has_route(struct dfg_msu *msu, struct dfg_route *route)
Returns 1 if the given MSU has the route as an endpoint.
Definition: dfg.c:121
uint8_t vertex_type
Whether the MSU is #ENTRY, #EXIT, or possible #ENTRY | #EXIT.
Definition: dfg.h:218
int n_src_types
The number of types that should route to this MSU.
Definition: dfg.h:131
uint32_t ip
Definition: dfg.h:231
struct dfg_msu * msus[8]
MSUs placed on that thread.
Definition: dfg.h:107
void set_dfg(struct dedos_dfg *dfg)
Sets the local copy of the DFG, so it doesn't have to be passed in for each call. ...
Definition: dfg.c:34
int n_msu_types
The number of elements in dedos_dfg::msu_types.
Definition: dfg.h:250
static int route(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Definition: baremetal_msu.c:30
int n_dst_types
The number of types that this msu should route to.
Definition: dfg.h:133
msu_locality
Whether an MSU is located on the same runtime or a remote runtime.
Definition: dfg.h:196
unsigned char uint8_t
Definition: uthash.h:97
Default – threads should not have this mode.
Definition: dfg.h:92
char name[32]
A name describing the function of the MSU.
Definition: dfg.h:179
int id
Unique identifier for the runtime.
Definition: dfg.h:74
#define MAX_ROUTES
The total maximum number of routes that may be present in the DFG.
Definition: dfg.h:49
struct dfg_route * get_dfg_rt_route_by_type(struct dfg_runtime *rt, struct dfg_msu_type *route_type)
Returns the route on the given runtime with the specified MSU type.
Definition: dfg.c:90
struct dfg_msu * get_dfg_msu(unsigned int id)
Returns the MSU with the given ID.
Definition: dfg.c:86
#define MAX_MSU_NAME_LEN
The maximum length of the name for an MSU type.
Definition: dfg.h:55
int colocation_group
Definition: dfg.h:191
struct dfg_msu_type * type
The type of the MSU and meta-routing information.
Definition: dfg.h:221
char application_name[64]
Description of the whole application.
Definition: dfg.h:240
char pwd[16]
Definition: dfg.h:235
#define MAX_MSU_PER_THREAD
The maximum number of MSUs which can be placed on a single thread.
Definition: dfg.h:61
Representation of a runtime in the DFG.
Definition: dfg.h:73
struct dfg_dependency * dependencies[32]
These MSU types must be present in order for this MSU type to be cloned.
Definition: dfg.h:183
struct dfg_route_endpoint * endpoints[256]
The endpoints of the route.
Definition: dfg.h:156
struct db_info * get_db_info()
Returns DB info.
Definition: dfg.c:56
char name[16]
Definition: dfg.h:233
uint8_t str_to_vertex_type(char *type_str)
Converts a string containing exit and/or entry to the correct bitmask.
Definition: dfg.c:162
int n_endpoints
The number of endpoints in dfg_route::endpoints.
Definition: dfg.h:157
struct dfg_runtime * runtime
The runtime on which an MSU is running.
Definition: dfg.h:117
int n_runtimes
The number of elements in dedos_dfg::runtimes.
Definition: dfg.h:260
int add_dfg_route_to_msu(struct dfg_route *route, struct dfg_msu *msu)
Subscribes an MSU to a route, so it can send to the route's endpoints.
Definition: dfg.c:428
struct dfg_msu * msu
The MSU at this endpoint to which a message would be delivered.
Definition: dfg.h:143
#define MAX_INIT_DATA_LEN
The maximum length of the initial data that may be passed to an MSU.
Definition: dfg.h:53
int delete_dfg_route(struct dfg_route *route)
Deletes the provided route from the DFG.
Definition: dfg.c:399
struct dfg_route_endpoint * add_dfg_route_endpoint(struct dfg_msu *msu, uint32_t key, struct dfg_route *route)
Adds an MSU as an endpoint to a route.
Definition: dfg.c:455
struct dfg_msu_type * src_types[512]
The types that should route to this MSU.
Definition: dfg.h:130
A type of MSU.
Definition: dfg.h:176
struct dfg_msu_type * msu_types[32]
MSU types which may be present in the application.
Definition: dfg.h:248
struct dfg_thread * get_dfg_thread(struct dfg_runtime *rt, unsigned int id)
Returns the thread on the given runtime with the specified ID.
Definition: dfg.c:108
int id
A unique identifier for the MSU.
Definition: dfg.h:217
blocking_mode
Whether an MSU is blocking or non-blocking.
Definition: dfg.h:161
int cloneable
If cloneable == N, this MSU can be cloned on runtimes numbered up to and including N...
Definition: dfg.h:189
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
Definition: dfg.h:66
int n_unpinned_threads
Number of the above-threads which are unpinned.
Definition: dfg.h:81
Describes which MSU types a given MSU type should route to if it is cloned.
Definition: dfg.h:129
int port
Definition: dfg.h:232
struct dfg_thread * thread
The thread on which an MSU is running.
Definition: dfg.h:118
struct db_info db
DB information.
Definition: dfg.h:245
int id
Unique identifier for the thread.
Definition: dfg.h:105
Representation of a single MSU in the dfg.
Definition: dfg.h:216
struct dfg_thread * create_dfg_thread(struct dfg_runtime *rt, int thread_id, enum thread_mode mode)
Creates a new thread on the given runtime.
Definition: dfg.c:539
struct dfg_route * get_dfg_msu_route_by_type(struct dfg_msu *msu, struct dfg_msu_type *route_type)
Returns the route which the given MSU sends to of the specified MSU type.
Definition: dfg.c:99
struct dfg_msu_type * dst_types[512]
The types that this msu should route to.
Definition: dfg.h:132
#define MAX_MSU
The maximum number of MSUs which can be present in the system at a time.
Definition: dfg.h:39
struct dfg_runtime * runtime
The runtime on which the route is located.
Definition: dfg.h:154
int n_pinned_threads
Number of the above-threads which are pinned.
Definition: dfg.h:80
int id
A unique identifier for the MSU type.
Definition: dfg.h:177
char user[16]
Definition: dfg.h:234
int id
A unique identifier for the route.
Definition: dfg.h:153
int mod_dfg_route_endpoint(struct dfg_route *route, struct dfg_route_endpoint *ep, uint32_t new_key)
Modifies the key associated with an MSU endpoint.
Definition: dfg.c:505
enum msu_locality locality
Whether it must be present on the same machine.
Definition: dfg.h:205
struct dfg_route * routes[32]
Definition: dfg.h:119
Top-level structure holding the data-flow graph.
Definition: dfg.h:239
A route through which MSU messages can be passed.
Definition: dfg.h:152
static struct dedos_dfg * dfg
Static local copy of the DFG, so each call doesn't have to pass a copy.
Definition: dfg.c:32
struct msu_init_data init_data
Initial data passed to the MSU.
Definition: dfg.h:219
enum thread_mode str_to_thread_mode(char *mode)
Converts a string of pinned/unpinned to the corresponding enumerator.
Definition: dfg.c:139
struct dfg_runtime * get_dfg_runtime(unsigned int id)
Returns the runtime with the given ID.
Definition: dfg.c:64
struct dfg_route * create_dfg_route(unsigned int id, struct dfg_msu_type *type, unsigned int runtime_id)
Creates a route with the specified parameters.
Definition: dfg.c:366
Info to connect and use database.
Definition: dfg.h:230
struct dfg_runtime * runtimes[16]
The runtimes present in the application.
Definition: dfg.h:258
A single endpoint for an MSU route.
Definition: dfg.h:139
void free_dfg(struct dedos_dfg *dfg)
Frees the entirety of the DFG structure.
Definition: dfg.c:596
struct dfg_thread * threads[32]
Threads located on the runtime.
Definition: dfg.h:79
uint32_t key
The key associated with this endpoint.
Definition: dfg.h:140
struct dfg_route * get_dfg_route(unsigned int id)
Returns the route with the given ID.
Definition: dfg.c:76
Structure representing the scheduling of an MSU on a runtime.
Definition: dfg.h:116
Representation of a thread on a runtime in the DFG.
Definition: dfg.h:104
int n_routes
Number of routes above.
Definition: dfg.h:84
char init_data[64]
Definition: dfg.h:67
static int runtime_id(int runtime_fd)
unsigned int uint32_t
Definition: uthash.h:96
int n_instances
The number of instances of this MSU type.
Definition: dfg.h:187
int n_dependencies
The number of elements in dfg_msu_type::dependencies.
Definition: dfg.h:184
struct dfg_msu * copy_dfg_msu(struct dfg_msu *input)
Allocates a new MSU with the same fields as the input MSU (though unscheduled)
Definition: dfg.c:190
int port
Port on which the runtime is listening for controller/inter-runtime.
Definition: dfg.h:76
struct dfg_meta_routing meta_routing
Which types of msus route to/from this MSU.
Definition: dfg.h:180
int free_dfg_msu(struct dfg_msu *input)
Frees an MSU structure.
Definition: dfg.c:225
Default value – not to be used.
Definition: dfg.h:197
#define MAX_ROUTE_ENDPOINTS
The maximum number of endpoints that a single route may have as destinations.
Definition: dfg.h:51
#define MAX_RUNTIMES
The maximum number of runtimes that may be present in the DFG.
Definition: dfg.h:45
Default value – used when unset, should never be specified.
Definition: dfg.h:162
enum blocking_mode blocking_mode
Whether the MSU is blocking or not.
Definition: dfg.h:223
struct dfg_msu * msu_type_on_runtime(struct dfg_runtime *rt, struct dfg_msu_type *type)
Returns 1 if the given MSU type is present on the provided runtime.
Definition: dfg.c:130
struct dfg_msu_type * msu_type
The type of MSU to which this route delivers.
Definition: dfg.h:155
struct dfg_msu * init_dfg_msu(unsigned int id, struct dfg_msu_type *type, uint8_t vertex_type, enum blocking_mode mode, struct msu_init_data *init_data)
Allocates a new MSU with the given parameters.
Definition: dfg.c:200
struct dfg_msu * msus[512]
The MSUs present in the application.
Definition: dfg.h:253
int del_dfg_route_endpoint(struct dfg_route *route, struct dfg_route_endpoint *ep)
Removes an MSU as a route endpoint.
Definition: dfg.c:487