My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions | Variables
dfg.c File Reference

Code for the creation and modifcation of the data-flow graph. More...

#include "dfg.h"
#include "logging.h"
#include <stdbool.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define SEARCH_FOR_ID(s, n, field, id_)
 Convenience macro to search a field within a structure for the element with an ID. More...
 

Functions

void set_dfg (struct dedos_dfg *dfg_in)
 Sets the local copy of the DFG, so it doesn't have to be passed in for each call. More...
 
struct db_infoget_db_info ()
 Returns DB info. More...
 
int get_dfg_n_runtimes ()
 Returns the number of registered runtime. More...
 
struct dfg_runtimeget_dfg_runtime (unsigned int runtime_id)
 Returns the runtime with the given ID. More...
 
struct dfg_msu_typeget_dfg_msu_type (unsigned int id)
 Returns the MSU type with the given ID. More...
 
struct dfg_routeget_dfg_runtime_route (struct dfg_runtime *rt, unsigned int id)
 
struct dfg_routeget_dfg_route (unsigned int id)
 Returns the route with the given ID. More...
 
struct dfg_msuget_dfg_msu (unsigned int id)
 Returns the MSU with the given ID. More...
 
struct dfg_routeget_dfg_rt_route_by_type (struct dfg_runtime *rt, struct dfg_msu_type *type)
 Returns the route on the given runtime with the specified MSU type. More...
 
struct dfg_routeget_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. More...
 
struct dfg_threadget_dfg_thread (struct dfg_runtime *rt, unsigned int id)
 Returns the thread on the given runtime with the specified ID. More...
 
struct dfg_route_endpointget_dfg_route_endpoint (struct dfg_route *route, unsigned int msu_id)
 Returns the endpoint within the given route which has the specified MSU ID. More...
 
int msu_has_route (struct dfg_msu *msu, struct dfg_route *route)
 Returns 1 if the given MSU has the route as an endpoint. More...
 
struct dfg_msumsu_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. More...
 
enum thread_mode str_to_thread_mode (char *mode_str)
 Converts a string of pinned/unpinned to the corresponding enumerator. More...
 
enum blocking_mode str_to_blocking_mode (char *mode_str)
 Converts a string of blocking/non-blocking to the correct enumerator. More...
 
uint8_t str_to_vertex_type (char *str_type)
 Converts a string containing exit and/or entry to the correct bitmask. More...
 
static void set_msu_properties (struct dfg_msu *template, struct dfg_msu *target)
 Sets the non-scheduling properties of the MSU to be equal to those of the passed in target. More...
 
struct dfg_msucopy_dfg_msu (struct dfg_msu *input)
 Allocates a new MSU with the same fields as the input MSU (though unscheduled) More...
 
struct dfg_msuinit_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. More...
 
int free_dfg_msu (struct dfg_msu *input)
 Frees an MSU structure. More...
 
static int schedule_msu_on_thread (struct dfg_msu *msu, struct dfg_thread *thread, struct dfg_runtime *rt)
 Adds the MSU to the thread, runtime, and instance, and adds the thread and runtime to the MSU. More...
 
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. More...
 
static int remove_msu_from_thread (struct dfg_msu *msu)
 Removes the msu from it's thread, runtime, and instance, and removes the thread and runtime from the MSU. More...
 
int unschedule_dfg_msu (struct dfg_msu *msu)
 Removes the given MSU from its runtime and thread. More...
 
struct dfg_routecreate_dfg_route (unsigned int id, struct dfg_msu_type *type, unsigned int runtime_id)
 Creates a route with the specified parameters. More...
 
int delete_dfg_route (struct dfg_route *route)
 Deletes the provided route from the DFG. More...
 
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. More...
 
struct dfg_route_endpointadd_dfg_route_endpoint (struct dfg_msu *msu, uint32_t key, struct dfg_route *route)
 Adds an MSU as an endpoint to a route. More...
 
int del_dfg_route_endpoint (struct dfg_route *route, struct dfg_route_endpoint *ep)
 Removes an MSU as a route endpoint. More...
 
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. More...
 
struct dfg_threadcreate_dfg_thread (struct dfg_runtime *rt, int thread_id, enum thread_mode mode)
 Creates a new thread on the given runtime. More...
 
static void free_dfg_msu_type (struct dfg_msu_type *type)
 Frees elements in the MSU type structure. More...
 
static void free_dfg_runtime (struct dfg_runtime *rt)
 Frees the runtime and all threads and routes associated with it. More...
 
void free_dfg (struct dedos_dfg *dfg)
 Frees the entirety of the DFG structure. More...
 

Variables

static struct dedos_dfgdfg
 Static local copy of the DFG, so each call doesn't have to pass a copy. More...
 

Detailed Description

Code for the creation and modifcation of the data-flow graph.

Definition in file dfg.c.

Macro Definition Documentation

#define SEARCH_FOR_ID (   s,
  n,
  field,
  id_ 
)
Value:
if (dfg == NULL) \
return NULL; \
for (int i=0; i<(n); ++i) { \
if (field[i]->id == id_) { \
return field[i]; \
} \
} \
return NULL;
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

Convenience macro to search a field within a structure for the element with an ID.

Specifically, searches field[i]->id for each element in field.

Parameters
sA parent structure. If NULL, returns NULL
nThe number of elements in the field to search
fieldThe list of structures to search for the given ID
id_The ID to search for in the list of structures

Definition at line 46 of file dfg.c.

Function Documentation

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 at line 455 of file dfg.c.

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 at line 428 of file dfg.c.

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 at line 190 of file dfg.c.

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 at line 366 of file dfg.c.

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 at line 539 of file dfg.c.

int del_dfg_route_endpoint ( struct dfg_route route,
struct dfg_route_endpoint ep 
)

Removes an MSU as a route endpoint.

Definition at line 487 of file dfg.c.

int delete_dfg_route ( struct dfg_route route)

Deletes the provided route from the DFG.

Definition at line 399 of file dfg.c.

void free_dfg ( struct dedos_dfg dfg)

Frees the entirety of the DFG structure.

Definition at line 596 of file dfg.c.

int free_dfg_msu ( struct dfg_msu input)

Frees an MSU structure.

Definition at line 225 of file dfg.c.

static void free_dfg_msu_type ( struct dfg_msu_type type)
static

Frees elements in the MSU type structure.

Definition at line 574 of file dfg.c.

static void free_dfg_runtime ( struct dfg_runtime rt)
static

Frees the runtime and all threads and routes associated with it.

Definition at line 582 of file dfg.c.

struct db_info* get_db_info ( )

Returns DB info.

Definition at line 56 of file dfg.c.

struct dfg_msu* get_dfg_msu ( unsigned int  id)

Returns the MSU with the given ID.

Definition at line 86 of file dfg.c.

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 at line 99 of file dfg.c.

struct dfg_msu_type* get_dfg_msu_type ( unsigned int  id)

Returns the MSU type with the given ID.

Definition at line 68 of file dfg.c.

int get_dfg_n_runtimes ( )

Returns the number of registered runtime.

Definition at line 60 of file dfg.c.

struct dfg_route* get_dfg_route ( unsigned int  id)

Returns the route with the given ID.

Definition at line 76 of file dfg.c.

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 at line 112 of file dfg.c.

struct dfg_route* get_dfg_rt_route_by_type ( struct dfg_runtime rt,
struct dfg_msu_type type 
)

Returns the route on the given runtime with the specified MSU type.

Definition at line 90 of file dfg.c.

struct dfg_runtime* get_dfg_runtime ( unsigned int  runtime_id)

Returns the runtime with the given ID.

Definition at line 64 of file dfg.c.

struct dfg_route* get_dfg_runtime_route ( struct dfg_runtime rt,
unsigned int  id 
)

Definition at line 72 of file dfg.c.

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 at line 108 of file dfg.c.

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 at line 200 of file dfg.c.

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 at line 505 of file dfg.c.

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 at line 121 of file dfg.c.

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 at line 130 of file dfg.c.

static int remove_msu_from_thread ( struct dfg_msu msu)
static

Removes the msu from it's thread, runtime, and instance, and removes the thread and runtime from the MSU.

Definition at line 298 of file dfg.c.

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 at line 261 of file dfg.c.

static int schedule_msu_on_thread ( struct dfg_msu msu,
struct dfg_thread thread,
struct dfg_runtime rt 
)
static

Adds the MSU to the thread, runtime, and instance, and adds the thread and runtime to the MSU.

Definition at line 237 of file dfg.c.

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.

Parameters
dfgThe copy of the DFG to set statically

Definition at line 34 of file dfg.c.

static void set_msu_properties ( struct dfg_msu template,
struct dfg_msu target 
)
static

Sets the non-scheduling properties of the MSU to be equal to those of the passed in target.

Parameters
templateThe MSU from which to copy the properties
targetThe MSU into which the properties are to be copied

Definition at line 182 of file dfg.c.

enum blocking_mode str_to_blocking_mode ( char *  mode_str)

Converts a string of blocking/non-blocking to the correct enumerator.

String should be "blocking" or "non-blocking" (or "nonblocking") (case insensitive).

Definition at line 150 of file dfg.c.

enum thread_mode str_to_thread_mode ( char *  mode)

Converts a string of pinned/unpinned to the corresponding enumerator.

String should be "pinned" or "unpinned" (case insensitive).

Definition at line 139 of file dfg.c.

uint8_t str_to_vertex_type ( char *  str_type)

Converts a string containing exit and/or entry to the correct bitmask.

Definition at line 162 of file dfg.c.

int unschedule_dfg_msu ( struct dfg_msu msu)

Removes the given MSU from its runtime and thread.

Definition at line 339 of file dfg.c.

Variable Documentation

struct dedos_dfg* dfg
static

Static local copy of the DFG, so each call doesn't have to pass a copy.

Definition at line 32 of file dfg.c.