Skip to content

Conversation

@andrew-platt
Copy link
Collaborator

@andrew-platt andrew-platt commented Oct 2, 2025

Needs some review and testing.

Feature or improvement description
TurbSim has been single-threaded forever. This PR adds parallelization through OpenMP and should in theory run faster as a result.

If OpenMP is enabled at compile time, parallelization for MKL will be automatically turned off. We saw this the MKL parallelization is an issue in #3018 when the MKL would try to parallelize some tiny matrix manipulation incurring massive overhead costs.

Still need to extend to the following routines:

  • CalcFourierCoeffs_API
  • CalcFourierCoeffs_General
  • CalcFourierCoeffs_None

Related issue, if one exists
#3018

Impacted areas of the software
TurbSim only

Additional supporting information

  • A PRIVATE(<allocatable_array>) in a !$OMP PARALLEL DO pragma doesn't always allocate the copy of that array. This leads to segfaults. I have messy workarounds for this. There may be a better way to do it, but I have no idea if the ROCM Flang compiler will be able to handle anything more advanced.
  • Using THREADPRIVATE with COPYIN works better than the original solution

Test results, if applicable
No test results should change.

The TRH_in in the SHARED was causing memory issues.  Removing that makes things identical now.
No need for the inner loop.
…se THREADPRIVATE and COPYIN to create the necessary copies of TRH array in CalcFourierCoeffs_IEC instead of doing it manually
…hen not using OpenMP or explicitly setting the BLAS vendor. This should reduce the chances of slowdowns from calling the MKL with many small calculations trying to distribute it over many threads.
Copy link
Collaborator Author

@andrew-platt andrew-platt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deslaughter's changes are great - a much better method than what I proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants