Ignore:
Timestamp:
Apr 15, 2017, 4:42:33 PM (2 years ago)
Author:
nmedfort
Message:

First attempt to allow Kernels to wait for consumers to finish processing before performing a realloc.

File:
1 edited

Legend:

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

    r5402 r5408  
    7070}
    7171
    72 void KernelInterface::addKernelDeclarations(Module * client) {
     72void KernelInterface::addKernelDeclarations(Module * const client) {
    7373    Module * saveModule = iBuilder->getModule();
    7474    auto savePoint = iBuilder->saveIP();
     
    7777        throw std::runtime_error("Kernel interface " + getName() + " not yet finalized.");
    7878    }
    79     PointerType * selfType = PointerType::getUnqual(mKernelStateType);
     79    PointerType * const selfType = mKernelStateType->getPointerTo();
     80    IntegerType * const sizeTy = iBuilder->getSizeTy();
     81    PointerType * const consumerTy = StructType::get(sizeTy, sizeTy->getPointerTo()->getPointerTo(), nullptr)->getPointerTo();
    8082
    8183    // Create the initialization function prototype
    82     std::vector<Type *> initParameters = {selfType};
     84    std::vector<Type *> initParameters = {selfType};   
    8385    for (auto binding : mScalarInputs) {
    8486        initParameters.push_back(binding.type);
    8587    }
     88    initParameters.insert(initParameters.end(), mStreamSetOutputs.size(), consumerTy);
     89
    8690    FunctionType * initType = FunctionType::get(iBuilder->getVoidTy(), initParameters, false);
    8791    Function * init = Function::Create(initType, GlobalValue::ExternalLinkage, getName() + INIT_SUFFIX, client);
     
    9397        (++args)->setName(binding.name);
    9498    }
     99    for (auto binding : mStreamSetOutputs) {
     100        args->setName(binding.name + "ConsumerLogicalSegments");       
     101//        args->addAttr(Attribute::NoCapture);
     102//        args->addAttr(Attribute::ReadOnly);
     103        ++args;
     104    }
    95105
    96     /// INVESTIGATE: should we explicitly mark whether to track a kernel output's consumed amount? It would have
    97     /// to be done at the binding level using the current architecture. It would reduce the number of arguments
    98     /// passed between kernels.
    99 
    100     // Create the doSegment function prototype.   
    101     IntegerType * const sizeTy = iBuilder->getSizeTy();
    102 
     106    // Create the doSegment function prototype.
    103107    std::vector<Type *> params = {selfType, iBuilder->getInt1Ty()};
    104     params.insert(params.end(), mStreamSetInputs.size() + mStreamSetOutputs.size(), sizeTy);
     108    params.insert(params.end(), mStreamSetInputs.size(), sizeTy);
    105109
    106110    FunctionType * const doSegmentType = FunctionType::get(iBuilder->getVoidTy(), params, false);
     
    113117    (++args)->setName("doFinal");
    114118    for (const Binding & input : mStreamSetInputs) {
    115         (++args)->setName(input.name + "_availableItems");
    116     }
    117     for (const Binding & output : mStreamSetOutputs) {
    118         (++args)->setName(output.name + "_consumedItems");
     119        (++args)->setName(input.name + "AvailableItems");
    119120    }
    120121
Note: See TracChangeset for help on using the changeset viewer.