Ignore:
Timestamp:
Apr 25, 2017, 2:33:31 PM (2 years ago)
Author:
nmedfort
Message:

Changes towards separate compilation

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
7 edited

Legend:

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

    r5418 r5425  
    139139    args->setName("self");
    140140
     141    linkExternalMethods();
     142
    141143    iBuilder->setModule(saveModule);
    142144}
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5418 r5425  
    141141protected:
    142142
     143    virtual void linkExternalMethods() = 0;
     144
    143145    KernelInterface(IDISA::IDISA_Builder * builder,
    144146                    std::string kernelName,
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5418 r5425  
    55
    66#include "kernel.h"
    7 #include <kernels/toolchain.h>
     7#include <toolchain/toolchain.h>
    88#include <kernels/streamset.h>
    99#include <llvm/IR/Constants.h>
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5422 r5425  
    77#define KERNEL_BUILDER_H
    88
    9 #include "interface.h"      // for KernelInterface
     9#include "interface.h"
    1010#include <boost/container/flat_map.hpp>
    1111#include <IR_Gen/idisa_builder.h>
    12 #include <kernels/pipeline.h>
     12#include <toolchain/pipeline.h>
    1313#include <llvm/IR/Constants.h>
    14 
    15 //#include <string>           // for string
    16 //#include <memory>           // for unique_ptr
    1714
    1815namespace llvm { class Function; }
     
    3431    using Kernels = std::vector<KernelBuilder *>;
    3532
    36     friend void ::generateSegmentParallelPipeline(IDISA::IDISA_Builder *, const Kernels &);
    37     friend void ::generatePipelineLoop(IDISA::IDISA_Builder *, const Kernels &);
    38     friend void ::generateParallelPipeline(IDISA::IDISA_Builder *, const Kernels &);
     33    friend void ::generateSegmentParallelPipeline(std::unique_ptr<IDISA::IDISA_Builder> &, const Kernels &);
     34    friend void ::generatePipelineLoop(std::unique_ptr<IDISA::IDISA_Builder> &, const Kernels &);
     35    friend void ::generateParallelPipeline(std::unique_ptr<IDISA::IDISA_Builder> &, const Kernels &);
    3936public:
    4037   
     
    120117    }
    121118
    122 //    llvm::Value * getScalarField(llvm::Value * index) const {
    123 //        return iBuilder->CreateLoad(getScalarFieldPtr(index));
    124 //    }
    125 
    126119    // Set the value of a scalar field for the current instance.
    127120    void setScalarField(const std::string & fieldName, llvm::Value * value) const {
    128121        iBuilder->CreateStore(value, getScalarFieldPtr(fieldName));
    129122    }
    130 
    131 //    void setScalarField(llvm::Value * index, llvm::Value * value) const {
    132 //        iBuilder->CreateStore(value, getScalarFieldPtr(index));
    133 //    }
    134123
    135124    // Synchronization actions for executing a kernel for a particular logical segment.
     
    204193
    205194    void prepareStreamSetNameMap();
     195
     196    void linkExternalMethods() override { }
    206197
    207198    virtual void prepareKernel();
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.cpp

    r5421 r5425  
    77#include <IR_Gen/idisa_builder.h>
    88#include <kernels/streamset.h>
     9#include <sys/stat.h>
     10#include <fcntl.h>
    911
    1012using namespace llvm;
    1113
     14uint64_t file_size(const uint32_t fd) {
     15    struct stat st;
     16    if (LLVM_UNLIKELY(fstat(fd, &st) != 0)) {
     17        st.st_size = 0;
     18    }
     19    return st.st_size;
     20}
     21
    1222namespace kernel {
     23
     24void MMapSourceKernel::linkExternalMethods() {
     25    mFileSizeFunction = iBuilder->LinkFunction("file_size", &file_size);
     26}
    1327
    1428void MMapSourceKernel::generateInitializeMethod() {
     
    1731    BasicBlock * exit = CreateBasicBlock("Exit");
    1832
    19     Value * fd = getScalarField("fileDescriptor");
    20     Value * fileSize = iBuilder->CreateFileSize(fd);
     33    Value * const fd = getScalarField("fileDescriptor");
     34    Value * fileSize = iBuilder->CreateCall(mFileSizeFunction, fd);
    2135    if (mCodeUnitWidth > 8) {
    2236        fileSize = iBuilder->CreateUDiv(fileSize, iBuilder->getSize(mCodeUnitWidth / 8));
     
    120134    {Binding{iBuilder->getInt32Ty(), "fileDescriptor"}}, {Binding{iBuilder->getSizeTy(), "fileSize"}}, {Binding{iBuilder->getVoidPtrTy(), "readableBuffer"}})
    121135, mSegmentBlocks(blocksPerSegment)
    122 , mCodeUnitWidth(codeUnitWidth) {
     136, mCodeUnitWidth(codeUnitWidth)
     137, mFileSizeFunction(nullptr) {
    123138
    124139}
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.h

    r5418 r5425  
    1818public:
    1919    MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8); 
    20     bool moduleIDisSignature() override {return true;}
     20    bool moduleIDisSignature() override { return true; }
    2121private:
     22    void linkExternalMethods() override;
    2223    void generateInitializeMethod() override;
    2324    void generateDoSegmentMethod() override;
    2425    void generateFinalizeMethod() override;
    2526private:
    26     const unsigned mSegmentBlocks;
    27     const unsigned mCodeUnitWidth;
     27    const unsigned          mSegmentBlocks;
     28    const unsigned          mCodeUnitWidth;
     29    llvm::Function *        mFileSizeFunction;
    2830};
    2931
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5418 r5425  
    1515#include <llvm/IR/CFG.h>
    1616#include <kernels/kernel.h>
    17 #include <kernels/toolchain.h>
     17#include <toolchain/toolchain.h>
    1818
    1919namespace llvm { class Constant; }
Note: See TracChangeset for help on using the changeset viewer.