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

relock gil #3196

Merged
merged 2 commits into from
Mar 9, 2024
Merged

relock gil #3196

merged 2 commits into from
Mar 9, 2024

Conversation

trixirt
Copy link
Contributor

@trixirt trixirt commented Feb 25, 2024

Releasing causes a fault in the 'if (isObject) ' path because a malloc happens and the gil is assumed to be held.

@trixirt trixirt requested a review from ptillet as a code owner February 25, 2024 11:50
@@ -239,6 +239,7 @@ void init_triton_llvm(py::module &&m) {
}
std::string obj = translateLLVMIRToASM(
*module, triple, proc, features, flags, enable_fp_fusion, isObject);
py::gil_scoped_acquire no_threads;
Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM, but can you fix the formatting? :)

@@ -239,6 +239,7 @@ void init_triton_llvm(py::module &&m) {
}
std::string obj = translateLLVMIRToASM(
*module, triple, proc, features, flags, enable_fp_fusion, isObject);
py::gil_scoped_acquire no_threads;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor issue: this results in an unnecessary sequence of unlock -> lock -> unlock -> lock because gil_scoped_acquire releases the GIL in its destructor. It would be better to move the gil_scoped_release into a more narrow scope, e.g.

{
  py::gil_scoped_release allow_threads;
  ...
}
return isObject ? py::bytes(obj) : py::str(obj);

Releasing causes a fault in the 'if (isObject) ' path because a malloc happens
and the gil is assumed to be held.

Signed-off-by: Tom Rix <trix@redhat.com>
@trixirt trixirt force-pushed the gil_scoped_acquire branch from 6f99015 to c34cf2e Compare March 4, 2024 14:57
@trixirt
Copy link
Contributor Author

trixirt commented Mar 4, 2024

Changes requested have been made.

@ptillet ptillet enabled auto-merge (squash) March 9, 2024 21:49
@ptillet ptillet merged commit a6aaebb into triton-lang:main Mar 9, 2024
4 checks passed
htyu pushed a commit to htyu/triton that referenced this pull request Mar 20, 2024
Releasing causes a fault in the 'if (isObject) ' path because a malloc
happens and the gil is assumed to be held.

Signed-off-by: Tom Rix <trix@redhat.com>
Co-authored-by: Philippe Tillet <phil@openai.com>
karupayun pushed a commit to openxla/triton that referenced this pull request Apr 3, 2024
Releasing causes a fault in the 'if (isObject) ' path because a malloc
happens and the gil is assumed to be held.

Signed-off-by: Tom Rix <trix@redhat.com>
Co-authored-by: Philippe Tillet <phil@openai.com>
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.

3 participants