So far I have only used OpenMP to parallelize for loop in C++. However I wonder if I can execute other lines of codes which are not for loops in Parallel.
void minimization(int *a, int *x) {
// this part of the code is dependent of other library.
}
void checkForNaN(int *a){
// check nan points
}
int main() {
// read data
minimization (a,b);
checkForNaN(x);
}
Consider the sample snippet above, whereby minimization(,)
and checkForNaN()
are independent that is results of either one does not affect the other once. Is it possible to parallelize it?
I am thinking something like this:
int main() {
// read data
#pragma omp parallel
{
minimization (a,b);
checkForNaN(x);
}
}
Does it looks correct?