Jump to content

  • Log In with Google      Sign In   
  • Create Account

NDIR

Member Since 22 Sep 2007
Offline Last Active Sep 19 2014 04:40 PM

#5181603 Poor STL threads performance

Posted by NDIR on 19 September 2014 - 01:59 PM

 

Do you actually split the work between the threads or do you simply multiply the work with every thread?

 

Not sure what you mean, but i tried multiple approaches.

The one i wrote above, and this one too :

 

for(int m_prime = 0; i < N; i++)

{

     threads.push_back(std::thread(&Ocean::DoFFT, this, 1, m_prime * N));

     if(threads.size() == 4)

     {

           //.. join all 4 threads before moving to the next batch.

     }

}

 

But like Hogman mentioned, i am spawning 64 threads even with this approach, i'll just create some kind of threadpool of 4 permanent threads instead.

 

Side question though, assuming i make this thing work properly with expected fps boost, would i get better performance with OpenMP (so code still executed on CPU), or should i jump directly to a OpenCL implementation ?

 

Thanks for your help !

 

 

Take 4 threads (from a pool, don't create new ones every frame / update) and split the work between those 4 threads.

 

So thread 1 executes (in the Ocean::DoFFT):

 

for (int m_prime = 0; m_prime < N/4; m_prime++) {
fft->fft(h_tilde, h_tilde, 1, m_prime * N);
fft->fft(h_tilde_slopex, h_tilde_slopex, 1, m_prime * N);
fft->fft(h_tilde_slopez, h_tilde_slopez, 1, m_prime * N);
fft->fft(h_tilde_dx, h_tilde_dx, 1, m_prime * N);
fft->fft(h_tilde_dz, h_tilde_dz, 1, m_prime * N);
}

 

Thread 2 executes:

 

for (int m_prime = N/4; m_prime < N/4+N/4; m_prime++) {
fft->fft(h_tilde, h_tilde, 1, m_prime * N);
fft->fft(h_tilde_slopex, h_tilde_slopex, 1, m_prime * N);
fft->fft(h_tilde_slopez, h_tilde_slopez, 1, m_prime * N);
fft->fft(h_tilde_dx, h_tilde_dx, 1, m_prime * N);
fft->fft(h_tilde_dz, h_tilde_dz, 1, m_prime * N);
}

 

and so on.




#4953739 Line intersecting a face

Posted by NDIR on 28 June 2012 - 01:01 PM

Do a simple ray-plane intersection test. Then in case of intersection, test if that point lies within your polygon.


#4874244 Raytracing a Box

Posted by NDIR on 19 October 2011 - 05:04 AM

then you should do &ray or *ray


PARTNERS