Hi I have below function :
PS: feat is vector or eigen matrix.
#pragma omp parallel for
for (int x = 0; x < count_feature; x++) {
auto distance = ( feat.row(x)- b_cmp ).squaredNorm();
// std::cout << id << " "<< distance << std::endl ;
if (distance < 0.5) {
std::cout << std::endl << "Buldummm : " << x << " " << distance <<std::endl;
mutex1.lock();
found_number.push_back(x);
mutex1.unlock();
}
}
also I am running the same function with :
std::vector<std::thread> threadList;
for(int i = 0; i < n_thread_num; i++)
{
std::cout << "chunks : " << i*chunk_number << " to " << (i+1)*chunk_number << std::endl;
threadList.push_back(std::thread (FindDistance, std::ref(feat), std::ref(b_cmp), i*chunk_number, (i+1)*chunk_number));
}
std::cout<<"wait for all the worker thread to finish"<<std::endl;
std::for_each(threadList.begin(),threadList.end(), std::mem_fn(&std::thread::join));
Same thread number.
but OpenMP version is : 1.14889 second ThreadPoll version: 2.61334
why there is more than X2 difference ? Is this the best way ?
Aucun commentaire:
Enregistrer un commentaire