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

FW=1 operations

File:
1 edited

Legend:

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

    r1570 r1573  
    197197template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<128>::popcount(bitblock256_t arg1);
    198198template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<256>::popcount(bitblock256_t arg1);
    199 template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::neg(bitblock256_t arg1);
    200199template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::neg(bitblock256_t arg1);
    201200template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<4>::neg(bitblock256_t arg1);
     
    318317template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<128>::add(bitblock256_t arg1, bitblock256_t arg2);
    319318template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<256>::add(bitblock256_t arg1, bitblock256_t arg2);
    320 template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::abs(bitblock256_t arg1);
    321319template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::abs(bitblock256_t arg1);
    322320template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<4>::abs(bitblock256_t arg1);
     
    573571}
    574572
    575 //The total number of operations is 95
     573//The total number of operations is 1
    576574template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::max(bitblock256_t arg1, bitblock256_t arg2)
    577575{
    578         bitblock256_t high_bit = simd256<1>::constant<(1)>();
    579         return simd_xor(simd256<1>::umax(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    580 }
    581 
    582 //The total number of operations is 47
     576        return simd_and(arg1, arg2);
     577}
     578
     579//The total number of operations is 29
    583580template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::max(bitblock256_t arg1, bitblock256_t arg2)
    584581{
    585         bitblock256_t high_bit = simd256<2>::constant<(2)>();
    586         return simd_xor(simd256<2>::umax(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
     582        bitblock256_t hiAns = simd256<(1)>::max(arg1, arg2);
     583        bitblock256_t loAns = simd256<(1)>::umax(arg1, arg2);
     584        bitblock256_t eqMask1 = simd256<2>::srli<(1)>(simd256<(1)>::eq(hiAns, arg1));
     585        bitblock256_t eqMask2 = simd256<2>::srli<(1)>(simd256<(1)>::eq(hiAns, arg2));
     586        return simd256<1>::ifh(simd256<2>::himask(), hiAns, simd256<1>::ifh(eqMask1, simd256<1>::ifh(eqMask2, loAns, arg1), arg2));
    587587}
    588588
     
    638638}
    639639
    640 //The total number of operations is 216
     640//The total number of operations is 1
    641641template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::mult(bitblock256_t arg1, bitblock256_t arg2)
    642642{
    643         bitblock256_t loMask = simd256<(2)>::lomask();
    644         bitblock256_t tmpAns1 = simd256<(2)>::mult(simd_and(loMask, arg1), simd_and(loMask, arg2));
    645         bitblock256_t tmpAns2 = simd256<(2)>::mult(simd256<(2)>::srli<1>(arg1), simd256<(2)>::srli<1>(arg2));
    646         return simd256<1>::ifh(loMask, tmpAns1, simd256<(2)>::slli<1>(tmpAns2));
     643        return simd_and(arg1, arg2);
    647644}
    648645
     
    727724}
    728725
    729 //The total number of operations is 124
     726//The total number of operations is 1
    730727template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::gt(bitblock256_t arg1, bitblock256_t arg2)
    731728{
    732         bitblock256_t high_bit = simd256<1>::constant<(1)>();
    733         return simd256<1>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    734 }
    735 
    736 //The total number of operations is 60
     729        return simd_andc(arg2, arg1);
     730}
     731
     732//The total number of operations is 30
    737733template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::gt(bitblock256_t arg1, bitblock256_t arg2)
    738734{
    739         bitblock256_t high_bit = simd256<2>::constant<(2)>();
    740         return simd256<2>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
     735        bitblock256_t hiAns = simd256<(1)>::gt(arg1, arg2);
     736        bitblock256_t loAns = simd256<(1)>::ugt(arg1, arg2);
     737        bitblock256_t mask = simd_and(loAns, simd256<2>::srli<(1)>(simd256<(1)>::eq(arg1, arg2)));
     738        mask = simd_or(mask, simd256<2>::slli<(1)>(mask));
     739        return simd_or(simd256<2>::srai<(1)>(hiAns), mask);
    741740}
    742741
     
    879878}
    880879
    881 //The total number of operations is 182
     880//The total number of operations is 1
    882881template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::ult(bitblock256_t arg1, bitblock256_t arg2)
    883882{
    884         return simd256<1>::ifh(simd256<(2)>::himask(), simd256<(2)>::ult(arg1, simd_and(simd256<(2)>::himask(), arg2)), simd256<(2)>::ult(simd_andc(arg1, simd256<(2)>::himask()), simd_andc(arg2, simd256<(2)>::himask())));
    885 }
    886 
    887 //The total number of operations is 88
     883        return simd_andc(arg2, arg1);
     884}
     885
     886//The total number of operations is 29
    888887template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::ult(bitblock256_t arg1, bitblock256_t arg2)
    889888{
    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)));
     889        bitblock256_t tmpAns = simd256<(1)>::ult(arg1, arg2);
     890        bitblock256_t mask = simd_and(tmpAns, simd256<2>::srli<(1)>(simd256<(1)>::eq(arg1, arg2)));
     891        mask = simd_or(mask, simd256<2>::slli<(1)>(mask));
     892        return simd_or(simd256<2>::srai<(1)>(tmpAns), mask);
    891893}
    892894
     
    940942}
    941943
    942 //The total number of operations is 184
     944//The total number of operations is 1
    943945template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::lt(bitblock256_t arg1, bitblock256_t arg2)
    944946{
    945         bitblock256_t high_bit = simd256<1>::constant<(1)>();
    946         return simd256<1>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    947 }
    948 
    949 //The total number of operations is 90
     947        return simd_andc(arg1, arg2);
     948}
     949
     950//The total number of operations is 30
    950951template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::lt(bitblock256_t arg1, bitblock256_t arg2)
    951952{
    952         bitblock256_t high_bit = simd256<2>::constant<(2)>();
    953         return simd256<2>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
     953        bitblock256_t hiAns = simd256<(1)>::lt(arg1, arg2);
     954        bitblock256_t loAns = simd256<(1)>::ult(arg1, arg2);
     955        bitblock256_t mask = simd_and(loAns, simd256<2>::srli<(1)>(simd256<(1)>::eq(arg1, arg2)));
     956        mask = simd_or(mask, simd256<2>::slli<(1)>(mask));
     957        return simd_or(simd256<2>::srai<(1)>(hiAns), mask);
    954958}
    955959
     
    11071111}
    11081112
    1109 //The total number of operations is 122
     1113//The total number of operations is 1
    11101114template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::ugt(bitblock256_t arg1, bitblock256_t arg2)
    11111115{
    1112         return simd256<1>::ifh(simd256<(2)>::himask(), simd256<(2)>::ugt(simd_and(simd256<(2)>::himask(), arg1), arg2), simd256<(2)>::ugt(simd_andc(arg1, simd256<(2)>::himask()), simd_andc(arg2, simd256<(2)>::himask())));
    1113 }
    1114 
    1115 //The total number of operations is 58
     1116        return simd_andc(arg1, arg2);
     1117}
     1118
     1119//The total number of operations is 29
    11161120template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::ugt(bitblock256_t arg1, bitblock256_t arg2)
    11171121{
    1118         return simd256<1>::ifh(simd256<(4)>::himask(), simd256<(4)>::ugt(simd_and(simd256<(4)>::himask(), arg1), arg2), simd256<(4)>::ugt(simd_andc(arg1, simd256<(4)>::himask()), simd_andc(arg2, simd256<(4)>::himask())));
     1122        bitblock256_t tmpAns = simd256<(1)>::ugt(arg1, arg2);
     1123        bitblock256_t mask = simd_and(tmpAns, simd256<2>::srli<(1)>(simd256<(1)>::eq(arg1, arg2)));
     1124        mask = simd_or(mask, simd256<2>::slli<(1)>(mask));
     1125        return simd_or(simd256<2>::srai<(1)>(tmpAns), mask);
    11191126}
    11201127
     
    12731280        bitblock256_t tmpAns = simd256<(128)>::popcount(arg1);
    12741281        return simd256<(128)>::add(simd_and(tmpAns, simd256<256>::lomask()), simd256<256>::srli<(128)>(tmpAns));
    1275 }
    1276 
    1277 //The total number of operations is 1
    1278 template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::neg(bitblock256_t arg1)
    1279 {
    1280         return simd256<1>::sub(simd256<1>::constant<0>(), arg1);
    12811282}
    12821283
     
    16471648}
    16481649
    1649 //The total number of operations is 95
     1650//The total number of operations is 1
    16501651template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::min(bitblock256_t arg1, bitblock256_t arg2)
    16511652{
    1652         bitblock256_t high_bit = simd256<1>::constant<(1)>();
    1653         return simd_xor(simd256<1>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    1654 }
    1655 
    1656 //The total number of operations is 47
     1653        return simd_or(arg1, arg2);
     1654}
     1655
     1656//The total number of operations is 29
    16571657template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::min(bitblock256_t arg1, bitblock256_t arg2)
    16581658{
    1659         bitblock256_t high_bit = simd256<2>::constant<(2)>();
    1660         return simd_xor(simd256<2>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
     1659        bitblock256_t hiAns = simd256<(1)>::min(arg1, arg2);
     1660        bitblock256_t loAns = simd256<(1)>::umin(arg1, arg2);
     1661        bitblock256_t eqMask1 = simd256<2>::srli<(1)>(simd256<(1)>::eq(hiAns, arg1));
     1662        bitblock256_t eqMask2 = simd256<2>::srli<(1)>(simd256<(1)>::eq(hiAns, arg2));
     1663        return simd256<1>::ifh(simd256<2>::himask(), hiAns, simd256<1>::ifh(eqMask1, simd256<1>::ifh(eqMask2, loAns, arg1), arg2));
    16611664}
    16621665
     
    17121715}
    17131716
    1714 //The total number of operations is 92
     1717//The total number of operations is 1
    17151718template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::umin(bitblock256_t arg1, bitblock256_t arg2)
    17161719{
    1717         return simd_or(simd_and(simd256<(2)>::himask(), simd256<(2)>::umin(arg1, arg2)), simd256<(2)>::umin(simd_and(simd256<(2)>::lomask(), arg1), simd_and(simd256<(2)>::lomask(), arg2)));
    1718 }
    1719 
    1720 //The total number of operations is 44
     1720        return simd_and(arg1, arg2);
     1721}
     1722
     1723//The total number of operations is 28
    17211724template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::umin(bitblock256_t arg1, bitblock256_t arg2)
    17221725{
    1723         return simd_or(simd_and(simd256<(4)>::himask(), simd256<(4)>::umin(arg1, arg2)), simd256<(4)>::umin(simd_and(simd256<(4)>::lomask(), arg1), simd_and(simd256<(4)>::lomask(), arg2)));
     1726        bitblock256_t tmpAns = simd256<(1)>::umin(arg1, arg2);
     1727        bitblock256_t eqMask1 = simd256<2>::srli<(1)>(simd256<(1)>::eq(tmpAns, arg1));
     1728        bitblock256_t eqMask2 = simd256<2>::srli<(1)>(simd256<(1)>::eq(tmpAns, arg2));
     1729        return simd256<1>::ifh(simd256<2>::himask(), tmpAns, simd256<1>::ifh(eqMask1, simd256<1>::ifh(eqMask2, tmpAns, arg1), arg2));
    17241730}
    17251731
     
    17731779}
    17741780
    1775 //The total number of operations is 92
     1781//The total number of operations is 1
    17761782template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::umax(bitblock256_t arg1, bitblock256_t arg2)
    17771783{
    1778         return simd_or(simd_and(simd256<(2)>::himask(), simd256<(2)>::umax(arg1, arg2)), simd256<(2)>::umax(simd_and(simd256<(2)>::lomask(), arg1), simd_and(simd256<(2)>::lomask(), arg2)));
    1779 }
    1780 
    1781 //The total number of operations is 44
     1784        return simd_or(arg1, arg2);
     1785}
     1786
     1787//The total number of operations is 28
    17821788template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::umax(bitblock256_t arg1, bitblock256_t arg2)
    17831789{
    1784         return simd_or(simd_and(simd256<(4)>::himask(), simd256<(4)>::umax(arg1, arg2)), simd256<(4)>::umax(simd_and(simd256<(4)>::lomask(), arg1), simd_and(simd256<(4)>::lomask(), arg2)));
     1790        bitblock256_t tmpAns = simd256<(1)>::umax(arg1, arg2);
     1791        bitblock256_t eqMask1 = simd256<2>::srli<(1)>(simd256<(1)>::eq(tmpAns, arg1));
     1792        bitblock256_t eqMask2 = simd256<2>::srli<(1)>(simd256<(1)>::eq(tmpAns, arg2));
     1793        return simd256<1>::ifh(simd256<2>::himask(), tmpAns, simd256<1>::ifh(eqMask1, simd256<1>::ifh(eqMask2, tmpAns, arg1), arg2));
    17851794}
    17861795
     
    18341843}
    18351844
    1836 //The total number of operations is 113
     1845//The total number of operations is 2
    18371846template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::eq(bitblock256_t arg1, bitblock256_t arg2)
    18381847{
    1839         return simd_or(simd_and(simd256<(2)>::himask(), simd256<(2)>::eq(simd_and(simd256<(2)>::himask(), arg1), simd_and(simd256<(2)>::himask(), arg2))), simd_and(simd256<(2)>::lomask(), simd256<(2)>::eq(simd_and(simd256<(2)>::lomask(), arg1), simd_and(simd256<(2)>::lomask(), arg2))));
    1840 }
    1841 
    1842 //The total number of operations is 53
     1848        return simd_not(simd_xor(arg1, arg2));
     1849}
     1850
     1851//The total number of operations is 18
    18431852template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::eq(bitblock256_t arg1, bitblock256_t arg2)
    18441853{
    1845         return simd_or(simd_and(simd256<(4)>::himask(), simd256<(4)>::eq(simd_and(simd256<(4)>::himask(), arg1), simd_and(simd256<(4)>::himask(), arg2))), simd_and(simd256<(4)>::lomask(), simd256<(4)>::eq(simd_and(simd256<(4)>::lomask(), arg1), simd_and(simd256<(4)>::lomask(), arg2))));
     1854        bitblock256_t tmpAns = simd256<(1)>::eq(arg1, arg2);
     1855        bitblock256_t loMask = simd_and(tmpAns, simd256<2>::srli<(1)>(tmpAns));
     1856        bitblock256_t hiMask = simd256<2>::slli<(1)>(loMask);
     1857        return simd_or(loMask, hiMask);
    18461858}
    18471859
     
    20612073}
    20622074
    2063 //The total number of operations is 128
    2064 template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<1>::abs(bitblock256_t arg1)
    2065 {
    2066         bitblock256_t gtMask = simd256<1>::gt(arg1, simd256<1>::constant<0>());
    2067         return simd256<1>::ifh(gtMask, arg1, simd256<1>::sub(gtMask, arg1));
    2068 }
    2069 
    20702075//The total number of operations is 45
    20712076template <> IDISA_ALWAYS_INLINE bitblock256_t simd256<2>::abs(bitblock256_t arg1)
     
    21202125}
    21212126
    2122 //The total number of operations is 652
     2127//The total number of operations is 561
    21232128template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<2>::umin_hl(bitblock256_t arg1, bitblock256_t arg2)
    21242129{
     
    21262131}
    21272132
    2128 //The total number of operations is 428
     2133//The total number of operations is 412
    21292134template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<4>::umin_hl(bitblock256_t arg1, bitblock256_t arg2)
    21302135{
     
    22162221}
    22172222
    2218 //The total number of operations is 534
     2223//The total number of operations is 414
    22192224template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<2>::packss(bitblock256_t arg1, bitblock256_t arg2)
    22202225{
     
    24082413}
    24092414
    2410 //The total number of operations is 655
     2415//The total number of operations is 561
    24112416template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<2>::min_hl(bitblock256_t arg1, bitblock256_t arg2)
    24122417{
     
    24142419}
    24152420
    2416 //The total number of operations is 431
     2421//The total number of operations is 413
    24172422template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<4>::min_hl(bitblock256_t arg1, bitblock256_t arg2)
    24182423{
     
    24562461}
    24572462
    2458 //The total number of operations is 414
     2463//The total number of operations is 344
    24592464template <> IDISA_ALWAYS_INLINE bitblock256_t hsimd256<2>::packus(bitblock256_t arg1, bitblock256_t arg2)
    24602465{
Note: See TracChangeset for help on using the changeset viewer.