17个版本
| 0.6.3 | 2023年12月1日 |
|---|---|
| 0.6.2 | 2023年10月13日 |
| 0.6.1 | 2023年7月13日 |
| 0.5.4 | 2023年2月24日 |
| 0.1.0 | 2020年11月24日 |
#336 in 模拟
用于 caminos
1MB
25K SLoC
caminos-lib
此crate提供CAMINOS模拟器作为库。这是坎塔布里亚可适应和模块化互连开源模拟器。
用法
此crate是caminos-lib。要使用它,请将caminos-lib添加到项目的Cargo.toml中的依赖项。
[dependencies]
caminos-lib = "0.6"
或者,考虑是否二进制crate caminos符合您的预期用途。
破坏性更改
[0.6.0] to ...
- 所有周期现在由
Time别名u64表示;而不是usize。 - 从Eventful特质中删除了方法
pending_events、add_pending_event和clear_pending_events,以支持schedule方法。 - 路由器方法插入和确认现在返回
Vec<EventGeneration>并负责其调度。 - 将Traffic命名法中的服务器重命名为任务。这包括将ServerTrafficState重命名为TaskTrafficState,以及将
server_state重命名为task_state。旧配置名称仍受支持。 - 为特质Traffic添加了方法
number_tasks。
[0.5.0] to [0.6.0]
- 从路由器Basic和InputOutput中删除了不必要的泛型参数TM。现在它们可以选择要采用的
传输机制。 - 将TransmissionFromServer重命名为TransmissionFromOblivious。
- 在Dragonfly结构中进行了某些更改,以允许更多的全局安排。
Event::process现在接收SimulationShared和SimulationMut以更好地封装。- 将每个
&RefCell<StdRng>替换为&mut StdRng。
[0.4.0] to [0.5.0]
- 将函数
server_state添加到Traffic特性中。 - 输出模块上的函数现在使用 ExperimentFiles 代替 Path。
- 向
Traffic::try_consume添加了一个服务器参数。 - 向
RequestInfo添加了 phit。 - 从 rand-0.4 升级到 rand-0.8。
- 在所有接口中使用
&dyn Topology代替&Box<dyn Topology>。 Topology::coordinated_routing_record现在接受切片。CartesianData::new现在接受一个切片。- SpaceAtReceptor 和 Stage 现在其 Result 类型中使用 Error 类型。
config::{evaluate,reevaluate}现在返回一个Result。
[0.3.0] 到 [0.4.0]
- 向
config::{evaluate,reevaluate}添加了path参数。 - 文件
create_output和类似文件现在在其results参数中接收实验索引。 - routings 现在返回
RoutingNextCandidates。除了候选人的向量外,它还包含一个idempotent字段,允许进行一些检查和优化。 - 添加了需求
VirtualChannelPolicy: Debug。 file_main函数现在接收一个free_args参数。形式为path=value的自由参数用于覆盖配置。
[0.2.0] 到 [0.3.0]
- 向
Traffic::should_generate添加了参数cycle。
[0.1.0] 到 [0.2.0]
- 向
Routing和Router 特性添加了收集统计信息的方法。 - 添加了方法
Routing::performed_request,允许路由在路由器向候选人发出请求时做出决策。 - 添加了
ConfigurationValue::NamedExperiments(String,Vec<ConfigurationValue>)。 - 从配置
LitStr和Literal中移除了周围的引号。 - 现在必须始终使用
neighbour_router_iter而不是0..degree()来检查与其他路由器的端口。请注意,当有非连接端口时,例如在网格等不规则拓扑中,degree不提供有效的范围。 Plugs现在包括一个stages属性。- 从
Topology接口移除了从未使用的方法num_arcs、average_distance和distance_distribution。
公共接口
caminos-lib提供了directory_main和file_main函数,旨在在最终二进制程序调用配置文件参数时使用文件版本,在调用目录参数时使用目录版本。
directory_main函数接收一个假定包含main.cfg、main.od、可选的remote、任何生成的文件和子目录的&Path。
main.cfg包含要执行的实验的定义,预期展开成多个模拟。main.od包含所需输出的定义。例如csv文件或(《code>pdf,《code>latex)-plot。remote允许定义一个远程位置,从中拉取结果文件。journal跟踪对实验执行的操作。特别有用的是跟踪当前在哪些slurm作业中启动的执行。runs/job<action_index>/launch<experiment_index>是启动到slurm的脚本。action_index是当前操作的编号。experiment_index预期是slurm作业中包含的某个实验的实验索引。runs/job<action_index>/launch<experiment_index>-<slurm_index>.{out,err}是启动到slurm的脚本的输出。slurm_index是slurm给出的作业ID。runs/run<experiment_index>/local.cfg是针对模拟编号experiment_index的独有配置。runs/run<experiment_index>/local.result将包含模拟编号experiment_index的结果值,在成功模拟之后。
directory_main还接收一个Action。在crate caminos中,这是通过其--action=<method>标志完成的。
local_and_output在本地运行所有剩余的模拟并生成输出。local在本地运行所有模拟,之后不处理结果。output处理目前可用的结果并生成输出。slurm将剩余的模拟启动到slurm系统中。check仅显示我们得到了多少结果以及有多少结果目前在slurm中。pull从定义的远程主机获取结果文件。remote_check在远程主机上执行check操作。push比较本地的 main.cfg 与远程主机的 remote.cfg。它报告差异并在缺少时创建远程路径。slurm_cancel使用在日志文件中找到的作业 ID 执行scancel。shell使用默认配置文件创建实验文件夹。或者,当收到--source=another_experiment时,它将其他实验的配置复制到当前实验中。pack强制创建二进制 .results 文件并删除详细的原始结果文件。在某些极端情况下,它可以减少相当大的空间并加快计算速度。
配置语法
配置文件使用 gramatica crate 进行解析。这些文件被解析为以下定义的 ConfigurationValue。
pub enum ConfigurationValue
{
Literal(String),
Number(f64),
Object(String,Vec<(String,ConfigurationValue)>),
Array(Vec<ConfigurationValue>),
Experiments(Vec<ConfigurationValue>),
NamedExperiments(String,Vec<ConfigurationValue>),
True,
False,
Where(Rc<ConfigurationValue>,Expr),
Expression(Expr),
}
- 一个
Object是一个类型为Name的对象,格式如下:{ key1 : value1, key2 : value2, [...] }。 - 一个
Array是一个格式如下:[value1, value2, value3, [...]]的数组。 - 一个
Experiments是一个格式如下:![value1, value2, value3, [...]]的类型。这些用于表示实验中的多个模拟。这意味着要执行的模拟集合是这种类型所有列表的乘积。 - 一个
NamedExperiments是一个格式如下:username![value1, value2, value3, [...]]的类型。其大小必须与其他同名的NamedExperiment匹配。因此,如果存在{firstkey: alpha![value1, value2, value3],secondkey: alpha![other1,other2,other3]},那么模拟将包括{firstkey:value1, secondkey:other1}和{firstkey:value3,secondkey:other3},但它不会包括{firstkey:value1,secondkey:other3}。 - 一个
Number可以写作 2 或 3.1。存储为f64。 - 一个
Literal是一个双引号字符串。 True写作true,而False写作false。表达式被类型化为=expr,在输出描述中非常有用。Where子句尚未实现。
实验示例
main.cfg 文件的示例
Configuration
{
random_seed: ![42,43,44],//Simulate each seed
warmup: 20000,//Cycles to warm the network
measured: 10000,//Cycles measured for the results
topology: RandomRegularGraph//The topology is given as a named record
{
servers_per_router: 5,//Number of host connected to each router
routers: 500,//Total number of routers in the network
degree: 10,//Number of router ports reserved to go to other routers
legend_name: "random 500-regular graph",//Name used on generated outputs
},
traffic: HomogeneousTraffic//Select a traffic. e.g., traffic repeating a pattern continously.
{
pattern: ![//We can make a simulation for each of several patterns.
Uniform { legend_name:"uniform" },
RandomPermutation { legend_name:"random server permutation" },
],
servers: 2500,//Servers involved in the traffic. Typically equal to the total of servers.
//The load offered from the servers. A common case where to include many simulation values.
load: ![0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0],
message_size: 16,//The size in phits of the messages created by the servers.
},
maximum_packet_size: 16,//Messages of greater length will be broken into several packets.
router: Basic//The router is another object with a large description
{
//The number of virtual channels. The basic router sets a buffer for each virtual channel in each port, both at input and output.
virtual_channels: 8,
//Policies that filter the candidate routes given by the routing algorithm. They may be used to break deadlock or to give preference to some choices.
//EnforceFlowControl must be included to actually use flow control restrictions.
virtual_channel_policies: [ EnforceFlowControl, WideHops{width:1}, LowestSinghWeight{extra_congestion:0, extra_distance:0, aggregate_buffers:true, use_internal_space:true}, Random ],
delay: 0,//not actually implemted in the basic router. In the future it may be removed or actually implemented.
buffer_size: 64,//phits available in each input buffer
bubble: false,//to enable bubble mechanism in Cartesian topologies.
flit_size: 16,//set to maximum_packet_size to have Virtual Cut-Through.
intransit_priority: false,//whether to give preference to transit over injection.
allow_request_busy_port: true,//whether to allow input buffer to make requests to ports that are transmitting
output_buffer_size:32,//Available phits in each output_buffer.
output_priorize_lowest_label: true,//whether arbiters give priority to requests with lowest label.
},
routing: ![//Algorithm to provide candidate exit ports.
Shortest { legend_name: "shortest" },
Valiant {
//The meta-routing by Valiant in which we sent shortest to a random middle router
//And then shortest from the middle to the destination.
first: Shortest,//We can change the sub-routing in either the first or second segment.
second: Shortest,//If we do not have arguments we only put the object name. No need for braces.
legend_name: "generic Valiant",
},
],
link_classes: [
//We can set the delays of different class of links. The number of classes depends on the topology.
LinkClass {
//In random regular graphs all router--router links have the same class.
delay:1,
},
//The last class always correspond to the links between server and router
LinkClass { delay: 1},
//In a dragonfly topology we would have 0=routers from same group, 1=routers from different groups, and 2=from server
],
launch_configurations: [
//We may put here options to send to the SLURM system.
Slurm
{
job_pack_size: 2,//number of simulations to go in each slurm job.
time: "1-11:59:59",//maximum time allocated to each slurm job.
},
],
}
示例输出描述
输出描述的示例 main.od 是
[
CSV//To generate a csv with a selection of fields
{
fields: [=configuration.traffic.pattern.legend_name, =configuration.traffic.load, =result.accepted_load, =result.average_message_delay, =configuration.routing.legend_name, =result.server_consumption_jain_index, =result.server_generation_jain_index, =result.average_packet_hops, =result.average_link_utilization, =result.maximum_link_utilization],
filename: "results.csv",
},
Plots//To plot curves of data.
{
selector: =configuration.traffic.pattern.legend_name,//Make a plot for each value of the selector
kind: [
//We may create groups of figures.
//In this example. For each value of pattern we draw three graphics.
Plotkind{
//The first one is accepted load for each offered load.
//Simulations with same parameter, here offered load, are averaged together.
parameter: =configuration.traffic.load,
abscissas: =configuration.traffic.load,
label_abscissas: "offered load",
ordinates: =result.accepted_load,
label_ordinates: "accepted load",
min_ordinate: 0.0,
max_ordinate: 1.0,
},
//In this example we draw message delay against accepted load, but we
//continue to average by offered load. The offered load is also used for
//the order in which points are joined by lines.
Plotkind{
parameter: =configuration.traffic.load,
abscissas: =result.accepted_load,
label_abscissas: "accepted load",
ordinates: =result.average_message_delay,
label_ordinates: "average message delay",
min_ordinate: 0.0,
max_ordinate: 200.0,
},
],
legend: =configuration.routing.legend_name,
prefix: "loaddelay",
backend: Tikz
{
//We use tikz to create the figures.
//We generate a tex file easy to embed in latex document.
//We also generate apdf file, using the latex in the system.
tex_filename: "load_and_delay.tex",
pdf_filename: "load_and_delay.pdf",
},
},
Plots
{
selector: =configuration.traffic.pattern.legend_name,//Make a plot for each value of the selector
//We can create histograms.
kind: [Plotkind{
label_abscissas: "path length",
label_ordinates: "amount fo packets",
histogram: =result.total_packet_per_hop_count,
min_ordinate: 0.0,
//max_ordinate: 1.0,
}],
legend: =configuration.routing.legend_name,
prefix: "hophistogram",
backend: Tikz
{
tex_filename: "hop_histogram.tex",
pdf_filename: "hop_histogram.pdf",
},
},
]
为了使 tikz 后端工作,需要有一个包含 pgfplots 包的 LaTeX 安装。在某些 Linux 发行版中,它是 texlive-pictures 包的一部分。它可能还需要 texlive-latexextra 包。
插件
两个条目 directory_main 和 file_main 都接收一个 &Plugs 参数,该参数可以用来向模拟器提供新的实现。这样,可以在 caminos 包中复制 main,并为其实现的 Router、Topology、Routing、Traffic、Pattern 和 VirtualChannelPolicy 声明插件。
依赖项
~14–24MB
~321K SLoC