Ignore:
Timestamp:
Dec 29, 2016, 8:35:20 PM (3 years ago)
Author:
cameron
Message:

Add pthread create, join and exit support into CBuilder

File:
1 edited

Legend:

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

    r5238 r5242  
    8383    iBuilder->SetInsertPoint(exitThreadBlock);
    8484    Value * nullVal = Constant::getNullValue(voidPtrTy);
    85     Function * pthreadExitFunc = m->getFunction("pthread_exit");
    86     CallInst * exitThread = iBuilder->CreateCall(pthreadExitFunc, {nullVal});
    87     exitThread->setDoesNotReturn();
     85    iBuilder->CreatePThreadExitCall(nullVal);
    8886    iBuilder->CreateRetVoid();
    8987
     
    131129    iBuilder->restoreIP(ip);
    132130
    133     Function * pthreadCreateFunc = m->getFunction("pthread_create");
    134     Function * pthreadJoinFunc = m->getFunction("pthread_join");
    135 
    136131    for (unsigned i = 0; i < threadNum; i++) {
    137         iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtrs[i], nullVal, thread_functions[i], iBuilder->CreateBitCast(sharedStruct, int8PtrTy)}));
     132        iBuilder->CreatePThreadCreateCall(pthreadsPtrs[i], nullVal, thread_functions[i], iBuilder->CreateBitCast(sharedStruct, int8PtrTy));
    138133    }
    139134
     
    144139   
    145140    for (unsigned i = 0; i < threadNum; i++) {
    146         iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadIDs[i], status}));
     141        iBuilder->CreatePThreadJoinCall(threadIDs[i], status);
    147142    }
    148143
     
    151146void generatePipelineParallel(IDISA::IDISA_Builder * iBuilder, std::vector<KernelBuilder *> kernels) {
    152147 
    153     Module * m = iBuilder->getModule();
    154 
    155     Type * pthreadTy = iBuilder->getSizeTy();     
     148    Type * pthreadTy = iBuilder->getSizeTy();
    156149    Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    157150    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
     
    176169    iBuilder->restoreIP(ip);
    177170
    178     Function * pthreadCreateFunc = m->getFunction("pthread_create");
    179     Function * pthreadJoinFunc = m->getFunction("pthread_join");
    180 
    181     for (unsigned i = 0; i < kernels.size(); i++) {
    182         iBuilder->CreateCall(pthreadCreateFunc, std::vector<Value *>({pthreadsPtrs[i], nullVal, kernel_functions[i], iBuilder->CreateBitCast(kernels[i]->getInstance(), int8PtrTy)}));
     171    for (unsigned i = 0; i < kernels.size(); i++) {
     172        iBuilder->CreatePThreadCreateCall(pthreadsPtrs[i], nullVal, kernel_functions[i], iBuilder->CreateBitCast(kernels[i]->getInstance(), int8PtrTy));
    183173    }
    184174
     
    189179   
    190180    for (unsigned i = 0; i < kernels.size(); i++) {
    191         iBuilder->CreateCall(pthreadJoinFunc, std::vector<Value *>({threadIDs[i], status}));
     181        iBuilder->CreatePThreadJoinCall(threadIDs[i], status);
    192182    }
    193183}
Note: See TracChangeset for help on using the changeset viewer.