我该如何编译&在gem5完整系统中运行c程序(使用OpenMP)? [英] How can i compile & run a c program (with OpenMP) in gem5 Full System?

查看:426
本文介绍了我该如何编译&在gem5完整系统中运行c程序(使用OpenMP)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名本科生,正在研究有关并行编程的论文. 我正在使用OpenMP模型.现在我想使用gem5来衡量性能. 这就是为什么我通过以下链接成功安装gem5完整系统:

I am an undergraduate student working on my thesis about parallel programming. I am using OpenMP model. Now i want to use gem5 for measure performance. That's why i install gem5 Full System successfully by following link:

http://cearial01.kaist. ac.kr/index.php/2016/08/26/gem5-documentation/

现在我要编译&使用gem5使用OpenMP(matmul.c)运行c程序. 我该如何编译&运行这个程序? 我的意思是我将程序文件(matmul.c)存储在哪个文件夹中以便进行编译? 我如何创建该程序的目标文件? 在运行&期间,如何更改处理器数量,缓存内存大小,CPU数量?编译吗?

Now i want to compile & run a c program with OpenMP (matmul.c) using gem5. How can i compile & run this program? I mean inside which folder i stored this program file (matmul.c) for compile? How i create object file of this program? How can i change no of processor, cache memory size, no of cpu during running & compilation?

我是本节的新学生.这就是为什么我的询问清单太大! 希望任何人都不介意.

I am new student of this section. That's why my asking list is too big! Hope anybody don't mind.

最好的问候, 利图

推荐答案

如何编译和运行此程序?我的意思是我将程序文件(matmul.c)存储在哪个文件夹中以便进行编译?如何创建该程序的目标文件?

How can I compile and run this program? I mean inside which folder I stored this program file (matmul.c) for compile? How I create object file of this program?

如何交叉编译映像不是gem5特有的,因此我将做简短介绍.

How to cross compile for an image is not gem5 specific, so I'll be brief.

首先,您必须为图像获取一个交叉编译器.

First you must obtain a cross compiler for the image.

最好的方法是从与映像相同的来源获得交叉编译器,以确保兼容性.

The best way to do that, is to get a cross compiler from the same source as the image to ensure compatibility.

我的首选方法是使用最少的Buildroot映像. Buildroot:

My preferred approach is to use minimal Buildroot images. Buildroot:

  • 为我构建交叉编译器和映像,从而确保兼容性
  • 使用其打包系统使自动构建新软件变得容易
  • 可以生成非常简单的图像,更适合gem5和建筑研究

这是我在GitHub上的设置.它包含最小的 OpenMP问候世界我已经在gem5中成功运行了.

This is my setup on GitHub. It contains a minimal OpenMP hello world which I have successfully run inside of gem5.

另一个好的选择是使用 https://crosstool-ng.github.io/

Another good option is to use https://crosstool-ng.github.io/

由于需要OpenMP支持,因此必须使用支持构建GCC交叉编译器.

Since you want OpenMP support, you must build the GCC cross compiler compiler with support.

我认为这是在GCC中使用的:

I think this is done in GCC with:

./configure --enable-libgomp

或通过Buildroot选项:

or through the Buildroot option:

BR2_GCC_ENABLE_OPENMP=y

然后在编译时,必须将-fopenmp选项传递给gcc.

And then when compiling, you must pass the -fopenmp option to gcc.

如何更改处理器数量和缓存大小?

How can I change the number of processors and the cache memory size?

亲自回答该问题的最佳方法是使用类似以下内容的

The best way to answer that question yourself is to use something like:

./build/ARM/gem5.opt configs/example/fs.py -h

并搜索选项.

您遇到了:

  • -n NUM_CPUS, --num-cpus=NUM_CPUS.

对于ARM,您还需要传递带有相应内核数的.dtb,例如:./system/arm/dt/armv7_gem5_v1_2cpu.dtb用于2个内核.

For ARM you also need to pass a .dtb with the corresponding core count, e.g.: ./system/arm/dt/armv7_gem5_v1_2cpu.dtb for 2 cores.

缓存:您可以轻松找到以下选项:

caches: you will find the following options easily:

 --caches --l1d_size=1024 --l1i_size=1024 --l2cache --l2_size=1024 --l3_size=1024

但是请记住:

  • the Linux kernel does not see the cache sizes correctly as of fbe63074e3a8128bdbe1a5e8f6509c565a3abbd4 How to switch CPU models in gem5 after restoring a checkpoint and then observe the difference?
  • caches only affect certain CPU types, usually the more detailed such as ARM HPI and x86 DerivO3CPU, but not AtomicSimpleCPU.

这篇关于我该如何编译&在gem5完整系统中运行c程序(使用OpenMP)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆