24 #include <sys/types.h>
26 #include <arpa/inet.h>
41 #define NEXT_MSU_LOCAL 1
42 #define NEXT_MSU_REMOTE 2
46 #define NOSTYLE "\e[0m"
48 #define HELP_PREAMBLE \
49 "\nList of available commands : \n" \
51 "\t******* Note: " UL "ARGUMENTS" NOSTYLE " fields are required, excluding " \
52 UL "[BRACKETED]" NOSTYLE " ****\n" \
68 printf(
"Runtime id: %d -- ", dfg->
runtimes[i]->
id);
70 printf(
"NOT CONNECTED\n");
72 printf(
"fd: %d\n", fd);
78 #define NEXT_ARG(arg, args) \
79 if ( ( arg = strtok(args, " \r\n") ) == NULL){ \
80 log_error("Missing required argument"); \
98 debug(
"Could not allocate memory for to_schedule");
103 int num_to_alloc = 0;
115 ts->
msu_ids = to_allocate_msus;
130 int msu_id = atoi(arg);
134 printf(
"MSU id %d is not registered with the controller\n", msu_id);
149 printf(
"Could not retrieve runtime %d from DFG", runtime_id);
156 for (
int i=0; i<dfg->
n_msus; i++) {
159 printf(
"ID: %d\t Thread: %d \t Type: %s (%d)\n",
168 printf(
"Could not send report MSUs message to runtime %d", runtime_id);
184 int msu_id = atoi(arg);
191 thread_id = atoi(arg);
194 if (vertex_type == NULL) {
202 init_data = strtok(NULL,
"\r\n");
203 if (init_data != NULL) {
204 debug(
"init data: %s, len: %zu", init_data, strlen(init_data));
205 memcpy(data, init_data, strlen(init_data));
208 int ret =
add_msu(msu_id, msu_type, data, msu_mode, vertex_type, thread_id, runtime_id);
210 log_error(
"Could not trigger new MSU creation");
219 int msu_id = atoi(arg);
224 log_error(
"Could not deletion of MSU %d", msu_id);
232 int route_id = atoi(arg);
235 int msu_id = atoi(arg);
239 log_error(
"Could not add route %d to msu %d", route_id, msu_id);
247 int route_id = atoi(arg);
250 int msu_id = atoi(arg);
255 log_error(
"Could not delete route %d from msu %d", route_id, msu_id);
263 int route_id = atoi(arg);
266 int msu_id = atoi(arg);
273 log_error(
"Could not add endpoint %d to route %d", msu_id, route_id);
281 int route_id = atoi(arg);
284 int msu_id = atoi(arg);
288 log_error(
"Could not delete endpoint %d from route %d", msu_id, route_id);
296 int route_id = atoi(arg);
299 int msu_id = atoi(arg);
306 log_error(
"Could not modify range for endpoiont %d on route %d to %u",
307 msu_id, route_id, key);
319 int thread_id = atoi(arg);
327 log_error(
"Could not create new worker thread on runtime %d", runtime_id);
337 FILE *f = fopen(filename,
"r");
340 log_error(
"Could not open cfg file %s", filename);
347 while ( ( read = getline(&line, &len, f) ) != -1 ) {
362 int id = atoi(msu_c);
365 if (to_clone == NULL) {
370 if (cloned == NULL) {
381 int id = atoi(msu_c);
392 log_error(
"Could not unclone msu %d",
id);
402 int id = atoi(msu_c);
412 printf(
"Route: %d\tType: %d\n", route->
id, route->
msu_type->
id);
421 int id = atoi(route_id_c);
425 log_error(
"Route %d does not exist",
id);
431 printf(
"Destination: %d\tKey: %d\n", ep->
msu->
id, (
int)ep->
key);
441 "List connected runtimes and socket num"},
444 "Get MSUs running on the runtime" },
447 "display stored time serie for a given msu"},
450 "display routes attached to a given msu"},
453 "display endpoints of a given route"},
456 "clones and schedules the clone of an MSU"},
459 "Removes an MSU and dependencies"},
462 {
"RUNTIME-ID",
"MSU_TYPE",
"MSU-ID",
"MSU_MODE",
"THREAD-ID",
"[VERTEX_TYPE]",
464 "(MSU_MODE: blocking/non-blocking; VERTEX_TYPE: entry/exit/entry,exit)"},
469 {
"ROUTE-ID",
"MSU-ID"},
470 "Adds an outgoing route to an MSU"},
473 {
"ROUTE-ID",
"MSU-ID"},
474 "Deletes an outgoing route from an MSU"},
477 {
"ROUTE-ID",
"MSU-ID",
"KEY"},
478 "Adds an MSU as an endpoint to a given route"},
481 {
"ROUTE-ID",
"MSU-ID"},
482 "Deletes an MSU as an endpoint from a given route"},
485 {
"ROUTE-ID",
"MSU-ID",
"KEY"},
486 "Modifies the key range associated with an MSU endpoint on the given route"},
489 {
"RUNTIME-ID",
"THREAD-ID",
"MODE"},
490 "(MODE=pinned/unpinned) Creates a worker thread on an unused core"},
493 "gather all msu not possessing a 'scheduling' object, and compute a placement"},
496 "load a suite of commands from a file"},
498 {
"help",
parse_help, {},
"display available commands"},
500 {
"quit", NULL, {},
""},
502 {
"\0", NULL, {},
"\0"}
507 size_t ln = strlen(cmd) - 1;
508 if (*cmd && cmd[ln] ==
'\n') {
513 strcpy(cmd_cpy, cmd);
516 for (
int i = 0; cmd_actions[i].
cmd[0] !=
'\0'; i++ ){
517 if ( strncasecmp(cmd, cmd_actions[i].cmd, strlen(cmd_actions[i].cmd)) == 0 ) {
518 if ( cmd_actions[i].
action ) {
519 rtn = cmd_actions[i].
action(cmd + strlen(cmd_actions[i].cmd) + 1 );
527 log_error(
"Error parsing command: %s", cmd_cpy);
536 for (
int i=0; cmd_actions[i].
cmd[0] !=
'\0'; i++){
538 for (
int j=0; cmd_actions[i].
args[j][0]!=
'\0'; j++) {
539 printf(
" " UL "%s" NOSTYLE, cmd_actions[i].args[j]);
541 printf(
"\n\t\t%s\n", cmd_actions[i].
help);
554 printf(
"> Enter command: ");
555 next = getline(&line, &size, stdin);
557 if (strcmp(line,
"quit\n") == 0) {
570 err = pthread_create(cli_thread, NULL,
cli_loop, NULL);
572 debug(
"ERROR: can't create thread :[%s]", strerror(err));
574 debug(
"CLI Thread created successfully");
#define NEXT_ARG(arg, args)
int n_routes
The routes that an MSU can send to.
Interface for general-purpose socket communication.
int n_msus
The number of MSUs in dedos_dfg::msus.
struct dfg_scheduling scheduling
Information about where an MSU is scheduled.
static int parse_show_msus(char *args)
struct dfg_route * get_dfg_route(unsigned int id)
Returns the route with the given ID.
uint8_t vertex_type
Whether the MSU is #ENTRY, #EXIT, or possible #ENTRY | #EXIT.
static int parse_unclone_msu(char *args)
struct dfg_msu * clone_msu(int msu_id)
Clone a msu of given ID.
struct dfg_runtime * get_dfg_runtime(unsigned int runtime_id)
Returns the runtime with the given ID.
static int parse_show_routes(char *args)
char name[32]
A name describing the function of the MSU.
static int parse_load_cfg(char *args)
int id
Unique identifier for the runtime.
int add_endpoint(unsigned int msu_id, uint32_t key, unsigned int route_id)
Logging of status messages to the terminal.
struct dfg_msu_type * type
The type of the MSU and meta-routing information.
Representation of a runtime in the DFG.
static int parse_del_msu(char *args)
struct dfg_route_endpoint * endpoints[256]
The endpoints of the route.
static int parse_show_stats(char *args)
Display controller's time series for a given msu.
int n_endpoints
The number of endpoints in dfg_route::endpoints.
struct dfg_runtime * runtime
The runtime on which an MSU is running.
static int parse_del_route(char *args)
int n_runtimes
The number of elements in dedos_dfg::runtimes.
int remove_msu(unsigned int id)
#define log_error(fmt,...)
struct dfg_msu * msu
The MSU at this endpoint to which a message would be delivered.
static int parse_del_endpoint(char *args)
#define MAX_INIT_DATA_LEN
The maximum length of the initial data that may be passed to an MSU.
static int parse_add_route(char *args)
int id
A unique identifier for the MSU.
static int parse_show_route(char *args)
struct dfg_thread * thread
The thread on which an MSU is running.
int id
Unique identifier for the thread.
Representation of a single MSU in the dfg.
static int parse_show_runtimes(char *args)
int del_endpoint(unsigned int msu_id, unsigned int route_id)
int start_cli_thread(pthread_t *cli_thread)
int add_route_to_msu(unsigned int msu_id, unsigned int route_id)
#define MAX_MSU
The maximum number of MSUs which can be present in the system at a time.
int id
A unique identifier for the MSU type.
int runtime_fd(unsigned int runtime_id)
int id
A unique identifier for the route.
struct dfg_route * routes[32]
Top-level structure holding the data-flow graph.
A route through which MSU messages can be passed.
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.
static int parse_help(char *cmd)
Interfaces for the creation and modification of the data-flow-graph and and general description of th...
static int parse_add_msu(char *args)
static int parse_create_thread(char *args)
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)
struct dfg_runtime * runtimes[16]
The runtimes present in the application.
A single endpoint for an MSU route.
uint32_t key
The key associated with this endpoint.
struct cmd_action cmd_actions[]
static int runtime_id(int runtime_fd)
static int parse_allocate()
//FIXME: broken behavior since dfg_vertex members are not pointers anymore Get a list of all MSU not ...
struct dedos_dfg * get_dfg()
static int parse_add_endpoint(char *args)
int create_worker_thread(unsigned int thread_id, enum blocking_mode mode)
Starts a new worker thread with the given thread ID and pinned/unpinned status.
int mod_endpoint(unsigned int msu_id, uint32_t key, unsigned int route_id)
int parse_cmd_action(char *cmd)
static int parse_mod_endpoint(char *args)
static int parse_clone_msu(char *args)
void show_stats(struct dfg_msu *msu)
int unclone_msu(int msu_id)
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.