Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:48:27+00:00 2026-06-03T20:48:27+00:00

If I use nested parallel for loops like this: #pragma omp parallel for schedule(dynamic,1)

  • 0

If I use nested parallel for loops like this:

#pragma omp parallel for schedule(dynamic,1)
for (int x = 0; x < x_max; ++x) {
    #pragma omp parallel for schedule(dynamic,1)
    for (int y = 0; y < y_max; ++y) { 
    //parallelize this code here
   }
//IMPORTANT: no code in here
}

is this equivalent to:

for (int x = 0; x < x_max; ++x) {
    #pragma omp parallel for schedule(dynamic,1)
    for (int y = 0; y < y_max; ++y) { 
    //parallelize this code here
   }
//IMPORTANT: no code in here
}

Is the outer parallel for doing anything other than creating a new task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:48:28+00:00Added an answer on June 3, 2026 at 8:48 pm

    If your compiler supports OpenMP 3.0, you can use the collapse clause:

    #pragma omp parallel for schedule(dynamic,1) collapse(2)
    for (int x = 0; x < x_max; ++x) {
        for (int y = 0; y < y_max; ++y) { 
        //parallelize this code here
        }
    //IMPORTANT: no code in here
    }
    

    If it doesn’t (e.g. only OpenMP 2.5 is supported), there is a simple workaround:

    #pragma omp parallel for schedule(dynamic,1)
    for (int xy = 0; xy < x_max*y_max; ++xy) {
        int x = xy / y_max;
        int y = xy % y_max;
        //parallelize this code here
    }
    

    You can enable nested parallelism with omp_set_nested(1); and your nested omp parallel for code will work but that might not be the best idea.

    By the way, why the dynamic scheduling? Is every loop iteration evaluated in non-constant time?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do this: omp_set_nested(1); #pragma omp parallel for private(j) for (i =
My problem is to use nested for loops in order to create this output:
I would like to learn how I can use nested template tags where the
I have nested iframes and I would like to use onload function for the
looks like when scala 2.8.0 is out, we can use nested @annotations in our
I'd like to use nested lists in my data acquistion application to store my
I use nested set with doctrine 1.2. Here is my example. I got this
Have a program request the user to enter an uppercase letter. Use nested loops
I'm having trouble getting this to work. I want to use nested attributes in
I would like to use nested classes as a part of an application I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.