-
Notifications
You must be signed in to change notification settings - Fork 14
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
Generate Python bindings for TaskBasedCpuContractor.hpp #19
Conversation
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.
This looks great! One question though:
|
||
const std::string class_name = "TaskBasedCpuContractor" + Type<T>::suffix; | ||
|
||
py::class_<TaskBasedCpuContractor>(m, class_name.c_str(), R"( |
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.
Just a question really: do we need to worry about the pthreads launched from taskflow causing problems with the python GIL? I know OpenMP backed C++ code doesn't have any issues launching threads given the different mechanism, but I wonder if this is going to cause any problems with pthreads. Since everything is run on the C++ layer, I assume it will be fine (and would hope there is no issue here), as it would be a huge performance penalty to acquire the GIL during use. I guess if the plan is to add Python tasks it may be another issue.
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.
Excellent question! My intuition is that this will not be a concern since the pthreads spawned by taskflow are not trying to acquire the GIL; however, the only way we can know for sure is by running a large benchmark using both the C++ code and the Python bindings and comparing the execution times.
Even if the GIL is problematic, I would still argue that the right move is to merge this PR for the functionality and fix any multithreading issues in a future PR. Do you agree?
Context:
This PR concludes a series of changes to generate Python bindings for the Jet C++ API.
Description of the Change:
Tensor::AddTensors()
no longer throws an exception when invoked with a non-scalarTensor
and the zeroTensor
.Benefits:
jet
Python package includes functionality for contracting a tensor network using task-based parallelism.TaskBasedCpuContractor
class can handle reductions of non-scalar results.Possible Drawbacks:
None.
Related GitHub Issues:
None.