58 int total = n_pinned + n_unpinned;
59 for (
int t=0; t < total; t++) {
68 log(LOG_DFG_READER,
"Setting thread %d with no MSUs to pinned", t);
70 }
else if (n_unpinned > 0) {
72 log(LOG_DFG_READER,
"Setting thread %d with no MSUs to unpinned", t);
75 log_error(
"Cannot determine pinned/unpinned status of threads "
76 "based on number of blocking/nonblock MSUs");
81 if (n_pinned < 0 || n_unpinned < 0) {
82 log_error(
"More pinned/unpinned threads specified by MSUs than by DFG on rt %d: "
83 "%d more pinned, %d more unpinned", rt->
id, -1 * n_pinned, -1 * n_unpinned);
121 log_error(
"Application name '%s' is too long", name);
133 int rtn = inet_pton(AF_INET, ip, &addr);
135 log_perror(
"Error converting '%s' to IP address", ip);
154 int rtn = inet_pton(AF_INET, ip, &addr);
156 log_perror(
"Error converting '%s' to IP address", ip);
159 dfg->
db.
ip = addr.s_addr;
176 memcpy(dfg->
db.
user, str_db_user, strlen(str_db_user));
185 memcpy(dfg->
db.
pwd, str_db_pwd, strlen(str_db_pwd));
194 memcpy(dfg->
db.
name, str_db_name, strlen(str_db_name));
219 dfg->
msus[index] = calloc(1,
sizeof(
struct dfg_msu));
258 strcpy(type->
name, name);
299 log_error(
"Init data '%s' too long", init_data);
345 log_error(
"Unknown blocking mode specified: %s", str_mode);
355 if (thread == NULL) {
356 log(LOG_DFG_READER,
"Waiting for thread instantiation");
365 log_error(
"Can only put blocking MSUs on pinned threads, and nonblock MSUs on unpinned");
386 int rtn = inet_pton(AF_INET, ip, &addr);
388 log_perror(
"Error converting '%s' to IP address", ip);
391 rt->
ip = addr.s_addr;
416 for (
int i=n_existing; i<n_existing+n_new; i++) {
431 for (
int i=n_existing; i < n_existing + n_new; i++) {
458 if (existing != NULL) {
459 log_error(
"Route with ID %d exists twice in DFG",
id);
463 log(LOG_DFG_PARSING,
"Created route with id: %d",
id);
509 log(LOG_DFG_PARSING,
"MSU %d is not yet instantiated", msu_id);
520 bool found_types =
true;
526 log(LOG_DFG_PARSING,
"Type %d is not yet instantiated", str_type);
533 if (found_types ==
false)
541 bool found_types =
true;
547 log(LOG_DFG_PARSING,
"Type %d is not yet instantiated", str_type);
555 if (found_types ==
false) {
570 log(LOG_DFG_PARSING,
"Type %d is not yet instantiated", type_id);
582 if (strcasecmp(str_loc,
"local") == 0) {
584 }
else if (strcasecmp(str_loc,
"remote") == 0) {
587 log_error(
"Unknown locality %s specified. Must be 'local' or 'remote'", str_loc);
599 log(LOG_DFG_PARSING,
"Runtime %d is not yet instantiated",
id);
612 log(LOG_DFG_PARSING,
"MSU runtime not yet instantiated");
617 if (thread == NULL) {
619 log(LOG_DFG_PARSING,
"Thread %d not yet instantiated",
id);
629 for (
int i=0; i<dfg->
n_msus; i++) {
637 log(LOG_DFG_PARSING,
"Msu for thead %d not yet instantiated",
id);
650 bool set_routes =
true;
658 log(LOG_DFG_PARSING,
"Route %d not yet instantiated for msu", route_id);
static int set_dep_type(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
key: "type", object DEPENDENCIES
static int set_scheduling(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "scheduling", Object MSUS.
int n_routes
The routes that an MSU can send to.
MSUs which must be present for another MSU to be cloned.
#define START_ITER_TOK_LIST(i)
Macro to iterate over a list of tokens.
char * tok_to_str(jsmntok_t *tok, char *j)
Destructively extracts a c-string from a jsmn token.
static int set_route_type(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "type", object ROUTES.
int n_msus
The number of MSUs in dedos_dfg::msus.
static int set_msu_vertex_type(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "vertex_type", Object MSUS.
enum thread_mode mode
Pinned/unpinned mode for the thread.
uint32_t ip
IP of the node on which the runtime is running.
#define MAX_APP_NAME_LENGTH
The maximum length for the name of the application.
static struct json_state init_dfg_msu_type(struct json_state *in__, int index__)
Key: element in "MSU_types", Object ROOT.
struct dfg_msu_type * type
The MSU type which must be present.
static int set_msu_thread(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "thread_id", object: SCHEDULING.
static int set_db_user(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "db_user", Object ROOT.
uint8_t str_to_vertex_type(char *str_type)
Converts a string containing exit and/or entry to the correct bitmask.
int global_ctl_port
Port of the global controller.
int n_msus
Number of MSUs placed on the thread.
static int set_app_name(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "application_name", Object: ROOT.
static int fix_num_threads(struct dedos_dfg *dfg)
Fixes the thread assignment within the DFG such that the pinned and unpinned threads are accurate...
struct dfg_scheduling scheduling
Information about where an MSU is scheduled.
struct dfg_route * routes[64]
Routes located on this runtime.
struct dfg_msu * instances[512]
Each instance of this MSU type.
uint32_t global_ctl_ip
IP address of the global controller.
#define GET_STR_TOK()
Within a PARSE_FN, gets the token being read as a string.
int n_cores
Number of cores on the runtime node.
static int set_colocation_group(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "colocation_group", object MSU_TYPES.
static int set_db_ip(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "db_ip", Object: ROOT.
struct dfg_route * get_dfg_route(unsigned int id)
Returns the route with the given ID.
static struct json_state init_dependencies(struct json_state *in__, int index__)
Key: Element in "dependencies", Object: MSU_TYPES.
uint8_t vertex_type
Whether the MSU is #ENTRY, #EXIT, or possible #ENTRY | #EXIT.
static int set_cloneable(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "cloneable", Object MSU_TYPES.
static int set_dest_key(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "key", object DESTINATIONS.
struct dfg_msu * msus[8]
MSUs placed on that thread.
static struct json_state init_endpoint(struct json_state *in__, int index__)
Key: Element in "endpoints", object ROUTES.
int n_msu_types
The number of elements in dedos_dfg::msu_types.
struct dfg_runtime * get_dfg_runtime(unsigned int runtime_id)
Returns the runtime with the given ID.
static struct json_state init_runtime(struct json_state *in__, int index__)
Key: element in "runtimes", Object ROOT.
static int set_msu_types(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "MSU_types", Object: ROOT.
Default – threads should not have this mode.
char name[32]
A name describing the function of the MSU.
#define log_perror(fmt,...)
int id
Unique identifier for the runtime.
static int set_msu_type_id(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "id", Object: MSU_TYPES.
Logging of status messages to the terminal.
static int set_msu_id(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "id", Object MSUS.
static int set_rt_port(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: port, object RUNTIMES.
Structure to hold state while parsing JSON.
static int set_route_id(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "id", object ROUTES.
object_type
The objects types which can be located in the json DFG See key_map for usage.
static int set_msu_type(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key "type", Object MSUS.
static int set_dest_msu(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "msu", object DESTINATIONS.
#define MAX_MSU_NAME_LEN
The maximum length of the name for an MSU type.
struct dfg_msu_type * type
The type of the MSU and meta-routing information.
char application_name[64]
Description of the whole application.
Structure to map a key + state to a function.
Representation of a runtime in the DFG.
struct dfg_dependency * dependencies[32]
These MSU types must be present in order for this MSU type to be cloned.
static int set_source_types(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "source_types", object META_ROUTING.
struct dfg_route_endpoint * endpoints[256]
The endpoints of the route.
int n_endpoints
The number of endpoints in dfg_route::endpoints.
#define PARSE_FN(fn_name)
Macro for defining a jsmn_parsing_fn.
struct dfg_runtime * runtime
The runtime on which an MSU is running.
int n_runtimes
The number of elements in dedos_dfg::runtimes.
static int set_db_port(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "global_ctl_port", Object: ROOT.
#define log_error(fmt,...)
static int set_dst_types(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "dst_types", object META_ROUTING.
static int set_route_endpoints(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "endpoints", object ROUTES.
struct dfg_msu * msu
The MSU at this endpoint to which a message would be delivered.
#define MAX_INIT_DATA_LEN
The maximum length of the initial data that may be passed to an MSU.
#define GET_OBJ_INDEX()
In an INIT_OBJ_FN, returns the index of the currently parsed object list.
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. ...
Declares function for converting JSON to dedos_dfg.
struct dfg_msu_type * msu_types[32]
MSU types which may be present in the application.
#define PARSE_OBJ_LIST_FN(fn_name, init_fn)
Macro for parsing a list of objects in a json file.
int id
A unique identifier for the MSU.
int cloneable
If cloneable == N, this MSU can be cloned on runtimes numbered up to and including N...
int n_unpinned_threads
Number of the above-threads which are unpinned.
static int not_implemented(jsmntok_t **tok, char *j, struct json_state *in, struct json_state **saved)
To be used to raise an error when a JSON key is deprecated.
static struct json_state init_dfg_msu_from_json(struct json_state *in__, int index__)
Key: element in "MSUs", Object ROOT.
struct dfg_thread * thread
The thread on which an MSU is running.
General-purpose function to interact with JSMN library, and create objects (potentially with circular...
static int set_ctl_ip(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "global_ctl_ip", Object: ROOT.
struct db_info db
DB information.
int id
Unique identifier for the thread.
Representation of a single MSU in the dfg.
static int set_msu_init_data(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "init_data", Object: MSUS.
static int set_blocking_mode(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
key: "blocking_mode", object: MSUS
void * get_root_jsmn_obj()
Returns the initial object passed into the JSON parser.
#define PARSE_OBJ_FN(fn_name, parent_obj_type, parent_obj_field, new_type)
Macro to descend into a JSON object and the corresponding C struct for parsing.
static int set_meta_routing(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "meta_routing", Object: MSU_TYPES.
struct dfg_runtime * runtime
The runtime on which the route is located.
int parse_file_into_obj(const char *filename, void *obj, struct key_mapping *km)
Using the provided functions, parses the JSON present in 'filename' and stores the resulting object i...
int n_pinned_threads
Number of the above-threads which are pinned.
int id
A unique identifier for the MSU type.
int id
A unique identifier for the route.
static int set_msus(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "MSUs", Object ROOT.
static int set_msu_type_name(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "name", Object: MSU_TYPES.
static int set_rt_n_cores(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: num_cores, object RUNTIMES.
static int set_dep_locality(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "locality", object: DEPENDENCIES.
enum msu_locality locality
Whether it must be present on the same machine.
struct dfg_route * routes[32]
Top-level structure holding the data-flow graph.
#define RETURN_OBJ(data__, type__)
Should be the last line in an INIT_OBJ_FN.
A route through which MSU messages can be passed.
struct dedos_dfg * parse_dfg_json_file(const char *filename)
Converts a json file to a dfg structure.
static struct dedos_dfg * dfg
Static local copy of the DFG, so each call doesn't have to pass a copy.
struct msu_init_data init_data
Initial data passed to the MSU.
#define GET_PARSE_OBJ()
Within a PARSE_FN, gets the object currently being constructed.
Interfaces for the creation and modification of the data-flow-graph and and general description of th...
static int set_msu_routes(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
key: "routes", object SCHEDULING
struct dfg_thread * get_dfg_thread(struct dfg_runtime *rt, unsigned int id)
Returns the thread on the given runtime with the specified ID.
struct dfg_msu * get_dfg_msu(unsigned int id)
Returns the MSU with the given ID.
#define GET_INT_TOK()
Within a PARSE_FN, gets the token being read as an integer.
static int set_db_pwd(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "db_pwd", Object ROOT.
struct dfg_runtime * runtimes[16]
The runtimes present in the application.
A single endpoint for an MSU route.
struct dfg_thread * threads[32]
Threads located on the runtime.
uint32_t key
The key associated with this endpoint.
static int set_rt_routes(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "routes", object RUNTIMES.
static int set_ctl_port(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "global_ctl_port", Object: ROOT.
static int set_msu_runtime(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "runtime", object: SCHEDULING.
Structure representing the scheduling of an MSU on a runtime.
static int set_db_name(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "db_name", Object ROOT.
Representation of a thread on a runtime in the DFG.
static struct key_mapping key_map[]
Provides the mapping between the keys in the JSON and the functions which are called when those keys ...
int n_routes
Number of routes above.
int n_instances
The number of instances of this MSU type.
static int set_runtimes(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "runtimes", Object ROOT.
#define log(level, fmt,...)
Log at a custom level.
static struct json_state init_route(struct json_state *in__, int index__)
Key: Element in "routes", object RUNTIMES.
enum blocking_mode str_to_blocking_mode(char *mode_str)
Converts a string of blocking/non-blocking to the correct enumerator.
int n_dependencies
The number of elements in dfg_msu_type::dependencies.
#define INIT_OBJ_FN(fn_name)
Macro for instantiating a new struct based on the appearance of a new JSON object.
static int set_dependencies(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: "dependencies", Object MSU_TYPES.
static int set_rt_id(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: id, Object RUNTIMES.
struct dfg_msu_type * get_dfg_msu_type(unsigned int id)
Returns the MSU type with the given ID.
#define END_ITER_TOK_LIST(i)
Macro that should appear at the end of the iteration of a list of tokens.
static int set_num_unpinned_threads(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: num_unpinned_threads, object RUNTIMES.
int port
Port on which the runtime is listening for controller/inter-runtime.
struct dfg_meta_routing meta_routing
Which types of msus route to/from this MSU.
static int set_num_pinned_threads(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: num_pinned_threads, object RUNTIMES.
#define log_warn(fmt,...)
Default value – used when unset, should never be specified.
enum blocking_mode blocking_mode
Whether the MSU is blocking or not.
struct dfg_msu_type * msu_type
The type of MSU to which this route delivers.
struct dfg_msu * msus[512]
The MSUs present in the application.
static int set_rt_ip(jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
Key: ip, Object RUNTIMES.