1

Say we have a serial application that stops normally for a while 'till a completely independent function is computed. How can one use OpenMP to spawn that function only to a thread and only printf its result when it ends? [without stopping the main application]

EDIT: Can it be done if the independent function is run inside the main app?

1

1 Answer 1

1

You can use parallel sections.

#pragma omp parallel sections
{
   #pragma omp section
   YourMainApp ();

   #pragma omp section
   YourIndepFunction ();
}
Sign up to request clarification or add additional context in comments.

4 Comments

TY. Can the above be done by having the independent function inside the main app?
They both should run in independent threads. But I guess ultimately it's actually up to the OpenMP implementation...
[I edited the initial comment-question] Can the above be done by having the independent function inside the main app?
Nevermind, I opened a new question stackoverflow.com/questions/4292191/… and it answered my confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.