mirror of
https://github.com/OpenMathLib/OpenBLAS
synced 2026-05-31 00:45:48 +08:00
fix avx2 detection
reword commits to make it clearer
This commit is contained in:
16
cpuid_x86.c
16
cpuid_x86.c
@@ -202,7 +202,7 @@ int support_avx(){
|
||||
if ((ecx & (1 << 28)) != 0 && (ecx & (1 << 27)) != 0 && (ecx & (1 << 26)) != 0){
|
||||
xgetbv(0, &eax, &edx);
|
||||
if((eax & 6) == 6){
|
||||
ret=1; //OS support AVX
|
||||
ret=1; //OS supports saving xmm and ymm registers (6 = (1<<1) | (1<<2))
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -219,8 +219,8 @@ int support_avx2(){
|
||||
if (!support_avx())
|
||||
return 0;
|
||||
cpuid(7, &eax, &ebx, &ecx, &edx);
|
||||
if((ebx & (1<<7)) != 0)
|
||||
ret=1; //OS supports AVX2
|
||||
if((ebx & (1<<5)) != 0)
|
||||
ret=1; //CPU supports AVX2
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
@@ -235,14 +235,14 @@ int support_avx512(){
|
||||
if (!support_avx())
|
||||
return 0;
|
||||
cpuid(7, &eax, &ebx, &ecx, &edx);
|
||||
if((ebx & 32) != 32){
|
||||
ret=0; //OS does not even support AVX2
|
||||
if((ebx & (1<<5)) == 0){
|
||||
ret=0; //cpu does not have avx2 flag
|
||||
}
|
||||
if((ebx & (1<<31)) != 0){
|
||||
if((ebx & (1<<31)) != 0){ //AVX512VL flag
|
||||
xgetbv(0, &eax, &edx);
|
||||
if((eax & 0xe0) == 0xe0)
|
||||
ret=1; //OS supports AVX512VL
|
||||
}
|
||||
ret=1; //OS supports saving zmm registers
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
|
||||
@@ -330,8 +330,8 @@ int support_avx2(){
|
||||
if (!support_avx())
|
||||
return 0;
|
||||
cpuid(7, &eax, &ebx, &ecx, &edx);
|
||||
if((ebx & (1<<7)) != 0)
|
||||
ret=1; //OS supports AVX2
|
||||
if((ebx & (1<<5)) != 0)
|
||||
ret=1; //AVX2 flag is set
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
@@ -346,13 +346,13 @@ int support_avx512(){
|
||||
if (!support_avx())
|
||||
return 0;
|
||||
cpuid(7, &eax, &ebx, &ecx, &edx);
|
||||
if((ebx & (1<<7)) == 0){
|
||||
ret=0; //OS does not even support AVX2
|
||||
if((ebx & (1<<5)) == 0){
|
||||
ret=0; //cpu does not have avx2 flag
|
||||
}
|
||||
if((ebx & (1u<<31)) != 0){
|
||||
if((ebx & (1<<31)) != 0){ //AVX512VL flag is set
|
||||
xgetbv(0, &eax, &edx);
|
||||
if((eax & 0xe0) == 0xe0)
|
||||
ret=1; //OS supports AVX512VL
|
||||
ret=1; //OS supports saving zmm register
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user