Skip to content

Commit

Permalink
Merge commit 'd6a31c68a0f39656257322a55c9e04dd579de828'
Browse files Browse the repository at this point in the history
  • Loading branch information
soumith committed Apr 28, 2017
2 parents 96a281d + d6a31c6 commit fd490c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion torch/lib/TH/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Environment variables control the disabling of certain explicit SIMD optimizations.

```
x64 options:
TH_NO_AVX2=1 # disable AVX2 codepaths
TH_NO_AVX=1 # disable AVX codepaths
TH_NO_SSE=1 # disable SSE codepaths
```
ppc64le options:
TH_NO_VSX=1 # disable VSX codepaths
```
12 changes: 9 additions & 3 deletions torch/lib/TH/generic/simd/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ static inline uint32_t detectHostSIMDExtensions()

static inline uint32_t detectHostSIMDExtensions()
{
return SIMDExtension_VSX;
uint32_t hostSimdExts = SIMDExtension_DEFAULT;
char *evar;

evar = getenv("TH_NO_VSX");
if (evar == NULL || strncmp(evar, "1", 2) != 0)
hostSimdExts = SIMDExtension_VSX;
return hostSimdExts;
}

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

#endif

#else // x86
static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
Expand Down Expand Up @@ -146,7 +152,7 @@ static inline uint32_t detectHostSIMDExtensions()

evar = getenv("TH_NO_SSE");
if (evar == NULL || strncmp(evar, "1", 2) != 0)
TH_NO_SSE = 0;
TH_NO_SSE = 0;
if (edx & CPUID_SSE_BIT && TH_NO_SSE == 0) {
hostSimdExts |= SIMDExtension_SSE;
}
Expand Down

0 comments on commit fd490c6

Please sign in to comment.