Skip to content

Add thread safety (OpenMP critical) to command registration #1143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025

Conversation

zoziha
Copy link
Contributor

@zoziha zoziha commented May 17, 2025

When I was testing the compilation of fpm in MSYS2, after enabling --flag "-fopenmp", I found that this could cause the compilation of fpm projects by the generated fpm to be interrupted with a certain probability. I realized that this should be related to the build process and OpenMP. I traced this situation back to the "add compile_commands_table_t to the build backend" commit. I found that the problem is caused by the race condition writing of table%command (intent(inout)).

type(compile_command_table_t), intent(inout) :: table

This commit is recommended to be merged before the fpm 0.12.0 is released.

@zoziha zoziha requested a review from perazz May 17, 2025 09:59
@zoziha zoziha marked this pull request as draft May 17, 2025 10:00
@zoziha zoziha changed the title fix(fpm_compile_commands): Add thread safety (OpenMP critical) to command registration Add thread safety (OpenMP critical) to command registration May 17, 2025
@zoziha zoziha marked this pull request as ready for review May 17, 2025 10:12
@zoziha zoziha mentioned this pull request May 17, 2025
Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

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

Well done @zoziha, LGTM. This is absolutely necessary as the compile_commands_t structure is shared across threds during openmp builds.

Let's merge this before the new release. I wonder if next, a test can be established for openmp builds?

@perazz perazz merged commit 87ffc0a into fortran-lang:main May 17, 2025
27 checks passed
@zoziha
Copy link
Contributor Author

zoziha commented May 17, 2025

I wonder if next, a test can be established for openmp builds?

Yes, it is necessary to add CI testing of fpm for omp parallel building later. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants