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?
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.
My preferred approach is to use minimal Buildroot images. Buildroot:
- builds both the cross compiler and the image for me, and thus ensure compatibility
- makes it easy to automate building new software with its package system
- can produce very simple images, which are more suitable for gem5 and architecture research
This is my setup on GitHub. It contains a minimal OpenMP hello world which I have successfully run inside of gem5.
Another good option is to use https://crosstool-ng.github.io/
Since you want OpenMP support, you must build the GCC cross compiler compiler with support.
I think this is done in GCC with:
./configure --enable-libgomp
or through the Buildroot option:
BR2_GCC_ENABLE_OPENMP=y
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
and search the options.
You come across:
-n NUM_CPUS, --num-cpus=NUM_CPUS
.
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
But keep in mind that: