Changeset 5224 for icGREP


Ignore:
Timestamp:
Dec 15, 2016, 12:56:58 PM (3 years ago)
Author:
cameron
Message:

Move responsibility for acquire/release of logical segment number into pipeline compilers.

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

Legend:

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

    r5220 r5224  
    6969    }
    7070
    71     virtual llvm::Value * getLogicalSegmentNo(llvm::Value * kernelInstance) = 0;
    7271    virtual llvm::Value * getProcessedItemCount(llvm::Value * kernelInstance) = 0;
    7372    virtual llvm::Value * getProducedItemCount(llvm::Value * kernelInstance) = 0;
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5220 r5224  
    180180    Value * self = &*(args++);
    181181    Value * blocksToDo = &*(args);
    182     Value * segmentNo = getLogicalSegmentNo(self);
    183182   
    184183    std::vector<Value *> inbufProducerPtrs;
     
    277276        iBuilder->CreateAtomicStoreRelease(produced, producerPosPtr);
    278277    }
    279 
    280     // Must be the last action, for synchronization.
    281     setLogicalSegmentNo(self, iBuilder->CreateAdd(segmentNo, ConstantInt::get(size_ty, 1)));
    282278    iBuilder->CreateBr(finalExit);
    283    
    284279    iBuilder->SetInsertPoint(finalExit);
    285280
     
    308303}
    309304
    310 Value * KernelBuilder::getLogicalSegmentNo(Value * self) {
     305Value * KernelBuilder::acquireLogicalSegmentNo(Value * self) {
    311306    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(logicalSegmentNoScalar)});
    312307    LoadInst * segNo = iBuilder->CreateAtomicLoadAcquire(ptr);
     
    326321}
    327322
    328 void KernelBuilder::setLogicalSegmentNo(Value * self, Value * newCount) {
     323void KernelBuilder::releaseLogicalSegmentNo(Value * self, Value * newCount) {
    329324    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(logicalSegmentNoScalar)});
    330325    iBuilder->CreateAtomicStoreRelease(newCount, ptr);
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5220 r5224  
    5151
    5252    Value * getBlockNo(Value * self);
    53     virtual llvm::Value * getLogicalSegmentNo(llvm::Value * kernelInstance) override;
    5453    virtual llvm::Value * getProcessedItemCount(llvm::Value * kernelInstance) override;
    5554    virtual llvm::Value * getProducedItemCount(llvm::Value * kernelInstance) override;
     
    6362        return getBuilder()->getStreamSetTy(NumElements, FieldWidth);
    6463    }
     64   
     65    // Synchronization actions for executing a kernel for a particular logical segment.
     66    //
     67    // Before the segment is processed, acquireLogicalSegmentNo must be used to load
     68    // the segment number of the kernel state to ensure that the previous segment is
     69    // complete (by checking that the acquired segment number is equal to the desired segment
     70    // number).
     71    // After all segment processing actions for the kernel are complete, and any necessary
     72    // data has been extracted from the kernel for further pipeline processing, the
     73    // segment number must be incremented and stored using releaseLogicalSegmentNo.
     74    llvm::Value * acquireLogicalSegmentNo(llvm::Value * kernelInstance);
     75    void releaseLogicalSegmentNo(llvm::Value * kernelInstance, Value * newFieldVal);
     76
    6577
    6678protected:
     
    124136   
    125137    void setBlockNo(Value * self, Value * newFieldVal);
    126     virtual void setLogicalSegmentNo(llvm::Value * self, Value * newFieldVal);
    127138    virtual void setProcessedItemCount(llvm::Value * self, Value * newFieldVal);
    128139    virtual void setProducedItemCount(llvm::Value * self, Value * newFieldVal);
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5221 r5224  
    7070    for (unsigned i = 0; i < kernels.size(); i++) {
    7171        iBuilder->SetInsertPoint(segmentWait[i]);
    72         Value * processedSegmentCount = kernels[i]->getLogicalSegmentNo(instancePtrs[i]);
     72        Value * processedSegmentCount = kernels[i]->acquireLogicalSegmentNo(instancePtrs[i]);
    7373        Value * cond = iBuilder->CreateICmpEQ(segNo, processedSegmentCount);
    7474        iBuilder->CreateCondBr(cond, segmentLoopBody[i], segmentWait[i]);
     
    7676        iBuilder->SetInsertPoint(segmentLoopBody[i]);
    7777        kernels[i]->createDoSegmentCall(instancePtrs[i], segmentBlocks);
     78        // Must be the last action, for synchronization.
     79        kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, ConstantInt::get(iBuilder->getSizeTy(), 1)));
    7880        if (i == last_kernel) break;
    7981        iBuilder->CreateBr(segmentWait[i+1]);
     
    214216    for (unsigned i = 0; i < kernels.size(); i++) {
    215217        kernels[i]->createDoSegmentCall(kernels[i]->getInstance(), segBlocks);
     218        Value * segNo = kernels[i]->acquireLogicalSegmentNo(kernels[i]->getInstance());
     219        kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->CreateAdd(segNo, ConstantInt::get(iBuilder->getSizeTy(), 1)));
    216220    }
    217221    Value * endSignal = kernels.back()->getTerminationSignal(kernels.back()->getInstance());
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5217 r5224  
    5555    Value * blocksToDo = &*(args);
    5656    ////iBuilder->CallPrintInt("blocksToDo", blocksToDo);
    57     Value * segmentNo = getLogicalSegmentNo(self);
    5857    Value * streamStructPtr = getStreamSetStructPtr(self, "codeUnitBuffer");
    5958    //iBuilder->CallPrintInt("streamStructPtr", iBuilder->CreatePtrToInt(streamStructPtr, iBuilder->getInt64Ty()));
     
    9190    iBuilder->CreateBr(stdOutexit);
    9291    iBuilder->SetInsertPoint(stdOutexit);
    93     // Must be the last action, for synchronization.
    94     setLogicalSegmentNo(self, iBuilder->CreateAdd(segmentNo, ConstantInt::get(iBuilder->getSizeTy(), 1)));
    9592    iBuilder->CreateRetVoid();
    9693    iBuilder->restoreIP(savePoint);
     
    112109    Value * processed = getProcessedItemCount(self);
    113110    Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
    114 //    Value * segmentNo = getLogicalSegmentNo(self);
    115111    Value * blockNo = getScalarField(self, blockNoScalar);
    116112    Value * basePtr = getStreamSetBlockPtr(self, "codeUnitBuffer", blockNo);
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r5218 r5224  
    4949        default:
    5050            //TODO handle FixString
    51             ParseFailure("Unsupport RE syntax!");
     51            ParseFailure("Unsupported RE syntax!");
    5252            break;
    5353    }
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5221 r5224  
    313313    Type * const int32ty = iBuilder->getInt32Ty();
    314314    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    315     Type * const voidPtrTy = Type::getVoidTy(mod->getContext())->getPointerTo();
    316 
     315    Type * const voidPtrTy = TypeBuilder<void *, false>::get(mod->getContext());
     316   
    317317    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
    318318    main->setCallingConv(CallingConv::C);
Note: See TracChangeset for help on using the changeset viewer.