I recently started working with C ++ again and wrote a simple test application that finds the best way through the matrix of integer values. To improve the performance of this application, I implemented multithreading using C ++ 11 std :: thread.
unsigned int threadCount = std::thread::hardware_concurrency(); std::vector<std::thread> threads; for (unsigned int threadIndex = 0; threadIndex < threadCount; threadIndex++) { threads.push_back(std::thread(&AltitudeMapPath::bestPath, this, threadCount, threadIndex)); } for (auto& thread : threads) { thread.join(); }
As of now, I simply determine the total number of threads available and run my test for each thread. It worked fantastic, but it made me think ...
Is it a good idea to try to use all available threads for this system? Besides this simple example, are multi-threaded performance-level applications trying to capture as many threads as they can (or, it might seem, a problem), or shouldn't I be so greedy?
Thanks,
source share