[gem5-users] Re: How to use the memory address version of m5ops such as m5_exit_addr in an external C progam?
Hi Ciro. You are correct that there isn't a header for those symbols, although the signature for m5_exit and m5_exit_addr should be identical. The mechanism supporting those symbols should all be in place and there are unit tests for them, although those tests are at least partially still under review. I hadn't figured out what would be the best way to add those symbols without a lot of duplication, but if you want to define an m5_exit_addr with the same signature as the original that should just work, assuming you've set it up to use the right address through other means. I'm still not sure exactly what the best approach is in general, so we should probably hold off on any large scale change for now. Gabe On Tue, Oct 27, 2020 at 6:54 AM Ciro Santilli via gem5-users < gem5-users@gem5.org> wrote: > Hi, > > I have m5_exit working on a C program at > https://gem5.googlesource.com/public/gem5-resources/+/refs/heads/stable/src/simple/m5_exit.c#41 > but > now I wanted to create one using the memory address version. > > We already have a m5_exit_addr symbol defined in the library, but I > couldn't find it exposed in any headers. > > Do I just submit a patch adding all the symbols to include/gem5/m5ops.h, > e.g. void m5_exit_addr(uint64_t ns_delay); ? Or is there already a way to > access those that you know of? > > If a patch is needed, any clues what would be the best approach? I see > that currently the magic happens under: > > struct DispatchTable > { > #define M5OP(name, func) __typeof__(&::name) name; > M5OP_FOREACH > #undef M5OP > > and: > > DispatchTable addr_dispatch = { > #define M5OP(name, func) .name = &::M5OP_MERGE_TOKENS(name, _addr), > M5OP_FOREACH > #undef M5OP > > so I'm guessing I could add a similar M5OP_FOREACH + __typeof__ hack to > include/gem5/m5ops.h > to avoid repeating each function? > > ___ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: Single Step Support in x86
The IRET instruction is implemented in arch/x86/isa/insts/general_purpose/control_transfer/interrupts_and_exceptions.py. It's fairly involved since IRET is an inherently complicated instruction, but it's commented and follows the pseudo code which was in the AMD manuals at the time it was written. Setting the trap flag in RFLAGS may not actually do anything in gem5 though, since this hasn't been a high priority for the sort of modelling people have wanted to do on it. There are mechanisms which will let you schedule an event on a CPU after it executes N more instructions, so at least in principle there should be most of what you'd need to implement it. There are some strange instructions which have an interrupt shadow which may not be interruptable with that flag, but I'd have to look at the documentation again to double check. The DelayedCommit mechanism was added a long time ago to help with those situations, where you may not be allowed to interrupt execution even between certain instructions, or even during others like the string instructions. I don't think that mechanism was fully fleshed out, but it's there if it helps. Gabe On Tue, Oct 27, 2020 at 12:38 AM Deepak Mohan via gem5-users < gem5-users@gem5.org> wrote: > Hi, > Is single stepping supported in gem5 x86 (by setting the Trap Flag in > RFLAGS register) ? I was working with an educational OS that runs on gem5, > and was trying to add a single step feature to it. But when I set the Trap > flag in the RFLAGS saved on stack and called IRETQ instruction, it seems > that the Trap Flag is not set in the RFLAGS register. Can anyone provide > some information on this, like where to look in the gem5 source code to get > a better understanding. > > Thanks, > Deepak Mohan > ___ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: How to use the new libm5.a
Hi Gabe, The public/gem5-website repo is the place to update the documentation. The README file (https://gem5.googlesource.com/public/gem5-website/+/refs/heads/stable/README.md) should contain needed information to run a local instance of the website as well as the procedure of updating the repo. The file that generates the m5ops documentation page is https://gem5.googlesource.com/public/gem5-website/+/refs/heads/stable/_pages/documentation/general_docs/m5ops.md Making changes on public/gem5-website should be very similar to making changes on public/gem5. However, this change should happen on the stable branch of gem5-website as the documentation should be compatible with gem5's stable branch. We appreciate all the help with the documentation! Regards, Hoa Nguyen On 10/26/20, Gabe Black via gem5-users wrote: > Hi Wenqi. The updated libm5.a should be used in basically the same way as > the old version. Just link against the library, include the header file, > and call into the op you want using the normal function call syntax. > > Hoa, the documentation you've linked to is a little out of date. How can it > be updated? > > Gabe > > On Sun, Oct 25, 2020 at 9:31 PM Hoa Nguyen via gem5-users < > gem5-users@gem5.org> wrote: > >> Hi Wenqi, >> >> We have some documentation about the new m5 utility here: >> https://www.gem5.org/documentation/general_docs/m5ops/ >> >> The following link is an example of annotating PARSEC: >> https://github.com/darchr/parsec-benchmark/commits/gem5-20-annotations >> >> Regards, >> Hoa Nguyen >> >> On 10/25/20, wqyin--- via gem5-users wrote: >> > Hello all, >> > >> > I noticed the util/m5 has big changes since this >> > commit:26454e8072e607d54ac67c42b33355d7c94d6d60 around Apr 27. I am >> > wondering how should I use this new interface/implementation to call >> > m5ops in my program? Shall I also instantiate a default CallType and >> > then use it to obtain the dispatch table and finally pass it to >> > Command::run? Also is there any examples which use the new >> > implementation to annotate any benchmarks running inside gem5? Thanks >> > >> > Best, >> > >> > Wenqi >> > >> > >> ___ >> gem5-users mailing list -- gem5-users@gem5.org >> To unsubscribe send an email to gem5-users-le...@gem5.org >> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >> > ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: Multi-process shared memory in SE mode
Hi Jason, thanks for the feedback! About your suggestions: - Yes, pthreads worked correctly for the simple examples I tried. But still has this drawback of shared memory I was trying to avoid.. - Do you have any pointers on implementing syscalls on gem5? It could be anything I could take as a 'guide' to get started with it since I'm not sure about how hard or easy that might be. I'll take a look since it might be a good solution for the short-term goals of making multi-processing work. Again, thank you. Best, Pedro. ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] SE Mode and Std::thread
Hey all, I'm running into a strange issue where threads are not spawning when launched with std::thread. It seems to work once, and then I try to launch again using a newly allocated thread pointer (after deleting the old one) and it hangs. Minimal example: void foo() { printf("Foo alive from tid %lu\n", m5_cpu_id()); //m5_cpu_id is a pseudo_instruction I added to return tc->cpuId() } void main() { printf("Launching foo 1"\n); std::thread * mythread = new std::thread(foo,...); printf("Done Launching foo 1"\n); printf("Joining foo 1"\n); myThread->join(); delete myThread; printf("Launching foo 2"\n); mythread = new std::thread(foo,...); printf("Done Launching foo 2"\n); printf("Joining foo 2"\n); myThread->join(); //< IT HANGS HERE printf("Done Everything!\n"); delete myThread; } __ It works fine with TimingSimpleCPU, but then with DerivO3CPU I get the failure. Output for DerivO3CPU: Launch 1 Done Launch 1 I'm alive on tid 1 Launch 2 Done Launch 2 And there it Hangs. FYI I am using apu_se.py, though with the above minimal example I've managed to reproduce the bug with no GPU code (nor even hipcc) involved. I went back to the original code I found that showed std::thread could be used here: https://www.gem5.org/documentation/learning_gem5/part3/running/ [image: image.png] The comment there that -1 is required for SE mode, and then the subsequent comment about appeasing SE mode... What exactly do those comments mean? I'm going to keep debugging, but if anyone has any suggestions for debug flags that could be helpful it would be appreciated. (I'm using SyscallAll and going to investigate some of the syscalls SE mode ignores). I'm wondering if maybe it is calling join() multiple times that might be the problem? Though unsure why at this point. Thanks! Dan ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: Multi-process shared memory in SE mode
Hi Predro, It would certainly be easier in FS mode :D. Also, I would worry that the system call emulation layer might not model your application with high enough fidelity if you care about multithreaded apps (e.g., the futex system call will take 0 time in SE mode). If you dynamically link your application to the pthread library, it *should* work, at least functionally, in SE mode. This has been tested in the past. However, I don't think we have a test for it in our current regressions, so it's possible this has been broken. If using different processes in SE mode is a requirement, I think the only option is to implement the shared memory syscalls. If you go this route, we would be happy to take the contribution of these new syscall implementations upstream! Cheers, Jason On Tue, Oct 27, 2020 at 2:15 AM Pedro Becker via gem5-users < gem5-users@gem5.org> wrote: > Hi all, > > Is it possible to do any form of communication between two applications > running in SE mode? > > I know we can span two apps with the se.py script with -c "app1;app2", but > if one of these apps try to use syscalls like shmget() or shmat() > simulation does not work because the syscalls are not implemented. > I could simulate the communication between threads (with pthreads), but > I'd like to do it with different processes (with separate memory spaces). > > Is there any way do to it? Am I obligated to use the FS mode in this case? > > Thank you. > > --- > Pedro Becker. > ___ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s > ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] How to use the memory address version of m5ops such as m5_exit_addr in an external C progam?
Hi, I have m5_exit working on a C program at https://gem5.googlesource.com/public/gem5-resources/+/refs/heads/stable/src/simple/m5_exit.c#41 but now I wanted to create one using the memory address version. We already have a m5_exit_addr symbol defined in the library, but I couldn't find it exposed in any headers. Do I just submit a patch adding all the symbols to include/gem5/m5ops.h, e.g. void m5_exit_addr(uint64_t ns_delay); ? Or is there already a way to access those that you know of? If a patch is needed, any clues what would be the best approach? I see that currently the magic happens under: struct DispatchTable { #define M5OP(name, func) __typeof__(&::name) name; M5OP_FOREACH #undef M5OP and: DispatchTable addr_dispatch = { #define M5OP(name, func) .name = &::M5OP_MERGE_TOKENS(name, _addr), M5OP_FOREACH #undef M5OP so I'm guessing I could add a similar M5OP_FOREACH + __typeof__ hack to include/gem5/m5ops.h to avoid repeating each function? ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: track the write syscall in the kernel
On full system you can also try to instrument the syscall function symbol, we do something analogous for panic detection: https://github.com/gem5/gem5/blob/f28b2e773f2ee97bf9c755b33aef9befc052d281/src/arch/arm/linux/fs_workload.cc#L207 From: ABD ALRHMAN ABO ALKHEEL via gem5-users Sent: Saturday, October 24, 2020 10:00 PM To: gem5 users mailing list ; gem5-users Cc: ABD ALRHMAN ABO ALKHEEL Subject: [gem5-users] track the write syscall in the kernel Hi All; I want to track the write syscall in order to do some calculations on the written bytes. I just want to know what is the function that does write syscall function and how I can the written bytes from it. Any help would be appreciated. Thanks https://github.com/torvalds/linux/blob/master/fs/read_write.c ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Re: How to use the new libm5.a
Hi Wenqi, Have you tried: https://stackoverflow.com/questions/62757008/how-to-use-m5-in-gem5-20/62759204#62759204 or has something changed since then too? Seems to work on develop just now. From: wqyin--- via gem5-users Sent: Sunday, October 25, 2020 7:36 PM To: gem5-users@gem5.org Cc: wq...@utexas.edu Subject: [gem5-users] How to use the new libm5.a Hello all, I noticed the util/m5 has big changes since this commit: 26454e8072e607d54ac67c42b33355d7c94d6d60 around Apr 27. I am wondering how should I use this new interface/implementation to call m5ops in my program? Shall I also instantiate a default CallType and then use it to obtain the dispatch table and finally pass it to Command::run? Also is there any examples which use the new implementation to annotate any benchmarks running inside gem5? Thanks Best, Wenqi ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Multi-process shared memory in SE mode
Hi all, Is it possible to do any form of communication between two applications running in SE mode? I know we can span two apps with the se.py script with -c "app1;app2", but if one of these apps try to use syscalls like shmget() or shmat() simulation does not work because the syscalls are not implemented. I could simulate the communication between threads (with pthreads), but I'd like to do it with different processes (with separate memory spaces). Is there any way do to it? Am I obligated to use the FS mode in this case? Thank you. --- Pedro Becker. ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
[gem5-users] Single Step Support in x86
Hi, Is single stepping supported in gem5 x86 (by setting the Trap Flag in RFLAGS register) ? I was working with an educational OS that runs on gem5, and was trying to add a single step feature to it. But when I set the Trap flag in the RFLAGS saved on stack and called IRETQ instruction, it seems that the Trap Flag is not set in the RFLAGS register. Can anyone provide some information on this, like where to look in the gem5 source code to get a better understanding. Thanks, Deepak Mohan ___ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s