Changeset 3519 for trunk/lib/carryQ.hpp


Ignore:
Timestamp:
Sep 18, 2013, 9:49:50 AM (6 years ago)
Author:
cameron
Message:

Updates for carry_t = uint64_t support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/carryQ.hpp

    r3457 r3519  
    5858public:
    5959
     60#ifndef CARRY64
    6061    #define Carry0 simd<BLOCK_SIZE>::constant<0>()
    6162    #define Carry1 simd<BLOCK_SIZE>::constant<1>()
    62  
     63#endif
     64#ifdef CARRY64
     65    #define Carry0 0
     66    #define Carry1 1
     67#endif
     68
    6369        carry_t cq[CarryCount + AdvanceNCount];
    6470        //BitBlock pending64[AdvanceNCount];
    6571        CarryArray()
    6672        {
    67             memset (cq, 0, sizeof(BitBlock) * (CarryCount + AdvanceNCount));
     73            memset (cq, 0, sizeof(carry_t) * (CarryCount + AdvanceNCount));
    6874            //memset(pending64, 0, sizeof(BitBlock) * AdvanceNCount);
    6975        }
    7076        ~CarryArray() {}
    7177
    72         IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_ci_co(BitBlock strm, BitBlock carryin, uint16_t carryno)
     78        IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_ci_co(BitBlock strm, carry_t carryin, uint16_t carryno)
    7379        {
    7480                BitBlock rslt;
     
    7783        }
    7884
    79         IDISA_ALWAYS_INLINE BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, BitBlock carryin, const uint16_t carryno)
     85        IDISA_ALWAYS_INLINE BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, carry_t carryin, const uint16_t carryno)
    8086        {
    8187                BitBlock sum;
     
    8490        }
    8591
    86         IDISA_ALWAYS_INLINE BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, BitBlock carryin, uint16_t carryno)
     92        IDISA_ALWAYS_INLINE BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, carry_t carryin, uint16_t carryno)
    8793        {
    8894                BitBlock diff;
     
    9197        }
    9298
    93         IDISA_ALWAYS_INLINE BitBlock BitBlock_scantofirst(BitBlock charclass, BitBlock carryin, uint16_t carryno)
     99        IDISA_ALWAYS_INLINE BitBlock BitBlock_scantofirst(BitBlock charclass, carry_t carryin, uint16_t carryno)
    94100        {
    95101                BitBlock marker;
     
    100106        }
    101107
    102         IDISA_ALWAYS_INLINE BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, BitBlock carryin, uint16_t carryno)
     108        IDISA_ALWAYS_INLINE BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, carry_t carryin, uint16_t carryno)
    103109        {
    104110                BitBlock markers1;
     
    107113        }
    108114
    109         IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_then_scanthru(BitBlock markers0, BitBlock charclass, BitBlock carryin, uint16_t carryno)
     115        IDISA_ALWAYS_INLINE BitBlock BitBlock_advance_then_scanthru(BitBlock markers0, BitBlock charclass, carry_t carryin, uint16_t carryno)
    110116        {
    111117                BitBlock markers1;
     
    115121        }
    116122
    117         IDISA_ALWAYS_INLINE BitBlock BitBlock_span_upto(BitBlock starts, BitBlock follows, BitBlock carryin, uint16_t carryno)
     123        IDISA_ALWAYS_INLINE BitBlock BitBlock_span_upto(BitBlock starts, BitBlock follows, carry_t carryin, uint16_t carryno)
    118124        {
    119125                BitBlock span;
     
    122128        }
    123129
    124         IDISA_ALWAYS_INLINE BitBlock BitBlock_inclusive_span(BitBlock starts, BitBlock ends, BitBlock carryin, uint16_t carryno)
     130        IDISA_ALWAYS_INLINE BitBlock BitBlock_inclusive_span(BitBlock starts, BitBlock ends, carry_t carryin, uint16_t carryno)
    125131        {
    126132                BitBlock span;
     
    129135        }
    130136
    131         IDISA_ALWAYS_INLINE BitBlock BitBlock_exclusive_span(BitBlock starts, BitBlock ends, BitBlock carryin, uint16_t carryno)
     137        IDISA_ALWAYS_INLINE BitBlock BitBlock_exclusive_span(BitBlock starts, BitBlock ends, carry_t carryin, uint16_t carryno)
    132138        {
    133139                BitBlock span;
     
    136142        }
    137143
    138 
     144/*
    139145        IDISA_ALWAYS_INLINE BitBlock BitBlock_advance32_ci_co(BitBlock strm, uint32_t pending_in, uint32_t & pending_out)
    140146        {
     
    142148                return simd_or(simd<BLOCK_SIZE>::slli<32>(strm), mvmd<BLOCK_SIZE>::fill((uint64_t)pending_in));
    143149        }
    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)
    146154        {
    147155                BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in);
     
    152160                return result;
    153161        }
     162*/
    154163
    155164        IDISA_ALWAYS_INLINE bool CarryTest(uint16_t carryno, uint16_t carry_count)
    156165        {
    157                   BitBlock c1 = cq[carryno];
     166                  carry_t c1 = cq[carryno];
    158167                  int ubound = carryno + carry_count;
    159168                  for (int i = carryno + 1; i < ubound ; i++) {
     
    163172        }
    164173
    165         IDISA_ALWAYS_INLINE BitBlock CarryRange(uint16_t carryno, uint16_t carry_count)
    166         {
    167                   BitBlock c1 = cq[carryno];
     174        IDISA_ALWAYS_INLINE carry_t CarryRange(uint16_t carryno, uint16_t carry_count)
     175        {
     176                  carry_t c1 = cq[carryno];
    168177                  int ubound = carryno + carry_count;
    169178                  for (int i = carryno + 1; i < ubound ; i++) {
     
    189198        }
    190199
    191         IDISA_ALWAYS_INLINE void CarryCombine(BitBlock local_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)
    192201        {
    193202                  for (int i = 0; i < carry_count; i++) {
     
    202211        }
    203212
    204         IDISA_ALWAYS_INLINE BitBlock get_carry_in(uint16_t carryno) const
    205         {
    206                 return carry2bitblock(cq[carryno]);
    207         }
    208 
    209         // Deprecated (renamed)
    210         IDISA_ALWAYS_INLINE BitBlock GetCarry(uint16_t carryno) const
    211         {
    212                 return carry2bitblock(cq[carryno]);
    213         }
    214 
    215         IDISA_ALWAYS_INLINE void SetCarry(BitBlock carryVal, 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)
    216225        {
    217226                cq[carryno] = carryVal;
     
    220229
    221230        // Deprecated in PabloJ, retained for legacy compiler.
    222         IDISA_ALWAYS_INLINE BitBlock get_pending64(uint16_t advance_n_blkno) const
     231        IDISA_ALWAYS_INLINE carry_t get_pending64(uint16_t advance_n_blkno) const
    223232        {
    224233                return cq[CarryCount + advance_n_blkno];
    225234        }
    226235
    227         IDISA_ALWAYS_INLINE BitBlock Pending64(uint16_t advance_n_blkno) const
     236        IDISA_ALWAYS_INLINE carry_t Pending64(uint16_t advance_n_blkno) const
    228237        {
    229238                return cq[CarryCount + advance_n_blkno];
     
    232241//private:
    233242        // helpers
    234 
    235         // Deprecated (renamed)
    236         IDISA_ALWAYS_INLINE BitBlock carry_flip(BitBlock carry) const
     243#ifndef  CARRY64
     244        // Deprecated (renamed)
     245        IDISA_ALWAYS_INLINE carry_t carry_flip(carry_t carry) const
    237246        {
    238247                return simd_xor(carry, Carry1);
    239248        }
    240249
    241         IDISA_ALWAYS_INLINE BitBlock CarryFlip(BitBlock carry) const
     250        IDISA_ALWAYS_INLINE BitBlock CarryFlip(carry_t carry) const
    242251        {
    243252                return simd_xor(carry, Carry1);
    244253        }
    245254
    246         IDISA_ALWAYS_INLINE bool test_carry(BitBlock carry) const
     255        IDISA_ALWAYS_INLINE bool test_carry(carry_t carry) const
    247256        {
    248257                return bitblock::any(carry);
    249258        }
    250259
    251         IDISA_ALWAYS_INLINE BitBlock carry_or(BitBlock carry1, BitBlock carry2) const
     260        IDISA_ALWAYS_INLINE carry_t carry_or(carry_t carry1, carry_t carry2) const
    252261        {
    253262                return simd_or(carry1, carry2);
    254263        }
    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
    258287
    259288};
Note: See TracChangeset for help on using the changeset viewer.