2

I have a C code that takes value form two input file calculate multiplication and write the time into another text file. First I compile and make executable with GCC and the name is Method1_X86_BINARY_

gcc DecMulTimeMeasure.c decContext.c decDouble.c decQuad.c -o Method1_X86_BINARY_

The executable is working ./Method1_X86_BINARY_ file! Now I want to compile using gem5 SE mode by bellow command

./build/X86/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/x86/linux/Method1_X86_BINARY_

After that I receive following error

GEM5 SIMULATION START problem reading inputA.txt file Exiting @ tick 9053500 because exiting with last active thread context Simulated exit code not 0! Exit code is 1

The Message GEM5 SIMULATION START and problem reading inputA.txt file shows form my C code where bellow :

>FILE *ptr_file_read, *ptr_file_readB,*ptr_file_write , *Mptr_file_write;
 char fileNameA [40] = "final_result_a.txt";
 char fileNameB [40] = "final_result_b.txt";
 printf("GEM5 SIMULATION START");
ptr_file_read = fopen(fileNameA, "r"); //Name of the input file
if (!ptr_file_read)
{
     printf("problem reading inputA.txt file");
      return 1;
 }

So the message GEM5 SIMULATION START indicate that the executable is okay where as the message problem reading inputA.txt file indicates the problem is during reading form text file.

My question is how I can run the file in GEM-5 simulator.

Here I upload full project with little description in readme. github.com/riazcseiu/DecimalMultiplication.git

  • 1
    Print the error message using `perror` so you know what kind of error has occurred. Is the file `final_result_a.txt` in the same directory as `Method1_X86_BINARY_`? – Hadi Brais Jun 07 '19 at 10:01
  • 1
    I have tested with 08c79a194d1a3430801c04f37d13216cc9ec1da3 and a simple C program that writes and reads to a file, and the program worked exactly inside of gem5 and on my host. Does your program work on your host? Can you provide a minimal failing C program so that others can try to reproduce? Mailing list thread: https://www.mail-archive.com/gem5-users@gem5.org/msg16597.html – Ciro Santilli Jun 07 '19 at 15:36
  • Thanks for the reply. Here I upload full project with little description in readme for you. https://github.com/riazcseiu/DecimalMultiplication.git – Riaz Ul Haque Mian Jun 09 '19 at 05:48

1 Answers1

0

General compile and run shown at: How to compile and run an executable in gem5 syscall emulation mode with se.py?

Then, I test it in gem5 211869ea950f3cc3116655f06b1d46d3fa39fb3a (October 2019), and opening and closing or regular files just works normally: files can be read from host, and written to host filesystem normally.

I have tested this with this minimal C file write / read example.

The file src/doc/se-files.txt documents the implementation of this feature.

I believe gem5 then treats some special Linux files e.g. under /proc and /sys specially since those require more complex interactions with the kernel that gem5 is simulating in SE.

Ciro Santilli
  • 3,693
  • 1
  • 18
  • 44