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

  • Home
  • SEARCH
  • 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 7910093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:43:42+00:00 2026-06-03T12:43:42+00:00

Quick question about OpenMP: I’m not sure how to implement a nested double for

  • 0

Quick question about OpenMP:

I’m not sure how to implement a nested double for loop in parallel using open MP.As in, two for loops inside of a larger for loop. The algorithm using such the loops in is a “double ended selection sort”.

void project::parallelDeSelectionSort()
{
  //Printarr(arr,size);
  int comparisons = 0;
  int j = 0;
  int k = 0;


  #pragma omp parallel for private (j, k)
  for(int i = 0;  i < arrSize; i++)
  {
      int min = i;
      int max = ((arrSize-1) - i);
      int maxtemp = max;
      int mintemp = min;


  for(j = min;  j < arrSize;  j++)
  {
       if(data[min] > data[j])
       {
           min = j;
       }
       comparisons++;
       //Printarr(data,arrSize);
  }//end for


  for(k = max; k > 0; k--)
  {
       if(data[max] < data[k])
       {
           max = k;
       }
       comparisons++;
       //Printarr(data,arrSize);
  }//end for

  if(min > mintemp)
  {
      swap(data[min], data[mintemp]);
  }
  comparisons++;

  if(max < maxtemp)
  {
      swap(data[max], data[maxtemp]);
  }
  comparisons++;

  //Printarr(data,arrSize);
  }//end outer for

  //cout<<GetCounter()<<endl;
  cout<<"number of comparisons in parallel DE selection sort: "<< comparisons<<endl;
}

Many thanks to any and all who answer.

  • 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-03T12:43:45+00:00Added an answer on June 3, 2026 at 12:43 pm

    this is a good tutorial on that topic:

    http://msdn.microsoft.com/en-us/magazine/cc163717.aspx

    I would suggest a

    #pragma omp parallel for
    

    for the most external loop, then

    #pragma omp for
    

    for the nested loops.

    However, I do not have now an OpenMP setup to test.

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

Sidebar

Related Questions

I have a quick question about the two examples below. Currently I am using
quick question about using ORMLite. I am trying to make sure that my implementation
Have a quick question about what would be the best way to implement iterators
Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I'm
quick question about Heroku. My app is using a gem called opentok. To function
Quick question about database design. If I have two databases: User_DB and Group_DB, and
A quick question about work balancing. Program processing files in parallel. Lets say size
I have a quick question about while loop. I want to read ASCII char
I have a quick question about using logical operators in an if statement. Currently
I have a quick question about namespace scope: I have two namespaces, A and

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.