Changeset 5192


Ignore:
Timestamp:
Oct 14, 2016, 6:53:44 AM (2 years ago)
Author:
cameron
Message:

CreateAtomicLoadAcquire?, CreateAtomicStoreRelease? with NVPTX overrides

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.cpp

    r5140 r5192  
    419419}
    420420
    421 }
     421LoadInst * IDISA_Builder::CreateAtomicLoadAcquire(Value * ptr) {
     422    unsigned alignment = dyn_cast<PointerType>(ptr->getType())->getElementType()->getPrimitiveSizeInBits()/8;
     423    LoadInst * inst = CreateAlignedLoad(ptr, alignment);
     424    inst->setOrdering(AtomicOrdering::Acquire);
     425    return inst;
     426   
     427}
     428StoreInst * IDISA_Builder::CreateAtomicStoreRelease(Value * val, Value * ptr) {
     429    unsigned alignment = dyn_cast<PointerType>(ptr->getType())->getElementType()->getPrimitiveSizeInBits()/8;
     430    StoreInst * inst = CreateAlignedStore(val, ptr, alignment);
     431    inst->setOrdering(AtomicOrdering::Release);
     432    return inst;
     433}
     434
     435}
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r5185 r5192  
    149149    }
    150150   
     151    virtual llvm::LoadInst* CreateAtomicLoadAcquire(Value * ptr);
     152    virtual llvm::StoreInst *  CreateAtomicStoreRelease(Value * val, Value * ptr);
    151153   
    152154protected:
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_nvptx_builder.cpp

    r5165 r5192  
    268268}
    269269
    270 }
     270LoadInst * IDISA_NVPTX20_Builder::CreateAtomicLoadAcquire(Value * ptr) {
     271    return CreateLoad(ptr);
     272   
     273}
     274StoreInst * IDISA_NVPTX20_Builder::CreateAtomicStoreRelease(Value * val, Value * ptr) {
     275    return CreateStore(val, ptr);
     276}
     277
     278   
     279}
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_nvptx_builder.h

    r5175 r5192  
    4444    Value * LongAdd(Value * const valA, Value * const valB, Value * carryIn);
    4545
     46    LoadInst * CreateAtomicLoadAcquire(Value * ptr) override;
     47    StoreInst * CreateAtomicStoreRelease(Value * val, Value * ptr) override;
    4648
    4749private:
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5188 r5192  
    189189    std::vector<Value *> producerPos;
    190190    /* Determine the actually available data examining all input stream sets. */
    191     LoadInst * p = iBuilder->CreateAlignedLoad(inbufProducerPtrs[0], sizeof(size_t));
    192     p->setOrdering(AtomicOrdering::Acquire);
     191    LoadInst * p = iBuilder->CreateAtomicLoadAcquire(inbufProducerPtrs[0]);
    193192    producerPos.push_back(p);
    194193    Value * availablePos = producerPos[0];
    195194    for (unsigned i = 1; i < inbufProducerPtrs.size(); i++) {
    196         LoadInst * p = iBuilder->CreateAlignedLoad(inbufProducerPtrs[i], sizeof(size_t));
    197         p->setOrdering(AtomicOrdering::Acquire);
     195       
     196        LoadInst * p = iBuilder->CreateAtomicLoadAcquire(inbufProducerPtrs[i]);
    198197        producerPos.push_back(p);
    199198        /* Set the available position to be the minimum of availablePos and producerPos. */
     
    269268        Value * ssStructPtr = getStreamSetStructPtr(self, mStreamSetOutputs[i].ssName);
    270269        Value * producerPosPtr = mStreamSetOutputBuffers[i]->getProducerPosPtr(ssStructPtr);
    271         iBuilder->CreateAlignedStore(produced, producerPosPtr, sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     270        iBuilder->CreateAtomicStoreRelease(produced, producerPosPtr);
    272271    }
    273272
     
    301300Value * KernelBuilder::getLogicalSegmentNo(Value * self) {
    302301    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(logicalSegmentNoScalar)});
    303     LoadInst * segNo = iBuilder->CreateAlignedLoad(ptr, sizeof(size_t));
    304     segNo->setOrdering(AtomicOrdering::Acquire);
     302    LoadInst * segNo = iBuilder->CreateAtomicLoadAcquire(ptr);
    305303    return segNo;
    306304}
     
    322320void KernelBuilder::setLogicalSegmentNo(Value * self, Value * newCount) {
    323321    Value * ptr = iBuilder->CreateGEP(self, {iBuilder->getInt32(0), getScalarIndex(logicalSegmentNoScalar)});
    324     iBuilder->CreateAlignedStore(newCount, ptr, sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     322    iBuilder->CreateAtomicStoreRelease(newCount, ptr);
    325323}
    326324
     
    475473    Value * waitCondTest = ConstantInt::get(int1ty, 1);   
    476474    for (unsigned i = 0; i < outbufProducerPtrs.size(); i++) {
    477         LoadInst * producerPos = iBuilder->CreateAlignedLoad(outbufProducerPtrs[i], sizeof(size_t));
    478         producerPos->setOrdering(AtomicOrdering::Acquire);
     475        LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(outbufProducerPtrs[i]);
    479476        // iBuilder->CallPrintInt(name + ":output producerPos", producerPos);
    480         LoadInst * consumerPos = iBuilder->CreateAlignedLoad(outbufConsumerPtrs[i], sizeof(size_t));
    481         consumerPos->setOrdering(AtomicOrdering::Acquire);
     477        LoadInst * consumerPos = iBuilder->CreateAtomicLoadAcquire(outbufConsumerPtrs[i]);
    482478        // iBuilder->CallPrintInt(name + ":output consumerPos", consumerPos);
    483479        waitCondTest = iBuilder->CreateAnd(waitCondTest, iBuilder->CreateICmpULE(producerPos, iBuilder->CreateAdd(consumerPos, bufferSize)));
     
    494490    waitCondTest = ConstantInt::get(int1ty, 1);
    495491    for (unsigned i = 0; i < inbufProducerPtrs.size(); i++) {
    496         LoadInst * producerPos = iBuilder->CreateAlignedLoad(inbufProducerPtrs[i], sizeof(size_t));
    497         producerPos->setOrdering(AtomicOrdering::Acquire);
     492        LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(inbufProducerPtrs[i]);
    498493        // iBuilder->CallPrintInt(name + ":input producerPos", producerPos);
    499         LoadInst * consumerPos = iBuilder->CreateAlignedLoad(inbufConsumerPtrs[i], sizeof(size_t));
    500         consumerPos->setOrdering(AtomicOrdering::Acquire);
     494        LoadInst * consumerPos = iBuilder->CreateAtomicLoadAcquire(inbufConsumerPtrs[i]);
    501495        // iBuilder->CallPrintInt(name + ":input consumerPos", consumerPos);
    502496        waitCondTest = iBuilder->CreateAnd(waitCondTest, iBuilder->CreateICmpULE(iBuilder->CreateAdd(consumerPos, requiredSize), producerPos));
     
    521515    for (unsigned i = 0; i < inbufConsumerPtrs.size(); i++) {
    522516        Value * consumerPos = iBuilder->CreateAdd(iBuilder->CreateLoad(inbufConsumerPtrs[i]), segSize);
    523         iBuilder->CreateAlignedStore(consumerPos, inbufConsumerPtrs[i], sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     517        iBuilder->CreateAtomicStoreRelease(consumerPos, inbufConsumerPtrs[i]);
    524518    }
    525519   
    526520    Value * produced = getProducedItemCount(self);
    527521    for (unsigned i = 0; i < outbufProducerPtrs.size(); i++) {
    528         iBuilder->CreateAlignedStore(produced, outbufProducerPtrs[i], sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     522        iBuilder->CreateAtomicStoreRelease(produced, outbufProducerPtrs[i]);
    529523    }
    530524   
     
    564558    for (unsigned i = 0; i < inbufConsumerPtrs.size(); i++) {
    565559        Value * consumerPos = iBuilder->CreateAdd(iBuilder->CreateLoad(inbufConsumerPtrs[i]), remainingBytes);
    566         iBuilder->CreateAlignedStore(consumerPos, inbufConsumerPtrs[i], sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     560        iBuilder->CreateAtomicStoreRelease(consumerPos, inbufConsumerPtrs[i]);
    567561    }
    568562    for (unsigned i = 0; i < outbufProducerPtrs.size(); i++) {
    569         iBuilder->CreateAlignedStore(producerPos, outbufProducerPtrs[i], sizeof(size_t))->setOrdering(AtomicOrdering::Release);
     563        iBuilder->CreateAtomicStoreRelease(producerPos, outbufProducerPtrs[i]);
    570564    }
    571565
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5185 r5192  
    236236        Value * ssStructPtr = getStreamSetStructPtr(self, mStreamSetOutputs[i].ssName);
    237237        Value * producerPosPtr = mStreamSetOutputBuffers[i]->getProducerPosPtr(ssStructPtr);
    238         iBuilder->CreateAlignedStore(i16UnitsGenerated, producerPosPtr, sizeof(size_t))->setOrdering(AtomicOrdering::Release);
    239     }
    240     iBuilder->CreateRetVoid();
    241     iBuilder->restoreIP(savePoint);
    242 }
    243    
    244    
    245 }
     238        iBuilder->CreateAtomicStoreRelease(i16UnitsGenerated, producerPosPtr);
     239    iBuilder->CreateRetVoid();
     240    iBuilder->restoreIP(savePoint);
     241}
     242   
     243   
     244}
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5188 r5192  
    5454    //iBuilder->CallPrintInt("streamStructPtr", iBuilder->CreatePtrToInt(streamStructPtr, iBuilder->getInt64Ty()));
    5555
    56     LoadInst * producerPos = iBuilder->CreateAlignedLoad(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr), sizeof(size_t));
    57     producerPos->setOrdering(AtomicOrdering::Acquire);
     56    LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    5857    //iBuilder->CallPrintInt("producerPos", producerPos);
    5958    Value * endSignal = iBuilder->CreateLoad(mStreamSetInputBuffers[0]->hasEndOfInputPtr(streamStructPtr));
     
    101100    Value * self = getParameter(finalBlockFunction, "self");
    102101    Value * streamStructPtr = getStreamSetStructPtr(self, "codeUnitBuffer");
    103     LoadInst * producerPos = iBuilder->CreateAlignedLoad(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr), sizeof(size_t));
    104     producerPos->setOrdering(AtomicOrdering::Acquire);
     102    LoadInst * producerPos = iBuilder->CreateAtomicLoadAcquire(mStreamSetInputBuffers[0]->getProducerPosPtr(streamStructPtr));
    105103    Value * processed = getProcessedItemCount(self);
    106104    Value * itemsAvail = iBuilder->CreateSub(producerPos, processed);
Note: See TracChangeset for help on using the changeset viewer.