source: icGREP/icgrep-devel/icgrep/kernels/streams_merge.cpp @ 5357

Last change on this file since 5357 was 5338, checked in by lindanl, 2 years ago

Provide option to build separated kernels for each regular expression.

File size: 1.4 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#include "streams_merge.h"
7#include <IR_Gen/idisa_builder.h>
8#include <llvm/IR/Value.h>
9
10using namespace llvm;
11
12namespace kernel {
13
14StreamsMerge::StreamsMerge(IDISA::IDISA_Builder * iBuilder, unsigned streamsPerSet, unsigned inputSets)
15    : BlockOrientedKernel(iBuilder, "streamsMerge", {}, {}, {}, {}, {})
16    , mStreamsPerSet(streamsPerSet)
17    , mInputSets(inputSets) {
18        for (unsigned i = 0; i < mInputSets; i++) {
19            mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "inputGroup" + std::to_string(i)});
20        }
21        mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "output"});
22    }
23
24void StreamsMerge::generateDoBlockMethod() {
25
26    std::vector<Value *> resultStreams;
27
28    for (unsigned j = 0; j < mStreamsPerSet; j++) {
29        resultStreams.push_back(loadInputStreamBlock("inputGroup" + std::to_string(0), iBuilder->getInt32(j)));
30    }
31
32    for (unsigned i = 1; i < mInputSets; i++) {
33        for (unsigned j = 0; j < mStreamsPerSet; j++) {
34            resultStreams[j] = iBuilder->CreateOr(resultStreams[j], loadInputStreamBlock("inputGroup" + std::to_string(i), iBuilder->getInt32(j)));
35        }
36    }
37    for (unsigned j = 0; j < mStreamsPerSet; j++) {
38        storeOutputStreamBlock("output", iBuilder->getInt32(j), resultStreams[j]);
39    }
40}
41
42
43}
Note: See TracBrowser for help on using the repository browser.