1

I am new in gem5. I have downloaded, build run a simple hello world program. Now I want to run my own programs like finding a prime no. I have some questions related to this.. 1. How I can run my own programs? 2. How I can set my own parameters in gem.How? 3. How much knowledge of Python I must have to learn it?

  • 2
    As an extra to Ciro's answer, regarding your first question, and assuming SE is used: Cross-compile your program to whatever architecture you are using and run it. Ex (should work with no params, although you likely want to set some; the name of the program is prime, but could be anything; remove quotes when running): "/build/X86/gem5.opt /configs/example/se.py -c /primes ". Regarding Python knowledge, just basic programming is enough. You might need to edit a config file or two, but as Ciro said, Google is your friend. – Daniel Carvalho Oct 30 '18 at 09:20
  • Thank you very much for reply. I will try and revert to you. – Surendra Shukla Oct 31 '18 at 17:20
  • Dear Sir I made a program list.c. I saved this file in the gem5/tests/test-my/list. – Surendra Shukla Nov 01 '18 at 07:21
  • Dear Sir I made a program list.c. I saved this file in the gem5/tests/test-my/list. Now I am trying to run as you suggested I gave the command samr time I am in the gem5 directory:- ./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-my/list.c it give following "fatal cant't load object file ./tests/test-my/list.c – Surendra Shukla Nov 01 '18 at 07:31
  • I find the mistake I was putting list.c I should have to put the out file list.o i done with this modification & I get the following result "aborted core dumped" – Surendra Shukla Nov 01 '18 at 07:38
  • @ Daniel Carvalho I am not getting any statics in the stat.txt file. – Surendra Shukla Nov 01 '18 at 07:40
  • You should not use neither the C file (.c), not the object file (.o). You should use the executable. Ex: If you compile with "gcc list.c -o list" then you should pass "list" to Gem5. More info on the difference between these file types here: "https://www.quora.com/What-is-the-difference-between-source-file-executable-file-and-object-file" – Daniel Carvalho Nov 01 '18 at 14:09
  • @Daniel Carvalho Thank you very much. – Surendra Shukla Nov 01 '18 at 15:40

1 Answers1

1

How can I run my own programs

First you have to decide if you will run full system or syscall emulation.

The tradeoffs are discussed at: When to use full system FS vs syscall emulation SE with userland programs in gem5?

For full system, here is an easy to use setup: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8815312cad053d0284c4d91bfbf36a1e9ea207af#gem5-buildroot-setup-getting-started You can just add your program next to the other userland programs at packages/lkmc/userland.

For syscall emulation, get started with: How to compile and run an executable in gem5 syscall emulation mode with se.py?

How I can set my own parameters in gem5

Hard to answer without which parameter you have in mind. Generally:

  • fs.py --param for simpler things
  • more complex Python script options / patches for more complex things
  • touch the C++ core for even more complex / perf critical things

How much knowledge of Python I must have to learn it?

Python is easy, just try to do stuff, and Google away until you know enough.

Ciro Santilli
  • 3,693
  • 1
  • 18
  • 44
  • Could you please comment on the following:- I have a c program for printing prime nos. It is compiled in ubuntu 14.04 and run in the same. Now I have a files prime.c and one file a.out. When I am trying to give the path for the execution of the prime.c file with the gem5.out and se.py script file it states file not found. could you please send me the screen shots how to do this. If possible send the screen shot. Thanks – Surendra Shukla Oct 31 '18 at 10:19
  • @SurendraShukla see this: https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049 Please don't send screenshots of code, just send the code itself as text. – Ciro Santilli Oct 31 '18 at 14:01
  • Dear Sir I made a program list.c. I saved this file in the gem5/tests/test-my/list. Now I am trying to run as you suggested I gave the command samr time I am in the gem5 directory:- ./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-my/list.c it give following "fatal cant't load object file ./tests/test-my/list.c After that I made a modification putted list.o in file name I find the mistake I was putting list.c I should have to put the out file list.o i done with this modification & I get the following result "aborted core dumped" – Surendra Shukla Nov 01 '18 at 07:56
  • @SurendraShukla you have to run the executable file, not the .c source file – Ciro Santilli Nov 01 '18 at 10:36
  • How we can convert the .c file in executable in ubuntu please guide. – Surendra Shukla Nov 01 '18 at 10:38
  • 1
    @SurendraShukla this is too basic, please google before asking. I even said it in my other post. – Ciro Santilli Nov 01 '18 at 10:39
  • what about "aborted core dumped – Surendra Shukla Nov 01 '18 at 10:40
  • 1
    :- Thank you very much, now I successfully run the program. Your clue about the executable file was main hint. – Surendra Shukla Nov 01 '18 at 11:01
  • @SurendraShukla great thanks. Consider accepting the answer if it solved your problem (greeen tick under upvote / downvote count). – Ciro Santilli Nov 01 '18 at 11:43