Thanks, Andreas.

I've just been lucky to solve the problem.

According to the symptoms, it seems some memory regions are overlapped. So
I looked at the m5threads source code, and found that the default stack
size was set to 64KB. After I change it to 64MB, my program works fine,
both the pthreads and omp versions.

In m5threads, the thread stack is placed aside the thread local storage, so
stack overflow will modify data in the TLS. That's what I observed.

Best regards,
Zehan

On Tue, Dec 23, 2014 at 4:53 PM, Andreas Hansson <[email protected]>
wrote:
>
>  Hi Zehan,
>
>  The only two things that come to mind are: 1) valgrind, 2) full-system.
> At least with (2) you know that the results you get are actually reflecting
> the behaviour of a real OS.
>
>  Andreas
>
>   From: Zehan Cui via gem5-users <[email protected]>
> Reply-To: Zehan Cui <[email protected]>, gem5 users mailing list <
> [email protected]>
> Date: Tuesday, 23 December 2014 07:22
> To: "[email protected]" <[email protected]>
> Subject: [gem5-users] variables modified inexplicably when using m5threads
>
>  Hello,
>
>  I'm trying to use m5threads to compiler my program, but encounter
> several errors.
>
>  In brief, I found that some variables in the program are
> modified inexplicably.
>
>  Here are two symptoms when using m5threads to run on the host machine
> directly (not in gem5):
>
>  First, I ran 2 threads and the code had some printf(). Using gdb, I
> found that the last several elements of one array are modified by the
> printf() call. After realizing this, I allocate additional space for the
> array, e.g., twice the original array size, to set a safe margin for the
> array. It actually works.
>
>  Then, I ran 4 threads and found that one important thread-local
> variable, myid, was modifed. Gdb didn't help this time, and I didn't find
> who modify it.
>
>  I have been stuck by such problems for a week. Does anyone have similar
> experience or know possible reasons?
>
>  I'm using m5threads-dcec9ee72f99. The test program works fine. The
> program that I'm using is the graph500 reference code (breath-first
> search). The original code is written in openmp. I tried to directly
> compile the openmp code using m5threads, but didn't work. Then I change it
> into pthreads and encounter the problems mentioned before. (btw, using
> standard pthreads library works fine.)
>
>
>  Best regards,
> Zehan
>
> -- 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.
>
> ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ,
> Registered in England & Wales, Company No: 2557590
> ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ,
> Registered in England & Wales, Company No: 2548782
>
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to