 Timestamp:
 Jul 24, 2015, 11:47:14 AM (4 years ago)
 Location:
 icGREP/icgrepdevel/icgrep
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/IDISA/idisa_builder.cpp
r4665 r4697 151 151 } 152 152 153 Value * IDISA_Builder::mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex) { 154 Value * aVec = fwCast(fw, a); 155 return mLLVMBuilder>CreateExtractElement(aVec, mLLVMBuilder>getInt32(fieldIndex)); 156 } 157 153 158 Value * IDISA_Builder::mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift) { 154 159 unsigned field_count = mBitBlockSize/fw; 
icGREP/icgrepdevel/icgrep/IDISA/idisa_builder.h
r4665 r4697 58 58 Value * hsimd_signmask(unsigned fw, Value * a); 59 59 60 61 Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex); 60 62 Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift); 61 63 
icGREP/icgrepdevel/icgrep/pablo/carry_data.h
r4696 r4697 92 92 } 93 93 94 unsigned longAdvanceCarryDataOffset(unsigned advanceIndex) const {95 return fullOrPartialBlocks(longAdvance.frameOffsetinBits, BLOCK_SIZE) + advanceIndex;96 }97 98 94 unsigned longAdvanceEntries(unsigned shift_amount) const { 99 95 return fullOrPartialBlocks(shift_amount, BLOCK_SIZE); … … 105 101 106 102 bool blockHasLongAdvances() const { return longAdvance.entries > 0;} 107 108 unsigned shortAdvanceCarryDataOffset(unsigned advanceIndex) const {109 return fullOrPartialBlocks(shortAdvance.frameOffsetinBits, PACK_SIZE) + advanceIndex;110 }111 112 unsigned unitAdvanceCarryDataOffset(unsigned advanceIndex) const {113 return fullOrPartialBlocks(advance1.frameOffsetinBits, PACK_SIZE) + advanceIndex;114 }115 116 unsigned carryOpCarryDataOffset(unsigned idx) const {117 return fullOrPartialBlocks(addWithCarry.frameOffsetinBits, PACK_SIZE) + idx;118 }119 120 unsigned summaryCarryDataIndex() const {121 return fullOrPartialBlocks(summary.frameOffsetinBits, PACK_SIZE);122 }123 103 124 104 unsigned getLocalCarryPackIndex () { return shortAdvance.frameOffsetinBits / PACK_SIZE; } 
icGREP/icgrepdevel/icgrep/pablo/carry_manager.cpp
r4696 r4697 146 146 /* Helper routines */ 147 147 148 unsigned CarryManager::absPosition(unsigned frameOffsetinBits, unsigned relPos) { 149 #ifdef PACKING 150 return mCurrentFrameIndex + frameOffsetinBits + relPos; 151 #else 152 return mCurrentFrameIndex + frameOffsetinBits/BLOCK_SIZE + relPos; 153 #endif 154 } 155 156 157 unsigned CarryManager::carryOpPosition(unsigned localIndex) { 158 return absPosition(mCarryInfo>addWithCarry.frameOffsetinBits, localIndex); 159 } 160 161 unsigned CarryManager::advance1Position(unsigned localIndex) { 162 return absPosition(mCarryInfo>advance1.frameOffsetinBits, localIndex); 163 } 164 165 unsigned CarryManager::shortAdvancePosition(unsigned localIndex) { 166 return absPosition(mCarryInfo>shortAdvance.frameOffsetinBits, localIndex); 167 } 168 169 unsigned CarryManager::longAdvancePosition(unsigned localIndex) { 170 return absPosition(mCarryInfo>longAdvance.frameOffsetinBits, localIndex); 171 } 172 173 unsigned CarryManager::summaryPosition() { 174 return absPosition(mCarryInfo>summary.frameOffsetinBits, 0); 175 } 176 177 unsigned CarryManager::summaryBits() { 178 return mCarryInfo>summary.allocatedBits; 179 } 180 181 148 182 149 183 Value * CarryManager::getCarryPack(unsigned packIndex) { … … 199 233 200 234 Value * CarryManager::getCarryOpCarryIn(int localIndex) { 201 unsigned cd_index = mCurrentFrameIndex + mCarryInfo>carryOpCarryDataOffset(localIndex);202 #ifdef PACKING 203 return getCarryBit( cd_index);204 #else 205 return getCarryPack( cd_index);235 unsigned posn = carryOpPosition(localIndex); 236 #ifdef PACKING 237 return getCarryBit(posn); 238 #else 239 return getCarryPack(posn); 206 240 #endif 207 241 } … … 209 243 210 244 void CarryManager::setCarryOpCarryOut(unsigned localIndex, Value * carry_out) { 211 #ifdef PACKING 212 #else 213 unsigned cd_index = mCurrentFrameIndex + mCarryInfo>carryOpCarryDataOffset(localIndex); 214 mCarryOutPack[cd_index] = carry_out; 245 unsigned posn = carryOpPosition(localIndex); 246 #ifdef PACKING 247 setCarryBits(posn, carry_out); 248 #else 249 mCarryOutPack[posn] = carry_out; 215 250 if (mCarryInfo>getWhileDepth() == 0) { 216 storeCarryPack( cd_index);251 storeCarryPack(posn); 217 252 } 218 253 #endif … … 233 268 234 269 Value * CarryManager::unitAdvanceCarryInCarryOut(int localIndex, Value * strm) { 235 #ifdef PACKING 236 #else 237 238 unsigned carryDataIndex = mCurrentFrameIndex + mCarryInfo>unitAdvanceCarryDataOffset(localIndex); 239 mCarryOutPack[carryDataIndex] = strm; 240 Value * carry_in = getCarryPack(carryDataIndex); 270 unsigned posn = advance1Position(localIndex); 271 #ifdef PACKING 272 unsigned offset = posn % PACK_SIZE; 273 unsigned rshift = PACK_SIZE  offset  1; 274 Value * field = iBuilder>mvmd_extract(PACK_SIZE, strm, BLOCK_SIZE/PACK_SIZE  1); 275 if (rshift != 0) { 276 field = mBuilder>CreateLShr(field, mBuilder>getInt64(rshift)); 277 } 278 if (offset != 0) { 279 field = mBuilder>CreateAnd(field, mBuilder>getInt64(1<<offset)); 280 } 281 setCarryBits(posn  offset, field); 282 Value* carry_longint = mBuilder>CreateZExt(getCarryBit(posn), mBuilder>getIntNTy(BLOCK_SIZE)); 283 Value* strm_longint = mBuilder>CreateBitCast(strm, mBuilder>getIntNTy(BLOCK_SIZE)); 284 Value* adv_longint = mBuilder>CreateOr(mBuilder>CreateShl(strm_longint, 1), carry_longint); 285 result_value = mBuilder>CreateBitCast(adv_longint, mBitBlockType); 286 return result_value; 287 #else 288 mCarryOutPack[posn] = strm; 289 Value * carry_in = getCarryPack(posn); 241 290 if (mCarryInfo>getWhileDepth() == 0) { 242 storeCarryPack( carryDataIndex);291 storeCarryPack(posn); 243 292 } 244 293 Value* result_value; … … 259 308 260 309 Value * CarryManager::shortAdvanceCarryInCarryOut(int localIndex, int shift_amount, Value * strm) { 261 #ifdef PACKING 262 #else 263 unsigned carryDataIndex = mCurrentFrameIndex + mCarryInfo>shortAdvanceCarryDataOffset(localIndex); 264 mCarryOutPack[carryDataIndex] = strm; 265 Value * carry_in = getCarryPack(carryDataIndex); 310 unsigned posn = shortAdvancePosition(localIndex); 311 #ifdef PACKING 312 unsigned offset = posn % PACK_SIZE; 313 unsigned rshift = PACK_SIZE  offset  shift_amount; 314 Value * field = iBuilder>mvmd_extract(PACK_SIZE, strm, BLOCK_SIZE/PACK_SIZE  1); 315 if (rshift != 0) { 316 field = mBuilder>CreateLShr(field, mBuilder>getInt64(rshift)); 317 } 318 if (offset != 0) { 319 field = mBuilder>CreateAnd(field, mBuilder>getInt64(((1<<shift_amount)  1) << offset)); 320 } 321 setCarryBits(posn  offset, field); 322 Value* carry_longint = mBuilder>CreateZExt(getCarryRange(posn, shift_amount), mBuilder>getIntNTy(BLOCK_SIZE)); 323 Value* strm_longint = mBuilder>CreateBitCast(strm, mBuilder>getIntNTy(BLOCK_SIZE)); 324 Value* adv_longint = mBuilder>CreateOr(mBuilder>CreateShl(strm_longint, 1), carry_longint); 325 result_value = mBuilder>CreateBitCast(adv_longint, mBitBlockType); 326 return result_value; 327 #else 328 mCarryOutPack[posn] = strm; 329 Value * carry_in = getCarryPack(posn); 266 330 if (mCarryInfo>getWhileDepth() == 0) { 267 storeCarryPack( carryDataIndex);331 storeCarryPack(posn); 268 332 } 269 333 Value* advanceq_longint = mBuilder>CreateBitCast(carry_in, mBuilder>getIntNTy(BLOCK_SIZE)); … … 294 358 295 359 Value * CarryManager::longAdvanceCarryInCarryOut(int localIndex, int shift_amount, Value * carry_out) { 296 unsigned carryDataIndex = mCurrentFrameIndex + mCarryInfo>longAdvanceCarryDataOffset(localIndex);360 unsigned carryDataIndex = longAdvancePosition(localIndex); 297 361 Value * advBaseIndex = mBuilder>getInt64(carryDataIndex); 298 362 if (shift_amount <= BLOCK_SIZE) { … … 339 403 340 404 Value * CarryManager::getCarrySummaryExpr() { 341 #ifdef PACKING 342 #else 343 unsigned summary_idx = mCurrentFrameIndex + mCarryInfo>summaryCarryDataIndex(); 344 return getCarryPack(summary_idx); 405 unsigned summary_posn = summaryPosition(); 406 #ifdef PACKING 407 return getCarryRange(summary_posn, getSummaryBits()); 408 #else 409 return getCarryPack(summary_posn); 345 410 #endif 346 411 } … … 352 417 return; 353 418 } 354 const unsigned carrySummaryIndex = mCurrentFrameIndex + mCarryInfo>summaryCarryDataIndex();419 const unsigned carrySummaryIndex = summaryPosition(); 355 420 PHINode * summary_phi = mBuilder>CreatePHI(mBitBlockType, 2, "summary"); 356 421 summary_phi>addIncoming(mZeroInitializer, ifEntryBlock); … … 368 433 } 369 434 370 const unsigned carrySummaryIndex = mCurrentFrameIndex + mCarryInfo>summaryCarryDataIndex();435 const unsigned carrySummaryIndex = summaryPosition(); 371 436 372 437 Value * carry_summary = mZeroInitializer; … … 390 455 enterScope(inner_blk); 391 456 if (blockHasCarries()) { 392 carry_summary = mBuilder>CreateOr(carry_summary, mCarryOutPack[ mCurrentFrameIndex + mCarryInfo>summaryCarryDataIndex()]);457 carry_summary = mBuilder>CreateOr(carry_summary, mCarryOutPack[summaryPosition()]); 393 458 } 394 459 leaveScope(); … … 398 463 enterScope(inner_blk); 399 464 if (blockHasCarries()) { 400 carry_summary = mBuilder>CreateOr(carry_summary, mCarryOutPack[ mCurrentFrameIndex + mCarryInfo>summaryCarryDataIndex()]);465 carry_summary = mBuilder>CreateOr(carry_summary, mCarryOutPack[summaryPosition()]); 401 466 } 402 467 leaveScope(); 
icGREP/icgrepdevel/icgrep/pablo/carry_manager.h
r4696 r4697 136 136 void setCarryBits(unsigned carryBit_lo, Value * bits); 137 137 138 139 138 unsigned absPosition(unsigned frameOffsetinBits, unsigned relPos); 139 unsigned carryOpPosition(unsigned localIndex) ; 140 unsigned advance1Position(unsigned localIndex); 141 unsigned shortAdvancePosition(unsigned localIndex); 142 unsigned longAdvancePosition(unsigned localIndex); 143 unsigned summaryPosition(); 144 unsigned summaryBits(); 145 140 146 }; 141 147
Note: See TracChangeset
for help on using the changeset viewer.