Initially, I'm getting the number of cores in a system.
int num_cpus = (int)std::thread::hardware_concurrency();
After that i created lambda function for thread compution function
auto properties = [&](int _startIndex)
{
for (int layer = _startIndex; layer < inputcount; layer += num_cpus)
{
..........//body
}
};
calling thread function and joining the thread
std::vector<std::thread> orientation_threads;
for (int i = 0; i < num_cpus; i++)
{
orientation_threads.push_back(std::thread(properties, i));
}
for (std::thread& trd : orientation_threads)
{
if (trd.joinable())
trd.join();
}
I'm getting the result correct but I want to change the thread allocation method. means, Initially, 8 thread is executing in 8 core 1st thread->1st core like this all 8 thread is allocated. 5th thread is executed first remaining 7thread is still executing. now the 5th core is free I want to allocate 9th thread to 5th core. like all thread should allocate based on which core is free