【Booksim】Booksim2.0模拟器集成新拓扑

news2024/9/22 13:27:35
  • Incorporating a new topology in Booksim
    • 1. 新拓扑结构
    • 2. 需要添加的文件
    • 3. 修改步骤
      • 3.1 添加testnet.hpp
      • 3.2 添加testnet.cpp
      • 3.3 将testnet集成到network.cpp中
      • 3.4 创建配置文件testnetconfig
      • 3.5 在main.cpp和global.hpp中加入gP_testnet和gA_testnet变量
      • 3.6 make进行编译
    • 4. 仿真模拟结果

Incorporating a new topology in Booksim

1. 新拓扑结构

在这里插入图片描述

如图1所示,拟集成一种上述的拓扑。

2. 需要添加的文件

Booksim中集成新的拓扑,我们需要添加如下文件:

  • 拓扑文件
    • testnet.cpp
    • testnet.cpp
  • 配置文件
    • Testnetconfig
  • 修改文件
    • network.cpp

3. 修改步骤

3.1 添加testnet.hpp

 #ifndef _TestNet_HPP_
 #define _TestNet_HPP_

 #include "network.hpp"
 #include "routefunc.hpp"

 class TestNet : public Network {
 public:
 TestNet( const Configuration &config, const string & name );
 static void RegisterRoutingFunctions() ;

 private:

 int _a;// 路由器总数
 int _p;// 每个路由器管理的处理节点
 int _k;// 每个路由器的端口数

 void _ComputeSize( const Configuration &config );// 计算拓扑大小
 void _BuildNet( const Configuration& config );// 构建网络
 };

 int testnet_port(int rID, int src, int dest);

 //
 // Routing Functions
 //
 void min_testnet( const Router *r, const Flit *f, int in_channel, OutputSet *outputs, bool inject ) ;

 #endif

3.2 添加testnet.cpp

  1. 构造函数
TestNet::TestNet( const Configuration& config, const string & name ) 
: Network(config, name) 
{
cout<< "testnet constructor starts..."<<endl;
_ComputeSize(config);
_Alloc();
_BuildNet(config);
cout<< "testnet constructor ends..."<<endl;

}
  1. _ComputeSize()
void TestNet::_ComputeSize( const Configuration &config ) {

cout<< "_ComputeSize starts..."<<endl;

// _a _p _k 均为硬编码,但可以使用GetInt()从配置文件中获取
_a = 4;// 路由器总数
_p = 3;// 每个路由器管理的处理节点

_k = (_a-1) + _p;// 每个路由器的端口数

// 以下三个参数为network中需要使用的
_nodes    = _a * _p; // Number of nodes in network 总节点数(除却路由器)
_size     = _a + _a * _p;      // Number of routers in network 包括路由器和处理节点
_channels = _a * (_a-1);     // 路由器之间的uni-directional link,不包括处理节点

// 全局变量,路由函数需要
gP_testnet = _p;
gA_testnet = _a;

cout<< "_ComputeSize ends..."<<endl;
}
  1. _Alloc()
    _Alloc()定义在network.cpp,用于分配注入弹出通道和路由器link

  2. _BuildNet()
    _BuildNet()初始化路由器,添加所有的通道。如下图所示:
    在这里插入图片描述

void TestNet::_BuildNet( const Configuration& config ) {
// for every router 
    // build the router object
    // add the links to the processing nodes
    // add the links to the other routers

ostringstream router_name;
int node;
int c, cnt;
int port_to_routers = _a - 1;

for (node = 0; node < _a; ++node) {
    // create router
    router_name<< "router";
    router_name<< "_"<< node;
    // k是输入输出端口数
    _routers[node] = Router::NewRouter(config, this, router_name.str(), node, _k, _k);
    _timed_modules.push_back(_routers[node]);
    router_name.str("");
    
    // add input and output channels to processing nodes
    for(cnt = 0; cnt < _p; cnt++){
    c = _p * node + cnt; // for router 0, c is 0,1,2; router 1, c is 3,4,5 and so on.
    _routers[node]->AddInputChannel(_inject[c], _inject_cred[c]);
    }

    for(cnt = 0; cnt < _p; cnt++){
    c = _p * node + cnt; // for router 0, c is 0,1,2; router 1, c is 3,4,5 and so on.
    _routers[node]->AddOutputChannel(_eject[c], _eject_cred[c]);
    }

    // add output and input channels to other routers
    // add output channels
    for(cnt = 0; cnt < _a - 1; cnt++){
    c = port_to_routers * node + cnt; // for router 0, c is 0,1,2; router 1, c is 3,4,5 and so on.
    _routers[node]->AddOutputChannel(_chan[c], _chan_cred[c]);
    }

    // add input channels
    for(cnt = 0; cnt < _a; cnt++)
    {
    if(cnt == node)
    {
        continue;// do nothing
    }
    else if(cnt < node)
    {
        c = cnt * port_to_routers - 1 + node;
    }
    else if(cnt > node)
    {
        c = cnt * port_to_routers + node;
    }
    _routers[node]->AddInputChannel(_chan[c], _chan_cred[c]);
    }
}
}
  1. RegisterRoutingFunctions()
    该函数注册拓扑的路由算法,而gRoutingFunctionMap定义在routefunc.cpp
void TestNet::RegisterRoutingFunctions() {
    gRoutingFunctionMap["min_testnet"] = &min_testnet;
}

对于一组特定的router, flit和input channel, 需要提供一个output port和output VC用于路由。
6. testnet_port(int rID, int src, int dest)选择正确的输出端口

int testnet_port(int rID, int src, int dest)// find the right port
{
    int dst_router;
    int out_port;

    dst_router = dest / gP_testnet;

    if(rID == dst_router)// 目标node是在当前路由器管理之下
    {
        out_port = dest % gP_testnet;
    }
    else// 如果是在其他router下管理
    {
        if(dst_router < rID)
        {
        out_port = gP_testnet + dst_router;
        }
        else{
        out_port = gP_testnet + dst_router - 1;
        }
    }

    return out_port;
}

  1. min_testnet()进行路由
void min_testnet( const Router *r, const Flit *f, int in_channel, OutputSet *outputs, bool inject )
{
  int debug = f->watch;
  outputs->Clear();

  if(inject)
  {
      int inject_vc = RandomInt(gNumVCs-1);
      outputs->AddRange(-1, inject_vc, inject_vc);
      return;
  }

  int rID = r->GetID();

  int out_port = -1;
  int out_vc = 0;

  if(in_channel < gP_testnet)// source node assign to vc0
  {
      out_vc = 0;
  }
  else// dest node assign it to vc1
  {
      out_vc = 1;
  }

  out_port = testnet_port(rID, f->src, f->dest);

  outputs->AddRange(out_port, out_vc, out_vc);

  if(debug)
  {
      *gWatchOut << GetSimTime()<<" | "<<r->FullName()<<" | "
          <<" through output port : "<< out_port
          <<" out vc: "<< out_vc << endl;
  }
}

3.3 将testnet集成到network.cpp中

- 添加testnet.hpp

在这里插入图片描述

- 加入testnet拓扑

在这里插入图片描述

3.4 创建配置文件testnetconfig

```
// Topology
topology = testnet;

//a = 4;
//p = 3;

//Routing
routing_function = min;

// Flow control
num_vcs = 2;

// Traffic
traffic = uniform;
injection_rate = 0.25;
```

3.5 在main.cpp和global.hpp中加入gP_testnet和gA_testnet变量

3.6 make进行编译

4. 仿真模拟结果

  • a = 4, p = 3时运行booksim得到如下结果:
====== Overall Traffic Statistics ======
====== Traffic class 0 ======
Packet latency average = 14.392 (1 samples)
        minimum = 7 (1 samples)
        maximum = 78 (1 samples)
Network latency average = 14.3911 (1 samples)
        minimum = 7 (1 samples)
        maximum = 78 (1 samples)
Flit latency average = 14.4049 (1 samples)
        minimum = 7 (1 samples)
        maximum = 78 (1 samples)
Fragmentation average = 0 (1 samples)
        minimum = 0 (1 samples)
        maximum = 0 (1 samples)
Injected packet rate average = 0.250979 (1 samples)
        minimum = 0.24025 (1 samples)
        maximum = 0.26 (1 samples)
Accepted packet rate average = 0.251208 (1 samples)
        minimum = 0.23125 (1 samples)
        maximum = 0.27025 (1 samples)
Injected flit rate average = 0.250979 (1 samples)
        minimum = 0.24025 (1 samples)
        maximum = 0.26 (1 samples)
Accepted flit rate average = 0.251208 (1 samples)
        minimum = 0.23125 (1 samples)
        maximum = 0.27025 (1 samples)
Injected packet size average = 1 (1 samples)
Accepted packet size average = 1 (1 samples)
Hops average = 1.74948 (1 samples)
Total run time 0.0592558
  • a = 8, p = 4时运行booksim得到如下结果:
====== Overall Traffic Statistics ======
====== Traffic class 0 ======
Packet latency average = 14.1645 (1 samples)
        minimum = 7 (1 samples)
        maximum = 40 (1 samples)
Network latency average = 14.1645 (1 samples)
        minimum = 7 (1 samples)
        maximum = 40 (1 samples)
Flit latency average = 14.1681 (1 samples)
        minimum = 7 (1 samples)
        maximum = 40 (1 samples)
Fragmentation average = 0 (1 samples)
        minimum = 0 (1 samples)
        maximum = 0 (1 samples)
Injected packet rate average = 0.248344 (1 samples)
        minimum = 0.236 (1 samples)
        maximum = 0.261667 (1 samples)
Accepted packet rate average = 0.248417 (1 samples)
        minimum = 0.223667 (1 samples)
        maximum = 0.273667 (1 samples)
Injected flit rate average = 0.248344 (1 samples)
        minimum = 0.236 (1 samples)
        maximum = 0.261667 (1 samples)
Accepted flit rate average = 0.248417 (1 samples)
        minimum = 0.223667 (1 samples)
        maximum = 0.273667 (1 samples)
Injected packet size average = 1 (1 samples)
Accepted packet size average = 1 (1 samples)
Hops average = 1.87333 (1 samples)
Total run time 0.14817

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1596757.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

网络篇12 | 链路层 ARP

网络篇12 | 链路层 ARP 01 简介1&#xff09;工作过程2&#xff09;ARP缓存2.1 动态ARP表项2.2 静态ARP表项2.3 短静态ARP表项2.4 长静态ARP表项 02 ARP报文格式1&#xff09;ARP请求报文格式2&#xff09;ARP响应报文格式3&#xff09;套一层以太网帧&#xff08;ARP帧&#x…

网络篇11 | 网络层 ICMP

网络篇11 | 网络层 ICMP 01 简介02 报文格式1&#xff09;Type(类型)2&#xff09;Code(代码)3&#xff09;Checksum(校验和)4&#xff09;ICMP数据部分 03 ICMP数据抓包1&#xff09;类型 8&#xff1a;回显请求&#xff08;Echo Request&#xff09;2&#xff09;类型 13&…

Navicat的安装与破解

个人介绍 hello hello~ &#xff0c;这里是 code袁~&#x1f496;&#x1f496; &#xff0c;欢迎大家点赞&#x1f973;&#x1f973;关注&#x1f4a5;&#x1f4a5;收藏&#x1f339;&#x1f339;&#x1f339; &#x1f981;作者简介&#xff1a;一名喜欢分享和记录学习的…

代码随想录算法训练营第五十五天 | 392. 判断子序列、115. 不同的子序列

代码随想录算法训练营第五十五天 | 392. 判断子序列、115. 不同的子序列 392. 判断子序列题目解法 115. 不同的子序列题目解法 感悟 392. 判断子序列 题目 解法 题解链接 自己的想法实现 class Solution { public:bool isSubsequence(string s, string t) {if(s.size() >…

Python+Appium自动化测试(ios+Android)

一、软件安装 安装清单&#xff1a; JDKPythonnode.jsandroid-sdk(作者通过Android Studio安装)iOS-deploybrewlibimobiledevice依赖库ideviceinstallercarthage依赖库 appium-doctor&#xff08;安装后可在命令行中通过命令:appium-doctor检查还少啥&#xff09; WebDriverAg…

IBM SPSS Statistics for Mac:数据分析的卓越工具

IBM SPSS Statistics for Mac是一款功能强大的数据分析软件&#xff0c;专为Mac用户设计&#xff0c;提供了一系列专业的统计分析和数据管理功能。无论是科研人员、数据分析师还是学生&#xff0c;都能从中获得高效、准确的数据分析支持。 IBM SPSS Statistics for Mac v27.0.1…

Windows10为Git Bash添加文件传输命令rsync(详细图文配置)

文章目录 1. 安装git bash2. 下载所需要的4个包3. 下载解压包的软件4. 复制每个包下面的usr到git安装目录下4.1 所遇问题4.2 解决 5. 安装完成6. 需要注意 Windows上要使用 rsync命令上传或下载文件&#xff0c;需要使用git bash&#xff0c;git bash没有rsync&#xff0c;需要…

记录--病理切片图像处理

简介 数字病理切片&#xff0c;也称为全幻灯片成像&#xff08;Whole Slide Imaging&#xff0c;WSI&#xff09;或数字切片扫描&#xff0c;是将传统的玻片病理切片通过高分辨率扫描仪转换为数字图像的技术。这种技术对病理学领域具有革命性的意义&#xff0c;因为它允许病理…

Excel VBA技术:编织数据之梦的魔法语言

想要让你的Excel技能瞬间升级&#xff0c;成为数据处理与展示的顶尖高手吗&#xff1f;Excel VBA技术正是你不可错过的魔法武器&#xff01;它能让你轻松驾驭复杂的数据任务&#xff0c;自动化处理繁琐操作&#xff0c;释放你的双手和大脑。通过VBA&#xff0c;你可以创建精美的…

跨境电商MercadoLibre(美客多)平台预约号操作流程自动化系统

目录 一、前置配置准备 1. 安装Chrome插件 2. 添加预约配置 二、开始使用 MercadoLibre&#xff08;美客多&#xff09;于2021年10月18号上线了新预约入仓系统&#xff0c;在MercadoLibre美客多平台上&#xff0c;新入仓预约系统是一项非常重要的功能&#xff0c;它可以帮助…

Python-VBA函数之旅-dir函数

dir函数在 Python 中是一个非常实用的内置函数&#xff0c;它可以在多种场景下被使用。常见应用场景有&#xff1a; 1、交互式探索&#xff1a;当你在Python交互式解释器或Jupyter Notebook中工作时&#xff0c;dir()函数可以帮助你快速了解一个对象有哪些属性和方法。尤其是你…

如何通过Linux pciehp sysfs接口控制PCIe Slot电源状态?-3

pciehp sysfs接口电源控制与NVME驱动卸载的区别 从NVMe SSD设计本身而言&#xff0c;当通过pciehp sysfs接口对PCIe插槽执行Power Off操作时&#xff0c;由于NVMe SSD作为PCIe设备&#xff0c;其电源供应是直接依赖于所连接的PCIe插槽提供的。当插槽电源被关闭时&#xff0c;会…

HTML5 新增语义标签及属性

个人主页&#xff1a;学习前端的小z 个人专栏&#xff1a;HTML5和CSS3悦读 本专栏旨在分享记录每日学习的前端知识和学习笔记的归纳总结&#xff0c;欢迎大家在评论区交流讨论&#xff01; 文章目录 ✍HTML5 新增语义标签及属性&#x1f48e;1 HTML5 新增的块级语义化标签&…

查看 Linux 接入的 USB 设备速率是 USB2 还是 USB3

查看接入 usb 设备的速率 使用以下命令查看接入的 USB 设备速率&#xff08;每一行最后的 xxM 字样&#xff09;。插入设备前查看一次&#xff0c;插入设备后查看一次&#xff0c;对比即可定位到刚插入的设备是哪一条。 lsusb -t命令输出如下图 对照 USB 速率表 对照 USB 速…

网络基础(二)——传输层

1、再谈端口号 端口号(Port)标识了一个主机上进行通信的不同的应用程序; 在TCP/IP协议中, 用 "源IP", "源端口号", "目的IP", "目的端口号", "协议号" 这样一个五元组来标识一个通信(可以通过 netstat -n查看); 1.1、端口号…

java:多线程

多线程 在java程序中同时执行多个线程,每个线程独立执行不同的任务. 可以提高程序的性能和资源利用率,增加程序的并发性. 多线程的作用 1,提高程序性能 可以将一个任务分解成多个子任务并行处理,从而提高程序的运行速度 2,提高资源利用率 可以更好地利用CPU资源,提高CPU…

从0到1,六步搭建AI智能客服机器人

现如今&#xff0c;智能客服机器人成为了企业提升服务效率、优化客户体验的重要工具。它不仅可以24小时不间断地为客户提供服务&#xff0c;还减少人工成本。那么&#xff0c;如何从零开始搭建一个AI智能客服机器人呢&#xff1f;本文将为您简要介绍几个关键步骤。 一、明确需求…

Mybatis generate xml 没有被覆盖

添加插件即可 <plugin type"org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>

51单片机学习笔记——点亮数码管、模块化编程

工作原理图 138译码器 G1、G2A、G2B为138译码器的使能端 P22、P23、P24为输入口控制Y0-Y7的动作&#xff0c;以二进制的算法 具体如下&#xff1a; P22 P23 P24 0 0 0 Y0为1其余为0 0 0 1 Y1为1其余为0 0 1 0 Y2…

【香橙派zero3蓝牙串口wifi配网教程】

【香橙派zero3蓝牙串口wifi配网教程】 1. 简介2. 准备工作2.1 zero3串口5开启2.2 硬件连接 3. 配网步骤3.1 连接串口3.2 打开串口终端3.3 运行配网脚本3.4 输入WiFi信息 4. 注意事项5. 总结 1. 简介 香橙派Zero3是一款基于H618处理器的单板计算机&#xff0c;具有丰富的接口和…