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

Last change on this file since 5718 was 5440, checked in by nmedfort, 2 years ago

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File size: 1.5 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(const std::unique_ptr<KernelBuilder> &iBuilder) {
24
25    std::vector<Value *> resultStreams;
26
27    for (unsigned j = 0; j < mStreamsPerSet; j++) {
28        resultStreams.push_back(iBuilder->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], iBuilder->loadInputStreamBlock("inputGroup" + std::to_string(i), iBuilder->getInt32(j)));
34        }
35    }
36    for (unsigned j = 0; j < mStreamsPerSet; j++) {
37        iBuilder->storeOutputStreamBlock("output", iBuilder->getInt32(j), resultStreams[j]);
38    }
39}
40
41
42}
Note: See TracBrowser for help on using the repository browser.