Commit 8a8302aa authored by jaco's avatar jaco

wip windows compile error fixing 2

parent 3b6da730
......@@ -64,50 +64,23 @@ private:
float _coeffs2[NUM_COMP], _coeffs4[NUM_COMP], _coeffs8[NUM_COMP];
};
inline int __builtin_popcount(unsigned int x) {
static const unsigned int m1 = 0x55555555; //binary: 0101...
static const unsigned int m2 = 0x33333333; //binary: 00110011..
static const unsigned int m4 = 0x0f0f0f0f; //binary: 4 zeros, 4 ones ...
static const unsigned int h01= 0x01010101; //the sum of 256 to the power of 0,1,2,3...
x -= (x >> 1) & m1; //put count of each 2 bits into those 2 bits
x = (x & m2) + ((x >> 2) & m2); //put count of each 4 bits into those 4 bits
x = (x + (x >> 4)) & m4; //put count of each 8 bits into those 8 bits
return (x * h01) >> 24; //returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24)
}
inline int __builtin_popcountl(unsigned long x) {
return __builtin_popcount(static_cast<int>(x));
}
inline int __builtin_popcountll(unsigned long long x) {
static const unsigned long long m1 = 0x5555555555555555; //binary: 0101...
static const unsigned long long m2 = 0x3333333333333333; //binary: 00110011..
static const unsigned long long m4 = 0x0f0f0f0f0f0f0f0f; //binary: 4 zeros, 4 ones ...
static const unsigned long long h01 = 0x0101010101010101; //the sum of 256 to the power of 0,1,2,3...
x -= (x >> 1) & m1; //put count of each 2 bits into those 2 bits
x = (x & m2) + ((x >> 2) & m2); //put count of each 4 bits into those 4 bits
x = (x + (x >> 4)) & m4; //put count of each 8 bits into those 8 bits
return static_cast<int>((x * h01)>>56); //returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
}
inline float FilterTIG::dot(const INT64 tig1, const INT64 tig2, const INT64 tig4, const INT64 tig8)
{
INT64 bcT1 = __builtin_popcountll(tig1);
INT64 bcT2 = __builtin_popcountll(tig2);
INT64 bcT4 = __builtin_popcountll(tig4);
INT64 bcT8 = __builtin_popcountll(tig8);
INT64 bcT1 = POPCNT64(tig1);
INT64 bcT2 = POPCNT64(tig2);
INT64 bcT4 = POPCNT64(tig4);
INT64 bcT8 = POPCNT64(tig8);
INT64 bc01 = (__builtin_popcountll(_bTIGs[0] & tig1) << 1) - bcT1;
INT64 bc02 = ((__builtin_popcountll(_bTIGs[0] & tig2) << 1) - bcT2) << 1;
INT64 bc04 = ((__builtin_popcountll(_bTIGs[0] & tig4) << 1) - bcT4) << 2;
INT64 bc08 = ((__builtin_popcountll(_bTIGs[0] & tig8) << 1) - bcT8) << 3;
INT64 bc01 = (POPCNT64(_bTIGs[0] & tig1) << 1) - bcT1;
INT64 bc02 = ((POPCNT64(_bTIGs[0] & tig2) << 1) - bcT2) << 1;
INT64 bc04 = ((POPCNT64(_bTIGs[0] & tig4) << 1) - bcT4) << 2;
INT64 bc08 = ((POPCNT64(_bTIGs[0] & tig8) << 1) - bcT8) << 3;
INT64 bc11 = (__builtin_popcountll(_bTIGs[1] & tig1) << 1) - bcT1;
INT64 bc12 = ((__builtin_popcountll(_bTIGs[1] & tig2) << 1) - bcT2) << 1;
INT64 bc14 = ((__builtin_popcountll(_bTIGs[1] & tig4) << 1) - bcT4) << 2;
INT64 bc18 = ((__builtin_popcountll(_bTIGs[1] & tig8) << 1) - bcT8) << 3;
INT64 bc11 = (POPCNT64(_bTIGs[1] & tig1) << 1) - bcT1;
INT64 bc12 = ((POPCNT64(_bTIGs[1] & tig2) << 1) - bcT2) << 1;
INT64 bc14 = ((POPCNT64(_bTIGs[1] & tig4) << 1) - bcT4) << 2;
INT64 bc18 = ((POPCNT64(_bTIGs[1] & tig8) << 1) - bcT8) << 3;
return _coeffs1[0] * (bc01 + bc02 + bc04 + bc08) + _coeffs1[1] * (bc11 + bc12 + bc14 + bc18);
}
......@@ -173,13 +173,13 @@ typedef unsigned long UINT64;
//#define UINT64 unsigned long
#endif
/*
#if (_MSC_VER >= 1500)
#if defined(_MSC_VER)
# include <intrin.h>
# define POPCNT(x) __popcnt(x)
# define POPCNT64(x) __popcnt64(x)
#endif
*/
#if defined(__GNUC__)
# define POPCNT(x) __builtin_popcount(x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment