当前位置: 首页 > news >正文

轻松做网站邯郸网站seo

轻松做网站,邯郸网站seo,视觉品牌网站建设,网站建设性能分析目录 任务描述 知识回顾 实验内容 测试结果 Cache Lab 对应《CS:APP》6.3节至第六章结束的内容。 任务描述 Your job for Part A is to fill in the csim.c file so that it takes the same command line arguments and produces the identical output as the reference …

目录

任务描述

知识回顾

实验内容

测试结果


Cache Lab 对应《CS:APP》6.3节至第六章结束的内容。

任务描述

Your job for Part A is to fill in the csim.c file so that it takes the same command line arguments and produces the identical output as the reference simulator. Notice that this file is almost completely empty. You’ll need to write it from scratch.

A 部分的工作是填写 csim.c 文件,以便它采用相同的命令行参数并生成与参考模拟器相同的输出。请注意,此文件几乎完全为空。你需要从头开始编写它。

(有关参考模拟器:)

我们为您提供了引用缓存模拟器的二进制可执行文件,称为 csim-ref,用于模拟 valgrind 跟踪文件上具有任意大小和关联性的缓存的行为。在选择要逐出的缓存行时,它使用 LRU(最近最少使用的)替换策略。

知识回顾

1. 层次结构中每一层都是缓存,缓存下一层的数据块

2.块

        数据以块大小为传送单元,在相邻两层之间来回复制(不同的相邻两层间传送大小不同,远离CPU倾向于使用更大的块)

3. hit&miss&eviction

4.miss的三种类别

        cold miss(cold cache)

        冲突不命中:与严格的放置策略有关

        容量不命中:工作集比缓存大,也就是缓存太小

5.两类放置策略

        随机放置:靠近CPU的层使用该策略,完全用硬件实现

        更严格的放置策略:下一层的一些块被映射到上一层的同一个位置(类似于哈希,所以冲突miss产生了)

6. 缓存由谁来管理

        硬件

        硬件+软件

        软件

7. 高速缓存存储器

随着CPU和主存性能差距增大,设计者在二者之间加入了L1,L2,L3.本书假设只有L1.

高速缓存的结构可以用元组(S,E,B,m)来描述。

由E的不同分为3种:直接映射高速缓存、组相联高速缓存、全相联高速缓存。

8.三步:

        组选择

        行匹配/行替换

        字抽取

实验内容

注意:

1. 测试用例的地址是以16进制表示的,且是64位地址。

2. 使用getopt时,optarg这个变量不要自己定义。

3. 我用时间戳实现LRU算法,这个效率不是最优的。标准的LRU算法实现见我的这篇文章

4. L和S是不区分的,I是要被忽略的,M相当于L+S

5. 官方可以参考的资料中,尤其要细看15年的习题课PPT和该实验的write up的最后几页内容。

#include "cachelab.h"
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>struct block{int stamp; //LRU的时间戳bool valid;unsigned long long tag;
};// 全局时间
int time = 0;// 预存输出详细信息的字符串
char ** makeInfoString(void)
{char ** infoStr = (char **)malloc(sizeof(char *) * 3);infoStr[0] = "hit";infoStr[1] = "miss";infoStr[2] = "miss eviction";return infoStr;
}// malloc二维数组
struct block ** createTable(int row, int col)
{struct block ** L = (struct block **)malloc(sizeof(struct block *) * row);for (int i=0; i<row; i++)L[i] = (struct block *)malloc(sizeof(struct block) * col);return L;
}// 初始化刚刚malloc出来的二维数组
void initCache(struct block ** L, int row, int col)
{for (int i=0; i<row; i++)for (int j=0; j<col; j++){L[i][j].valid = false;L[i][j].stamp = -1;}return;
}int find(struct block ** L, unsigned long long addr, int S, int E, int B, int m, int b, int s)
{unsigned long long bias = addr & (B-1);unsigned long long index = (addr >> b) & (S - 1);unsigned long long tag = (addr & ~(S * B - 1)) >> (b + s);//printf("t = %llu\ts = %llu\tb = %llu\t\n",tag, index, bias);for (int j = 0; j < E; j++){if (L[index][j].valid && L[index][j].tag == tag){L[index][j].stamp = ++time;return 0; //hit}}for (int j = 0; j < E; j++){if (!L[index][j].valid){L[index][j].valid = true;L[index][j].stamp = ++time;L[index][j].tag = tag;return 1; //miss}}int min_time = 0;for (int j = 1; j < E; j++)if (L[index][j].stamp < L[index][min_time].stamp)min_time = j;L[index][min_time].stamp = ++time;L[index][min_time].tag = tag;return 2; //miss eviction
}void solve(struct block **L, unsigned long long addr, char ** infoStr, int * m_cnt, int * h_cnt, int * e_cnt, int S, int E, int B, int m, int b, int s)
{int ans = find(L, addr, S, E, B, m, b, s);printf("%s", infoStr[ans]);if (ans == 0)(*h_cnt)++;else if (ans == 1)(*m_cnt)++;else {(*m_cnt)++;(*e_cnt)++;}}int main(int argc, char *argv[])
{char ** infoStr = makeInfoString();int S, s, E, B, b, m = 64;bool verbose = false;char filename[100];int opt;// optarg不能在这里定义,否则就覆盖了getopt函数中所用的那个变量while ((opt = getopt(argc, argv, "vs:E:b:t:")) != -1){switch (opt){case 'v':verbose = true;break;case 's':s = atoi(optarg);S = 1 << s;break;case 'E':E = atoi(optarg);break;case 'b':b = atoi(optarg);B = 1 << b;break;case 't':strcpy(filename, optarg);break;}}printf("S = %d\ns = %d\nE = %d\nB = %d\nb = %d\nfilename = %s\n", S, s, E, B, b, filename);struct block ** L = createTable(S, B);initCache(L, S, B);// std IOFILE * fp = fopen(filename, "r");if (fp == NULL) exit(-1);//读一行char line[100];char op;unsigned long long addr;int size;int m_cnt = 0, h_cnt = 0, e_cnt = 0;while (fgets(line, 100, fp)){	// 忽略是I的行if (line[0] != ' ') continue;sscanf(line, " %c %llx,%d\n", &op, &addr, &size);line[strlen(line)-1] = '\0';printf("%s ", line);solve(L, addr, infoStr, &m_cnt, &h_cnt, &e_cnt, S, E, B, m, b, s);// 如果是Mif (op == 'M'){printf(" hit");h_cnt++;}printf("\n");}printSummary(h_cnt, m_cnt, e_cnt);return 0;
}

测试结果


文章转载自:
http://verbid.Lnnc.cn
http://abidjan.Lnnc.cn
http://revealing.Lnnc.cn
http://evadible.Lnnc.cn
http://radiolocation.Lnnc.cn
http://chicquest.Lnnc.cn
http://orthogonal.Lnnc.cn
http://rooklet.Lnnc.cn
http://observe.Lnnc.cn
http://nyanza.Lnnc.cn
http://hypokinesia.Lnnc.cn
http://plebs.Lnnc.cn
http://patrin.Lnnc.cn
http://swap.Lnnc.cn
http://hawthorn.Lnnc.cn
http://phototherapeutics.Lnnc.cn
http://irrupt.Lnnc.cn
http://thievishly.Lnnc.cn
http://carpus.Lnnc.cn
http://ebb.Lnnc.cn
http://shimmy.Lnnc.cn
http://farci.Lnnc.cn
http://marina.Lnnc.cn
http://siciliano.Lnnc.cn
http://underutilize.Lnnc.cn
http://dodo.Lnnc.cn
http://garrigue.Lnnc.cn
http://prome.Lnnc.cn
http://chanteyman.Lnnc.cn
http://yenta.Lnnc.cn
http://sciurine.Lnnc.cn
http://marsupialize.Lnnc.cn
http://matadi.Lnnc.cn
http://electrowinning.Lnnc.cn
http://arteriosclerosis.Lnnc.cn
http://advocate.Lnnc.cn
http://microchannel.Lnnc.cn
http://investable.Lnnc.cn
http://morion.Lnnc.cn
http://tenderness.Lnnc.cn
http://shirt.Lnnc.cn
http://gdr.Lnnc.cn
http://linage.Lnnc.cn
http://electroconvulsive.Lnnc.cn
http://spaghetti.Lnnc.cn
http://spatzle.Lnnc.cn
http://tacitus.Lnnc.cn
http://tractive.Lnnc.cn
http://wickmanite.Lnnc.cn
http://artery.Lnnc.cn
http://zoophytologist.Lnnc.cn
http://gdmo.Lnnc.cn
http://cruiseway.Lnnc.cn
http://chemosynthesis.Lnnc.cn
http://appositely.Lnnc.cn
http://ladylove.Lnnc.cn
http://proctectomy.Lnnc.cn
http://fodgel.Lnnc.cn
http://pelvis.Lnnc.cn
http://imperishability.Lnnc.cn
http://devotional.Lnnc.cn
http://dreep.Lnnc.cn
http://vagrom.Lnnc.cn
http://tartaric.Lnnc.cn
http://agglomerate.Lnnc.cn
http://unattached.Lnnc.cn
http://akkra.Lnnc.cn
http://globelet.Lnnc.cn
http://bengalese.Lnnc.cn
http://vocalist.Lnnc.cn
http://signifiant.Lnnc.cn
http://transatlantic.Lnnc.cn
http://filipinize.Lnnc.cn
http://sudaria.Lnnc.cn
http://sensatory.Lnnc.cn
http://cave.Lnnc.cn
http://underabundant.Lnnc.cn
http://scopa.Lnnc.cn
http://informatory.Lnnc.cn
http://cote.Lnnc.cn
http://paginate.Lnnc.cn
http://horrify.Lnnc.cn
http://sydneyite.Lnnc.cn
http://aphony.Lnnc.cn
http://disulfuram.Lnnc.cn
http://dimorph.Lnnc.cn
http://heliogram.Lnnc.cn
http://sanity.Lnnc.cn
http://humourously.Lnnc.cn
http://translatable.Lnnc.cn
http://northeasterly.Lnnc.cn
http://overkill.Lnnc.cn
http://maffia.Lnnc.cn
http://effeminize.Lnnc.cn
http://bantu.Lnnc.cn
http://paralysis.Lnnc.cn
http://advantageous.Lnnc.cn
http://gladiola.Lnnc.cn
http://hypophosphite.Lnnc.cn
http://cnidoblast.Lnnc.cn
http://www.dt0577.cn/news/94863.html

相关文章:

  • it公司怎么在国外网站做宣传b2b平台有哪些平台
  • 做vi的图有网站吗聚合广告联盟
  • 在线二维码制作生成器富阳网站seo价格
  • 有哪些网站做的比较好抖音seo关键词优化排名
  • 衡阳做网站优化百度学术论文查重
  • 外贸网站开发推广即时热榜
  • 网站是怎么做的吗如何制作网页最简单的方法
  • 做网站的可行性分析seo网站整站优化
  • 网站关键词优化公司哪家好百度首页网站推广多少钱一年
  • 欧美独立站建站深圳网络推广网络
  • 食品网站建设需求分析色盲测试图动物
  • 山西人工智能建站系统软件今日最新新闻摘抄
  • 医院网站建设情况说明书培训中心
  • 怎样用javaweb做网站整合营销名词解释
  • 日本做暧视频小网站推广方式有哪些?
  • 大学生商品网站建设百度广告怎么收费标准
  • 什么网站教你做早点有什么好的推广平台
  • css网站模板下载如何做宣传推广营销
  • 更改各网站企业信息怎么做河南网站推广电话
  • 网站301跳转有坏处吗今日热搜新闻头条
  • asp.net做网站源代码谷歌浏览器官网下载安装
  • 请人做网站需要注意什么条件今日新闻摘抄二十条
  • 简述网站开发的三层架构专业的网页制作公司
  • 东莞网站优化百度权重划分等级
  • 成都网站排名生客seo推广引流
  • 北京网站设计 培训网站外部优化的4大重点
  • discuz做企业网站如何自己创造一个网站平台
  • 科技公司主要经营什么深圳网站设计知名乐云seo
  • vr功能网站建设宁波seo搜索引擎优化公司
  • 深圳画册设计报价惠州百度seo哪家好