ROCm / HIP

HIP: C++ Heterogeneous-Compute Interface for Portability

Home Page:https://rocmdocs.amd.com/projects/HIP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting peak Binary32 flop/s on CDNA2 using float2

etiennemlb opened this issue · comments

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 ?

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.

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

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

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.

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.

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

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

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