Skip to content
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

Increase codegen thread safety #44454

Merged
merged 2 commits into from
Mar 29, 2022

Conversation

pchintalapudi
Copy link
Member

Removes a few global variables, marks some other ones as const where possible, and makes globalUnique an atomic integer.

Depends on #43770 for removing other LLVM globals.

PM.run(M);
{
//Lock around our pass manager
std::lock_guard<std::mutex> lock(this->mutex);
Copy link
Member

Choose a reason for hiding this comment

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

priority inversion? Can you add these locks to doc/src/devdocs/locks.md

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this be considered a level 1 lock since it never holds another lock within its scope?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, if it does not need any others, which seems might be the case? That means our LLVM passes must not use any Julia state (global lookups, etc), but that seems probably true anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

This probably doesn't affect us right now, since all of our work is done under the codegen lock anyways, but I wonder if the targetmachine used in llvm-cpufeatures will bite us here later then.

src/codegen.cpp Outdated Show resolved Hide resolved
@pchintalapudi pchintalapudi marked this pull request as ready for review March 4, 2022 19:48

static const auto jl_new_opaque_closure_jlcall_func = new JuliaFunction{XSTR(jl_new_opaque_closure_jlcall), get_func_sig, get_func_attrs};

static int globalUnique = 0;
static std::atomic<int> globalUniqueGeneratedNames{0};
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason you give these two different variables the same name now? Shouldn't matter for too much longer, as we are hopefully close to eliminating this counter, but just wondering

Copy link
Member Author

Choose a reason for hiding this comment

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

They originally had the same name, and they looked like they performed the same function, so I was just preserving the similarity. I can revert that back to globalUnique.

src/jitlayers.cpp Outdated Show resolved Hide resolved
@pchintalapudi pchintalapudi force-pushed the pc/sequester-globals branch 2 times, most recently from 1be7d85 to a91f25f Compare March 26, 2022 03:43
@vchuravy vchuravy added the merge me PR is reviewed. Merge when all tests are passing label Mar 26, 2022
@pchintalapudi pchintalapudi merged commit bbdd5d7 into JuliaLang:master Mar 29, 2022
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Apr 3, 2022
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.

4 participants