tsnkit.core package

Submodules

tsnkit.core._calculate module

Author: Chuanyu (skewcy@gmail.com) _calculate.py (c) 2023 Desc: description Created: 2023-10-08T04:36:18.116Z

tsnkit.core._common module

Author: Chuanyu (skewcy@gmail.com) _common.py (c) 2023 Desc: description Created: 2023-10-08T17:51:27.418Z

tsnkit.core._common._interface(name: str) Any[source]
tsnkit.core._common.benchmark(stream_path, network_path)[source]
tsnkit.core._common.flatten(list2d: Sequence[Sequence[Any]]) Sequence[Any][source]
tsnkit.core._common.parse_command_line_args()[source]
tsnkit.core._common.parse_command_line_constants(parser: ArgumentParser)[source]

tsnkit.core._config module

Author: Chuanyu (skewcy@gmail.com) _schedule.py (c) 2023 Desc: description Created: 2023-10-08T06:13:56.911Z

class tsnkit.core._config.Config[source]

Bases: object

to_csv(name, path)[source]
class tsnkit.core._config.Delay(init_list: List[List])[source]

Bases: list

A list of [stream_id, frame_id, delay]

static format_delay_type(init_list: List[List]) None[source]

[Note]: This will modify the input list

Args:

init_list (List[List]): _description_

static is_valid_delay_format(init_list: List[List]) bool[source]
to_csv(path: str) None[source]
class tsnkit.core._config.GCL(init_list: List[List])[source]

Bases: list

A list of [link, queue, start, end, cycle]

Args:

init_list (List[List[link, queue, start, end, cycle]]): [description]

static format_gcl_type(init_list: List[List]) bool[source]
static is_overlap(init_list: List[List]) bool[source]
static is_small_entry(init_list: List[List]) bool[source]
static is_valid_gcl_format(init_list: List[List]) bool[source]
to_csv(path: str) None[source]
class tsnkit.core._config.Queue(init_list: List[List])[source]

Bases: list

A list of [stream_id, frame_id, link, queue]

Args:

init_list (List[List[stream_id, frame_id, link, queue]]): [description]

static format_queue_type(init_list: List[List]) None[source]

[Note]: This will modify the input list

Args:

init_list (List[List]): _description_

static is_valid_queue_format(init_list: List[List]) bool[source]
static is_valid_queue_range(init_list: List[List]) bool[source]
to_csv(path: str) None[source]
class tsnkit.core._config.Release(init_list: List[List])[source]

Bases: list

A list of [stream_id, frame_id, release_time]

static format_release_type(init_list: List[List]) None[source]

[Note]: This will modify the input list

Args:

init_list (List[List]): _description_

static is_valid_release_format(init_list: List[List]) bool[source]
to_csv(path: str) None[source]
class tsnkit.core._config.Route(init_list: List[List])[source]

Bases: list

A list of [stream_id, link] Each stream can contains several links as its route

format_route_type(init_list)[source]
static is_valid_route_format(init_list: List[List]) bool[source]
static is_valid_route_logic(init_list: List[List]) bool[source]
to_csv(path)[source]
class tsnkit.core._config.Size(iterable=(), /)[source]

Bases: list

This i only used for FRAG based model now [NOTE]: No type check for

to_csv(path: str) None[source]
tsnkit.core._config.result_slot_to_ns(result: List[List[float]], col: List[int]) bool[source]

_summary_ [NOTE] it will modify the input result

tsnkit.core._constants module

Author: Chuanyu (skewcy@gmail.com) _constants.py (c) 2023 Desc: description Created: 2023-10-21T02:24:36.212Z

tsnkit.core._io module

Author: Chuanyu (skewcy@gmail.com) _io.py (c) 2023 Desc: description Created: 2023-10-08T06:13:41.041Z

class tsnkit.core._io.Result(value)[source]

Bases: Enum

error = -1
schedulable = 1
unknown = 2
unschedulable = 0
class tsnkit.core._io.Statistics(name: str = '-', result: Result = Result.unknown, algo_time: float = 0, algo_mem: float = 0, extra_time: float = 0, extra_mem: float = 0)[source]

Bases: object

content(name: str = '-') None[source]

Print the content of the output

header() None[source]

Print the header of the output

output_format = '| {:<13} | {:<13} | {:<6} | {:<10} | {:<10} | {:<10}'
to_list() List[str | float][source]

Convert the statistics to a list

Returns:

List[Union[str, int]]: [name, result, algo_time, total_time, algo_mem, total_mem]

update(result: Result, algo_time: int, algo_mem: int, extra_time: int = 0, extra_mem: int = 0) None[source]
tsnkit.core._io.check_time_limit(func)[source]
tsnkit.core._io.get_caller_name() str[source]

Used to be myname function

tsnkit.core._network module

Author: Chuanyu (skewcy@gmail.com) _network.py (c) 2023 Desc: description Created: 2023-10-08T06:13:46.561Z

Bases: int

Use simple link structure to improve the efficiency

The overload __hash__ and __eq__ function is used to achieve flexible interface. -> Use (0, 1), Link(src=0, dst=1), (Node(0), Node(1)) are equivalent in framework.

property dst
property name
property q_num
property rate
property src
property t_proc
property t_prop
property t_sync
class tsnkit.core._network.Network[source]

Bases: object

property e_nodes: List[Node]

Return all end station nodes

Returns:

List[Node]: _description_

get_all_path(src: int | Node, dst: int | Node) List[Path][source]
get_income_nodes(node: int | Node) List[Node][source]
get_node(nid: int | Node) Node[source]
get_nodes() List[Node][source]
get_nodes_es() List[Node][source]

Return all end station nodes

Returns:

List[Node]: _description_

get_nodes_sw() List[Node][source]

Return all switch nodes

Returns:

List[Node]: _description_

get_outcome_nodes(node: int | Node) List[Node][source]
get_shortest_path(src: int | Node, dst: int | Node) Path[source]
property max_t_proc: int
property net_np
property net_nx
property nodes: List[Node]
property num_l: int
property num_n: int
property s_nodes: List[Node]

Return all switch nodes

Returns:

List[Node]: _description_

class tsnkit.core._network.Node(*args, **kwargs)[source]

Bases: int

property num_port
property sync_error
property type
class tsnkit.core._network.NodeType(value)[source]

Bases: Enum

Sample enum class for node type

es = 1
sw = 0
class tsnkit.core._network.Path(path: List[int | Node | Tuple[int | Node, int | Node] | Link], network: Network)[source]

Bases: object

A path can be either a node path or a link path Initialize with node path or link path, the other one will be automatically

No iterator interface to avoid misuse

get_len_node() int[source]
get_next_node(node: int | Node) Node | None[source]
get_prev_node(node: int | Node) Node | None[source]
iter_node() Iterator[Node][source]
property llen
property nlen
property nodes
tsnkit.core._network.check_network_format(network: DataFrame)[source]
tsnkit.core._network.load_network(path: str) Network[source]

tsnkit.core._stream module

Author: Chuanyu (skewcy@gmail.com) _stream.py (c) 2023 Desc: description Created: 2023-10-08T06:14:04.079Z

class tsnkit.core._stream.Stream(*args, **kwargs)[source]

Bases: int

property deadline
property dst
property dst_mul
get_frame_indexes(lcm: int) List[int][source]
get_next_node(node: int | Node) Node | None[source]
get_num_frames(lcm: int) int[source]
get_prev_node(node: int | Node) Node | None[source]
get_t_trans(link: int | Link | Tuple[int | Node, int | Node]) int[source]
is_in_path(link: int | Link | Tuple[int | Node, int | Node]) bool[source]
property jitter
property period
property routing_path: Path
property size
property src
property t_trans: int
property t_trans_1g: int

Return max(transmission time on all links) Only used for uniform link rate assuming 1Gbps link rate. [NOTE]: This method it depreciated.

Returns:

int: _description_

class tsnkit.core._stream.StreamSet[source]

Bases: object

get_frame_index_pairs(s1: int | Stream, s2: int | Stream)[source]

Get all frame index pairs of two streams. LCM is calculated from s1.period and s2.period

Args:

s1 (Union[int, Stream]): _description_ s2 (Union[int, Stream]): _description_

Returns:

_type_: _description_

This function is often used in queue isolation constraint. Example:

Path1 = (a, b), (b, c) Path2 = (d, b), (b, c)

return [((a, b), (d, b), (b, c))]

Returns:

List[Tuple[Link1, Link2, Link3]]: Link1 and Link2 are the previous links of Link3. Link1, Link3 are in s1.Path Link2, Link3 are in s2.Path.

get_next_node(stream: int | Stream, node: int | Node) Node | None[source]
get_pairs(permute: bool = False) List[Tuple[Stream, Stream]][source]

Return all pairs of streams that share the same link

Args:

link (FlexLink): _description_ permute (bool, optional): _description_. Defaults to False. -> only return (i, j) where i < j

Raises:

Exception: _description_

Returns:

List[Tuple[Stream, Stream]]: _description_

get_prev_node(stream: int | Stream, node: int | Node) Node | None[source]
get_stream(stream: int | Stream) Stream[source]
get_streams() List[Stream][source]
get_t_trans(stream: int | Stream, link: int | Link | Tuple[int | Node, int | Node]) int[source]
is_route_valid(stream: int | Stream)[source]
property lcm
property length: int
property num_frames: int
set_routing(stream: int | Stream, routing_path: Path) None[source]

_summary_

Args:

stream (_type_): Stream_id or Stream object routing_path (_type_): Must be Path Object

set_routings(routings: Dict[int | Stream, Path] | List[Path])[source]

_summary_

Args:

routings (_type_): Must be either dict of {stream_id: Path} or list of [Path] where

property streams
tsnkit.core._stream.check_stream_format(stream_df: DataFrame)[source]
tsnkit.core._stream.load_stream(path: str) StreamSet[source]

tsnkit.core._system module

Author: Chuanyu (skewcy@gmail.com) _system.py (c) 2023 Desc: description Created: 2023-10-08T06:14:11.998Z

tsnkit.core._system.find_files_with_prefix(directory: str, prefix: str)[source]
tsnkit.core._system.init_output_folder(path: str) None[source]
tsnkit.core._system.is_timeout(thres: float) bool[source]
tsnkit.core._system.kill_if(main_proc: int, mem_limit: int, time_limit: int, sig: SynchronizedBase)[source]

Kill the process if it uses more than mem memory or more than time seconds Args:

main_proc: the main process id mem_limit: the memory limit, uint: GB time_limit: the time limit, uint: seconds

async tsnkit.core._system.kill_process(proc: Process, time_limit: float)[source]
tsnkit.core._system.mem_log() float[source]
tsnkit.core._system.oom_manager(name: str) Popen[source]
tsnkit.core._system.time_log() float[source]

Module contents

Author: Chuanyu (skewcy@gmail.com) __init__.py (c) 2023 Desc: description Created: 2023-10-06T17:54:47.806Z