Ignore:
Timestamp:
Jul 30, 2018, 1:36:48 AM (6 months ago)
Author:
xwa163
Message:
  1. Implement twist_kernel and untwist_kernel by PEXT and PDEP
  2. Use twist form for multiplexing lz4 grep
File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.cpp

    r6132 r6135  
    2727#include <kernels/lz4/aio/lz4_swizzled_aio.h>
    2828#include <kernels/lz4/aio/lz4_bitstream_aio.h>
    29 #include <kernels/lz4/aio/lz4_i4_bytestream_aio.h>
     29#include <kernels/lz4/aio/lz4_twist_aio.h>
    3030#include <kernels/bitstream_pdep_kernel.h>
    3131#include <kernels/lz4/lz4_bitstream_not_kernel.h>
     32#include <kernels/lz4/aio/twist_kernel.h>
     33#include <kernels/lz4/aio/untwist_kernel.h>
    3234
    3335namespace re { class CC; }
     
    428430
    429431
    430     if (compressedBitStreams[0]->getNumOfStreams() == 4) {
    431         StreamSetBuffer* twistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 4), this->getInputBufferBlocks(iBuilder));
    432         kernel::Kernel* twistK = mGrepDriver->addKernelInstance<kernel::P2S4StreamByPDEP>(iBuilder);
     432    size_t numOfStreams = compressedBitStreams[0]->getNumOfStreams();
     433
     434    // 1, 2, 4, 8
     435
     436    if (numOfStreams <= 2) {
     437        StreamSetBuffer* twistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 2), this->getInputBufferBlocks(iBuilder));
     438        kernel::Kernel* twistK = mGrepDriver->addKernelInstance<kernel::TwistByPDEPKernel>(iBuilder, numOfStreams, 2);
    433439        mGrepDriver->makeKernelCall(twistK, {compressedBitStreams[0]}, {twistedCharClasses});
    434440
    435 
    436         StreamSetBuffer* uncompressedTwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 4), this->getInputBufferBlocks(iBuilder));
    437         Kernel* lz4I4AioK = mPxDriver.addKernelInstance<LZ4I4ByteStreamAioKernel>(iBuilder);
     441        StreamSetBuffer* uncompressedTwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 2), this->getInputBufferBlocks(iBuilder));
     442        Kernel* lz4I4AioK = mPxDriver.addKernelInstance<LZ4TwistAioKernel>(iBuilder, 2);
    438443        lz4I4AioK->setInitialArguments({mFileSize});
    439444        mGrepDriver->makeKernelCall(lz4I4AioK, {
     
    450455                                    });
    451456
    452         StreamSetBuffer* untwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(iBuilder));
    453         kernel::Kernel* untwistK = mGrepDriver->addKernelInstance<kernel::S2P4StreamByPEXTKernel>(iBuilder);
     457        StreamSetBuffer* untwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(numOfStreams), this->getInputBufferBlocks(iBuilder));
     458        kernel::Kernel* untwistK = mGrepDriver->addKernelInstance<kernel::UntwistByPEXTKernel>(iBuilder, numOfStreams, 2);
     459        mGrepDriver->makeKernelCall(untwistK, {uncompressedTwistedCharClasses}, {untwistedCharClasses});
     460        return {untwistedCharClasses};
     461    }
     462
     463    if (numOfStreams <= 4) {
     464        StreamSetBuffer* twistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 4), this->getInputBufferBlocks(iBuilder));
     465        kernel::Kernel* twistK = mGrepDriver->addKernelInstance<kernel::TwistByPDEPKernel>(iBuilder, numOfStreams, 4);
     466        mGrepDriver->makeKernelCall(twistK, {compressedBitStreams[0]}, {twistedCharClasses});
     467
     468
     469        StreamSetBuffer* uncompressedTwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 4), this->getInputBufferBlocks(iBuilder));
     470
     471        Kernel* lz4I4AioK = mPxDriver.addKernelInstance<LZ4TwistAioKernel>(iBuilder, 4);
     472        lz4I4AioK->setInitialArguments({mFileSize});
     473        mGrepDriver->makeKernelCall(lz4I4AioK, {
     474                mCompressedByteStream,
     475
     476                // Block Data
     477                BlockData_IsCompressed,
     478                BlockData_BlockStart,
     479                BlockData_BlockEnd,
     480
     481                twistedCharClasses
     482        }, {
     483                                            uncompressedTwistedCharClasses
     484                                    });
     485
     486        StreamSetBuffer* untwistedCharClasses = mGrepDriver->addBuffer<StaticBuffer>(iBuilder, iBuilder->getStreamSetTy(numOfStreams), this->getInputBufferBlocks(iBuilder));
     487        kernel::Kernel* untwistK = mGrepDriver->addKernelInstance<kernel::UntwistByPEXTKernel>(iBuilder, numOfStreams, 4);
    454488        mGrepDriver->makeKernelCall(untwistK, {uncompressedTwistedCharClasses}, {untwistedCharClasses});
    455489        return {untwistedCharClasses};
Note: See TracChangeset for help on using the changeset viewer.