tags:

views:

55

answers:

1

Greetings all,

I want to run the code block inside the loop ,in seperate OpenMP thread. Have I defined correct OpenMP directives in the following code snippet:

#ifdef OPENMP_ENABLE
        #pragma omp parallel for
    #endif

for(int i=0;i<numOfSlices;i++){                  // Entire block inside this loop should be fun in new OpenMP thread

        int id =0;

        #ifdef OPENMP_ENABLE
               id=omp_get_thread_num();
              qDebug("------- OPENMP thread number  %d",id);
        #endif
            qDebug("      - Image Slice %d",i);

        int width=0,height=0;
        //Image Buffer
        unsigned char *buff=planeViewer->getImageBuggerOfSlice(i,height,width);

        //Trunk
        RzTrunk *rztrnk=planeViewer->getTrunkOfSlice(i);

        //If Empty trunk,add frame @TODO Hard coded
        if(rztrnk->getCurveCount()==0){
           RzCurve *crv=rztrnk->createFrameCurve(10,10,width-10,height-10);
           rztrnk->addCurve(crv);
        }

       //Covert Rinzo Trunk to Centy Trunk!
       //TODO Make sure to deallocate memory
       QImage *qimg=new QImage(buff,width,height,QImage::Format_RGB32);
       trnk_t *trnkt = convertRzTrunkToCntyTrunk(rztrnk, qimg->width(),qimg->height());


       //Convert QImage to Cnty Image format
       image_t *imgt=convertQImageToImaget(qimg);

       //This extract parts , first should detect outer border
       if(etype==EXTRACT_DEFL_INOUT){
            cnty_extract_contour(EXTRACT_DEFL_OUT, trnkt, imgt, NULL, NULL,settings2, NULL);
            trnk_make_crvs_nodes_active(trnkt);
       }

       cnty_extract_contour(etype, trnkt, imgt, NULL, NULL,settings, NULL);
       convertCntyTrunkToRzTrunk(trnkt, rztrnk);

       trnk_destruct(trnkt);
       destroyImaget(imgt);
       delete qimg;
       delete buff;    
} //end of for loop
A: 

I found the issue.the reason was that the "cnty_extract_contour()" method is not thread-safe.

umanga