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 8845735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:48:19+00:00 2026-06-14T11:48:19+00:00

I was trying to compile the following code: #pragma omp parallel shared (j) {

  • 0

I was trying to compile the following code:

#pragma omp parallel shared (j)
{
   #pragma omp for schedule(dynamic)
   for(i = 0; i != j; i++)
   {
      // do something
   }
}

but I got the following error: error: invalid controlling predicate.

The OpenMP standard states that for parallel for constructor it "only" allows one of the following operators: <, <=, > >=.

I do not understand the rationale for not allowing i != j. I could understand, in the case of the static schedule, since the compiler needs to pre-compute the number of iterations assigned to each thread. But I can’t understand why this limitation in such case for example. Any clues?


EDIT: even if I make for(i = 0; i != 100; i++), although I could just have put "<" or "<=" .

  • 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-14T11:48:20+00:00Added an answer on June 14, 2026 at 11:48 am

    .

    I sent an email to OpenMP developers about this subject, the answer I got:

    For signed int, the wrap around behavior is undefined. If we allow !=, programmers may get unexpected tripcount. The problem is whether the compiler can generate code to compute a trip count for the loop.

    For a simple loop, like:

    for( i = 0; i < n; ++i )
    

    the compiler can determine that there are ‘n’ iterations, if n>=0, and zero iterations if n < 0.

    For a loop like:

    for( i = 0; i != n; ++i ) 
    

    again, a compiler should be able to determine that there are ‘n’ iterations, if n >= 0; if n < 0, we don’t know how many iterations it has.

    For a loop like:

    for( i = 0; i < n; i += 2 )
    

    the compiler can generate code to compute the trip count (loop iteration count) as floor((n+1)/2) if n >= 0, and 0 if n < 0.

    For a loop like:

    for( i = 0; i != n; i += 2 )
    

    the compiler can’t determine whether ‘i’ will ever hit ‘n’. What if ‘n’ is an odd number?

    For a loop like:

    for( i = 0; i < n; i += k )
    

    the compiler can generate code to compute the trip count as floor((n+k-1)/k) if n >= 0, and 0 if n < 0, because the compiler knows that the loop must count up; in this case, if k < 0, it’s not a legal OpenMP program.

    For a loop like:

    for( i = 0; i != n; i += k )
    

    the compiler doesn’t even know if i is counting up or down. It doesn’t know if ‘i’ will ever hit ‘n’. It may be an infinite loop.

    Credits: OpenMP ARB

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

Sidebar

Related Questions

I am trying to compile the following code using clang but got the following
I am trying to compile the following code and i am getting the error:
I'm trying to compile the following code however I get an error on the
I am trying to compile the following code taken from here but I am
I am trying to compile the following code but I am getting linker errors.
I get this solitary error while trying to compile the following code in code::blocks.
When trying to compile the following code, I am getting a warning that line
I am trying to compile my gcc code using the following make command .
I'm trying to compile some code which contains the following declaration, because I would
I'm trying to compile a third-party library, but g++ is complaining about the following

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.