Functions for routing MSU messages between MSUs. More...
#include "dfg.h"
#include "routing.h"
#include "logging.h"
#include "runtime_dfg.h"
#include "local_msu.h"
#include "unused_def.h"
#include <stdlib.h>
#include <limits.h>
#include <pthread.h>
Go to the source code of this file.
Classes | |
struct | routing_table |
The core of the routing system, the routing table lists a route's destinations. More... | |
Macros | |
#define | MAX_DESTINATIONS 128 |
The maximum number of destinations a route can have. More... | |
#define | MAX_ROUTE_ID 10000 |
The maximum ID that may be assigned to a route. More... | |
#define | print_routing_table(t) |
#define | MAX_MSU_Q_SIZE INT_MAX |
Functions | |
static int | read_lock (struct routing_table *table) |
Simple wrapper to lock a routing table for reading. More... | |
static int | write_lock (struct routing_table *table) |
Simple wrapper to lock a routing table for writing. More... | |
static int | unlock (struct routing_table *table) |
Simple wrapper to unlock a locked routing table. More... | |
static int | find_value_index (struct routing_table *table, uint32_t value) |
Searches through the entries in the routing table, returning the index of the first key which surpasses the provided value. More... | |
static int | find_id_index (struct routing_table *table, int msu_id) |
Finds the index of the entry in the routing table with the destination that has the provided msu id. More... | |
static int | rm_routing_table_entry (struct routing_table *table, int msu_id) |
Removes a destination from the routing table. More... | |
int | add_routing_table_entry (struct routing_table *table, struct msu_endpoint *dest, uint32_t key) |
Adds a (copy of the) destination to a routing table. More... | |
static int | alter_routing_table_entry (struct routing_table *table, int msu_id, uint32_t new_key) |
Modifies the key associated with an existing destination in a routing table. More... | |
struct routing_table * | init_routing_table (int route_id, int type_id) |
Initializes and returns a new routing table. More... | |
static struct routing_table * | get_routing_table (int route_id) |
Gets the routing table associated with the route_id. More... | |
int | init_route (int route_id, int type_id) |
Initializes a new route with the given route_id and type_id. More... | |
int | get_shortest_queue_endpoint (struct routing_table *table, uint32_t key, struct msu_endpoint *endpoint) |
Gets the local endpoint from a route with the shortest queue length. More... | |
int | get_endpoint_by_index (struct routing_table *table, int index, struct msu_endpoint *endpoint) |
Gets endpoint witih given index in route set. More... | |
int | get_endpoint_by_id (struct routing_table *table, int msu_id, struct msu_endpoint *endpoint) |
Gets endpoint with the given MSU ID in the provided route. More... | |
int | get_endpoints_by_runtime_id (struct routing_table *table, int runtime_id, struct msu_endpoint *endpoints, int n_endpoints) |
Gets all of the endpoints in the provided routing table with the right runtime id. More... | |
int | get_n_endpoints (struct routing_table *table) |
int | get_route_endpoint (struct routing_table *table, uint32_t key, struct msu_endpoint *endpoint) |
Gets the endpoint associated with the given key in the provided route. More... | |
struct routing_table * | get_type_from_route_set (struct route_set *set, int type_id) |
Gets the route from the provided array of routes which has the correct type ID. More... | |
int | add_route_endpoint (int route_id, struct msu_endpoint endpoint, uint32_t key) |
Adds an endpoint to the route with the given ID. More... | |
int | remove_route_endpoint (int route_id, int msu_id) |
Removes destination from route with given ID. More... | |
int | modify_route_endpoint (int route_id, int msu_id, uint32_t new_key) |
Modifies key associated with MSU in route. More... | |
int | add_route_to_set (struct route_set *set, int route_id) |
Adds a route to a set of routes. More... | |
int | rm_route_from_set (struct route_set *set, int route_id) |
Removes a route from a set of routes. More... | |
int | init_msu_endpoint (int msu_id, int runtime_id, struct msu_endpoint *endpoint) |
Initializes an endpoint structure to point to the relevant msu. More... | |
Variables | |
static struct routing_table * | all_routes [10000] |
All of the created routes in this runtime. More... | |
Functions for routing MSU messages between MSUs.
Definition in file routing.c.
#define MAX_DESTINATIONS 128 |
#define MAX_ROUTE_ID 10000 |
int add_route_endpoint | ( | int | route_id, |
struct msu_endpoint | endpoint, | ||
uint32_t | key | ||
) |
int add_route_to_set | ( | struct route_set * | set, |
int | route_id | ||
) |
int add_routing_table_entry | ( | struct routing_table * | table, |
struct msu_endpoint * | dest, | ||
uint32_t | key | ||
) |
Adds a (copy of the) destination to a routing table.
Note: Kept non-static but excluded from header so it can be used for testing
table | The table to which the destination is to be added |
destination | The endpoint to add (a copy is made) |
key | The key to be associated with this destination |
|
static |
Modifies the key associated with an existing destination in a routing table.
table | The routing table to modify |
msu_id | The ID of the destination to modify |
new_key | The new key that should be associated with this destination |
|
static |
|
static |
Searches through the entries in the routing table, returning the index of the first key which surpasses the provided value.
table | the table to search |
value | the value to use in the search |
int get_endpoint_by_id | ( | struct routing_table * | table, |
int | msu_id, | ||
struct msu_endpoint * | endpoint | ||
) |
int get_endpoint_by_index | ( | struct routing_table * | table, |
int | index, | ||
struct msu_endpoint * | endpoint | ||
) |
int get_endpoints_by_runtime_id | ( | struct routing_table * | table, |
int | runtime_id, | ||
struct msu_endpoint * | endpoints, | ||
int | n_endpoints | ||
) |
Gets all of the endpoints in the provided routing table with the right runtime id.
table | The table to search for endpoints |
runtime_id | The ID of the runtime on which endpoints must reside |
endpoints | An array of endpoints to be filled. |
n_endpoints | The amount of endpoints allocated in endpoints |
endpoints
, or -1 if n_endpoints is too low int get_n_endpoints | ( | struct routing_table * | table | ) |
int get_route_endpoint | ( | struct routing_table * | table, |
uint32_t | key, | ||
struct msu_endpoint * | endpoint | ||
) |
|
static |
int get_shortest_queue_endpoint | ( | struct routing_table * | table, |
uint32_t | key, | ||
struct msu_endpoint * | endpoint | ||
) |
Gets the local endpoint from a route with the shortest queue length.
Ignores enpoints on remote runtimes.
table | The route to search for the shortest queue length |
key | Used as a tiebreaker in the case of multiple MSUs with same queue length |
endpoint | Points to appropriate endpoint on success |
struct routing_table* get_type_from_route_set | ( | struct route_set * | routes, |
int | type_id | ||
) |
Gets the route from the provided array of routes which has the correct type ID.
routes | Pointer to array of routes to search |
n_routes | Number of routes in route array |
type_id | Type ID to search for |
int init_msu_endpoint | ( | int | msu_id, |
int | runtime_id, | ||
struct msu_endpoint * | endpoint | ||
) |
int init_route | ( | int | route_id, |
int | type_id | ||
) |
struct routing_table* init_routing_table | ( | int | route_id, |
int | type_id | ||
) |
Initializes and returns a new routing table.
Note: Not for external access! Use init_route() Note: Kept non-static (but exclued from header) so it can be accessed during testing
int modify_route_endpoint | ( | int | route_id, |
int | msu_id, | ||
uint32_t | new_key | ||
) |
|
static |
int remove_route_endpoint | ( | int | route_id, |
int | msu_id | ||
) |
int rm_route_from_set | ( | struct route_set * | set, |
int | route_id | ||
) |
|
static |
|
static |
|
static |
|
static |