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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:19:06+00:00 2026-06-16T20:19:06+00:00

As the title states, I want to parallelize a sum using OpenMP. I searched

  • 0

As the title states, I want to parallelize a sum using OpenMP. I searched for different approaches but I either do not understand what they do or they didn’t work. Here’s what I found:

1)

!$OMP PARALLEL WORKSHARE
P_pump_t = 0.5d0 * dcv / pi**2 * sum( k * p_pump_k * dk )
!$OMP END PARALLEL WORKSHARE

Works, but I dont understand what happens and what benefit I get.

2)

!$OMP PARALLEL DO REDUCTION(+:P_pump_t)
do l = 1, n
P_pump_t = P_pump_t + 0.5d0 * dcv / pi**2 * k(l) * p_pump_k(l) * dk(l)
end do
!$OMP END PARALLEL DO

Gives wrong (different from 1) or 3)) results.

3) Of course I could compute a new array (parallelized) and let this one in the end summed up…

A hint on how to do it best?

  • 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-16T20:19:07+00:00Added an answer on June 16, 2026 at 8:19 pm

    Based on the amount of code that you share, I would guess that “but I dont 2)” means that the loop version gives incorrect (different?) results. This could be if you omitted the initialisation of P_pump_t to 0.0 before the summation loop. Also note that both codes might produce slightly different results because of the non-associativity of floating-point operations – for example, (a+b)+c might produce a slightly different result from a+(b+c) because of the rounding and normalisation applied after each operation. Something like this would better match the vectorised version of your code:

    P_pump_t = 0.0
    !$OMP PARALLEL DO REDUCTION(+:P_pump_t)
    do l = 1, n
      P_pump_t = P_pump_t + k(l) * p_pump_k(l) * dk(l)
    end do
    !$OMP END PARALLEL DO
    P_pump_t = 0.5d0 * dcv / pi**2 * P_pump_t
    

    It is quite possible that ifort already does extract the common multiplication after the loop – it is pretty good at performing such optimisations.

    Also note that with Intel’s OpenMP implementation the WORKSHARE directive is simply translated to SINGLE, i.e. the code actually runs in serial and on 32-bit machines that use x87 FPU instructions one can expect different results from the serial version than from the multithreaded one because of the higher internal precision of the x87 FPU.

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

Sidebar

Related Questions

As the title states, I want to group some ColumnSeries, I'm using Silverlight Charting
Well, the title pretty much states it. I want to be able to draw
As the title states, I am using devise. I came upon this link that
Just a simple question, just as the title states. I just want to know
As title states, my objective is to produce an HTML table using data from
The title already states it: I want to use some linux one liner (e.g.
As the title states, I am trying to import an UIView, but I can't
As the title states, I want to get the difference (in seconds) between 2
Basically the Title states the question, but the situation is this (it's difficult to
I made a button with IB then added custom images for different states but

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.