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

Last change on this file since 5439 was 5436, checked in by nmedfort, 2 years ago

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

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 <kernels/kernel_builder.h>
8
9using namespace llvm;
10
11namespace kernel {
12
13StreamsMerge::StreamsMerge(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, unsigned streamsPerSet, unsigned inputSets)
14: BlockOrientedKernel("streamsMerge", {}, {}, {}, {}, {})
15, mStreamsPerSet(streamsPerSet)
16, mInputSets(inputSets) {
17    for (unsigned i = 0; i < mInputSets; i++) {
18        mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "inputGroup" + std::to_string(i)});
19    }
20    mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(streamsPerSet, 1), "output"});
21}
22
23void StreamsMerge::generateDoBlockMethod() {
24
25    std::vector<Value *> resultStreams;
26
27    for (unsigned j = 0; j < mStreamsPerSet; j++) {
28        resultStreams.push_back(loadInputStreamBlock("inputGroup" + std::to_string(0), iBuilder->getInt32(j)));
29    }
30
31    for (unsigned i = 1; i < mInputSets; i++) {
32        for (unsigned j = 0; j < mStreamsPerSet; j++) {
33            resultStreams[j] = iBuilder->CreateOr(resultStreams[j], loadInputStreamBlock("inputGroup" + std::to_string(i), iBuilder->getInt32(j)));
34        }
35    }
36    for (unsigned j = 0; j < mStreamsPerSet; j++) {
37        storeOutputStreamBlock("output", iBuilder->getInt32(j), resultStreams[j]);
38    }
39}
40
41
42}
Note: See TracBrowser for help on using the repository browser.