public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: target/10395: sse2 datatype is not 16bytes aligned in threaded code
@ 2003-04-13 23:36 Tim Prince
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Prince @ 2003-04-13 23:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/10395; it has been noted by GNATS.

From: Tim Prince <timothyprince@sbcglobal.net>
To: vgrebinski@yahoo.com, gcc-gnats@gcc.gnu.org
Cc: vgrebinski@yahoo.com
Subject: Re: target/10395: sse2 datatype is not 16bytes aligned in threaded code
Date: Sun, 13 Apr 2003 16:31:16 -0700

 On Sunday 13 April 2003 15:44, vgrebinski@yahoo.com wrote:
 > >Number:         10395
 > >Category:       target
 > >Synopsis:       sse2 types are incorrectly aligned causing crash in
 > > multi-threaded apps Confidential:   no
 > >Severity:       serious
 > >Priority:       medium
 > >Responsible:    unassigned
 > >State:          open
 > >Class:          wrong-code
 > >Submitter-Id:   net
 > >Arrival-Date:   Sun Apr 13 22:46:00 UTC 2003
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Vladimir Grebinskiy
 > >Release:        3.3 20030410 (prerelease)
 > >Organization:
 > >Environment:
 >
 > System: Linux vag 2.4.21-pre5 #2 Sun Mar 2 00:28:31 EST 2003 i686 unknown
 > unknown GNU/Linux Architecture: i686
 >
 >
 > host: i386-pc-linux-gnu
 > build: i386-pc-linux-gnu
 > target: i386-pc-linux-gnu
 > configured with:
 > /build/packages/gcc/snap/gcc-snapshot-20030410/src/configure -v
 > --enable-languages=c,c++,java,f77,pascal,objc,ada
 > --prefix=/usr/lib/gcc-snapshot --infodir=/share/info --mandir=/share/man
 > --enable-shared --with-system-zlib --enable-nls --without-included-gettext
 > --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm
 > --enable-java-awt=xlib --with-cpp-install-dir=bin --enable-multilibs
 > --enable-objc-gc i386-linux
 >
 > >Description:
 >
 > support for sse2 instruction is an important addtion to gcc-3.3.
 > Unfortunately, code generated for functions called via pthread_create()
 > does not provide 16bytes alignment for local sse2 data, which causes crash
 > when these variables are used.
 >
 > >How-To-Repeat:
 >
 > The following short program demonstrates problem. The second call to
 > function "f" shows that variable is not aligned to 16 bytes:
 >
 > /* *** start ***/
 > #include <pthread.h>
 > #include <stdio.h>
 > #include <assert.h>
 >
 > #include <xmmintrin.h>
 > #include <mmintrin.h>
 >
 > #ifdef __ICC
 > #include <emmintrin.h>
 > #endif
 >
 > void * f(void *p)
 > {
 >   int x = (p == NULL) ? 0 : * (int *) p;
 >   __m128i s;
 >   printf("&x = %p &s= %p\n", &x, &s);
 >   return NULL;
 > }
 >
 > int main(int argc, char ** argv)
 > {
 >   pthread_t th;
 >
 >   f(& argc);
 >   assert(pthread_create(& th, NULL, f, &argc)==0);
 >   assert(pthread_join(th, NULL)==0);
 >   return 0;
 > }
 >
 > /* ***end *** /
 >
 > $ /usr/lib/gcc-snapshot/bin/gcc -pthread -msse2 gcc_test.c -o
 > gcc_test.LINUX $ ./gcc_test.LINUX
 > &x = 0xbffffb6c &s= 0xbffffb50
 > &x = 0xbf7ffae8 &s= 0xbf7ffacc <---- error
 >
 > >Fix:
 >
 > 
 Similar problem here, but I had to change --m128i to --m128.  Did you try 
 rebuilding libpthread with the proper options passed to gcc?  Otherwise, it 
 looks like an error in the library build.  gcc won't work unless libpthread 
 passes aligned stack to your function.  I tried another compiler, which 
 doesn't expect aligned stack, and it was OK.
 -- 
 Tim Prince


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: target/10395: sse2 datatype is not 16bytes aligned in threaded code
@ 2003-04-14  1:26 Vladimir Grebinskiy
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Grebinskiy @ 2003-04-14  1:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/10395; it has been noted by GNATS.

From: Vladimir Grebinskiy <vgrebinski@yahoo.com>
To: tprince@computer.org, gcc-gnats@gcc.gnu.org
Cc: vgrebinski@yahoo.com
Subject: Re: target/10395: sse2 datatype is not 16bytes aligned in threaded code
Date: Sun, 13 Apr 2003 18:24:27 -0700 (PDT)

 --- Tim Prince <timothyprince@sbcglobal.net> wrote:
 > On Sunday 13 April 2003 15:44, vgrebinski@yahoo.com wrote:
 > > >Number:         10395
 > > >Category:       target
 > > >Synopsis:       sse2 types are incorrectly aligned causing crash in
 > > > multi-threaded apps Confidential:   no
 > > >Severity:       serious
 > > >Priority:       medium
 > > >Responsible:    unassigned
 > > >State:          open
 > > >Class:          wrong-code
 > > >Submitter-Id:   net
 > > >Arrival-Date:   Sun Apr 13 22:46:00 UTC 2003
 > > >Closed-Date:
 > > >Last-Modified:
 > > >Originator:     Vladimir Grebinskiy
 > > >Release:        3.3 20030410 (prerelease)
 > > >Organization:
 > > >Environment:
 > >
 > > System: Linux vag 2.4.21-pre5 #2 Sun Mar 2 00:28:31 EST 2003 i686 unknown
 > > unknown GNU/Linux Architecture: i686
 > >
 > >
 > > host: i386-pc-linux-gnu
 > > build: i386-pc-linux-gnu
 > > target: i386-pc-linux-gnu
 > > configured with:
 > > /build/packages/gcc/snap/gcc-snapshot-20030410/src/configure -v
 > > --enable-languages=c,c++,java,f77,pascal,objc,ada
 > > --prefix=/usr/lib/gcc-snapshot --infodir=/share/info --mandir=/share/man
 > > --enable-shared --with-system-zlib --enable-nls --without-included-gettext
 > > --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm
 > > --enable-java-awt=xlib --with-cpp-install-dir=bin --enable-multilibs
 > > --enable-objc-gc i386-linux
 > >
 > > >Description:
 > >
 > > support for sse2 instruction is an important addtion to gcc-3.3.
 > > Unfortunately, code generated for functions called via pthread_create()
 > > does not provide 16bytes alignment for local sse2 data, which causes crash
 > > when these variables are used.
 > >
 > > >How-To-Repeat:
 > >
 > > The following short program demonstrates problem. The second call to
 > > function "f" shows that variable is not aligned to 16 bytes:
 > >
 > > /* *** start ***/
 > > #include <pthread.h>
 > > #include <stdio.h>
 > > #include <assert.h>
 > >
 > > #include <xmmintrin.h>
 > > #include <mmintrin.h>
 > >
 > > #ifdef __ICC
 > > #include <emmintrin.h>
 > > #endif
 > >
 > > void * f(void *p)
 > > {
 > >   int x = (p == NULL) ? 0 : * (int *) p;
 > >   __m128i s;
 > >   printf("&x = %p &s= %p\n", &x, &s);
 > >   return NULL;
 > > }
 > >
 > > int main(int argc, char ** argv)
 > > {
 > >   pthread_t th;
 > >
 > >   f(& argc);
 > >   assert(pthread_create(& th, NULL, f, &argc)==0);
 > >   assert(pthread_join(th, NULL)==0);
 > >   return 0;
 > > }
 > >
 > > /* ***end *** /
 > >
 > > $ /usr/lib/gcc-snapshot/bin/gcc -pthread -msse2 gcc_test.c -o
 > > gcc_test.LINUX $ ./gcc_test.LINUX
 > > &x = 0xbffffb6c &s= 0xbffffb50
 > > &x = 0xbf7ffae8 &s= 0xbf7ffacc <---- error
 > >
 > > >Fix:
 > >
 > > 
 > Similar problem here, but I had to change --m128i to --m128.  Did you try 
 > rebuilding libpthread with the proper options passed to gcc?  Otherwise, it 
 > looks like an error in the library build.  gcc won't work unless libpthread 
 > passes aligned stack to your function.  I tried another compiler, which 
 > doesn't expect aligned stack, and it was OK.
 
 Thanks for suggestion. I'll try to find out if libpthread should be compiled in a special way (I
 guess whole libc should be recompiled). Currently, all libraries are whatever is in
 Debian/unstable as of today. The code works as expected with Intel's compiler (build 7.1.011), I
 guess it uses the same libpthread as gcc does. 
 
 I just checked that there is a similar problem with MMX datatypes (in which case unaligned access
 is just slower?) -- data are not 8 bytes aligned when called inside a thread (checked also with
 3.2.3 20030407 (Debian prerelease)).
 
 Vladimir
 
 > -- 
 > Tim Prince
 
 
 __________________________________________________
 Do you Yahoo!?
 Yahoo! Tax Center - File online, calculators, forms, and more
 http://tax.yahoo.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* target/10395: sse2 datatype is not 16bytes aligned in threaded code
@ 2003-04-13 22:46 vgrebinski
  0 siblings, 0 replies; 3+ messages in thread
From: vgrebinski @ 2003-04-13 22:46 UTC (permalink / raw)
  To: gcc-gnats; +Cc: vgrebinski


>Number:         10395
>Category:       target
>Synopsis:       sse2 types are incorrectly aligned causing crash in multi-threaded apps
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 13 22:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Vladimir Grebinskiy
>Release:        3.3 20030410 (prerelease)
>Organization:
>Environment:
System: Linux vag 2.4.21-pre5 #2 Sun Mar 2 00:28:31 EST 2003 i686 unknown unknown GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /build/packages/gcc/snap/gcc-snapshot-20030410/src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada --prefix=/usr/lib/gcc-snapshot --infodir=/share/info --mandir=/share/man --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-java-awt=xlib --with-cpp-install-dir=bin --enable-multilibs --enable-objc-gc i386-linux
>Description:
support for sse2 instruction is an important addtion to gcc-3.3. Unfortunately, code generated for functions called via pthread_create() does not provide 16bytes alignment for local sse2 data, which causes crash when these variables are used. 
>How-To-Repeat:
The following short program demonstrates problem. The second call to function "f" shows that variable is not aligned to 16 bytes:

/* *** start ***/
#include <pthread.h>
#include <stdio.h>
#include <assert.h>

#include <xmmintrin.h>
#include <mmintrin.h>

#ifdef __ICC
#include <emmintrin.h>
#endif

void * f(void *p)
{
  int x = (p == NULL) ? 0 : * (int *) p;
  __m128i s;
  printf("&x = %p &s= %p\n", &x, &s);
  return NULL;
}

int main(int argc, char ** argv)
{
  pthread_t th;

  f(& argc);
  assert(pthread_create(& th, NULL, f, &argc)==0);
  assert(pthread_join(th, NULL)==0);
  return 0;
}

/* ***end *** /

$ /usr/lib/gcc-snapshot/bin/gcc -pthread -msse2 gcc_test.c -o gcc_test.LINUX
$ ./gcc_test.LINUX
&x = 0xbffffb6c &s= 0xbffffb50
&x = 0xbf7ffae8 &s= 0xbf7ffacc <---- error 

>Fix:
don't know

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-14  1:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-13 23:36 target/10395: sse2 datatype is not 16bytes aligned in threaded code Tim Prince
  -- strict thread matches above, loose matches on Subject: below --
2003-04-14  1:26 Vladimir Grebinskiy
2003-04-13 22:46 vgrebinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).