Jump to page: 1 2
Thread overview
[D-runtime] Need support in core.cpuid for AVX detection
Jan 15, 2012
Walter Bright
Jan 15, 2012
Alex
Jan 15, 2012
Alex
Jan 15, 2012
Walter Bright
Jan 15, 2012
Alex
Jan 15, 2012
Iain Buclaw
Jan 16, 2012
Martin Nowak
Jan 16, 2012
Don Clugston
Jan 16, 2012
Alex
Jan 16, 2012
Martin Nowak
Jan 16, 2012
Walter Bright
January 15, 2012
http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
January 15, 2012
For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
(for the cpuid instruction).

Regards,
Alex

On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright <walter at digitalmars.com> wrote:
> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
January 15, 2012
There seems to be commented out support for detecting AVX already: https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275

Any reason this isn't enabled?

Regards,
Alex

On Sun, Jan 15, 2012 at 11:08 PM, Alex <xtzgzorex at gmail.com> wrote:
> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
> (for the cpuid instruction).
>
> Regards,
> Alex
>
> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright <walter at digitalmars.com> wrote:
>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
January 15, 2012
That's bit 25, but you mentioned bit 28?

On 1/15/2012 2:11 PM, Alex wrote:
> There seems to be commented out support for detecting AVX already: https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275
>
> Any reason this isn't enabled?
>
> Regards,
> Alex
>
> On Sun, Jan 15, 2012 at 11:08 PM, Alex<xtzgzorex at gmail.com>  wrote:
>> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
>> (for the cpuid instruction).
>>
>> Regards,
>> Alex
>>
>> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright<walter at digitalmars.com>  wrote:
>>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>>> _______________________________________________
>>> D-runtime mailing list
>>> D-runtime at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/d-runtime
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
>
January 15, 2012
Hm, bit 25 is the AES extensions seemingly (at least in ECX).

See: http://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits

Regards,
Alex

On Sun, Jan 15, 2012 at 11:52 PM, Walter Bright <walter at digitalmars.com> wrote:
> That's bit 25, but you mentioned bit 28?
>
>
> On 1/15/2012 2:11 PM, Alex wrote:
>>
>> There seems to be commented out support for detecting AVX already:
>>
>> https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275
>>
>> Any reason this isn't enabled?
>>
>> Regards,
>> Alex
>>
>> On Sun, Jan 15, 2012 at 11:08 PM, Alex<xtzgzorex at gmail.com> ?wrote:
>>>
>>> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
>>> (for the cpuid instruction).
>>>
>>> Regards,
>>> Alex
>>>
>>> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright<walter at digitalmars.com> ?wrote:
>>>>
>>>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>>>> _______________________________________________
>>>> D-runtime mailing list
>>>> D-runtime at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>>
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>>
>>
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
January 15, 2012
On 15 January 2012 22:52, Walter Bright <walter at digitalmars.com> wrote:
> That's bit 25, but you mentioned bit 28?
>
>

A quick look-up, hasAVXinHardware() should check 28 bit in ECX,  Avx()
should check 27 bit and 28.



> On 1/15/2012 2:11 PM, Alex wrote:
>>
>> There seems to be commented out support for detecting AVX already:
>>
>> https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275
>>
>> Any reason this isn't enabled?
>>
>> Regards,
>> Alex
>>
>> On Sun, Jan 15, 2012 at 11:08 PM, Alex<xtzgzorex at gmail.com> ?wrote:
>>>
>>> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
>>> (for the cpuid instruction).
>>>
>>> Regards,
>>> Alex
>>>
>>> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright<walter at digitalmars.com> ?wrote:
>>>>
>>>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>>>> _______________________________________________
>>>> D-runtime mailing list
>>>> D-runtime at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>>
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>>
>>
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime



-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
January 16, 2012
On Sun, 15 Jan 2012 23:04:09 +0100, Walter Bright <walter at digitalmars.com> wrote:

> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime

I did wrote that too sometime ago.
DMD is missing the xgetbv instruction to do so.
January 16, 2012
On Sun, 15 Jan 2012 23:52:01 +0100, Walter Bright <walter at digitalmars.com> wrote:

> That's bit 25, but you mentioned bit 28?
>
> On 1/15/2012 2:11 PM, Alex wrote:
>> There seems to be commented out support for detecting AVX already: https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275
>>
>> Any reason this isn't enabled?
>>
>> Regards,
>> Alex
>>
>> On Sun, Jan 15, 2012 at 11:08 PM, Alex<xtzgzorex at gmail.com>  wrote:
>>> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
>>> (for the cpuid instruction).
>>>
>>> Regards,
>>> Alex
>>>
>>> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright<walter at digitalmars.com>  wrote:
>>>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>>>> _______________________________________________
>>>> D-runtime mailing list
>>>> D-runtime at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>>
>>
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime

https://github.com/dawgfoto/druntime/tree/DetectAVX

You need to check cpuid first for miscfeatures & OS_XSAVE (1 << 27).
Must be set or executing xgetbv will cause #GP.
Then xgetbv with index 0 will return the XFEATURES_ENABLED_MASK,
which shows you whether your OS does save YMM registers.
Currently this should work for linux, OSX > 10.6.8, Windows7 SP1.
January 15, 2012

On 1/15/2012 4:27 PM, Martin Nowak wrote:
>
> DMD is missing the xgetbv instruction to do so.
>

Not no more!
January 16, 2012
On 15 January 2012 23:11, Alex <xtzgzorex at gmail.com> wrote:
> There seems to be commented out support for detecting AVX already: https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L275
>
> Any reason this isn't enabled?

I actually wrote that code before any AVX processors had ever been released. So it was entirely speculative.

>
> Regards,
> Alex
>
> On Sun, Jan 15, 2012 at 11:08 PM, Alex <xtzgzorex at gmail.com> wrote:
>> For what it's worth, bit 28 of ECX indicates whether the CPU has AVX
>> (for the cpuid instruction).
>>
>> Regards,
>> Alex
>>
>> On Sun, Jan 15, 2012 at 11:04 PM, Walter Bright <walter at digitalmars.com> wrote:
>>> http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
>>> _______________________________________________
>>> D-runtime mailing list
>>> D-runtime at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/d-runtime
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
« First   ‹ Prev
1 2