Changeset 6238 for icGREP


Ignore:
Timestamp:
Dec 15, 2018, 3:51:53 PM (5 months ago)
Author:
nmedfort
Message:

Bug fix for last check in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/pipeline/pipeline_logic.hpp

    r6237 r6238  
    9696    b->restoreIP(resumePoint);
    9797    mPipelineKernel->setHandle(b, handle);
     98
     99    // use the process thread to handle the initial segment function after spawning
     100    // (n - 1) threads to handle the subsequent offsets
    98101    const unsigned threads = numOfThreads - 1;
    99102    Type * const pthreadsTy = ArrayType::get(sizeTy, threads);
    100103    AllocaInst * const pthreads = b->CreateAlloca(pthreadsTy);
    101     Value * threadIdPtr[threads];
    102     for (unsigned i = 0; i < threads; ++i) {
    103         threadIdPtr[i] = b->CreateGEP(pthreads, {ZERO, b->getInt32(i)});
    104     }
    105 
    106     // use the process thread to handle the initial segment function after spawning
    107     // (n - 1) threads to handle the subsequent offsets
    108     std::vector<Value *> localState(numOfThreads);
     104    std::vector<Value *> threadIdPtr(threads);
     105    std::vector<Value *> localState(threads);
    109106    for (unsigned i = 0; i < threads; ++i) {
    110107        AllocaInst * const threadState = b->CreateAlloca(threadStructType);
     
    113110        localState[i] = allocateThreadLocalSpace(b, localStateTy);
    114111        b->CreateStore(localState[i], b->CreateGEP(threadState, {ZERO, TWO}));
     112        threadIdPtr[i] = b->CreateGEP(pthreads, {ZERO, b->getInt32(i)});
    115113        b->CreatePThreadCreateCall(threadIdPtr[i], nullVoidPtrVal, threadFunc, threadState);
    116114    }
     
    119117    b->CreateStore(handle, b->CreateGEP(threadState, {ZERO, ZERO}));
    120118    b->CreateStore(b->getSize(0), b->CreateGEP(threadState, {ZERO, ONE}));
     119    Value * const processLocalState = allocateThreadLocalSpace(b, localStateTy);
     120    b->CreateStore(processLocalState, b->CreateGEP(threadState, {ZERO, TWO}));
    121121    b->CreateCall(threadFunc, b->CreatePointerCast(threadState, voidPtrTy));
    122122
     
    127127        deallocateThreadLocalSpace(b, localState[i]);
    128128    }
     129    deallocateThreadLocalSpace(b, processLocalState);
    129130
    130131}
Note: See TracChangeset for help on using the changeset viewer.