Hi All,

This question is partially a development question, but since I know that most 
of the prior conversations concerning the m5threads package has been on the 
gem5-user/m5-user lists, I want to make sure that all folks with m5threads 
experience see my question.

Does anyone have experience successfully using the OpenMP test in the m5threads 
package?  The particular ISA doesn't matter.  If so, I would be curious to know 
if you needed to make changes to pthreads.c, in particular the function 
"setup_thread_tls", to make it work.  Those of you familiar with that code know 
that there is some nasty pointer arithmetic in that function to copy the TLS 
from the ELF structure to the main thread's simulated TLS.  The confusing thing 
is that the pointer to the destination TLS is aligned twice.  First the 
tlsblock pointer is aligned according to the tls_align value, then the tlsblock 
pointer is aligned to some confusing combination of the tcb_offset and memsz to 
produce the tls_start_ptr.  My experience using the pthread tests that the 
second alignment makes no modifications and essentially copies the tlsblock 
value to the tls_start_ptr.  However, for the OpenMP test, the second alignment 
sets the tls_start_ptr to an illegal value, thus crashing the program.

I'm not sure why the second alignment modification is even necessary, and the 
OpenMP test seems to work if you simply remove it.  See diff below.  However, 
before I check in the change, I would like to know if others have a better 
understanding why the second alignment statement was added (...Daniel Sanchez?)

diff --git a/pthread.c b/pthread.c
--- a/pthread.c
+++ b/pthread.c
@@ -151,11 +151,9 @@
   void* tlsblock = (void *) (((uintptr_t) th_block_addr + 
thread_block_info.tls_align - 1)
                        & ~(thread_block_info.tls_align - 1));
   /* Initialize the TLS block.  */
-  char* tls_start_ptr = ((char *) tlsblock + tcb_offset
-                           - roundup (thread_block_info.tls_memsz, 
thread_block_info.tls_align ?: 1));
   //DEBUG("Init TLS: Copying %d bytes from 0x%llx to 0x%llx\n", filesz, 
(uint64_t) initimage, (uint64_t) tls_start_ptr)
;
-  memcpy (tls_start_ptr, thread_block_info.tls_initimage, 
thread_block_info.tls_filesz);
+  memcpy (tlsblock, thread_block_info.tls_initimage, 
thread_block_info.tls_filesz);
   //Rest of tls vars are already cleared (mmap returns zeroed memory)

Thanks,

Brad
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to