Ignore:
Timestamp:
Apr 10, 2018, 10:19:43 PM (12 months ago)
Author:
cameron
Message:

StreamsIntersect? kernel

File:
1 edited

Legend:

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

    r5440 r5960  
    1212
    1313StreamsMerge::StreamsMerge(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamsPerSet, unsigned inputSets)
    14 : BlockOrientedKernel("streamsMerge", {}, {}, {}, {}, {})
     14    : BlockOrientedKernel("streamsMerge" + std::to_string(streamsPerSet) + "_" + std::to_string(inputSets) , {}, {}, {}, {}, {})
    1515, mStreamsPerSet(streamsPerSet)
    1616, mInputSets(inputSets) {
     
    3939}
    4040
     41StreamsIntersect::StreamsIntersect(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamsPerSet, unsigned inputSets)
     42: BlockOrientedKernel("streamsIntersect" + std::to_string(streamsPerSet) + "_" + std::to_string(inputSets) , {}, {}, {}, {}, {})
     43, mStreamsPerSet(streamsPerSet)
     44, mInputSets(inputSets) {
     45    for (unsigned i = 0; i < mInputSets; i++) {
     46        mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "inputGroup" + std::to_string(i)});
     47    }
     48    mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "output"});
     49}
     50
     51void StreamsIntersect::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> &iBuilder) {
     52   
     53    std::vector<Value *> resultStreams;
     54   
     55    for (unsigned j = 0; j < mStreamsPerSet; j++) {
     56        resultStreams.push_back(iBuilder->loadInputStreamBlock("inputGroup" + std::to_string(0), iBuilder->getInt32(j)));
     57    }
     58   
     59    for (unsigned i = 1; i < mInputSets; i++) {
     60        for (unsigned j = 0; j < mStreamsPerSet; j++) {
     61            resultStreams[j] = iBuilder->CreateAnd(resultStreams[j], iBuilder->loadInputStreamBlock("inputGroup" + std::to_string(i), iBuilder->getInt32(j)));
     62        }
     63    }
     64    for (unsigned j = 0; j < mStreamsPerSet; j++) {
     65        iBuilder->storeOutputStreamBlock("output", iBuilder->getInt32(j), resultStreams[j]);
     66    }
     67}
     68   
    4169
    4270}
Note: See TracChangeset for help on using the changeset viewer.