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

Getting peak Binary32 flop/s on CDNA2 using float2 #3447

Open
etiennemlb opened this issue Apr 12, 2024 · 10 comments
Open

Getting peak Binary32 flop/s on CDNA2 using float2 #3447

etiennemlb opened this issue Apr 12, 2024 · 10 comments
Assignees

Comments

@etiennemlb
Copy link

etiennemlb commented Apr 12, 2024

The CDNA2 whitepaper mentions using packed float to fill a whole "lane" instead of wasting half to compute capability. In fact, an MI250X is capable of 23.9 TFlop/s of double and simple precision flop/s per GCD and 47 simple precision Tflop/s per GCD when using packed float2.

Using OpenCL and the -cl-mad-enable flag, one can indeed reach the +40 simple precision TFlop/s per GCD. I just can't begin to get this kind of performance out of HIP. In fact, when I use amdclang++ and float2, I end up with a bunch of v_pk_add and v_pk_mul instruction and not something like v_pk_fma which drops the Flop/s to 20 TFlop/s (indeed we do x2 more instruction and x0.5 more the OP/instruction and x2 Flop/OP, so 2 times less than the 40 TFlop/s I should get). I didnt dump the OpenCL generated machine code.

Any idea on how to get packed fma instructions to be generated ?

@b-sumner
Copy link
Contributor

The compiler will try to form packed operations from arbitrary code and will attempt to form fma when contractions are enabled. But ou can raise the likelihood of packed fma by directly calling fma(float2, float2, float2) and pf other supported packed operations by using float2 type variables.

@etiennemlb
Copy link
Author

etiennemlb commented Apr 12, 2024 via email

@etiennemlb
Copy link
Author

I couldnt use fma() on float2. Is there some specific header or flag ?

@b-sumner
Copy link
Contributor

This is OpenCL, correct? fma(float2, float2, float2) is a standard OpenCL builtin.

@etiennemlb
Copy link
Author

etiennemlb commented Apr 12, 2024 via email

@b-sumner
Copy link
Contributor

You could try -ffp-contract=fast. But unfortunately float2 means something in HIP and Cuda other that what it means in OpenCL. So using scalars may be the best approach.

@etiennemlb
Copy link
Author

AFAIK, -ffp-contract=fast-honor-pragma is the default for HIP. I tried any way without success.

Its a shame, I'm completely limited by the 1 instruction per clock I can push into the pipeline... Not even memory or compute, just front end stuff.

@b-sumner
Copy link
Contributor

@etiennemlb would it be possible for you to provide a minimal HIP application that demonstrates the issue?

@etiennemlb
Copy link
Author

I'll attach a reproducer for multiple cases which are of interest.
The assembly produced will also be given (generated by hipcc --offload-arch=gfx90a --save-temps -xhip -c fma.hip && cat fma-hip-amdgcn-amd-amdhsa-gfx90a.s | c++filt > gfx90a.s)?.
I used ROCm 5.7.1 and ROCm 6 and the ASM is same.

fma.zip

@b-sumner
Copy link
Contributor

Thank you. We now have an internal ticket open for this.

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

No branches or pull requests

3 participants