22 #include <arpa/inet.h>
35 int add_msu(
unsigned int msu_id,
unsigned int type_id,
36 char *init_data_c,
char *msu_mode,
char *vertex_type_c,
37 unsigned int thread_id,
unsigned int runtime_id) {
41 log_error(
"Could not get MSU type %d", type_id);
47 log_error(
"Could not get blocking mode from %s", msu_mode);
59 log_error(
"Error innitializing dfg MSU %d", msu_id);
70 log_error(
"Could not send create-msu-msg to runtime %u", runtime_id);
90 log_error(
"Error sending delete MSU msg for MSU %d",
id);
107 log_error(
"Could not find MSU type %u in dfg", type_id);
113 log_error(
"Could not create route %u in dfg", route_id);
119 log_error(
"Error sending create route message");
129 log_error(
"Route %u does not exist", route_id);
134 log_error(
"Error sending delete route message");
150 log_error(
"Could not retrieve route %u from dfg", route_id);
155 log_error(
"Could not retrieve MSU %u from DFG", msu_id);
168 log_error(
"Error sending add route to MSU msg");
180 log_error(
"Could not retrieve route %u from dfg", route_id);
185 log_error(
"Could not retrieve MSU %u from DFG", msu_id);
190 if (endpoint == NULL) {
197 log_error(
"Error sending add endpoint message");
201 log(LOG_API_CALLS,
"Added endpoint %u with key %d to route %u",
202 msu_id, (
int)key, route_id);
209 log_error(
"Could not retrieve route %u from dfg", route_id);
215 log_error(
"Could not get endpoint %u from dfg route", msu_id);
221 log_error(
"Error sending delete endpoint message");
227 log_error(
"Error deleting endpoint from DFG route");
237 log_error(
"Could not retrieve route %u from dfg", route_id);
243 log_error(
"Could not get endpoint %u from dfg route", msu_id);
249 log_error(
"Could not modify DFG route endpoint");
255 log_error(
"Error sending message to modify route endpoint");
264 log_error(
"could not retrieve runtime %u from dfg", runtime_id);
269 if (thread != NULL) {
270 log_error(
"Thread %u already exists on runtime %u", thread_id, runtime_id);
276 log_error(
"Could not get mode from %s", mode);
281 if (thread == NULL) {
288 log_error(
"Error sending create_thread_msg");
Interface for general-purpose socket communication.
int delete_dfg_route(struct dfg_route *route)
Deletes the provided route from the DFG.
uint8_t str_to_vertex_type(char *str_type)
Converts a string containing exit and/or entry to the correct bitmask.
thread_mode
Identifies if a thread is pinned to a core or able to be scheduled on any core.
int send_delete_msu_msg(struct dfg_msu *msu)
struct dfg_route * get_dfg_route(unsigned int id)
Returns the route with the given ID.
int del_dfg_route_endpoint(struct dfg_route *route, struct dfg_route_endpoint *ep)
Removes an MSU as a route endpoint.
int send_add_endpoint_msg(struct dfg_route *route, struct dfg_route_endpoint *endpoint)
int unschedule_dfg_msu(struct dfg_msu *msu)
Removes the given MSU from its runtime and thread.
int send_mod_endpoint_msg(struct dfg_route *route, struct dfg_route_endpoint *endpoint)
struct dfg_runtime * get_dfg_runtime(unsigned int runtime_id)
Returns the runtime with the given ID.
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.
int add_endpoint(unsigned int msu_id, uint32_t key, unsigned int route_id)
Logging of status messages to the terminal.
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.
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.
Representation of a runtime in the DFG.
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.
int delete_route(unsigned int route_id)
int send_create_msu_msg(struct dfg_msu *msu)
int register_msu_stats(unsigned int msu_id, int msu_type_id, int thread_id, int runtime_id)
int remove_msu(unsigned int id)
#define log_error(fmt,...)
int send_add_route_to_msu_msg(struct dfg_route *route, struct dfg_msu *msu)
static void unregister_msu_stats(int msu_id)
Unregisters the stat IDS that are relevant to an MSU.
blocking_mode
Whether an MSU is blocking or non-blocking.
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
Representation of a single MSU in the dfg.
int del_endpoint(unsigned int msu_id, unsigned int route_id)
int add_route_to_msu(unsigned int msu_id, unsigned int route_id)
int create_worker_thread(unsigned int thread_id, unsigned int runtime_id, char *mode)
A route through which MSU messages can be passed.
Interfaces for the creation and modification of the data-flow-graph and and general description of th...
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.
int add_msu(unsigned int msu_id, unsigned int type_id, char *init_data_c, char *msu_mode, char *vertex_type_c, unsigned int thread_id, unsigned int runtime_id)
int register_thread_stats(unsigned int thread_id, unsigned int runtime_id)
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.
A single endpoint for an MSU route.
uint32_t key
The key associated with this endpoint.
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.
Representation of a thread on a runtime in the DFG.
static int runtime_id(int runtime_fd)
int create_route(unsigned int route_id, unsigned int type_id, unsigned int runtime_id)
#define log(level, fmt,...)
Log at a custom level.
enum blocking_mode str_to_blocking_mode(char *mode_str)
Converts a string of blocking/non-blocking to the correct enumerator.
int send_delete_route_msg(struct dfg_route *route)
int send_create_route_msg(struct dfg_route *route)
int mod_endpoint(unsigned int msu_id, uint32_t key, unsigned int route_id)
int send_del_endpoint_msg(struct dfg_route *route, struct dfg_route_endpoint *endpoint)
int send_create_thread_msg(struct dfg_thread *thread, struct dfg_runtime *rt)
struct dfg_msu_type * get_dfg_msu_type(unsigned int id)
Returns the MSU type with the given ID.
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.
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.
enum thread_mode str_to_thread_mode(char *mode_str)
Converts a string of pinned/unpinned to the corresponding enumerator.
Default value – used when unset, should never be specified.