Change popcnt so that the code does not depend on ABM extenstions (SSE4)

This commit is contained in:
fireice-uk
2017-05-21 11:11:05 +01:00
parent 92e1f99cf5
commit b8061d8041
+14 -1
View File
@@ -3,6 +3,19 @@
#include "console.h"
#include <hwloc.h>
/*
* compat_popcnt is adapted from public domain code by:
* Portable Snippets - https://gitub.com/nemequ/portable-snippets
* Created by Evan Nemerson <evan@nemerson.com>
*/
int compat_popcnt(size_t x)
{
x = x - ((x >> 1) & (size_t)~(size_t)0/3);
x = (x & (size_t)~(size_t)0/15*3) + ((x >> 2) & (size_t)~(size_t)0/15*3);
x = (x + (x >> 4)) & (size_t)~(size_t)0/255*15;
return (size_t)(x * ((size_t)~(size_t)0/255)) >> (sizeof(size_t) - 1) * 8;
}
#ifdef _WIN32
#include <windows.h>
#else
@@ -98,7 +111,7 @@ private:
cpu >>= rightZeros(allcpu);
int nativeCores = __builtin_popcount(cpu);
int nativeCores = compat_popcnt(cpu);
int numPus = obj->arity;
for (int i = 0; i < numPus && numHashes != 0; i++)
{