Jump to content
  • Advertisement
Sign in to follow this  
david6327

multithreading basics

This topic is 4432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have only heard of multithreading and read a couple articles on google about c++ multithreading, but I am still unsure if it's a good idea to add multithreading capabilities to a search. Basically I have a vector of maps ( about 1000 std::map type files ) that needs to be searched for a specific text that the user has inputed. How about should I implement this multithreading capability? Thank You before hand.

Share this post


Link to post
Share on other sites
Advertisement
What I'd do is partition the map into chunks and use separate threads to search each chunk, and then after each thread has finished searching, collect the results from each search.

Share this post


Link to post
Share on other sites
Ask yourself this:
1) how much disk access is needed to search one map?
2) how much memory access is needed to search one map?
3) how much CPU usage is needed to search one map?

If you have very little disk access per map, then you are in good shape.
If you need lots of disk accesses per map, then threading isn't going to help you.

Likewise, memory accesses can kill a multithreaded application due to cache thrashing.
There is a much much higher limit on this than the disk bottleneck.

Now down to the CPU. You managed to get the memory and disk bandwidth down, and you are using lots of CPU checks (read tight inner loop)
to find your string.
What is the fastest way to do this? probably a batch job of X maps where X = # maps / # CPU's.
Split up the lists of maps(or range in the common container) and assign one batch per thread.
Collate your responses as each thread finishes, and return that to the user.

[Edited by - KulSeran on June 27, 2006 10:44:37 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!