LLCbench的安装和使用 ubuntu入门之十六

user@localhost:~$ tar -zxf llcbench.tar.gz 
user@localhost:~$ ls
Desktop    Image-xenomai-dele-x100-20220520a  Public     bin  libexec                           llcbench         perf-pc         test          ubuntu-kde-test.tar.gz
Documents  Music                              Templates  etc  linux-4.19-master-xenomai         llcbench.tar.gz  perf-test-data  test1         xenomai-v3.1.2
Downloads  Pictures                           Videos     lib  linux-4.19-master-xenomai.tar.gz  perf             share           test1.tar.gz  xenomai-v3.1.2.tar.bz2
user@localhost:~$ cd llcbench
user@localhost:~/llcbench$ ls
CHANGES  COPYING  Makefile  README  blasbench  cachebench  conf  doc  flushall.c  llcbench.h  misc  mpbench  results  sys.def  timer.c  user.def  www
user@localhost:~/llcbench$ ls
CHANGES  COPYING  Makefile  README  blasbench  cachebench  conf  doc  flushall.c  llcbench.h  misc  mpbench  results  sys.def  timer.c  user.def  www
user@localhost:~/llcbench$ make

Please use one of the following targets:

	alpha
	alpha-mpich
	linux-lam
	linux-mpich
	linux-opteron-mpich-acml
	ia64-mpich-ecc
	o2000
	pow2
	pow3
	ppc
	solaris
	solaris-mpich
	t3e
	reconfig (to bring this menu up again)

After configuration, please check the VBLASLIB variable in 
sys.def and make sure that it is pointing to the vendor BLAS
library if one exists.
user@localhost:~/llcbench$ make linux-lam
ln -s conf/sys.linux-lam sys.def
user@localhost:~/llcbench$ make
Please use one of the following targets:

For all three : compile, run, script, graph, clean, clobber, reconfig
For BlasBench : blas-bench, blas-run, blas-script, blas-graph
For CacheBench: cache-bench, cache-run, cache-script, cache-graph
For MPBench   : mp-bench, mp-run, mp-script, mp-graph

clean: removes object files and leaves result files
clobber: removes binary files and leaves result files
distclean: removes everything!
user@localhost:~/llcbench$ make cache-bench
cd cachebench; make 
make[1]: Entering directory '/home/user/llcbench/cachebench'
gcc -c -I.. ../flushall.c
gcc -O -Wall -c -I.. ../timer.c
gcc -O -Wall -DUSE_DOUBLE -I.. cachebench.c flushall.o timer.o -lrt -o cachebench
In file included from cachebench.c:10:
cachebench.c: In function ‘fake_out_optimizations’:
cachebench.c:296:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  296 |     assert(fd=open("/dev/null",O_WRONLY));
      |            ^~
cachebench.c: In function ‘do_memory_copy’:
cachebench.c:712:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  712 |   assert(y = (void *)malloc(memsize));
      |          ^
cachebench.c: In function ‘main’:
cachebench.c:947:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  947 |   assert(sizes = (long *)malloc(timeslots*sizeof(long)));
      |          ^~~~~
cachebench.c:949:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  949 |   assert(times = (double *)malloc(timeslots*repeat_count*sizeof(double)));
      |          ^~~~~
cachebench.c:951:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  951 |   assert(bws = (double *)malloc(timeslots*repeat_count*sizeof(double)));
      |          ^~~
cachebench.c:953:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  953 |   assert(percents = (double *)malloc(timeslots*repeat_count*sizeof(double)));
      |          ^~~~~~~~
cachebench.c:955:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  955 |   assert(x = (DATATYPE *)malloc((size_t)memsize));
      |          ^
make[1]: Leaving directory '/home/user/llcbench/cachebench'
user@localhost:~/llcbench$ ls
CHANGES  COPYING  Makefile  README  blasbench  cachebench  conf  doc  flushall.c  llcbench.h  misc  mpbench  results  sys.def  timer.c  user.def  www

cd cachebench; make 
make[1]: Entering directory '/home/user/llcbench/cachebench'
make[1]: 'cachebench' is up to date.
make[1]: Leaving directory '/home/user/llcbench/cachebench'
user@localhost:~/llcbench$ ls
CHANGES  COPYING  Makefile  README  blasbench  cachebench  conf  doc  flushall.c  llcbench.h  misc  mpbench  results  sys.def  timer.c  user.def  www
user@localhost:~/llcbench$ ls cachebench/
Makefile  cachebench  cachebench.c  cachegraph.gp  flushall.o  scripts  timer.o

user@localhost:~/llcbench$ cd cachebench/
user@localhost:~/llcbench/cachebench$ ./cachebench 

		Memory Set Library Cache Test

C Size		Nanosec		MB/sec		% Chnge
-------		-------		-------		-------
256             0.07            14006.49        1.00           
256             0.07            14007.11        1.00           
384             0.06            15007.76        0.93           
384             0.06            15007.85        1.00           
512             0.06            15563.79        0.96           
512             0.06            15563.29        1.00           
768             0.06            16162.41        0.96           
768             0.06            16162.38        1.00           
1024            0.06            16479.09        0.98           
1024            0.06            16479.26        1.00           
1536            0.06            16808.87        0.98           
1536            0.06            16792.13        1.00           
2048            0.06            16977.96        0.99 

参考:

使用llcbench测试缓存性能
https://blog.csdn.net/leishangwen/article/details/43339887

LLCbench - Low Level Architectural Characterization Benchmark Suite
https://icl.cs.utk.edu/llcbench/index.htm

以下是cachebench的核心代码,包括对不同类型缓存的读写测试和性能统计: ```c void test_cache(char* name, void* cache, int size, int count) { printf("Testing %s cache...\n", name); // Test read cache printf("Testing read...\n"); clock_t start = clock(); for (int i = 0; i < count; i++) { for (int j = 0; j < size; j++) { volatile char c = *(char*)(cache + j); } } clock_t end = clock(); double elapsed_time = ((double)(end - start)) / CLOCKS_PER_SEC; printf("Read time: %f seconds\n", elapsed_time); // Test write cache printf("Testing write...\n"); start = clock(); for (int i = 0; i < count; i++) { for (int j = 0; j < size; j++) { *(char*)(cache + j) = (char)i; } } end = clock(); elapsed_time = ((double)(end - start)) / CLOCKS_PER_SEC; printf("Write time: %f seconds\n", elapsed_time); } int main(int argc, char** argv) { int size = 1024 * 1024; int count = 10000; char* mem = malloc(size); memset(mem, 0, size); test_cache("L1", mem, size, count); int level = get_cache_level(2); if (level >= 0) { char* cache = get_cache(level); test_cache("L2", cache, size, count); } level = get_cache_level(3); if (level >= 0) { char* cache = get_cache(level); test_cache("L3", cache, size, count); } free(mem); return 0; } ``` 在主函数中,首先分配了一个指定大小的缓存,并初始化为0。然后使用`test_cache`函数对不同级别的缓存进行读写测试。`test_cache`函数中,先测试读取缓存的性能,然后测试写入缓存的性能,最后输出测试结果。`get_cache_level`和`get_cache`函数用于获取指定级别的缓存地址。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值