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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:29:36+00:00 2026-05-19T06:29:36+00:00

How does OpenMP deal with data declared inside a parallel section? Before C99 I

  • 0

How does OpenMP deal with data declared inside a parallel section? Before C99 I would use the private() clause to specify thread-local data, e.g.

int i, x;
#pragma omp parallel for private(x)
for (i=0; i<n; i++) {
   x=i;
}

Now that C99 allows mixing of data and code, I prefer to declare variables just before using them. Does declaring data within the scope of the loop guarantee it is thread-private? For example, is the following valid?

#pragma omp parallel for
for (int i=0; i<n; i++) {
   int x=i;
}

I tried adding private(x) just in case, but my compiler objects (probably since x isn’t declared yet).

  • 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-05-19T06:29:37+00:00Added an answer on May 19, 2026 at 6:29 am

    Some variables, including those declared within a parallel construct, have data-sharing attributes that are predetermined (eg, you can’t declare them shared or private). Those are defined in section 2.9.1.1 in the OMP3 standard.

    In this case, OpenMP Standard 3.0, 2.9.1.1: (p78, line 12) “Variables with automatic storage duration that are declared in a scope inside the construct are private.” I’m pretty sure it’s always been this way in OpenMP. So yes, in your C99 example, i and x are private; on the other hand, I understand that same section to say that if x was declared static, it’d be shared. I think in this respect, it more or less does what you’d expect.

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

Sidebar

Related Questions

Does OpenMP natively support reduction of a variable that represents an array? This would
Does anyone use have a good regex library that they like to use? Most
I want to write a code converter that takes an OpenMP based parallel program
I have a c99 function that uses openmp, which works as expected. I also
Does system.Reflection work when I use release folder ?
How does the OpenMP runtime determine the best number of threads when omp_set_dynamic is
Say we have a function that does not interfere with other data and runs
I have a C extension in which I'd like to use OpenMP. When I
Does anyone know how to use the define function and pass a variable into
Does Google force employees who have offers from Facebook to leave immediately?

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.