-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add OMP critical for make_archive #708
Conversation
See .rsp file operation in make_archive. It would be great if this PR could also be included in |
Thanks for fixing this @zoziha - I agree it would be good to get this in for v0.6.0! I encounter this error sporadically but I don't entirely understand the cause. I wonder if the critical section should go in fpm_filesystem::delete_file (around the entire contents) to narrow it down - can you try this to see if it has the same affect as your fix here? |
Move the critical section to |
Thanks for testing that out, okay yeah that's interesting. The reason I'm perplexed is that there should only be one archive object and hence only one thread that ever executes that code. So surely a critical section shouldn't have any effect? I'm now wondering if the critical section is indirectly fixing the issue by introducing a delay or synchronisation. |
I can't really understand this issue. It stands to reason that only one archive file needs to be created in the However, in any case, this PR ensures that when generating the archive file, only a single thread is used, and it is set as a critical process, ensuring that this part of the code is not affected by other threads.
@LKedward , do you also encounter this problem on Windows? |
Sorry yes, I only encounter it on Windows (msys2). So I think you're right that it might be a bug with the Windows filesystem or with mingw64. @awvwgk - how important is it that we delete the response file, could we simply leave it in place to avoid this error? |
Preferably we can remove temporary files we create, especially if they are not part of the overall build state (like object files or the digests). But if it is easier, we can just leave it around. |
During the use of these days, this PR has indeed avoided the occurrence of #707, and similar errors have not occurred again on my computer, but indeed this may be a bug related to There is often only one archive file that needs to be created at present, and it is acceptable to set a critical section for it, which makes opening the Since it's a tiny modification, we can improve it in the future when the real reason is found, also because it's small enough to let it pass now if we can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks both. Okay good point, in that case I'm happy to move forward with this. Can you add a comment to the function to explain the need for the critical section and perhaps reference the Github issue number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Fixes #707 .
Description
When building an archive, it involves generating and deleting the
.rsp
file. When compiling in parallel, this will cause an error to be reported. It can be solved by adding!$OMP critical
.This PR ensures that when generating the archive file, only a single thread is used, and it is set as a
critical
process, ensuring that this part of the code is not affected by other threads.