Ignore:
Timestamp:
Feb 16, 2017, 7:20:16 PM (2 years ago)
Author:
cameron
Message:

Changes from Adam

File:
1 edited

Legend:

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

    r5297 r5326  
    3939
    4040void PrintableBits::generateDoBlockMethod() {
    41     Value * strmPtr = getStream("bitStream", iBuilder->getInt32(0));
     41    // Load current block
     42    Value * bitStrmVal = loadInputStreamBlock("bitStream", iBuilder->getInt32(0));
     43
     44    Value * bits[8];
     45
     46    /*
     47    00110001 is the Unicode codepoint for '1' and 00101110 is the codepoint for '.'.
     48    We want to output a byte stream that is aligned with the input bitstream such that it contains 00110001 in each 1 position and 00101110 in each 0 position.
    4249   
    43     Value * bitStrmVal = iBuilder->CreateBlockAlignedLoad(strmPtr);
    44     Value * bits[8];
     50    For example, consider input bitstream 101. Our desired output is:
     51    00110001 00101110 00110001
     52
     53    We can do the bitstream to bytestream conversion in parallel by viewing the output stream in terms of parallel bit streams.
     54
     55    0   0   0 -> First bit position of every byte is all zeros
     56    0   0   0 -> Same for second bit
     57    1   1   1 -> Third bit is all ones
     58    1   0   1 -> 4th bit is 1 for a '1' byte and '0' for a zero byte. Matches input bit stream
     59    0   1   0 -> opposite
     60    0   1   0 -> opposite
     61    0   1   0 -> opposite
     62    1   0   1 -> same as 4th bit position.
     63   
     64    Armed with the above we can do the bit->byte conversion all at once
     65    rather than byte at a time! That's what we do below.
     66    */
     67
    4568    bits[0] = ConstantInt::getNullValue(iBuilder->getBitBlockType());
    4669    bits[1] = ConstantInt::getNullValue(iBuilder->getBitBlockType());
     
    5376    bits[7] = bitStrmVal;
    5477   
     78    // Reassemble the paralell bit streams into a byte stream
    5579    Value * printableBytes[8];
    5680    p2s(iBuilder, bits, printableBytes);
    5781   
    5882    for (unsigned j = 0; j < 8; ++j) {
    59         Value * ptr = getStream("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j));
    60         iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(printableBytes[j]), ptr);
     83        storeOutputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j), iBuilder->bitCast(printableBytes[j]));
    6184    }
    6285}
     
    82105        llvm::report_fatal_error("Stream index out of bounds.\n");
    83106   
    84     Value * strmPtr = getStream("bitStreams", iBuilder->getInt32(mStreamIndex));
    85     Value * bitStrmVal = iBuilder->CreateBlockAlignedLoad(strmPtr);
     107    Value * bitStrmVal = loadInputStreamBlock("bitStreams", iBuilder->getInt32(mStreamIndex));
    86108
    87     Value * ptr = getStream("bitStream", iBuilder->getInt32(0));
    88     iBuilder->CreateBlockAlignedStore(bitStrmVal, ptr);
     109    storeOutputStreamBlock("bitStream", iBuilder->getInt32(0), bitStrmVal);
    89110}
    90111}
Note: See TracChangeset for help on using the changeset viewer.