Commit 3b6da730 authored by jaco's avatar jaco

wip windows compile error fixing

parent 41f7952c
......@@ -64,6 +64,32 @@ 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)
{
......@@ -83,4 +109,5 @@ inline float FilterTIG::dot(const INT64 tig1, const INT64 tig2, const INT64 tig4
INT64 bc18 = ((__builtin_popcountll(_bTIGs[1] & tig8) << 1) - bcT8) << 3;
return _coeffs1[0] * (bc01 + bc02 + bc04 + bc08) + _coeffs1[1] * (bc11 + bc12 + bc14 + bc18);
}
......@@ -194,7 +194,7 @@ inline int popcnt64( register uint64_t u )
u = ( u & 0x00ff00ff00ff00ff ) + ( ( u >> 8 ) & 0x00ff00ff00ff00ff );
u = ( u & 0x0000ffff0000ffff ) + ( ( u >> 16 ) & 0x0000ffff0000ffff );
u = ( u & 0x00000000ffffffff ) + ( ( u >> 32 ) & 0x00000000ffffffff );
return u;
return (int)u;
}
inline int popcnt( register uint32_t u )
......@@ -204,7 +204,7 @@ inline int popcnt( register uint32_t u )
u = ( u & 0x0f0f0f0f ) + ( ( u >> 4 ) & 0x0f0f0f0f );
u = ( u & 0x00ff00ff ) + ( ( u >> 8 ) & 0x00ff00ff );
u = ( u & 0x0000ffff ) + ( ( u >> 16 ) & 0x0000ffff );
return u;
return (int)u;
}
inline int popcnt64_nibble( register uint64_t u )
......@@ -218,7 +218,7 @@ inline int popcnt64_nibble( register uint64_t u )
c += Table[u & 0xf];
u >>= 4;
}
return c;
return (int)c;
}
inline int popcnt_nibble( register uint32_t u )
......@@ -232,7 +232,7 @@ inline int popcnt_nibble( register uint32_t u )
c += Table[u & 0xf];
u >>= 4;
}
return c;
return (int)c;
}
inline int popcnt64_byte( register uint64_t u )
......@@ -252,7 +252,7 @@ inline int popcnt64_byte( register uint64_t u )
c += Table[u & 0xff];
u >>= 8;
}
return c;
return (int)c;
}
inline int popcnt_byte( register uint32_t u )
......@@ -272,7 +272,7 @@ inline int popcnt_byte( register uint32_t u )
c += Table[u & 0xff];
u >>= 8;
}
return c;
return (int)c;
}
/////
......
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