Changeset 4797 for icGREP/icgrepdevel/icgrep/pablo/carry_manager.cpp
 Timestamp:
 Sep 27, 2015, 1:32:27 AM (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/pablo/carry_manager.cpp
r4792 r4797 319 319 320 320 321 // Use field size 32 for BLOCK_SIZE 256, so that signmasks are i8.322 #if (BLOCK_SIZE==256)323 //#define PARALLEL_LONG_ADD324 #define PARALLEL_LONG_ADD_DIGIT_SIZE 32325 #endif326 327 321 /* Methods for getting and setting individual carry values. */ 328 322 … … 340 334 void CarryManager::setCarryOpCarryOut(unsigned localIndex, Value * carry_out_strm) { 341 335 unsigned posn = carryOpPosition(localIndex); 342 #ifndef PARALLEL_LONG_ADD343 336 if (mITEMS_PER_PACK > 1) {// #ifdef PACKING 344 337 extractAndSaveCarryOutBits(carry_out_strm, posn, 1); … … 351 344 } 352 345 } 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 383 348 Value* CarryManager::genShiftLeft64(Value* e) { 384 349 Value* i128_val = mBuilder>CreateBitCast(e, mBuilder>getIntNTy(BLOCK_SIZE)); … … 386 351 } 387 352 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 392 353 Value * CarryManager::addCarryInCarryOut(int localIndex, Value* e1, Value* e2) { 393 354 #if (BLOCK_SIZE == 128) … … 404 365 setCarryOpCarryOut(localIndex, carry_out_strm); 405 366 return sum; 406 #el if (defined(PARALLEL_LONG_ADD))367 #else 407 368 //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 carryout.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 #else431 //BLOCK_SIZE == 256, default implementation432 369 Value * carryq_value = getCarryOpCarryIn(localIndex); 433 370 Value* carrygen = mBuilder>CreateAnd(e1, e2, "carrygen"); … … 522 459 } 523 460 */ 461 524 462 525 463 Value * CarryManager::longAdvanceCarryInCarryOut(int localIndex, unsigned shift_amount, Value * carry_out) {
Note: See TracChangeset
for help on using the changeset viewer.