Changeset 3519
 Timestamp:
 Sep 18, 2013, 9:49:50 AM (5 years ago)
 Location:
 trunk/lib
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/bitblock256.hpp
r3453 r3519 26 26 27 27 /* The type used to store a carry bit. */ 28 #ifndef CARRY64 28 29 typedef bitblock256_t carry_t; 30 #endif 31 #ifdef CARRY64 32 typedef uint64_t carry_t; 33 #endif 29 34 30 35 static IDISA_ALWAYS_INLINE void add_ci_co(bitblock256_t x, bitblock256_t y, carry_t carry_in, carry_t & carry_out, bitblock256_t & sum); 31 36 static IDISA_ALWAYS_INLINE void sub_bi_bo(bitblock256_t x, bitblock256_t y, carry_t borrow_in, carry_t & borrow_out, bitblock256_t & difference); 32 static IDISA_ALWAYS_INLINE void adv_ci_co(bitblock256_t cursor, bitblock256_t carry_in, bitblock256_t & carry_out, bitblock256_t & rslt);37 static IDISA_ALWAYS_INLINE void adv_ci_co(bitblock256_t cursor, carry_t carry_in, carry_t & carry_out, bitblock256_t & rslt); 33 38 34 39 … … 39 44 static IDISA_ALWAYS_INLINE carry_t carryout2carry(bitblock256_t carryout); 40 45 46 41 47 static IDISA_ALWAYS_INLINE void adc(bitblock256_t x, bitblock256_t y, carry_t & carry, bitblock256_t & sum); 42 48 static IDISA_ALWAYS_INLINE void sbb(bitblock256_t x, bitblock256_t y, carry_t & borrow, bitblock256_t & difference); … … 51 57 static IDISA_ALWAYS_INLINE uint64_t convert (bitblock256_t v); 52 58 59 #ifndef CARRY64 53 60 static IDISA_ALWAYS_INLINE bitblock256_t carry2bitblock(carry_t carry) { return carry;} 54 61 static IDISA_ALWAYS_INLINE carry_t bitblock2carry(bitblock256_t carry) { return carry;} 55 56 static IDISA_ALWAYS_INLINE carry_t carryout2carry(bitblock256_t carryout) { 62 static IDISA_ALWAYS_INLINE uint64_t carry2uint64(carry_t carry) { return convert(carry);} 63 static IDISA_ALWAYS_INLINE carry_t uint2carry(uint64_t carry) { return convert(carry);} 64 #endif 65 #ifdef CARRY64 66 static IDISA_ALWAYS_INLINE bitblock256_t carry2bitblock(carry_t carry) { return convert(carry);} 67 static IDISA_ALWAYS_INLINE carry_t bitblock2carry(bitblock256_t carry) { return convert(carry);} 68 static IDISA_ALWAYS_INLINE uint64_t carry2uint64(carry_t carry) { return carry;} 69 static IDISA_ALWAYS_INLINE carry_t uint2carry(uint64_t carry) { return carry;} 70 #endif 71 72 static IDISA_ALWAYS_INLINE carry_t carryout2carry(carry_t carryout) { 57 73 return carryout; 58 74 } … … 65 81 bitblock256_t carry = simd_or(gen, simd_andc(prop, partial_sum)); 66 82 bitblock256_t bubble = simd256<64>::eq(partial_sum, all_ones); 67 uint64_t carry_mask = hsimd256<64>::signmask(carry) * 2 + c onvert(carry_in);83 uint64_t carry_mask = hsimd256<64>::signmask(carry) * 2 + carry2uint64(carry_in); 68 84 uint64_t bubble_mask = hsimd256<64>::signmask(bubble); 69 85 uint64_t carry_scan_thru_bubbles = (carry_mask + bubble_mask) &~ bubble_mask; 70 86 uint64_t increments = carry_scan_thru_bubbles  (carry_scan_thru_bubbles  carry_mask); 71 carry_out = convert(increments >> 4);87 carry_out = uint2carry(increments >> 4); 72 88 uint64_t spread = 0x0000200040008001 * increments & 0x0001000100010001; 73 89 sum = simd256<64>::add(partial_sum, _mm256_cvtepu16_epi64(avx_select_lo128(convert(spread)))); … … 80 96 bitblock256_t borrow = simd_or(gen, simd_and(prop, partial_diff)); 81 97 bitblock256_t bubble = simd256<64>::eq(partial_diff, simd<1>::constant<0>()); 82 uint64_t borrow_mask = hsimd256<64>::signmask(borrow) * 2 + c onvert(borrow_in);98 uint64_t borrow_mask = hsimd256<64>::signmask(borrow) * 2 + carry2uint64(borrow_in); 83 99 uint64_t bubble_mask = hsimd256<64>::signmask(bubble); 84 100 uint64_t borrow_scan_thru_bubbles = (borrow_mask + bubble_mask) &~ bubble_mask; 85 101 uint64_t decrements = borrow_scan_thru_bubbles  (borrow_scan_thru_bubbles  borrow_mask); 86 borrow_out = convert(decrements >> 4);102 borrow_out = uint2carry(decrements >> 4); 87 103 uint64_t spread = 0x0000200040008001 * decrements & 0x0001000100010001; 88 104 difference = simd256<64>::sub(partial_diff, _mm256_cvtepu16_epi64(avx_select_lo128(convert(spread)))); 89 105 } 90 106 91 static IDISA_ALWAYS_INLINE void adv_ci_co(bitblock256_t cursor, bitblock256_t carry_in, bitblock256_t & carry_out, bitblock256_t & rslt){107 static IDISA_ALWAYS_INLINE void adv_ci_co(bitblock256_t cursor, carry_t carry_in, carry_t & carry_out, bitblock256_t & rslt){ 92 108 bitblock256_t shift_out = simd256<64>::srli<63>(cursor); 93 bitblock256_t low_bits = simd_or(mvmd256<64>::slli<1>(shift_out), carry _in);94 carry_out = mvmd256<64>::srli<3>(shift_out);109 bitblock256_t low_bits = simd_or(mvmd256<64>::slli<1>(shift_out), carry2bitblock(carry_in)); 110 carry_out = bitblock2carry(mvmd256<64>::srli<3>(shift_out)); 95 111 rslt = simd_or(simd256<64>::add(cursor, cursor), low_bits); 96 112 } 
trunk/lib/carryQ.hpp
r3457 r3519 58 58 public: 59 59 60 #ifndef CARRY64 60 61 #define Carry0 simd<BLOCK_SIZE>::constant<0>() 61 62 #define Carry1 simd<BLOCK_SIZE>::constant<1>() 62 63 #endif 64 #ifdef CARRY64 65 #define Carry0 0 66 #define Carry1 1 67 #endif 68 63 69 carry_t cq[CarryCount + AdvanceNCount]; 64 70 //BitBlock pending64[AdvanceNCount]; 65 71 CarryArray() 66 72 { 67 memset (cq, 0, sizeof( BitBlock) * (CarryCount + AdvanceNCount));73 memset (cq, 0, sizeof(carry_t) * (CarryCount + AdvanceNCount)); 68 74 //memset(pending64, 0, sizeof(BitBlock) * AdvanceNCount); 69 75 } 70 76 ~CarryArray() {} 71 77 72 IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_ci_co(BitBlock strm, BitBlockcarryin, uint16_t carryno)78 IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_ci_co(BitBlock strm, carry_t carryin, uint16_t carryno) 73 79 { 74 80 BitBlock rslt; … … 77 83 } 78 84 79 IDISA_ALWAYS_INLINE BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, BitBlockcarryin, const uint16_t carryno)85 IDISA_ALWAYS_INLINE BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, carry_t carryin, const uint16_t carryno) 80 86 { 81 87 BitBlock sum; … … 84 90 } 85 91 86 IDISA_ALWAYS_INLINE BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, BitBlockcarryin, uint16_t carryno)92 IDISA_ALWAYS_INLINE BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, carry_t carryin, uint16_t carryno) 87 93 { 88 94 BitBlock diff; … … 91 97 } 92 98 93 IDISA_ALWAYS_INLINE BitBlock BitBlock_scantofirst(BitBlock charclass, BitBlockcarryin, uint16_t carryno)99 IDISA_ALWAYS_INLINE BitBlock BitBlock_scantofirst(BitBlock charclass, carry_t carryin, uint16_t carryno) 94 100 { 95 101 BitBlock marker; … … 100 106 } 101 107 102 IDISA_ALWAYS_INLINE BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, BitBlockcarryin, uint16_t carryno)108 IDISA_ALWAYS_INLINE BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, carry_t carryin, uint16_t carryno) 103 109 { 104 110 BitBlock markers1; … … 107 113 } 108 114 109 IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_then_scanthru(BitBlock markers0, BitBlock charclass, BitBlockcarryin, uint16_t carryno)115 IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_then_scanthru(BitBlock markers0, BitBlock charclass, carry_t carryin, uint16_t carryno) 110 116 { 111 117 BitBlock markers1; … … 115 121 } 116 122 117 IDISA_ALWAYS_INLINE BitBlock BitBlock_span_upto(BitBlock starts, BitBlock follows, BitBlockcarryin, uint16_t carryno)123 IDISA_ALWAYS_INLINE BitBlock BitBlock_span_upto(BitBlock starts, BitBlock follows, carry_t carryin, uint16_t carryno) 118 124 { 119 125 BitBlock span; … … 122 128 } 123 129 124 IDISA_ALWAYS_INLINE BitBlock BitBlock_inclusive_span(BitBlock starts, BitBlock ends, BitBlockcarryin, uint16_t carryno)130 IDISA_ALWAYS_INLINE BitBlock BitBlock_inclusive_span(BitBlock starts, BitBlock ends, carry_t carryin, uint16_t carryno) 125 131 { 126 132 BitBlock span; … … 129 135 } 130 136 131 IDISA_ALWAYS_INLINE BitBlock BitBlock_exclusive_span(BitBlock starts, BitBlock ends, BitBlockcarryin, uint16_t carryno)137 IDISA_ALWAYS_INLINE BitBlock BitBlock_exclusive_span(BitBlock starts, BitBlock ends, carry_t carryin, uint16_t carryno) 132 138 { 133 139 BitBlock span; … … 136 142 } 137 143 138 144 /* 139 145 IDISA_ALWAYS_INLINE BitBlock BitBlock_advance32_ci_co(BitBlock strm, uint32_t pending_in, uint32_t & pending_out) 140 146 { … … 142 148 return simd_or(simd<BLOCK_SIZE>::slli<32>(strm), mvmd<BLOCK_SIZE>::fill((uint64_t)pending_in)); 143 149 } 144 145 template <int n> IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_n_(BitBlock strm, BitBlock pending_in, uint16_t pendingno) 150 */ 151 152 /* 153 template <int n> IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_n_(BitBlock strm, carry_t pending_in, uint16_t pendingno) 146 154 { 147 155 BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in); … … 152 160 return result; 153 161 } 162 */ 154 163 155 164 IDISA_ALWAYS_INLINE bool CarryTest(uint16_t carryno, uint16_t carry_count) 156 165 { 157 BitBlockc1 = cq[carryno];166 carry_t c1 = cq[carryno]; 158 167 int ubound = carryno + carry_count; 159 168 for (int i = carryno + 1; i < ubound ; i++) { … … 163 172 } 164 173 165 IDISA_ALWAYS_INLINE BitBlockCarryRange(uint16_t carryno, uint16_t carry_count)166 { 167 BitBlockc1 = cq[carryno];174 IDISA_ALWAYS_INLINE carry_t CarryRange(uint16_t carryno, uint16_t carry_count) 175 { 176 carry_t c1 = cq[carryno]; 168 177 int ubound = carryno + carry_count; 169 178 for (int i = carryno + 1; i < ubound ; i++) { … … 189 198 } 190 199 191 IDISA_ALWAYS_INLINE void CarryCombine( BitBlocklocal_cq[], uint16_t carryno, uint16_t carry_count)200 IDISA_ALWAYS_INLINE void CarryCombine(carry_t local_cq[], uint16_t carryno, uint16_t carry_count) 192 201 { 193 202 for (int i = 0; i < carry_count; i++) { … … 202 211 } 203 212 204 IDISA_ALWAYS_INLINE BitBlockget_carry_in(uint16_t carryno) const205 { 206 return c arry2bitblock(cq[carryno]);207 } 208 209 // Deprecated (renamed) 210 IDISA_ALWAYS_INLINE BitBlockGetCarry(uint16_t carryno) const211 { 212 return c arry2bitblock(cq[carryno]);213 } 214 215 IDISA_ALWAYS_INLINE void SetCarry( BitBlockcarryVal, uint16_t carryno)213 IDISA_ALWAYS_INLINE carry_t get_carry_in(uint16_t carryno) const 214 { 215 return cq[carryno]; 216 } 217 218 // Deprecated (renamed) 219 IDISA_ALWAYS_INLINE carry_t GetCarry(uint16_t carryno) const 220 { 221 return cq[carryno]; 222 } 223 224 IDISA_ALWAYS_INLINE void SetCarry(carry_t carryVal, uint16_t carryno) 216 225 { 217 226 cq[carryno] = carryVal; … … 220 229 221 230 // Deprecated in PabloJ, retained for legacy compiler. 222 IDISA_ALWAYS_INLINE BitBlockget_pending64(uint16_t advance_n_blkno) const231 IDISA_ALWAYS_INLINE carry_t get_pending64(uint16_t advance_n_blkno) const 223 232 { 224 233 return cq[CarryCount + advance_n_blkno]; 225 234 } 226 235 227 IDISA_ALWAYS_INLINE BitBlockPending64(uint16_t advance_n_blkno) const236 IDISA_ALWAYS_INLINE carry_t Pending64(uint16_t advance_n_blkno) const 228 237 { 229 238 return cq[CarryCount + advance_n_blkno]; … … 232 241 //private: 233 242 // helpers 234 235 // Deprecated (renamed) 236 IDISA_ALWAYS_INLINE BitBlock carry_flip(BitBlockcarry) const243 #ifndef CARRY64 244 // Deprecated (renamed) 245 IDISA_ALWAYS_INLINE carry_t carry_flip(carry_t carry) const 237 246 { 238 247 return simd_xor(carry, Carry1); 239 248 } 240 249 241 IDISA_ALWAYS_INLINE BitBlock CarryFlip( BitBlockcarry) const250 IDISA_ALWAYS_INLINE BitBlock CarryFlip(carry_t carry) const 242 251 { 243 252 return simd_xor(carry, Carry1); 244 253 } 245 254 246 IDISA_ALWAYS_INLINE bool test_carry( BitBlockcarry) const255 IDISA_ALWAYS_INLINE bool test_carry(carry_t carry) const 247 256 { 248 257 return bitblock::any(carry); 249 258 } 250 259 251 IDISA_ALWAYS_INLINE BitBlock carry_or(BitBlock carry1, BitBlockcarry2) const260 IDISA_ALWAYS_INLINE carry_t carry_or(carry_t carry1, carry_t carry2) const 252 261 { 253 262 return simd_or(carry1, carry2); 254 263 } 255 256 #undef Carry0 257 #undef Carry1 264 #endif 265 #ifdef CARRY64 266 // Deprecated (renamed) 267 IDISA_ALWAYS_INLINE carry_t carry_flip(carry_t carry) const 268 { 269 return carry ^ 1; 270 } 271 272 IDISA_ALWAYS_INLINE BitBlock CarryFlip(carry_t carry) const 273 { 274 return carry ^ 1; 275 } 276 277 IDISA_ALWAYS_INLINE bool test_carry(carry_t carry) const 278 { 279 return carry != 0; 280 } 281 282 IDISA_ALWAYS_INLINE carry_t carry_or(carry_t carry1, carry_t carry2) const 283 { 284 return carry1  carry2; 285 } 286 #endif 258 287 259 288 }; 
trunk/lib/pabloSupport.hpp
r3457 r3519 125 125 } 126 126 127 template <typename T> IDISA_ALWAYS_INLINE carry_t pablo_blk_match(T bytedata[], const T match_str[], BitBlock v, int len) { 127 128 template <typename T> IDISA_ALWAYS_INLINE BitBlock pablo_blk_match(T bytedata[], const T match_str[], BitBlock v, int len) { 128 129 union {BitBlock bitblock; ScanWord elems[sizeof(BitBlock)/sizeof(ScanWord)];} u; 129 130 u.bitblock = v;
Note: See TracChangeset
for help on using the changeset viewer.