gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Is there any ways for the guest program to communicate with the GEM5 simulator?

F
Foobat
Sat, Jul 22, 2023 8:39 AM

I’m profiling an JIT compiler with GEM5 syscall emulation mode. The lifecycle of the JIT compiler has several phases: parsing the code, compiling the code, setting up runtime environment, running the compiled code, and cleaning up. I need to know the cost and some performance statistics of each phase, to find out which part needs more optimization. So the guest program need to tell the simulator, for example, “I have set up the runtime environment and I’m about to run the code”. Dose gem5 provide any ways to do this? Can the guest program communicate with the simulator by executing a special instruction, writing to a special memory address, or making a special syscall?

I’m profiling an JIT compiler with GEM5 syscall emulation mode. The lifecycle of the JIT compiler has several phases: parsing the code, compiling the code, setting up runtime environment, running the compiled code, and cleaning up. I need to know the cost and some performance statistics of each phase, to find out which part needs more optimization. So the guest program need to tell the simulator, for example, “I have set up the runtime environment and I’m about to run the code”. Dose gem5 provide any ways to do this? Can the guest program communicate with the simulator by executing a special instruction, writing to a special memory address, or making a special syscall?
RC
Richard Cooper
Mon, Jul 24, 2023 8:17 AM

Hello,

You can use the special "m5ops" instructions to communicate between your workload and the simulator. The documentation is here:
https://www.gem5.org/documentation/general_docs/m5ops/

The available instructions are listed here, and you can build these wrapper functions into a library to link to your code (see documentation above).
https://github.com/gem5/gem5/blob/stable/include/gem5/m5ops.h

The simplest option would be to use the m5_dump_reset_stats() to dump and reset the statistics between the different phases of your program, but you can also use m5ops to mark regions of interest, or even to drop back into the Python configuration script to take more complex action.

Hope this helps,

Best regards,
Richard.

-----Original Message-----
From: Foobat via gem5-users gem5-users@gem5.org
Sent: Saturday, July 22, 2023 9:39 AM
To: gem5-users@gem5.org
Cc: Foobat foobat@outlook.com
Subject: [gem5-users] Is there any ways for the guest program to communicate with the GEM5 simulator?

I’m profiling an JIT compiler with GEM5 syscall emulation mode. The lifecycle of the JIT compiler has several phases: parsing the code, compiling the code, setting up runtime environment, running the compiled code, and cleaning up. I need to know the cost and some performance statistics of each phase, to find out which part needs more optimization. So the guest program need to tell the simulator, for example, “I have set up the runtime environment and I’m about to run the code”. Dose gem5 provide any ways to do this? Can the guest program communicate with the simulator by executing a special instruction, writing to a special memory address, or making a special syscall?


gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-leave@gem5.org
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Hello, You can use the special "m5ops" instructions to communicate between your workload and the simulator. The documentation is here: https://www.gem5.org/documentation/general_docs/m5ops/ The available instructions are listed here, and you can build these wrapper functions into a library to link to your code (see documentation above). https://github.com/gem5/gem5/blob/stable/include/gem5/m5ops.h The simplest option would be to use the `m5_dump_reset_stats()` to dump and reset the statistics between the different phases of your program, but you can also use m5ops to mark regions of interest, or even to drop back into the Python configuration script to take more complex action. Hope this helps, Best regards, Richard. -----Original Message----- From: Foobat via gem5-users <gem5-users@gem5.org> Sent: Saturday, July 22, 2023 9:39 AM To: gem5-users@gem5.org Cc: Foobat <foobat@outlook.com> Subject: [gem5-users] Is there any ways for the guest program to communicate with the GEM5 simulator? I’m profiling an JIT compiler with GEM5 syscall emulation mode. The lifecycle of the JIT compiler has several phases: parsing the code, compiling the code, setting up runtime environment, running the compiled code, and cleaning up. I need to know the cost and some performance statistics of each phase, to find out which part needs more optimization. So the guest program need to tell the simulator, for example, “I have set up the runtime environment and I’m about to run the code”. Dose gem5 provide any ways to do this? Can the guest program communicate with the simulator by executing a special instruction, writing to a special memory address, or making a special syscall? _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-leave@gem5.org IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.