Subject: Re: [boost] [GSoC] SIMD proposal
From: Mathieu - (ptr.jetable_at_[hidden])
Date: 2011-03-24 08:54:24


On 24 March 2011 13:07, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> On 24/03/2011 01:16, Gruenke, Matt wrote:
>>
>> cpuid?  It seems to me that the *only* thing that should determine how the
>> program gets compiled is the compiler flags, since the target platform might
>> have either less or more capability than the build machine.  I've
>> experienced both cases, firsthand.
>>
>> GCC will define the following preprocessor macros, depending on which code
>> generation flags you specify:
>>
>>                __MMX__
>>                __SSE__
>>                __SSE2__
>>                __SSE3__
>>                __SSSE3__
>>                __SSE4A__
>>                __SSE4_1__
>>                __SSE4_2__
>>                __AES__
>>                __PCLMUL__
>>                __AVX__
>
> Alright, I just looked into how other compilers do it.
>
> On GCC, SSEx built-ins are only available if the suitable -mssex option is
> set, which you can detect with __SSEx__.
> On MSVC, SSE built-ins are always available but may result in a runtime
> error. There are only the /arch:SSE and /arch:AVX option used to tell the
> compiler that it can generate SSE or AVX instructions automatically, there
> are no /arch:SSEx options.
>
> Therefore there is no way to do the kind of thing you suggest with MSVC.

That's why I think the most sensible way to do it is to let the end
user specify what he wants to use, and just do everything
conditionnaly with ifdef's.