Skip to content

Commit

Permalink
Merge pull request #3801 from besser82/bugfix/cpu_h
Browse files Browse the repository at this point in the history
Better support for different and unknown architectures
  • Loading branch information
besser82 committed Apr 30, 2017
2 parents 6d96064 + 3d7650c commit ffb80ca
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/shogun/lib/cpu.h
Expand Up @@ -36,9 +36,23 @@
SG_FORCED_INLINE static void CpuRelax()
{
#ifdef _MSC_VER
_mm_pause();
_mm_pause();
#elif defined(__i386__) || defined(__x86_64__)
asm volatile("pause");
#elif defined(__arm__) || defined(__aarch64__)
asm volatile("yield");
#elif defined(__powerpc__) || defined(__ppc__)
asm volatile("or 27,27,27");
#elif defined(__s390__) || defined(__s390x__)
asm volatile("" : : : "memory");
#else
asm("pause");
#warning "Unknown architecture, defaulting to delaying loop."
static uint32_t bar = 13;
static uint32_t* foo = &bar;
for (unsigned int i = 0; i < 100000; i++)
{
*foo = (*foo * 33) + 17;
}
#endif
}

Expand Down

0 comments on commit ffb80ca

Please sign in to comment.