public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* short C code that uses AVX and fails under Cygwin
@ 2016-01-14 20:50 Ilya Razenshteyn
  2016-01-14 20:58 ` Ismail Donmez
  2016-01-14 23:03 ` Warren Young
  0 siblings, 2 replies; 4+ messages in thread
From: Ilya Razenshteyn @ 2016-01-14 20:50 UTC (permalink / raw)
  To: cygwin

Hi all,

the below C code fails under Cygwin. More specifically, the environment 
is: Windows 8.1, Cygwin 2.3.1, GCC 4.9.3, CPU 'Intel(R) Core(TM) 
i7-4510U CPU @ 2.00GHz', compilation options are '-O0 -mavx'. Is it 
indeed a bug in Cygwin or I don't understand something?

Cheers,
Ilya

#include "immintrin.h"

__m256 routine(void) {
   __m256 aux;
   return aux;
}

int main(void) {
   void *buf = malloc(1);
   __m256 res = routine();
   return 0;
}



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: short C code that uses AVX and fails under Cygwin
  2016-01-14 20:50 short C code that uses AVX and fails under Cygwin Ilya Razenshteyn
@ 2016-01-14 20:58 ` Ismail Donmez
  2016-01-14 21:18   ` Ilya Razenshteyn
  2016-01-14 23:03 ` Warren Young
  1 sibling, 1 reply; 4+ messages in thread
From: Ismail Donmez @ 2016-01-14 20:58 UTC (permalink / raw)
  To: cygwin

Hi,

On Thu, Jan 14, 2016 at 10:20 PM, Ilya Razenshteyn <ilyaraz@mit.edu> wrote:
> Hi all,
>
> the below C code fails under Cygwin. More specifically, the environment is:
> Windows 8.1, Cygwin 2.3.1, GCC 4.9.3, CPU 'Intel(R) Core(TM) i7-4510U CPU @
> 2.00GHz', compilation options are '-O0 -mavx'. Is it indeed a bug in Cygwin
> or I don't understand something?
>
> Cheers,
> Ilya
>
> #include "immintrin.h"
>
> __m256 routine(void) {
>   __m256 aux;
>   return aux;
> }
>
> int main(void) {
>   void *buf = malloc(1);
>   __m256 res = routine();
>   return 0;
> }

I believe this is due to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412 ,
https://stackoverflow.com/questions/5983389/how-to-align-stack-at-32-byte-boundary-in-gcc
has an ugly workaround which might work for you.

Regards,
ismail

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: short C code that uses AVX and fails under Cygwin
  2016-01-14 20:58 ` Ismail Donmez
@ 2016-01-14 21:18   ` Ilya Razenshteyn
  0 siblings, 0 replies; 4+ messages in thread
From: Ilya Razenshteyn @ 2016-01-14 21:18 UTC (permalink / raw)
  To: cygwin

Looks like this is indeed what happens! Thanks a lot!


Ilya

On 1/14/2016 11:49 PM, Ismail Donmez wrote:
> Hi,
>
> On Thu, Jan 14, 2016 at 10:20 PM, Ilya Razenshteyn <ilyaraz@mit.edu> wrote:
>> Hi all,
>>
>> the below C code fails under Cygwin. More specifically, the environment is:
>> Windows 8.1, Cygwin 2.3.1, GCC 4.9.3, CPU 'Intel(R) Core(TM) i7-4510U CPU @
>> 2.00GHz', compilation options are '-O0 -mavx'. Is it indeed a bug in Cygwin
>> or I don't understand something?
>>
>> Cheers,
>> Ilya
>>
>> #include "immintrin.h"
>>
>> __m256 routine(void) {
>>    __m256 aux;
>>    return aux;
>> }
>>
>> int main(void) {
>>    void *buf = malloc(1);
>>    __m256 res = routine();
>>    return 0;
>> }
>
> I believe this is due to
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412 ,
> https://stackoverflow.com/questions/5983389/how-to-align-stack-at-32-byte-boundary-in-gcc
> has an ugly workaround which might work for you.
>
> Regards,
> ismail
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: short C code that uses AVX and fails under Cygwin
  2016-01-14 20:50 short C code that uses AVX and fails under Cygwin Ilya Razenshteyn
  2016-01-14 20:58 ` Ismail Donmez
@ 2016-01-14 23:03 ` Warren Young
  1 sibling, 0 replies; 4+ messages in thread
From: Warren Young @ 2016-01-14 23:03 UTC (permalink / raw)
  To: The Cygwin Mailing List

On Jan 14, 2016, at 1:20 PM, Ilya Razenshteyn <ilyaraz@mit.edu> wrote:
> 
> the below C code fails under Cygwin.

It segfaults here.  Is that what you mean by “fails”?

> the environment is: Windows 8.1, Cygwin 2.3.1, GCC 4.9.3, CPU 'Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz’

It fails on my recently-updated Windows 10 64-bit VM running a recently-updated 64-bit Cygwin on an Intel(R) Core i7-3770 CPU @ 3.40GHz.

> int main(void) {
>  void *buf = malloc(1);

The problem isn’t the malloc, the problem is the pointer pushing ‘res’ 4 or 8 bytes down the stack.  The same thing happens with an int.

This feels like an alignment problem, so I started throwing other stuff ahead of res to see if I could make the symptom go away.  This is the smallest object I’ve been able to make that does that:

      uint8_t x[20] = { 0 };

I haven’t tried every value between 1 and 19, but all of the obvious ones (8, 10, 12, 16) fail.  I don’t know what makes 20 magic.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

end of thread, other threads:[~2016-01-14 20:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-14 20:50 short C code that uses AVX and fails under Cygwin Ilya Razenshteyn
2016-01-14 20:58 ` Ismail Donmez
2016-01-14 21:18   ` Ilya Razenshteyn
2016-01-14 23:03 ` Warren Young

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).