Ignore:
Timestamp:
Sep 27, 2015, 1:32:27 AM (4 years ago)
Author:
nmedfort
Message:

Progress on multi-target UCD compiler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4792 r4797  
    319319   
    320320   
    321 // Use field size 32 for BLOCK_SIZE 256, so that signmasks are i8.
    322 #if (BLOCK_SIZE==256)
    323 //#define PARALLEL_LONG_ADD
    324 #define PARALLEL_LONG_ADD_DIGIT_SIZE 32
    325 #endif
    326    
    327321/* Methods for getting and setting individual carry values. */
    328322   
     
    340334void CarryManager::setCarryOpCarryOut(unsigned localIndex, Value * carry_out_strm) {
    341335    unsigned posn = carryOpPosition(localIndex);
    342 #ifndef PARALLEL_LONG_ADD
    343336    if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
    344337        extractAndSaveCarryOutBits(carry_out_strm, posn, 1);
     
    351344        }
    352345    }
    353 #else
    354     if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
    355         // Carry is at low bit position
    356         unsigned packIndex = posn / mPACK_SIZE;
    357         unsigned packOffset = posn % mPACK_SIZE;
    358         Value * field = mBuilder->CreateZExt(carry_out_strm, mBuilder->getIntNTy(mPACK_SIZE));
    359         if (packOffset != 0) {
    360             field = mBuilder->CreateShl(field, mBuilder->getInt64(packOffset));
    361         }
    362         if (mCarryOutPack[packIndex] == nullptr) {
    363             mCarryOutPack[packIndex] = field;
    364         }
    365         else {
    366             mCarryOutPack[packIndex] = mBuilder->CreateOr(mCarryOutPack[packIndex], field);
    367         }       
    368     }
    369     else {
    370         Value * carry_bit = mBuilder->CreateZExt(carry_out_strm, mBuilder->getIntNTy(BLOCK_SIZE));
    371         mCarryOutPack[posn] = mBuilder->CreateBitCast(carry_bit, mBitBlockType);
    372         if (mCarryInfo->getWhileDepth() == 0) {
    373             storeCarryPack(posn);
    374         }
    375     }
    376 
    377    
    378 #endif
    379 }
    380 
    381    
    382    
     346}
     347
    383348Value* CarryManager::genShiftLeft64(Value* e) {
    384349    Value* i128_val = mBuilder->CreateBitCast(e, mBuilder->getIntNTy(BLOCK_SIZE));
     
    386351}
    387352
    388 Value* MatchStar(IRBuilder<> * b, Value * m, Value * c) {
    389     return b->CreateOr(b->CreateXor(b->CreateAdd(b->CreateAnd(m, c), c), c), m);
    390 }
    391        
    392353Value * CarryManager::addCarryInCarryOut(int localIndex, Value* e1, Value* e2) {
    393354#if (BLOCK_SIZE == 128)
     
    404365    setCarryOpCarryOut(localIndex, carry_out_strm);
    405366    return sum;
    406 #elif (defined(PARALLEL_LONG_ADD))
     367#else
    407368    //BLOCK_SIZE == 256, there is no other implementation
    408     Type * longAddVectorType = VectorType::get(mBuilder->getIntNTy(PARALLEL_LONG_ADD_DIGIT_SIZE), BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE);
    409     Type * longAddBitMaskIntegerType = mBuilder->getIntNTy(BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE);
    410     Type * longAddBitMaskVectorType = VectorType::get(mBuilder->getIntNTy(1), BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE);
    411     // double the mask size to allow room for carry-out.
    412     Type * longAddBitMaskManipulationType = mBuilder->getIntNTy(2 * BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE);
    413     Value * all_ones = Constant::getAllOnesValue(longAddVectorType);
    414     Value * carryin = iBuilder->mvmd_extract(2 * BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE, getCarryOpCarryIn(localIndex), 0);
    415     Value * carrygen = mBuilder->CreateAnd(e1, e2, "carrygen");
    416     Value * carryprop = mBuilder->CreateOr(e1, e2, "carryprop");
    417     // Sum individual digits.
    418     Value * digitsum = iBuilder->simd_add(PARALLEL_LONG_ADD_DIGIT_SIZE, e1, e2);
    419     Value * digitcarry = mBuilder->CreateOr(carrygen, mBuilder->CreateAnd(carryprop, mBuilder->CreateNot(digitsum)));
    420     Value * carry_mask = mBuilder->CreateZExt(iBuilder->hsimd_signmask(PARALLEL_LONG_ADD_DIGIT_SIZE, digitcarry), longAddBitMaskManipulationType);
    421     Value * bubble_fields = iBuilder->simd_eq(PARALLEL_LONG_ADD_DIGIT_SIZE, digitsum, all_ones);
    422     Value * bubble_mask = mBuilder->CreateZExt(iBuilder->hsimd_signmask(PARALLEL_LONG_ADD_DIGIT_SIZE, bubble_fields), longAddBitMaskManipulationType);
    423     Value * carry_markers = mBuilder->CreateAdd(mBuilder->CreateAdd(carry_mask, carry_mask), carryin); 
    424     Value * increments = MatchStar(mBuilder, carry_markers, bubble_mask);
    425     Value * carry_out = mBuilder->CreateLShr(increments, BLOCK_SIZE/PARALLEL_LONG_ADD_DIGIT_SIZE);
    426     Value * spread = mBuilder->CreateZExt(mBuilder->CreateBitCast(mBuilder->CreateTrunc(increments, longAddBitMaskIntegerType), longAddBitMaskVectorType), longAddVectorType);
    427     Value* sum = iBuilder->simd_add(PARALLEL_LONG_ADD_DIGIT_SIZE, digitsum, spread);
    428     setCarryOpCarryOut(localIndex, carry_out);
    429     return sum;
    430 #else
    431     //BLOCK_SIZE == 256, default implementation
    432369    Value * carryq_value = getCarryOpCarryIn(localIndex);
    433370    Value* carrygen = mBuilder->CreateAnd(e1, e2, "carrygen");
     
    522459 }
    523460 */
     461
    524462   
    525463Value * CarryManager::longAdvanceCarryInCarryOut(int localIndex, unsigned shift_amount, Value * carry_out) {
Note: See TracChangeset for help on using the changeset viewer.