Skip to content

Commit d6a31c6

Browse files
Bruno Rosasoumith
authored andcommitted
Add option to disable ppc64le's VSX support
Set environment variable TH_NO_VSX=1 to disable VSX.
1 parent 928f651 commit d6a31c6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
Environment variables control the disabling of certain explicit SIMD optimizations.
22

33
```
4+
x64 options:
45
TH_NO_AVX2=1 # disable AVX2 codepaths
56
TH_NO_AVX=1 # disable AVX codepaths
67
TH_NO_SSE=1 # disable SSE codepaths
7-
```
8+
9+
ppc64le options:
10+
TH_NO_VSX=1 # disable VSX codepaths
11+
```

generic/simd/simd.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ static inline uint32_t detectHostSIMDExtensions()
7878

7979
static inline uint32_t detectHostSIMDExtensions()
8080
{
81-
return SIMDExtension_VSX;
81+
uint32_t hostSimdExts = SIMDExtension_DEFAULT;
82+
char *evar;
83+
84+
evar = getenv("TH_NO_VSX");
85+
if (evar == NULL || strncmp(evar, "1", 2) != 0)
86+
hostSimdExts = SIMDExtension_VSX;
87+
return hostSimdExts;
8288
}
8389

8490
#else //PPC64 without VSX
@@ -89,7 +95,7 @@ static inline uint32_t detectHostSIMDExtensions()
8995
}
9096

9197
#endif
92-
98+
9399
#else // x86
94100
static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
95101
{
@@ -146,7 +152,7 @@ static inline uint32_t detectHostSIMDExtensions()
146152

147153
evar = getenv("TH_NO_SSE");
148154
if (evar == NULL || strncmp(evar, "1", 2) != 0)
149-
TH_NO_SSE = 0;
155+
TH_NO_SSE = 0;
150156
if (edx & CPUID_SSE_BIT && TH_NO_SSE == 0) {
151157
hostSimdExts |= SIMDExtension_SSE;
152158
}

0 commit comments

Comments
 (0)