OpenMP: copying vector using ' multithreading'
For a certain coding application i need to copy a vector consisting of big objects, so i want to make it more efficient. I'll give the old code below, with an attempt to use OpenMP to make it more efficient.
std::vector<Object> Objects, NewObjects;
Objects.reserve(30);
NewObjects.reserve(30);
// old code
Objects = NewObjects;
// new code
omp_set_num_threads(30);
#pragma omp parallel{
Objects[omp_get_thread_num()] = NewObjects[omp_get_thread_num()];
}
Would this give the same result? Or are there issues since i access the vector ' Object' . I thought it might work since i don't access the same index/Object.
from Recent Questions - Stack Overflow https://ift.tt/3w4grQJ
https://ift.tt/eA8V8J
Comments
Post a Comment