diff --git a/BM1D.cc b/BM1D.cc index db0ebe4..cd0f45a 100644 --- a/BM1D.cc +++ b/BM1D.cc @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) //todo fix parameters percent = 0.99; nGenerated = 7000; - nop = 30; + nop = 43; j_mu1=-25; j_sigma1=0.3; @@ -71,8 +71,8 @@ int main(int argc, char* argv[]) rat=0.9; percent = 0.99; - nGenerated = 4000; - nop = 30; + nGenerated = 8000; + nop = 40; vis = 1; typeOfRun = 1; @@ -114,10 +114,10 @@ int main(int argc, char* argv[]) Plotter* myPlotter = new Plotter(vis==1); myPlotter->Plot(nRuns, nSteps, myBM1DProcess->GetT(), myBM1DProcess->GetX()); - //int numCPU = sysconf(_SC_NPROCESSORS_ONLN); - //std::cout <<"cpus:"<GetT(), myBM1DProcess->GetX(),2); //nop percent nruns + Draw2D *myDraw2D = new Draw2D(nop, percent, nGenerated, myBM1DProcess->GetT(), myBM1DProcess->GetX(),numCPU); //nop percent nruns switch(random_type){ case 'g' : diff --git a/src/Draw2D.cc b/src/Draw2D.cc index b77e75f..b4b2007 100644 --- a/src/Draw2D.cc +++ b/src/Draw2D.cc @@ -64,8 +64,8 @@ void Draw2D::Histo2D() std::cout << "minMu:" << myLattice -> GetMuMin() << std::endl; - pthread_t thread[2]; - Draw2DWorkerThread *worker[2]; + pthread_t thread[nThreads]; + Draw2DWorkerThread *worker[nThreads]; pthread_attr_t attr; @@ -74,16 +74,43 @@ void Draw2D::Histo2D() int rc; void *status; - + int jobSize = myLattice -> GetLatticeSize(); + if(nThreads <= 0 || jobSize <= 0) + { + std::cout<<"nThreads >= 1!!"< 32) //small jobb size or too large nThreads? -> run single thread mode + { + std::cout<<"strange jobSize or nThread number!! run single thread mode!!"< GetLatticeSize()/2), x, t, nRuns, myLattice, BM1D_histo, BM1D_histo2, graphArray, &histoMutex); - worker[1] = new Draw2DWorkerThread((myLattice -> GetLatticeSize()/2), (myLattice -> GetLatticeSize()/2), x, t, nRuns, myLattice, BM1D_histo, BM1D_histo2, graphArray, &histoMutex); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - for(int i=0; i<2; i++) + for(int i=0; i