CSAPP Lab4 解题分析

MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); Lab4 的Cache Lab 的说明资料太少了,csim.c 里面空空的,惊了。身为弱渣的我只好先拿别人的代码来参考参考。这里选取的代码csim.c。 Part A: Writing a Cache Simulator需要些一个Cache模拟器,将 valgrind 内存访问记录作为参数,模拟是否命中缓存。输出命中,不命中,移除。 lab里提供了一个写好的程序 csim-ref ,使用LRU(least-recently used)替换原则,模拟缓存命中情况。 实验指导上给出了命令行参数 Usage: ./csim-ref [-hv] -s <s> -E <E> -b <b> -t <tracefile> -h: Optional help flag that prints usage info -v: Optional verbose flag that displays trace info -s <s>: Number of set index bits ($ S = 2^{s} $ is the number of sets) -E <E>: Associativity (number of lines per set) -b <b>: Number of block bits ($ B = 2^{b} $ is the block size) -t <tracefile>: Name of the valgrind trace to replay 所以在 csim.c 里也可以写个打印帮助的函数 1234567void printUsage(){ printf("Usage: ./csim [-h] [-v] -s <s> -E <E> -b <b> -t <tracefile>\n"); printf("-s: number of set index(2^s sets)\n"); printf("-E: number of lines per set\n"); printf("-b: number of block offset bits\n"); printf("-t: trace file name\n");}     Continue Reading
Xin Qiu's avatar
Xin Qiu Jun 07, 2016

Machine Learning Note 1

MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); Coursera 上的Machine Learning 算得上是经典的机器学习入门课程,是由Andrew Ng大牛上的课。出于对机器学习的好奇,打算用Python来完成这门课的学习。 Supervised learning 监督学习这里存在两种问题 regression 和 classification。前者是预测相关的问题,后者是分类相关的问题。 首先介绍的是监督学习,notes1中用房屋价格预测来介绍Linear Regression线性回归。这里因为没有数据集,所以我选择用ex1中的ex1data1.txt来做演示。 1234567891011import matplotlib.pyplot as pltimport numpy as npdata = np.loadtxt('ex1data1.txt', delimiter=',')m = data.shape[0]X = data[:,0]y = data[:, 1]plt.scatter(X, y, c='r', marker='x', linewidths=1)plt.xlim([3, max(X)+3])plt.ylabel('Profit in $10,000s')plt.xlabel('Population of City in 10,000s')plt.show() 可以画出数据分布散点图。     Continue Reading
Xin Qiu's avatar
Xin Qiu Jun 02, 2016