Ignore:
Timestamp:
Feb 14, 2017, 12:45:42 PM (2 years ago)
Author:
cameron
Message:

Simplify stream set access; better naming of access functions

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r5310 r5317  
    2121    Value * codeUnitPack[packCount];
    2222    for (unsigned i = 0; i < packCount; i++) {
    23         Value * ptr = getInputStream("codeUnitStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    24         codeUnitPack[i] = iBuilder->CreateBlockAlignedLoad(ptr);
     23        codeUnitPack[i] = loadInputStreamPack("codeUnitStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    2524    }
    2625    for (unsigned j = 0; j < mCharClasses.size();  j++) {
     
    5655            theCCstream = iBuilder->simd_or(theCCstream, pack);
    5756        }
    58         Value * ptr = getOutputStream("ccStream", iBuilder->getInt32(j));
    59         iBuilder->CreateBlockAlignedStore(theCCstream, ptr);
     57        storeOutputStreamBlock("ccStream", iBuilder->getInt32(j), theCCstream);
    6058    }
    6159}
  • icGREP/icgrep-devel/icgrep/kernels/cc_scan_kernel.cpp

    r5315 r5317  
    2626    std::vector<Value * > matchWordVectors;
    2727    for(unsigned d = 0; d < mStreamNum; d++) {
    28         Value * ptr = getInputStream("matchResults", iBuilder->getInt32(d));
    29         Value * matches = iBuilder->CreateBlockAlignedLoad(ptr);
     28        Value * matches = loadInputStreamBlock("matchResults", iBuilder->getInt32(d));
    3029        matchWordVectors.push_back(iBuilder->CreateBitCast(matches, scanwordVectorType));
    3130    }
  • icGREP/icgrep-devel/icgrep/kernels/deletion.cpp

    r5313 r5317  
    5555
    5656void DeletionKernel::generateDoBlockMethod() {
    57     Value * delMaskPtr = getInputStream("delMaskSet", iBuilder->getInt32(0));
    58     Value * delMask = iBuilder->CreateBlockAlignedLoad(delMaskPtr);
     57    Value * delMask = loadInputStreamBlock("delMaskSet", iBuilder->getInt32(0));
    5958    const auto move_masks = parallel_prefix_deletion_masks(iBuilder, mDeletionFieldWidth, delMask);
    6059    for (unsigned j = 0; j < mStreamCount; ++j) {
    61         Value * inputStreamPtr = getInputStream("inputStreamSet", iBuilder->getInt32(j));
    62         Value * input = iBuilder->CreateBlockAlignedLoad(inputStreamPtr);
     60        Value * input = loadInputStreamBlock("inputStreamSet", iBuilder->getInt32(j));
    6361        Value * output = apply_parallel_prefix_deletion(iBuilder, mDeletionFieldWidth, delMask, move_masks, input);
    64         Value * outputStreamPtr = getOutputStream("outputStreamSet", iBuilder->getInt32(j));
    65         iBuilder->CreateBlockAlignedStore(output, outputStreamPtr);
     62        storeOutputStreamBlock("outputStreamSet", iBuilder->getInt32(j), output);
    6663    }
    6764    Value * delCount = partial_sum_popcount(iBuilder, mDeletionFieldWidth, iBuilder->simd_not(delMask));
    68     Value * delCountPtr = getOutputStream("deletionCounts", iBuilder->getInt32(0));
    69     iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(delCount), delCountPtr);
     65    storeOutputStreamBlock("deletionCounts", iBuilder->getInt32(0), iBuilder->bitCast(delCount));
    7066}
    7167
     
    7470    Value * remaining = iBuilder->CreateZExt(remainingBytes, vecTy);
    7571    Value * EOF_del = iBuilder->bitCast(iBuilder->CreateShl(Constant::getAllOnesValue(vecTy), remaining));
    76     Value * const delmaskPtr = getInputStream("delMaskSet", iBuilder->getInt32(0));
    77     Value * delMask = iBuilder->CreateOr(EOF_del, iBuilder->CreateBlockAlignedLoad(delmaskPtr));
     72    Value * delMask = iBuilder->CreateOr(EOF_del, loadInputStreamBlock("delMaskSet", iBuilder->getInt32(0)));
    7873    const auto move_masks = parallel_prefix_deletion_masks(iBuilder, mDeletionFieldWidth, delMask);
    7974    for (unsigned j = 0; j < mStreamCount; ++j) {
    80         Value * inputStreamPtr = getInputStream("inputStreamSet", iBuilder->getInt32(j));
    81         Value * input = iBuilder->CreateBlockAlignedLoad(inputStreamPtr);
     75        Value * input = loadInputStreamBlock("inputStreamSet", iBuilder->getInt32(j));
    8276        Value * output = apply_parallel_prefix_deletion(iBuilder, mDeletionFieldWidth, delMask, move_masks, input);
    83         Value * outputStreamPtr = getOutputStream("outputStreamSet", iBuilder->getInt32(j));
    84         iBuilder->CreateBlockAlignedStore(output, outputStreamPtr);
     77        storeOutputStreamBlock("outputStreamSet", iBuilder->getInt32(j), output);
    8578    }
    8679    Value * delCount = partial_sum_popcount(iBuilder, mDeletionFieldWidth, iBuilder->simd_not(delMask));
    87     Value * delCountPtr = getOutputStream("deletionCounts", iBuilder->getInt32(0));
    88     iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(delCount), delCountPtr);
     80    storeOutputStreamBlock("deletionCounts", iBuilder->getInt32(0), iBuilder->bitCast(delCount));
    8981}
    9082
     
    132124
    133125void DeleteByPEXTkernel::generateDoBlockMethod() {
    134     Value * delMaskPtr = getInputStream("delMaskSet", iBuilder->getInt32(0));
    135     Value * delMask = iBuilder->CreateBlockAlignedLoad(delMaskPtr);
     126    Value * delMask = loadInputStreamBlock("delMaskSet", iBuilder->getInt32(0));
    136127    const auto masks = get_PEXT_masks(iBuilder, delMask);
    137128    for (unsigned j = 0; j < mStreamCount; ++j) {
    138         Value * inputStreamPtr = getInputStream("inputStreamSet", iBuilder->getInt32(j));
    139         Value * input = iBuilder->CreateBlockAlignedLoad(inputStreamPtr);
     129        Value * input = loadInputStreamBlock("inputStreamSet", iBuilder->getInt32(j));
    140130        Value * output = apply_PEXT_deletion(iBuilder, masks, input);
    141         Value * outputStreamPtr = getOutputStream("outputStreamSet", iBuilder->getInt32(j));
    142         iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(output), outputStreamPtr);
     131        storeOutputStreamBlock("outputStreamSet", iBuilder->getInt32(j), output);
    143132    }
    144133    Value * delCount = partial_sum_popcount(iBuilder, mDelCountFieldWidth, apply_PEXT_deletion(iBuilder, masks, iBuilder->simd_not(delMask)));
    145     Value * delCountPtr = getOutputStream("deletionCounts", iBuilder->getInt32(0));
    146     iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(delCount), delCountPtr);
     134    storeOutputStreamBlock("deletionCounts", iBuilder->getInt32(0), iBuilder->bitCast(delCount));
    147135}
    148136
     
    151139    Value * remaining = iBuilder->CreateZExt(remainingBytes, vecTy);
    152140    Value * EOF_del = iBuilder->bitCast(iBuilder->CreateShl(Constant::getAllOnesValue(vecTy), remaining));
    153     Value * const delmaskPtr = getInputStream("delMaskSet", iBuilder->getInt32(0));
    154     Value * delMask = iBuilder->CreateOr(EOF_del, iBuilder->CreateBlockAlignedLoad(delmaskPtr));
     141    Value * delMask = iBuilder->CreateOr(EOF_del, loadInputStreamBlock("delMaskSet", iBuilder->getInt32(0)));
    155142    const auto masks = get_PEXT_masks(iBuilder, delMask);
    156143    for (unsigned j = 0; j < mStreamCount; ++j) {
    157         Value * inputStreamPtr = getInputStream("inputStreamSet", iBuilder->getInt32(j));
    158         Value * input = iBuilder->CreateBlockAlignedLoad(inputStreamPtr);
     144        Value * input = loadInputStreamBlock("inputStreamSet", iBuilder->getInt32(j));
    159145        Value * output = apply_PEXT_deletion(iBuilder, masks, input);
    160         Value * outputStreamPtr = getOutputStream("outputStreamSet", iBuilder->getInt32(j));
    161         iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(output), outputStreamPtr);
     146        storeOutputStreamBlock("outputStreamSet", iBuilder->getInt32(j), output);
    162147    }
    163148    Value * delCount = partial_sum_popcount(iBuilder, mDelCountFieldWidth, apply_PEXT_deletion(iBuilder, masks, iBuilder->simd_not(delMask)));
    164     Value * delCountPtr = getOutputStream("deletionCounts", iBuilder->getInt32(0));
    165     iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(delCount), delCountPtr);
     149    storeOutputStreamBlock("deletionCounts", iBuilder->getInt32(0), iBuilder->bitCast(delCount));
    166150}
    167151
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5311 r5317  
    256256}
    257257
    258 Value * KernelBuilder::getInputStream(const std::string & name, Value * streamIndex) const {
     258Value * KernelBuilder::getInputStreamBlockPtr(const std::string & name, Value * streamIndex) const {
    259259    Value * const blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
    260260    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
    261     return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
    262 }
    263 
    264 Value * KernelBuilder::getInputStream(const std::string & name, Value * streamIndex, Value * packIndex) const {
     261    return buf->getStreamBlockPtr(getStreamSetBufferPtr(name), streamIndex, blockIndex);
     262}
     263
     264Value * KernelBuilder::loadInputStreamBlock(const std::string & name, Value * streamIndex) const {
     265    return iBuilder->CreateBlockAlignedLoad(getInputStreamBlockPtr(name, streamIndex));
     266}
     267
     268Value * KernelBuilder::getInputStreamPackPtr(const std::string & name, Value * streamIndex, Value * packIndex) const {
    265269    Value * const blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
    266270    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
    267     return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
    268 }
    269 
    270 llvm::Value * KernelBuilder::getInputStream(Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const {
     271    return buf->getStreamPackPtr(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
     272}
     273
     274Value * KernelBuilder::loadInputStreamPack(const std::string & name, Value * streamIndex, Value * packIndex) const {
     275    return iBuilder->CreateBlockAlignedLoad(getInputStreamPackPtr(name, streamIndex, packIndex));
     276}
     277
     278llvm::Value * KernelBuilder::getAdjustedInputStreamBlockPtr(Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const {
    271279    Value * blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
    272280    blockIndex = iBuilder->CreateAdd(blockIndex, blockAdjustment);
    273281    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
    274     return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
    275 }
    276 
    277 Value * KernelBuilder::getOutputStream(const std::string & name, Value * streamIndex) const {
     282    return buf->getStreamBlockPtr(getStreamSetBufferPtr(name), streamIndex, blockIndex);
     283}
     284
     285Value * KernelBuilder::getOutputStreamBlockPtr(const std::string & name, Value * streamIndex) const {
    278286    Value * const blockIndex = computeBlockIndex(mStreamSetOutputs, name, getProducedItemCount(name));
    279287    const StreamSetBuffer * const buf = getOutputStreamSetBuffer(name);
    280     return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
    281 }
    282 
    283 Value * KernelBuilder::getOutputStream(const std::string & name, Value * streamIndex, Value * packIndex) const {
     288    return buf->getStreamBlockPtr(getStreamSetBufferPtr(name), streamIndex, blockIndex);
     289}
     290
     291void KernelBuilder::storeOutputStreamBlock(const std::string & name, Value * streamIndex, Value * toStore) const {
     292    return iBuilder->CreateBlockAlignedStore(toStore, getOutputStreamBlockPtr(name, streamIndex));
     293}
     294
     295Value * KernelBuilder::getOutputStreamPackPtr(const std::string & name, Value * streamIndex, Value * packIndex) const {
    284296    Value * const blockIndex = computeBlockIndex(mStreamSetOutputs, name, getProducedItemCount(name));
    285297    const StreamSetBuffer * const buf = getOutputStreamSetBuffer(name);
    286     return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
     298    return buf->getStreamPackPtr(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
     299}
     300
     301void KernelBuilder::storeOutputStreamPack(const std::string & name, Value * streamIndex, Value * packIndex, Value * toStore) const {
     302    return iBuilder->CreateBlockAlignedStore(toStore, getOutputStreamPackPtr(name, streamIndex, packIndex));
    287303}
    288304
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5311 r5317  
    171171    }
    172172
    173     llvm::Value * getInputStream(const std::string & name, llvm::Value * streamIndex) const;
    174 
    175     llvm::Value * getInputStream(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
    176 
    177     llvm::Value * getOutputStream(const std::string & name, llvm::Value * streamIndex) const;
    178 
    179     llvm::Value * getOutputStream(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
    180 
    181     llvm::Value * getInputStream(llvm::Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const;
     173    llvm::Value * getInputStreamBlockPtr(const std::string & name, llvm::Value * streamIndex) const;
     174   
     175    llvm::Value * loadInputStreamBlock(const std::string & name, llvm::Value * streamIndex) const;
     176   
     177    llvm::Value * getInputStreamPackPtr(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
     178   
     179    llvm::Value * loadInputStreamPack(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
     180   
     181    llvm::Value * getOutputStreamBlockPtr(const std::string & name, llvm::Value * streamIndex) const;
     182   
     183    void storeOutputStreamBlock(const std::string & name, llvm::Value * streamIndex, llvm::Value * toStore) const;
     184   
     185    llvm::Value * getOutputStreamPackPtr(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
     186   
     187    void storeOutputStreamPack(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex, llvm::Value * toStore) const;
     188   
     189    llvm::Value * getAdjustedInputStreamBlockPtr(llvm::Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const;
    182190
    183191    llvm::Value * getRawInputPointer(const std::string & name, llvm::Value * streamIndex, llvm::Value * absolutePosition) const;
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5310 r5317  
    4444    Value * p_bitblock[8];
    4545    for (unsigned i = 0; i < 8; i++) {
    46         Value * ptr = getInputStream("basisBits", iBuilder->getInt32(i));
    47         p_bitblock[i] = iBuilder->CreateBlockAlignedLoad(ptr);
     46        p_bitblock[i] = loadInputStreamBlock("basisBits", iBuilder->getInt32(i));
    4847    }
    4948    Value * s_bytepack[8];
    5049    p2s(iBuilder, p_bitblock, s_bytepack);
    5150    for (unsigned j = 0; j < 8; ++j) {
    52         Value * ptr = getOutputStream("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j));
    53         iBuilder->CreateBlockAlignedStore(s_bytepack[j], ptr);
     51        storeOutputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j), s_bytepack[j]);
    5452    }
    5553}
     
    7068    Value * basisBits[8];
    7169    for (unsigned i = 0; i < 8; i++) {
    72         Value * basisBitsBlock_ptr = getInputStream("basisBits", iBuilder->getInt32(i));
    73         basisBits[i] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr);
     70        basisBits[i] = loadInputStreamBlock("basisBits", iBuilder->getInt32(i));
    7471    }
    7572    Value * bytePack[8];
     
    7774
    7875    unsigned units_per_register = iBuilder->getBitBlockWidth()/8;
    79     Value * delCountBlock_ptr = getInputStream("deletionCounts", iBuilder->getInt32(0));
     76    Value * delCountBlock_ptr = getInputStreamBlockPtr("deletionCounts", iBuilder->getInt32(0));
    8077    Value * unit_counts = iBuilder->fwCast(units_per_register, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr));
    8178
    82     Value * output_ptr = getOutputStream("byteStream", iBuilder->getInt32(0));
     79    Value * output_ptr = getOutputStreamBlockPtr("byteStream", iBuilder->getInt32(0));
    8380    output_ptr = iBuilder->CreatePointerCast(output_ptr, iBuilder->getInt8PtrTy());
    8481    Value * offset = iBuilder->getInt32(0);
     
    106103    Value * hi_input[8];
    107104    for (unsigned j = 0; j < 8; ++j) {
    108         Value * ptr = getInputStream("basisBits", iBuilder->getInt32(0), iBuilder->getInt32(j));
    109         hi_input[j] = iBuilder->CreateBlockAlignedLoad(ptr);
     105        hi_input[j] = loadInputStreamBlock("basisBits", iBuilder->getInt32(j));
    110106    }
    111107    Value * hi_bytes[8];
     
    113109    Value * lo_input[8];
    114110    for (unsigned j = 0; j < 8; ++j) {
    115         Value * ptr = getInputStream("basisBits", iBuilder->getInt32(0), iBuilder->getInt32(j + 8));
    116         lo_input[j] = iBuilder->CreateBlockAlignedLoad(ptr);
     111        lo_input[j] = loadInputStreamBlock("basisBits", iBuilder->getInt32(j + 8));
    117112    }
    118113    Value * lo_bytes[8];
     
    121116        Value * merge0 = iBuilder->bitCast(iBuilder->esimd_mergel(8, hi_bytes[j], lo_bytes[j]));
    122117        Value * merge1 = iBuilder->bitCast(iBuilder->esimd_mergeh(8, hi_bytes[j], lo_bytes[j]));
    123         Value * ptr0 = getOutputStream("i16Stream", iBuilder->getInt32(2 * j));
    124         iBuilder->CreateBlockAlignedStore(merge0, ptr0);
    125         Value * ptr1 = getOutputStream("i16Stream", iBuilder->getInt32(2 * j + 1));
    126         iBuilder->CreateBlockAlignedStore(merge1, ptr1);
     118        storeOutputStreamPack("i16Stream", iBuilder->getInt32(0), iBuilder->getInt32(2 * j), merge0);
     119        storeOutputStreamPack("i16Stream", iBuilder->getInt32(0), iBuilder->getInt32(2 * j + 1), merge1);
    127120    }
    128121}
     
    146139    Value * hi_input[8];
    147140    for (unsigned j = 0; j < 8; ++j) {
    148         Value * ptr = getInputStream("basisBits", iBuilder->getInt32(j));
    149         hi_input[j] = iBuilder->CreateBlockAlignedLoad(ptr);
     141        hi_input[j] = loadInputStreamBlock("basisBits", iBuilder->getInt32(j));
    150142    }
    151143    Value * hi_bytes[8];
     
    154146    Value * lo_input[8];
    155147    for (unsigned j = 0; j < 8; ++j) {
    156         Value * ptr = getInputStream("basisBits", iBuilder->getInt32(j + 8));
    157         lo_input[j] = iBuilder->CreateBlockAlignedLoad(ptr);
     148        lo_input[j] = loadInputStreamBlock("basisBits", iBuilder->getInt32(j + 8));
    158149    }
    159150    Value * lo_bytes[8];
    160151    p2s(iBuilder, lo_input, lo_bytes);
    161152
    162     Value * delCountBlock_ptr = getInputStream("deletionCounts", iBuilder->getInt32(0));
     153    Value * delCountBlock_ptr = getInputStreamBlockPtr("deletionCounts", iBuilder->getInt32(0));
    163154    Value * unit_counts = iBuilder->fwCast(iBuilder->getBitBlockWidth() / 16, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr));
    164155
    165156
    166     Value * u16_output_ptr = getOutputStream("i16Stream", iBuilder->getInt32(0));
     157    Value * u16_output_ptr = getOutputStreamBlockPtr("i16Stream", iBuilder->getInt32(0));
    167158    u16_output_ptr = iBuilder->CreatePointerCast(u16_output_ptr, int16PtrTy);
    168159    Value * i16UnitsGenerated = getProducedItemCount("i16Stream"); // units generated to buffer
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5311 r5317  
    100100
    101101    // A block is made up of 8 packs.  Get the pointer to the first pack (changes the type of the pointer only).
    102     Value * sourcePackPtr = getInputStream("sourceStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
    103     Value * outputPackPtr = getOutputStream("expandedStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
     102    Value * sourcePackPtr = getInputStreamPackPtr("sourceStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
     103    Value * outputPackPtr = getOutputStreamPackPtr("expandedStream", iBuilder->getInt32(0), iBuilder->getInt32(0));
    104104
    105105    Value * hasFullLoop = iBuilder->CreateICmpUGE(loopItemsToDo, triplePackSize);
     
    284284void radix64Kernel::generateDoBlockMethod() {
    285285    for (unsigned i = 0; i < 8; i++) {
    286         Value * expandedStream = getInputStream("expandedStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    287         Value * bytepack = iBuilder->CreateBlockAlignedLoad(expandedStream);
     286        Value * bytepack = loadInputStreamPack("expandedStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    288287        Value * radix64pack = processPackData(bytepack);
    289         Value * radix64stream = getOutputStream("radix64stream",iBuilder->getInt32(0), iBuilder->getInt32(i));
    290         iBuilder->CreateBlockAlignedStore(radix64pack, radix64stream);
     288        storeOutputStreamPack("radix64stream",iBuilder->getInt32(0), iBuilder->getInt32(i), radix64pack);
    291289    }
    292290    Value * produced = getProducedItemCount("radix64stream");
     
    316314    loopRemain->addIncoming(remainingBytes, entry);
    317315
    318     Value * expandedStreamLoopPtr = getInputStream("expandedStream", iBuilder->getInt32(0), idx);
    319     Value * bytepack = iBuilder->CreateBlockAlignedLoad(expandedStreamLoopPtr);
     316    Value * bytepack = loadInputStreamPack("expandedStream", iBuilder->getInt32(0), idx);
    320317    Value * radix64pack = processPackData(bytepack);
    321 
    322     Value * radix64streamPtr = getOutputStream("radix64stream", iBuilder->getInt32(0), idx);
    323     iBuilder->CreateBlockAlignedStore(radix64pack, radix64streamPtr);
     318    storeOutputStreamPack("radix64stream", iBuilder->getInt32(0), idx, radix64pack);
    324319
    325320    Value* nextIdx = iBuilder->CreateAdd(idx, ConstantInt::get(iBuilder->getInt32Ty(), 1));
     
    357352    Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, iBuilder->getInt8(75))));
    358353    Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, iBuilder->getInt8(15))));
    359     return iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(12))));
     354    return iBuilder->bitCast(iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(12)))));
    360355}
    361356
    362357void base64Kernel::generateDoBlockMethod() {
    363358    for (unsigned i = 0; i < 8; i++) {
    364         Value * radix64stream_ptr = getInputStream("radix64stream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    365         Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64stream_ptr);
    366         Value* base64pack = processPackData(bytepack);
    367         Value * base64stream_ptr = getOutputStream("base64stream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    368         iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr);
     359        Value * bytepack = loadInputStreamPack("radix64stream", iBuilder->getInt32(0), iBuilder->getInt32(i));
     360        Value * base64pack = processPackData(bytepack);
     361        storeOutputStreamPack("base64stream", iBuilder->getInt32(0), iBuilder->getInt32(i), base64pack);
    369362    }
    370363    Value * produced = getProducedItemCount("base64stream");
     
    456449    idx->addIncoming(ConstantInt::getNullValue(iBuilder->getInt32Ty()), entry);
    457450    loopRemain->addIncoming(remainingBytes, entry);
    458     Value * radix64streamPtr = getInputStream("radix64stream", iBuilder->getInt32(0), idx);
    459     Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64streamPtr);
     451    Value * bytepack = loadInputStreamPack("radix64stream", iBuilder->getInt32(0), idx);
    460452    Value * base64pack = processPackData(bytepack);
    461     Value * base64streamPtr = getOutputStream("base64stream", iBuilder->getInt32(0), idx);
    462     iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64streamPtr);
     453    storeOutputStreamPack("base64stream", iBuilder->getInt32(0), idx, base64pack);
    463454    idx->addIncoming(iBuilder->CreateAdd(idx, ConstantInt::get(iBuilder->getInt32Ty(), 1)), base64_loop);
    464455    Value* remainAfterLoop = iBuilder->CreateSub(loopRemain, packSize);
     
    472463
    473464    iBuilder->SetInsertPoint(doPadding);
    474     Value * i8output_ptr = getOutputStream("base64stream", iBuilder->getInt32(0));
     465    Value * i8output_ptr = getOutputStreamBlockPtr("base64stream", iBuilder->getInt32(0));
    475466    i8output_ptr = iBuilder->CreatePointerCast(i8output_ptr, iBuilder->getInt8PtrTy());
    476467    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, remainingBytes));
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5297 r5317  
    125125    Value * bytepack[8];
    126126    for (unsigned i = 0; i < 8; i++) {
    127         Value * byteStream = getInputStream("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    128         bytepack[i] = iBuilder->CreateBlockAlignedLoad(byteStream);
     127        bytepack[i] = loadInputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    129128    }
    130129    Value * basisbits[8];
    131130    s2p(iBuilder, bytepack, basisbits);
    132131    for (unsigned i = 0; i < 8; ++i) {
    133         Value * basisBits = getOutputStream("basisBits", iBuilder->getInt32(i));
    134         iBuilder->CreateBlockAlignedStore(basisbits[i], basisBits);
     132        storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), basisbits[i]);
    135133    }
    136134}
     
    156154
    157155    for (unsigned i = 0; i < 8; ++i) {
    158         Value * basisBitsPtr = getOutputStream("basisBits", iBuilder->getInt64(i));
    159         iBuilder->CreateBlockAlignedStore(Constant::getNullValue(iBuilder->getBitBlockType()), basisBitsPtr);
     156        storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), Constant::getNullValue(iBuilder->getBitBlockType()));
    160157    }
    161158
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5311 r5317  
    5151    Value * recordStart = getScalarField("LineStart");
    5252    Value * recordNum = getScalarField("LineNum");
    53     Value * matches = iBuilder->CreateBlockAlignedLoad(getInputStream("matchResults", iBuilder->getInt32(0)));
    54     Value * linebreaks = iBuilder->CreateBlockAlignedLoad(getInputStream("matchResults", iBuilder->getInt32(1)));
     53    Value * matches = loadInputStreamBlock("matchResults", iBuilder->getInt32(0));
     54    Value * linebreaks = loadInputStreamBlock("matchResults", iBuilder->getInt32(1));
    5555    Value * matchWordVector = iBuilder->CreateBitCast(matches, scanwordVectorType);
    5656    Value * breakWordVector = iBuilder->CreateBitCast(linebreaks, scanwordVectorType);
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5310 r5317  
    3535   
    3636    Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateAnd(processed, blockItems), itemBytes);
    37     Value * bytePtr = iBuilder->CreatePointerCast(getInputStream("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
     37    Value * bytePtr = iBuilder->CreatePointerCast(getInputStreamBlockPtr("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
    3838    bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    3939
     
    5252        // Calculate from the updated value of processed;
    5353        byteOffset = iBuilder->CreateMul(iBuilder->CreateAnd(processed, blockItems), itemBytes);
    54         Value * bytePtr = iBuilder->CreatePointerCast(getInputStream("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
     54        Value * bytePtr = iBuilder->CreatePointerCast(getInputStreamBlockPtr("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
    5555        bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    5656
     
    105105   
    106106    Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(processed, blockItems), itemBytes);
    107     Value * bytePtr = iBuilder->CreatePointerCast(getInputStream("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
     107    Value * bytePtr = iBuilder->CreatePointerCast(getInputStreamBlockPtr("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
    108108    bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    109109
     
    123123        // Calculate from the updated value of processed;
    124124        byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(processed, blockItems), itemBytes);
    125         Value * bytePtr = iBuilder->CreatePointerCast(getInputStream("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
     125        Value * bytePtr = iBuilder->CreatePointerCast(getInputStreamBlockPtr("codeUnitBuffer", iBuilder->getInt32(0)), i8PtrTy);
    126126        bytePtr = iBuilder->CreateGEP(bytePtr, byteOffset);
    127127        itemsToDo = iBuilder->CreateSub(producerPos[0], processed);
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5316 r5317  
    2121using namespace IDISA;
    2222
    23 ArrayType * resolveStreamSetType(IDISA_Builder * const b, Type * const type);
    24 
    25 StructType * resolveExpandableStreamSetType(IDISA_Builder * const b, Type * const type);
    26 
    2723void StreamSetBuffer::allocateBuffer() {
    2824    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType(), iBuilder->getSize(mBufferBlocks));
    2925}
    3026
    31 Value * StreamSetBuffer::getStream(Value * self, Value * streamIndex, Value * blockIndex) const {
    32     return iBuilder->CreateGEP(getStreamSetPtr(self, blockIndex), {iBuilder->getInt32(0), streamIndex});
    33 }
    34 
    35 Value * StreamSetBuffer::getStream(Value * self, Value * streamIndex, Value * blockIndex, Value * packIndex) const {
    36     return iBuilder->CreateGEP(getStreamSetPtr(self, blockIndex), {iBuilder->getInt32(0), streamIndex, packIndex});
     27Value * StreamSetBuffer::getStreamBlockPtr(Value * self, Value * streamIndex, Value * blockIndex) const {
     28    return iBuilder->CreateGEP(getStreamSetBlockPtr(self, blockIndex), {iBuilder->getInt32(0), streamIndex});
     29}
     30
     31Value * StreamSetBuffer::getStreamPackPtr(Value * self, Value * streamIndex, Value * blockIndex, Value * packIndex) const {
     32    return iBuilder->CreateGEP(getStreamSetBlockPtr(self, blockIndex), {iBuilder->getInt32(0), streamIndex, packIndex});
    3733}
    3834
     
    4642Value * StreamSetBuffer::getRawItemPointer(Value * self, Value * streamIndex, Value * absolutePosition) const {
    4743    Value * ptr = self;
    48     if (!isa<ConstantInt>(streamIndex) || !cast<ConstantInt>(streamIndex)->isZero()) {
    49         ptr = iBuilder->CreateGEP(ptr, {ConstantInt::getNullValue(streamIndex->getType()), streamIndex});
     44    if (isa<ConstantInt>(streamIndex) && cast<ConstantInt>(streamIndex)->isZero()) {
     45        ptr = iBuilder->CreateGEP(ptr, {iBuilder->getInt32(0), streamIndex});
    5046    }
    5147    IntegerType * const ty = cast<IntegerType>(mBaseType->getArrayElementType()->getVectorElementType());
     
    7874
    7975// For a single block buffer, the block pointer is always the buffer base pointer.
    80 Value * SingleBlockBuffer::getStreamSetPtr(Value * self, Value *) const {
     76Value * SingleBlockBuffer::getStreamSetBlockPtr(Value * self, Value *) const {
    8177    return self;
    8278}
     
    9591}
    9692
    97 Value * ExternalFileBuffer::getStreamSetPtr(Value * self, Value * blockNo) const {
     93Value * ExternalFileBuffer::getStreamSetBlockPtr(Value * self, Value * blockNo) const {
    9894    return iBuilder->CreateGEP(self, blockNo);
    9995}
     
    105101// Circular Buffer
    106102
    107 Value * CircularBuffer::getStreamSetPtr(Value * self, Value * blockIndex) const {
     103Value * CircularBuffer::getStreamSetBlockPtr(Value * self, Value * blockIndex) const {
    108104    assert (blockIndex->getType()->isIntegerTy());
    109105    Value * offset = nullptr;
    110106    if (mBufferBlocks == 1) {
    111107        offset = ConstantInt::getNullValue(iBuilder->getSizeTy());
    112     } else if (LLVM_LIKELY((mBufferBlocks & (mBufferBlocks - 1)) == 0)) { // is power of 2
     108    } else if ((mBufferBlocks & (mBufferBlocks - 1)) == 0) { // is power of 2
    113109        offset = iBuilder->CreateAnd(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks - 1));
    114110    } else {
     
    149145    Value * partialBlockSourcePtr = iBuilder->CreateGEP(overFlowAreaPtr, overFlowBlocks);
    150146    Value * copyBits = iBuilder->CreateMul(overFlowItems, iBuilder->getSize(fieldWidth));
    151     Value * copyBytes = iBuilder->CreateUDiv(iBuilder->CreateAdd(copyBits, iBuilder->getSize(7)), iBuilder->getSize(8));
     147    Value * copyBytes = iBuilder->CreateLShr(iBuilder->CreateAdd(copyBits, iBuilder->getSize(7)), iBuilder->getSize(3));
    152148    for (unsigned strm = 0; strm < numStreams; strm++) {
    153149        Value * strmTargetPtr = iBuilder->CreateGEP(partialBlockTargetPtr, {iBuilder->getInt32(0), iBuilder->getInt32(strm)});
     
    159155}
    160156
    161 Value * CircularCopybackBuffer::getStreamSetPtr(Value * self, Value * blockIndex) const {
     157Value * CircularCopybackBuffer::getStreamSetBlockPtr(Value * self, Value * blockIndex) const {
    162158    assert (blockIndex->getType()->isIntegerTy());
    163159   
     
    165161    if (mBufferBlocks == 1) {
    166162        offset = ConstantInt::getNullValue(iBuilder->getSizeTy());
    167     } else if (LLVM_LIKELY((mBufferBlocks & (mBufferBlocks - 1)) == 0)) { // is power of 2
     163    } else if ((mBufferBlocks & (mBufferBlocks - 1)) == 0) { // is power of 2
    168164        offset = iBuilder->CreateAnd(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks - 1));
    169165    } else {
     
    177173// Expandable Buffer
    178174
    179 void ExpandableBuffer::allocateBuffer() {
    180     mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType());
    181     Value * const capacityPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    182     iBuilder->CreateStore(iBuilder->getSize(mInitialCapacity), capacityPtr);
    183     Type * const bufferType = getType()->getStructElementType(1)->getPointerElementType();
    184     ConstantInt * const size = iBuilder->getSize(mBufferBlocks * mInitialCapacity);
    185     Value * const ptr = iBuilder->CreateAlignedMalloc(bufferType, size, iBuilder->getCacheAlignment());
    186     const auto alignment = bufferType->getPrimitiveSizeInBits() / 8;
    187     iBuilder->CreateMemZero(ptr, size, alignment);
    188     Value * const streamSetPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    189     iBuilder->CreateStore(ptr, streamSetPtr);
    190 }
    191 
    192 std::pair<Value *, Value *> ExpandableBuffer::getExpandedStreamOffset(llvm::Value * self, llvm::Value * streamIndex, Value * blockIndex) const {
    193 
    194     // MDNode *Weights = MDBuilder(Ctx).createBranchWeights(42, 13);
    195 
    196     // ENTRY
    197     Value * const capacityPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    198     Value * const capacity = iBuilder->CreateLoad(capacityPtr);
    199     Value * const streamSetPtr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    200     Value * const streamSet = iBuilder->CreateLoad(streamSetPtr);
    201 
    202     // Are we guaranteed that we can access this stream?
    203     if (LLVM_UNLIKELY(isa<ConstantInt>(streamIndex))) {
    204         if (LLVM_LIKELY(cast<ConstantInt>(streamIndex)->getLimitedValue() < mInitialCapacity)) {
    205             return {streamSet, capacity};
    206         }
    207     }
    208 
    209     BasicBlock * const entry = iBuilder->GetInsertBlock();
    210     BasicBlock * const expand = BasicBlock::Create(iBuilder->getContext(), "expand", entry->getParent());
    211     BasicBlock * const resume = BasicBlock::Create(iBuilder->getContext(), "resume", entry->getParent());
    212 
    213     assert (streamIndex->getType() == capacity->getType());
    214     Value * cond = iBuilder->CreateICmpULT(streamIndex, capacity);
    215     iBuilder->CreateCondBr(cond, resume, expand);
    216     // EXPAND
    217     iBuilder->SetInsertPoint(expand);
    218     /// TODO: this should call a function rather than be inlined into the block. REVISIT once tested.
    219     Value * newCapacity = iBuilder->CreateMul(streamIndex, iBuilder->getSize(2));
    220     iBuilder->CreateStore(newCapacity, capacityPtr);
    221     Type * bufferType = getType()->getStructElementType(1)->getPointerElementType();
    222     Value * size = iBuilder->CreateMul(newCapacity, iBuilder->getSize(mBufferBlocks));
    223     Value * newStreamSet = iBuilder->CreateAlignedMalloc(bufferType, size, iBuilder->getCacheAlignment());
    224     iBuilder->CreateStore(newStreamSet, streamSetPtr);
    225     Value * const diffCapacity = iBuilder->CreateSub(newCapacity, capacity);
    226     const auto alignment = bufferType->getPrimitiveSizeInBits() / 8;
    227     for (unsigned i = 0; i < mBufferBlocks; ++i) {
    228         ConstantInt * const offset = iBuilder->getSize(i);
    229         Value * srcOffset = iBuilder->CreateMul(capacity, offset);
    230         Value * srcPtr = iBuilder->CreateGEP(streamSet, srcOffset);
    231         Value * destOffset = iBuilder->CreateMul(newCapacity, offset);
    232         Value * destPtr = iBuilder->CreateGEP(newStreamSet, destOffset);
    233         iBuilder->CreateMemCpy(destPtr, srcPtr, capacity, alignment);
    234         Value * destZeroOffset = iBuilder->CreateAdd(destOffset, capacity);
    235         Value * destZeroPtr = iBuilder->CreateGEP(newStreamSet, destZeroOffset);
    236         iBuilder->CreateMemZero(destZeroPtr, diffCapacity, alignment);
    237     }
    238 
    239     iBuilder->CreateAlignedFree(streamSet);
    240     iBuilder->CreateBr(resume);
    241     // RESUME
    242     iBuilder->SetInsertPoint(resume);
    243 
    244     PHINode * phiStreamSet = iBuilder->CreatePHI(streamSet->getType(), 2);
    245     phiStreamSet->addIncoming(streamSet, entry);
    246     phiStreamSet->addIncoming(newStreamSet, expand);
    247 
    248     PHINode * phiCapacity = iBuilder->CreatePHI(capacity->getType(), 2);
    249     phiCapacity->addIncoming(capacity, entry);
    250     phiCapacity->addIncoming(newCapacity, expand);
    251 
    252     Value * offset = iBuilder->CreateAdd(iBuilder->CreateMul(blockIndex, phiCapacity), streamIndex);
    253 
    254     return {phiStreamSet, offset};
    255 }
    256 
    257 llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, Value * streamIndex, Value * blockIndex) const {
    258     Value * ptr, * offset;
    259     std::tie(ptr, offset) = getExpandedStreamOffset(self, streamIndex, blockIndex);
    260     return iBuilder->CreateGEP(ptr, offset);
    261 }
    262 
    263 llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, llvm::Value * streamIndex, Value * blockIndex, Value * packIndex) const {
    264     Value * ptr, * offset;
    265     std::tie(ptr, offset) = getExpandedStreamOffset(self, streamIndex, blockIndex);
    266     return iBuilder->CreateGEP(ptr, {offset, packIndex});
    267 }
    268 
    269 Value * ExpandableBuffer::getStreamSetPtr(Value *, Value *) const {
    270     report_fatal_error("Expandable buffers: getStreamSetPtr not supported.");
     175void ExpandableBuffer::ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const {
     176
     177}
     178
     179llvm::Value * ExpandableBuffer::getStreamBlockPtr(llvm::Value * self, Value * streamIndex, Value * blockIndex) const {
     180    ensureStreamCapacity(self, streamIndex);
     181
     182
     183
     184    return nullptr;
     185}
     186
     187llvm::Value * ExpandableBuffer::getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, Value *blockIndex, Value *packIndex) const {
     188    ensureStreamCapacity(self, streamIndex);
     189
     190
     191    return nullptr;
     192}
     193
     194Value * ExpandableBuffer::getStreamSetBlockPtr(Value *, Value *) const {
     195    report_fatal_error("Expandable buffers: getStreamSetBlockPtr not supported.");
    271196}
    272197
     
    276201
    277202// Constructors
     203
    278204SingleBlockBuffer::SingleBlockBuffer(IDISA::IDISA_Builder * b, llvm::Type * type)
    279 : StreamSetBuffer(BufferKind::BlockBuffer, b, type, resolveStreamSetType(b, type), 1, 0) {
     205: StreamSetBuffer(BufferKind::BlockBuffer, b, type, 1, 0) {
    280206
    281207}
    282208
    283209ExternalFileBuffer::ExternalFileBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace)
    284 : StreamSetBuffer(BufferKind::ExternalFileBuffer, b, type, resolveStreamSetType(b, type), 0, AddressSpace) {
     210: StreamSetBuffer(BufferKind::ExternalFileBuffer, b, type, 0, AddressSpace) {
    285211
    286212}
    287213
    288214CircularBuffer::CircularBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace)
    289 : StreamSetBuffer(BufferKind::CircularBuffer, b, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace) {
     215: StreamSetBuffer(BufferKind::CircularBuffer, b, type, bufferBlocks, AddressSpace) {
    290216
    291217}
    292218
    293219CircularCopybackBuffer::CircularCopybackBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
    294 : StreamSetBuffer(BufferKind::CircularCopybackBuffer, b, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
     220: StreamSetBuffer(BufferKind::CircularCopybackBuffer, b, type, bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
    295221
    296222}
    297223
    298224ExpandableBuffer::ExpandableBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace)
    299 : StreamSetBuffer(BufferKind::ExpandableBuffer, b, type, resolveExpandableStreamSetType(b, type), bufferBlocks, AddressSpace)
    300 , mInitialCapacity(type->getArrayNumElements()) {
    301 
    302 }
    303 
    304 inline StreamSetBuffer::StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, Type * baseType, Type * resolvedType, unsigned blocks, unsigned AddressSpace)
    305 : mBufferKind(k)
    306 , iBuilder(b)
    307 , mType(resolvedType)
    308 , mBufferBlocks(blocks)
    309 , mAddressSpace(AddressSpace)
    310 , mStreamSetBufferPtr(nullptr)
    311 , mBaseType(baseType) {
    312 
    313 }
    314 
    315 // Helper routines
    316 ArrayType * resolveStreamSetType(IDISA_Builder * const b, Type * const type) {
     225: StreamSetBuffer(BufferKind::ExpandableBuffer, b, type, bufferBlocks, AddressSpace) {
     226
     227}
     228
     229inline Type * resolveStreamSetType(IDISA_Builder * const b, Type * const type) {
    317230    if (type->isArrayTy()) {
    318231        Type * ty = type->getArrayElementType();
     
    323236                ty = b->getBitBlockType();
    324237                if (fieldWidth != 1) {
    325                     ty = ArrayType::get(ty, fieldWidth);
     238                    ty = llvm::ArrayType::get(ty, fieldWidth);
    326239                }
    327240                return ArrayType::get(ty, type->getArrayNumElements());
     
    336249}
    337250
    338 StructType * resolveExpandableStreamSetType(IDISA_Builder * const b, Type * const type) {
    339     if (type->isArrayTy()) {
    340         Type * ty = type->getArrayElementType();
    341         if (LLVM_LIKELY(ty->isVectorTy() && ty->getVectorNumElements() == 0)) {
    342             ty = ty->getVectorElementType();
    343             if (LLVM_LIKELY(ty->isIntegerTy())) {
    344                 const auto fieldWidth = cast<IntegerType>(ty)->getBitWidth();
    345                 ty = b->getBitBlockType();
    346                 if (fieldWidth != 1) {
    347                     ty = ArrayType::get(ty, fieldWidth);
    348                 }
    349                 return StructType::get(b->getSizeTy(), ty->getPointerTo(), nullptr);
    350             }
    351         }
    352     }
    353     std::string tmp;
    354     raw_string_ostream out(tmp);
    355     type->print(out);
    356     out << " is an unvalid stream set buffer type.";
    357     report_fatal_error(out.str());
    358 }
     251StreamSetBuffer::StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, Type * type, unsigned blocks, unsigned AddressSpace)
     252: mBufferKind(k)
     253, iBuilder(b)
     254, mType(resolveStreamSetType(b, type))
     255, mBufferBlocks(blocks)
     256, mAddressSpace(AddressSpace)
     257, mStreamSetBufferPtr(nullptr)
     258, mBaseType(type) {
     259
     260}
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5316 r5317  
    4444        return mStreamSetBufferPtr;
    4545    }
    46 
     46   
    4747    virtual void allocateBuffer();
    4848
    49     virtual llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const;
     49    virtual llvm::Value * getStreamBlockPtr(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const;
    5050
    51     virtual llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex) const;
     51    virtual llvm::Value * getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex) const;
    5252   
    5353    llvm::Value * getRawItemPointer(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * absolutePosition) const;
     
    5858protected:
    5959
    60     StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * baseType, llvm::Type * resolvedType, unsigned blocks, unsigned AddressSpace);
     60    StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * type, unsigned blocks, unsigned AddressSpace);
    6161
    6262    // Get the buffer pointer for a given block of the stream.
    63     virtual llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const = 0;
     63    virtual llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const = 0;
    6464
    6565protected:
     
    8282
    8383protected:
    84     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     84    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    8585};
    8686
     
    103103   
    104104protected:
    105     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     105    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    106106};
    107107   
     
    115115
    116116protected:
    117     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
     117    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    118118};
    119119   
     
    139139   
    140140protected:
    141     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
     141    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    142142private:
    143143    size_t mOverflowBlocks;
     
    154154    ExpandableBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    155155
    156     llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const override;
     156    llvm::Value * getStreamBlockPtr(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const override;
    157157
    158     llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex) const override;
     158    llvm::Value * getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex) const override;
    159159
    160160    llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
    161161   
    162     void allocateBuffer() override;
    163 
    164162protected:
    165163
    166     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
     164    void ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const;
    167165
    168 private:
    169 
    170     std::pair<llvm::Value *, llvm::Value *> getExpandedStreamOffset(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const;
    171 
    172 private:
    173 
    174     const uint64_t  mInitialCapacity;
    175 
     166    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    176167};
    177168
Note: See TracChangeset for help on using the changeset viewer.