[gem5-users] Re: Destructor for BaseCPU

2022-02-09 Thread Gabe Black via gem5-users
*Very* superficially looking at this (just at what's in the emails here),
you might want to make sure the BaseCPU destructor is virtual, or at least
the destructor of a base class is. If it isn't currently, the destructor of
SimObject should probably be virtual. I don't know for sure whether that
would cause your problem, but that would be the first thing I would check.
I know not having a virtual destructor can cause problems where things
don't get cleaned up properly.

That said, if you just want something generic to happen at the end of the
simulation (vs something to clean up some new part of BaseCPU),
registerExitCallback that Jason pointed out is probably the way to go.

Gabe

On Wed, Feb 9, 2022 at 5:24 PM Jason Lowe-Power via gem5-users <
gem5-users@gem5.org> wrote:

> Hi Scott,
>
> If you want something to execute before gem5 is completed, you can call
> `registerExitCallback`. See
> http://doxygen.gem5.org/release/current/namespacegem5.html#abcf3056836ee522620e5b14d9392ea87
>
> I *think* that will solve your problem, but let me know if not. I don't
> think there's a clean way to have a SimObject's destructor guaranteed to be
> called.
>
> Cheers,
> Jason
>
> On Wed, Feb 9, 2022 at 4:47 PM Scott Blankenberg via gem5-users <
> gem5-users@gem5.org> wrote:
>
>> Hello,
>>
>> In src/cpu/base.cc we have the following destructor:
>>
>> BaseCPU::~BaseCPU()
>> {
>> }
>>
>> By default nothing is inside of it. However, when I put code inside, it
>> does not seem to be executed at any point. Based on some previous threads I
>> have seen on the forums, it seems that the destructor for BaseCPU is not
>> being called at the end of the simulation.
>>
>> Has anyone found a way to make sure this destructor is called when the
>> simulation ends?
>>
>> Similarly, has anyone written a tracer which is a subclass of InstTracer
>> that has a destructor which is successfully called at the end of
>> simulation?
>>
>> Basically my objective is to make sure the destructor to my customTracer
>> is called at the end of the simulation.
>>
>> Thanks,
>>
>> Scott Blankenberg
>> ___
>> 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 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: findOrCreate function

2022-02-09 Thread Jason Lowe-Power via gem5-users
Hi Scott,

I think the answer is the same as the prior email. You need to register an
exit callback to close the file stream :). See, for instance, the elastic
trace code:
https://gem5.googlesource.com/public/gem5/+/refs/heads/stable/src/cpu/o3/probe/elastic_trace.cc#103

Cheers,
Jason

On Wed, Feb 9, 2022 at 5:19 PM Scott Blankenberg via gem5-users <
gem5-users@gem5.org> wrote:

> Hello all,
>
> Has anyone used the findOrCreate Gem5 function for opening custom file
> streams?
>
> For example in src/cpu/base.cc we see that this function is used in the
> constructor for BaseCPU
>
>   const std::string fname = csprintf("ftrace.%s", name());
>   functionTraceStream = simout.findOrCreate(fname)->stream();
>
>
> Has anyone who has used this function called it to create .gz files?
>
> I am having an issue right now where for some benchmarks I run that the
> final gz file I get out is not compressed correctly. When I attempt to
> decompress the .gz files, I will get errors such as "unexpected end of
> file".
>
> One possibility I can think of is that the file does not close properly.
> However, I am struggling to find out where I should close the file since I
> need to do it at the end of the simulation and there is no clear place in
> BaseCPU code to place code you want to execute at the end of simulation. I
> have tried using the BaseCPU destructor to close my stream files, but the
> code I put into this destructor does not seemed to be invoked.
>
> Anyways, has anyone ran into similar issues?
>
> Thanks,
>
> Scott Blankenberg
> ___
> 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: Destructor for BaseCPU

2022-02-09 Thread Jason Lowe-Power via gem5-users
Hi Scott,

If you want something to execute before gem5 is completed, you can call
`registerExitCallback`. See
http://doxygen.gem5.org/release/current/namespacegem5.html#abcf3056836ee522620e5b14d9392ea87

I *think* that will solve your problem, but let me know if not. I don't
think there's a clean way to have a SimObject's destructor guaranteed to be
called.

Cheers,
Jason

On Wed, Feb 9, 2022 at 4:47 PM Scott Blankenberg via gem5-users <
gem5-users@gem5.org> wrote:

> Hello,
>
> In src/cpu/base.cc we have the following destructor:
>
> BaseCPU::~BaseCPU()
> {
> }
>
> By default nothing is inside of it. However, when I put code inside, it
> does not seem to be executed at any point. Based on some previous threads I
> have seen on the forums, it seems that the destructor for BaseCPU is not
> being called at the end of the simulation.
>
> Has anyone found a way to make sure this destructor is called when the
> simulation ends?
>
> Similarly, has anyone written a tracer which is a subclass of InstTracer
> that has a destructor which is successfully called at the end of
> simulation?
>
> Basically my objective is to make sure the destructor to my customTracer
> is called at the end of the simulation.
>
> Thanks,
>
> Scott Blankenberg
> ___
> 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] findOrCreate function

2022-02-09 Thread Scott Blankenberg via gem5-users
Hello all,

Has anyone used the findOrCreate Gem5 function for opening custom file streams?

For example in src/cpu/base.cc we see that this function is used in the 
constructor for BaseCPU

  const std::string fname = csprintf("ftrace.%s", name());
  functionTraceStream = simout.findOrCreate(fname)->stream();


Has anyone who has used this function called it to create .gz files?

I am having an issue right now where for some benchmarks I run that the final 
gz file I get out is not compressed correctly. When I attempt to decompress the 
.gz files, I will get errors such as "unexpected end of file". 

One possibility I can think of is that the file does not close properly. 
However, I am struggling to find out where I should close the file since I need 
to do it at the end of the simulation and there is no clear place in BaseCPU 
code to place code you want to execute at the end of simulation. I have tried 
using the BaseCPU destructor to close my stream files, but the code I put into 
this destructor does not seemed to be invoked.

Anyways, has anyone ran into similar issues?

Thanks,

Scott Blankenberg
___
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] Destructor for BaseCPU

2022-02-09 Thread Scott Blankenberg via gem5-users
Hello, 

In src/cpu/base.cc we have the following destructor:

BaseCPU::~BaseCPU()
{
}

By default nothing is inside of it. However, when I put code inside, it does 
not seem to be executed at any point. Based on some previous threads I have 
seen on the forums, it seems that the destructor for BaseCPU is not being 
called at the end of the simulation.

Has anyone found a way to make sure this destructor is called when the 
simulation ends?

Similarly, has anyone written a tracer which is a subclass of InstTracer that 
has a destructor which is successfully called at the end of simulation? 

Basically my objective is to make sure the destructor to my customTracer is 
called at the end of the simulation.

Thanks,

Scott Blankenberg
___
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] Memory Issue using pthreads+m5threads+SE mode

2022-02-09 Thread Andronicus Samsundar Rajasukumar via gem5-users
Hi,

I'm running a multi-threaded application using pthreads + m5threads using SE 
mode. I see that as the simulation progresses, the memory consumption keeps 
increasing for the process until it gets killed. the process map shows that the 
address space is getting filled up with the application's code segment 
(r---s-), (hello-world-pthreads for example) and with eveery new thread I see a 
new mapping in the address space, like so.

7f84a757e00082686220   0 r--s- hello-world-pthread
7f84a7d9100082686860   0 r--s- hello-world-pthread
7f84a85a400082686860   0 r--s- hello-world-pthread
7f84a8db700082686920   0 r--s- hello-world-pthread
7f84a95ca00082686908   0 r--s- hello-world-pthread
7f84a9ddd00082686860   0 r--s- hello-world-pthread
7f84aa5f82686860   0 r--s- hello-world-pthread
7f84aae0300082686860   0 r--s- hello-world-pthread
...
...
...

I checked the m5threads implementation - the TCB is allocated using an mmap. 
The mmap is getting trapped correctly in gem5. I've uncommented the munmap in 
m5threads pthread_join to be safe to ensure this is unmapped and released.

I suspect the actual segment mapping is done by the clone syscall (Sorry not an 
expert in this, I may be wrong) and typically when the thread completes, these 
mappings should be freed?

Any insights on how I can fix this? If anyone has faced this issue before? 
Would appreciate pointers to this.

Thank you,
-Andronicus


___
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