CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

One severe limitation of OpenMP

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By aerosayan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 25, 2021, 05:51
Default One severe limitation of OpenMP
  #1
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
If you got 8 threads, you use as many threads as possible.
However, OpenMP only allows control on a per-loop basis.


I have this bit of section in my solver,
I calculate rho_inverse, a, a_inverse, PSV from CSV, pressure etc :
Code:
    //
    //             --- prepare commonly used data ---
    //

    // calculate rho inverse
    //
    inv_arrays(ri_, un1_, 1.0, ncells);

    // calculate x velocity, y velocity, energy
    //
    mul_arrays(vx_, un2_, ri_, ncells);
    mul_arrays(vy_, un3_, ri_, ncells);
    mul_arrays(e_ , un4_, ri_, ncells);

    // calculate pressure
    //
    calc_pressure(p_, un1_, e_, vx_, vy_, 0.4, ncells);

    // calculate the local speed of sound for all cells at once
    //
    calc_spdsound(a_, p_, ri_, 1.4, ncells);

    // calculate the reciprocal of the local speed of sound for all cells
    //
    inv_arrays(ai_, a_, 1.0, ncells);
However, all of this is serial. If I got 4 threads, I could calculate rho_inverse first serially, then use 3 threads to simultaneously calculate the x,y,e values, then calculate pressure, a, a_inverse serially.

The speedup would come from calculating the x,y,e values in parallel, instead of doing them serially one after another.

This kind of optimization opportunities are present throughout the code. However, OpenMP provides limited control.

There's OpenMP sections, and that's what I'm currently using, but they're very limited.

Using OpenMP sections, I can hardcode instructions to calculate x,y,e in parallel. However, since they're hardcoded, they're not scalable when we have more threads to use, and more equations to solve in parallel.

Will probably keep using OpenMP sections, until I find a better alternative.


If anyone knows of a better solution, kindly let me know.
ssh123 and aero_head like this.
aerosayan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using OpenMP similar to MPI? Bad idea? aerosayan Main CFD Forum 3 January 6, 2021 06:42
Particle tracking INTEGER limitation warning Peter023 FLUENT 0 June 24, 2013 04:59
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 06:50
Severe nonorthogonality and severe skewness problem qtian OpenFOAM Running, Solving & CFD 2 January 22, 2008 19:47
OpenMP and fortran John Deas Main CFD Forum 0 May 17, 2007 17:53


All times are GMT -4. The time now is 14:16.