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

Generate Python bindings for TaskBasedCpuContractor.hpp #19

Merged
merged 26 commits into from
May 31, 2021

Conversation

Mandrenkov
Copy link
Collaborator

Context:
This PR concludes a series of changes to generate Python bindings for the Jet C++ API.

Description of the Change:

Benefits:

  • The jet Python package includes functionality for contracting a tensor network using task-based parallelism.
  • The TaskBasedCpuContractor class can handle reductions of non-scalar results.

Possible Drawbacks:
None.

Related GitHub Issues:
None.

@Mandrenkov Mandrenkov added bug 🐛 Something isn't working enhancement ✨ New feature or request labels May 28, 2021
@github-actions
Copy link

github-actions bot commented May 28, 2021

Test Report (C++) on MacOS

    1 files  ±0      1 suites  ±0   0s ⏱️ ±0s
240 tests ±0  240 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
520 runs  ±0  520 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f124ae2. ± Comparison against base commit f124ae2.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented May 28, 2021

Test Report (C++) on Ubuntu

    1 files  ±0      1 suites  ±0   0s ⏱️ ±0s
240 tests ±0  240 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
520 runs  ±0  520 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f124ae2. ± Comparison against base commit f124ae2.

♻️ This comment has been updated with latest results.

Copy link
Member

@mlxd mlxd left a 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"(
Copy link
Member

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.

Copy link
Collaborator Author

@Mandrenkov Mandrenkov May 28, 2021

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?

Base automatically changed from dtype-support to main May 31, 2021 17:47
@Mandrenkov Mandrenkov merged commit f124ae2 into main May 31, 2021
@Mandrenkov Mandrenkov deleted the tbcc-binding branch May 31, 2021 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants