Ignore:
Timestamp:
Oct 22, 2011, 6:22:11 PM (8 years ago)
Author:
cameron
Message:

bitblock::(load,store) (aligned,unaligned); <1>::add, sub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/idisa_cpp/idisa_avx.cpp

    r1557 r1570  
    5858public:
    5959        static IDISA_ALWAYS_INLINE bitblock256_t mergel(bitblock256_t arg1, bitblock256_t arg2);
     60        static IDISA_ALWAYS_INLINE bitblock256_t signextendh(bitblock256_t arg1);
    6061        static IDISA_ALWAYS_INLINE bitblock256_t mergeh(bitblock256_t arg1, bitblock256_t arg2);
    6162        static IDISA_ALWAYS_INLINE bitblock256_t zeroextendh(bitblock256_t arg1);
    6263        static IDISA_ALWAYS_INLINE bitblock256_t zeroextendl(bitblock256_t arg1);
    63         static IDISA_ALWAYS_INLINE bitblock256_t signextendh(bitblock256_t arg1);
    6464        static IDISA_ALWAYS_INLINE bitblock256_t signextendl(bitblock256_t arg1);
    6565};
     
    8585{
    8686public:
     87        static IDISA_ALWAYS_INLINE bitblock256_t load_unaligned(bitblock256_t* arg1);
     88        static IDISA_ALWAYS_INLINE void store_aligned(bitblock256_t* arg1, bitblock256_t arg2);
    8789        static IDISA_ALWAYS_INLINE bool all(bitblock256_t arg1);
    8890        static IDISA_ALWAYS_INLINE bool any(bitblock256_t arg1);
    8991        static IDISA_ALWAYS_INLINE uint64_t popcount(bitblock256_t arg1);
     92        static IDISA_ALWAYS_INLINE bitblock256_t load_aligned(bitblock256_t* arg1);
     93        static IDISA_ALWAYS_INLINE void store_unaligned(bitblock256_t* arg1, bitblock256_t arg2);
    9094};
    9195
     
    875879}
    876880
    877 //The total number of operations is 186
     881//The total number of operations is 182
    878882template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::ult(bitblock256_t arg1, bitblock256_t arg2)
    879883{
     
    881885}
    882886
    883 //The total number of operations is 90
     887//The total number of operations is 88
    884888template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::ult(bitblock256_t arg1, bitblock256_t arg2)
    885889{
    886         bitblock256_t tmp = simd_not(arg1);
    887         bitblock256_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd256<256>::slli<1>(simd_and(tmp, arg2)), simd_or(tmp, arg2)));
    888         return simd256<1>::ifh(simd256<2>::himask(), tmpAns, simd256<256>::srli<1>(tmpAns));
     890        return simd_and(simd256<2>::srai<(1)>(simd_or(simd_and(simd_not(arg1), arg2), simd_and(simd_not(simd_xor(arg1, arg2)), simd256<2>::sub(arg1, arg2)))), simd_not(simd256<2>::eq(arg1, arg2)));
    889891}
    890892
     
    938940}
    939941
    940 //The total number of operations is 188
     942//The total number of operations is 184
    941943template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::lt(bitblock256_t arg1, bitblock256_t arg2)
    942944{
     
    945947}
    946948
    947 //The total number of operations is 91
     949//The total number of operations is 90
    948950template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::lt(bitblock256_t arg1, bitblock256_t arg2)
    949951{
    950         bitblock256_t tmp = simd_not(arg2);
    951         bitblock256_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd256<256>::slli<1>(simd_and(simd_not(arg1), arg2)), simd_or(arg1, tmp)));
    952         return simd256<1>::ifh(simd256<2>::himask(), tmpAns, simd256<256>::srli<1>(tmpAns));
     952        bitblock256_t high_bit = simd256<2>::constant<(2)>();
     953        return simd256<2>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    953954}
    954955
     
    10581059}
    10591060
    1060 //The total number of operations is 60
     1061//The total number of operations is 34
    10611062template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::ctz(bitblock256_t arg1)
    10621063{
     
    12741275}
    12751276
    1276 //The total number of operations is 92
     1277//The total number of operations is 1
    12771278template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::neg(bitblock256_t arg1)
    12781279{
     
    12801281}
    12811282
    1282 //The total number of operations is 44
     1283//The total number of operations is 18
    12831284template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::neg(bitblock256_t arg1)
    12841285{
     
    14301431}
    14311432
    1432 //The total number of operations is 92
     1433//The total number of operations is 1
    14331434template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::sub(bitblock256_t arg1, bitblock256_t arg2)
    14341435{
    1435         return simd256<1>::ifh(simd256<(2)>::himask(), simd256<(2)>::sub(arg1, simd_and(simd256<(2)>::himask(), arg2)), simd256<(2)>::sub(arg1, arg2));
    1436 }
    1437 
    1438 //The total number of operations is 44
     1436        return simd_xor(arg1, arg2);
     1437}
     1438
     1439//The total number of operations is 18
    14391440template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::sub(bitblock256_t arg1, bitblock256_t arg2)
    14401441{
    1441         return simd256<1>::ifh(simd256<(4)>::himask(), simd256<(4)>::sub(arg1, simd_and(simd256<(4)>::himask(), arg2)), simd256<(4)>::sub(arg1, arg2));
     1442        bitblock256_t ans = simd256<(1)>::sub(arg1, arg2);
     1443        bitblock256_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
     1444        bitblock256_t loMask = simd256<2>::lomask();
     1445        bitblock256_t borrow = simd256<2>::slli<1>(simd_and(borrowMask, loMask));
     1446        return simd256<1>::ifh(loMask, ans, simd256<(1)>::sub(ans, borrow));
    14421447}
    14431448
     
    19901995}
    19911996
    1992 //The total number of operations is 92
     1997//The total number of operations is 1
    19931998template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::add(bitblock256_t arg1, bitblock256_t arg2)
    19941999{
    1995         return simd256<1>::ifh(simd256<(2)>::himask(), simd256<(2)>::add(arg1, simd_and(simd256<(2)>::himask(), arg2)), simd256<(2)>::add(arg1, arg2));
    1996 }
    1997 
    1998 //The total number of operations is 44
     2000        return simd_xor(arg1, arg2);
     2001}
     2002
     2003//The total number of operations is 18
    19992004template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::add(bitblock256_t arg1, bitblock256_t arg2)
    20002005{
    2001         return simd256<1>::ifh(simd256<(4)>::himask(), simd256<(4)>::add(arg1, simd_and(simd256<(4)>::himask(), arg2)), simd256<(4)>::add(arg1, arg2));
     2006        bitblock256_t ans = simd256<(1)>::add(arg1, arg2);
     2007        bitblock256_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
     2008        bitblock256_t loMask = simd256<2>::lomask();
     2009        bitblock256_t carry = simd256<2>::slli<1>(simd_and(carryMask, loMask));
     2010        return simd256<1>::ifh(loMask, ans, simd256<(1)>::add(ans, carry));
    20022011}
    20032012
     
    20522061}
    20532062
    2054 //The total number of operations is 219
     2063//The total number of operations is 128
    20552064template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::abs(bitblock256_t arg1)
    20562065{
     
    21592168}
    21602169
    2161 //The total number of operations is 652
     2170//The total number of operations is 561
    21622171template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<2>::add_hl(bitblock256_t arg1, bitblock256_t arg2)
    21632172{
     
    21652174}
    21662175
    2167 //The total number of operations is 428
     2176//The total number of operations is 402
    21682177template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<4>::add_hl(bitblock256_t arg1, bitblock256_t arg2)
    21692178{
     
    32883297}
    32893298
     3299//The total number of operations is 1
     3300IDISA_ALWAYS_INLINE bitblock256_t bitblock256::load_unaligned(bitblock256_t* arg1)
     3301{
     3302        return _mm256_loadu_ps((bitblock256_t*)(arg1));
     3303}
     3304
     3305//The total number of operations is 1
     3306IDISA_ALWAYS_INLINE void bitblock256::store_aligned(bitblock256_t* arg1, bitblock256_t arg2)
     3307{
     3308        _mm256_store_ps((bitblock256_t*)(arg1), arg2);
     3309}
     3310
    32903311//The total number of operations is 209
    32913312IDISA_ALWAYS_INLINE uint64_t bitblock256::popcount(bitblock256_t arg1)
     
    33063327}
    33073328
     3329//The total number of operations is 1
     3330IDISA_ALWAYS_INLINE bitblock256_t bitblock256::load_aligned(bitblock256_t* arg1)
     3331{
     3332        return _mm256_load_ps((bitblock256_t*)(arg1));
     3333}
     3334
     3335//The total number of operations is 1
     3336IDISA_ALWAYS_INLINE void bitblock256::store_unaligned(bitblock256_t* arg1, bitblock256_t arg2)
     3337{
     3338        _mm256_storeu_ps((bitblock256_t*)(arg1), arg2);
     3339}
     3340
    33083341#endif
Note: See TracChangeset for help on using the changeset viewer.