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

[flang] MOD 7x performance regression #78641

Closed
vzakhari opened this issue Jan 18, 2024 · 5 comments · Fixed by #78745
Closed

[flang] MOD 7x performance regression #78641

vzakhari opened this issue Jan 18, 2024 · 5 comments · Fixed by #78745

Comments

@vzakhari
Copy link
Contributor

Polyhedron/ac slowed down by 3.7x after #77167
_FortranAModReal8 itself slowed down by 7.4x

I wonder if it can use the previous approach for not so different a and p.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 18, 2024

@llvm/issue-subscribers-flang-runtime

Author: Slava Zakharin (vzakhari)

Polyhedron/ac slowed down by 3.7x after https://github.com//pull/77167 `_FortranAModReal8` itself slowed down by 7.4x

I wonder if it can use the previous approach for not so different a and p.

@vzakhari
Copy link
Contributor Author

Another observation is that in the ac benchmark both values seem to be integers.

@klausler
Copy link
Contributor

Can you give me a link to the exact call site in the source that you believe is passing integer arguments?

@vzakhari
Copy link
Contributor Author

There is a single call site in file ac.f90:

      REAL FUNCTION GGL(Ds)

!     +     D1,
      DOUBLE PRECISION Ds , d2
!      DATA D1/2147483648.D0/
      DATA d2/2147483647.D0/
      Ds = DMOD(16807.D0*Ds,d2)
!     Generate U(0,1] distributed random numbers:
      GGL = Ds/d2

      CONTINUE
      END

@klausler
Copy link
Contributor

#78745 should improve things (it's faster in my experiments) but may not be fast enough; please let me know.

klausler added a commit to klausler/llvm-project that referenced this issue Jan 19, 2024
The new accurate algorithm for real MOD and MODULO in the
runtime is not as fast as std::fmod(), which is also
accurate.  So use std::fmod() for those floating-point
types that it supports.

Fixes llvm#78641.
klausler added a commit that referenced this issue Jan 25, 2024
The new accurate algorithm for real MOD and MODULO in the runtime is not
as fast as std::fmod(), which is also accurate. So use std::fmod() for
those floating-point types that it supports.

Fixes #78641.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants