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

Performance: Convert an FDIV to an FMUL in a hot loop #1030

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

heshpdx
Copy link

@heshpdx heshpdx commented Sep 17, 2024

Description

For the generic/CPU path, we noticed a super hot loop executing a floating point divide, where the divisor is a loop invariant and can be replaced by a floating point multiply. This can provide some speedup for microarchitectures which implement FMUL faster than FDIV.

Added dependencies: none

How to test

I could not build this repository on my box. We were testing with the SPEC CPU candidate drop of marian. The edit is small and contained, and verified within our framework without loss of accuracy. We are offering this patch in case it helps the community.

Here is a snippet of coverage from tensor_operations.cpp, where hit counts are listed to the right of the line numbers. In this image, line 1177 and 1181 are the ones we would edit.

image

Checklist

  • [y] I have tested the code manually
  • [n] I have run regression tests
  • [y] I have read and followed CONTRIBUTING.md
  • [y] I have updated CHANGELOG.md

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.

1 participant