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

Set threads warnings #443

Merged
merged 6 commits into from
Jul 9, 2021
Merged

Set threads warnings #443

merged 6 commits into from
Jul 9, 2021

Conversation

stavros11
Copy link
Member

Fixes #442 by:

  • Modifying qibo.set_threads to update the number threads only for the currently active backend.
  • Raising warnings when using qibo.set_threads with the numpy or tensorflow backends which do not support this kind of thread setting.

@stavros11 stavros11 requested a review from scarrazza July 9, 2021 11:53
@codecov
Copy link

codecov bot commented Jul 9, 2021

Codecov Report

Merging #443 (9ad5edf) into master (47ad4ad) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #443   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           83        83           
  Lines        11866     11883   +17     
=========================================
+ Hits         11866     11883   +17     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/qibo/backends/__init__.py 100.00% <100.00%> (ø)
src/qibo/backends/numpy.py 100.00% <100.00%> (ø)
src/qibo/backends/tensorflow.py 100.00% <100.00%> (ø)
src/qibo/tests/test_backends_init.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 47ad4ad...9ad5edf. Read the comment docs.

@@ -30,6 +30,11 @@ def set_device(self, name):
log.warning("Numpy does not support device placement. "
"Aborting device change.")

def set_threads(self, nthreads):
log.warning("Numpy backend supports only single-thread execution."
"Cannot change the number of threads.")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Cannot change the number of threads.")
" Cannot change the number of threads.")

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks.

@scarrazza
Copy link
Member

Great, thanks. Could you please fix another issues I have just observed, when changing to numpy the device list is [], for symmetry with other backends I think we could simply say something like /CPU:0...

@stavros11
Copy link
Member Author

Great, thanks. Could you please fix another issues I have just observed, when changing to numpy the device list is [], for symmetry with other backends I think we could simply say something like /CPU:0...

I changed the default numpy device to "/CPU:0". Let me know if you agree with the last changes.

Copy link
Member

@scarrazza scarrazza left a comment

Choose a reason for hiding this comment

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

Perfect, thank you.

@scarrazza scarrazza merged commit c319d97 into master Jul 9, 2021
@scarrazza scarrazza deleted the setthreads branch July 10, 2021 17:01
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.

Set threads warning messages
2 participants