-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Configurable flushing denormal numbers on CPU #5294
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
Conversation
apaszke
left a comment
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.
LGTM. Just curious why is that useful? Does it change the CPU performance a lot?
torch/_torch_docs.py
Outdated
| r""" | ||
| set_flush_denormal(on) -> bool | ||
| Returns ``True`` if it successfully configures flush denormal mode. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Yes. The benchmark of #4737 gets about 13x faster on my machine. Without flushing denormal numbers: With flushing denormal numbers: |
|
@pytorchbot test this please |
|
thanks @tunz ! |
Issue #4737
This PR provides a function to enable/disable flush denormal mode on x86 supporting SSE3. Intel is providing this two macros
_MM_SET_FLUSH_ZERO_MODEand_MM_SET_DENORMALS_ZERO_MODE, so I used these.it seems some old versions of gcc have an issue to prevent the use of intrinsics (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57202), so always add
-msse3option.I'm not sure if we have to enable this option by default or not, but I think this approach seems reasonable as a first step.