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

[Issue]: Hipfc doesn't appear to be passing on optimization level flags #185

Open
drtpotter opened this issue Aug 21, 2024 · 2 comments
Open

Comments

@drtpotter
Copy link

drtpotter commented Aug 21, 2024

Problem Description

I noticed that when running a verbose compilation with hipfc it doesn't appear to be passing on desired optimization flags (-O1, -O2, -O3) to backend compilers.

Operating System

Ubuntu 22.04.4 LTS (Jammy Jellyfish)

CPU

AMD Ryzen 6800H

GPU

AMD Radeon Pro VII

ROCm Version

ROCm 6.2.0

ROCm Component

hipfort

Steps to Reproduce

Install rocm 6.2.0 then

git clone https://github.com/pelagos-consulting/Hipfort_Course.git
cd Hipfort_Course/L4_Build_Hipfort_Software

Then do a dry run compilation with:

hipfc -vv -n hip_utils.f90 math_utils.f90 tensoradd_hip_fptr.f90 kernel_code.cpp -o tensoradd.exe

It produces this output

/opt/rocm-6.2.0/bin/hipcc -v -fno-gpu-rdc -fPIC --offload-arch=gfx1035 -c kernel_code.cpp -o /tmp/hipfc-tmp-12156/hipcc.o /opt/rocm-6.2.0/bin/../lib/llvm/bin/flang -v -cpp -I/opt/rocm-6.2.0/bin/..//include/hipfort/amdgcn hip_utils.f90 math_utils.f90 tensoradd_hip_fptr.f90 /tmp/hipfc-tmp-12156/hipcc.o -L/opt/rocm-6.2.0/bin/..//lib -lhipfort-amdgcn -L/opt/rocm-6.2.0/lib -lamdhip64 -Wl,-rpath=/opt/rocm-6.2.0/lib -lstdc++ -o tensoradd.exe #Info: Done

Despite the hipfc help string advertising this option, passing in -O3 to hipfc seems to make no difference to the flags being passed on to flang or hipcc. For example running

hipfc -O3 -vv -n hip_utils.f90 math_utils.f90 tensoradd_hip_fptr.f90 kernel_code.cpp -o tensoradd.exe

produces this output

/opt/rocm-6.2.0/bin/hipcc -v -fno-gpu-rdc -fPIC --offload-arch=gfx1035 -c kernel_code.cpp -o /tmp/hipfc-tmp-12226/hipcc.o /opt/rocm-6.2.0/bin/../lib/llvm/bin/flang -v -cpp -I/opt/rocm-6.2.0/bin/..//include/hipfort/amdgcn hip_utils.f90 math_utils.f90 tensoradd_hip_fptr.f90 /tmp/hipfc-tmp-12226/hipcc.o -L/opt/rocm-6.2.0/bin/..//lib -lhipfort-amdgcn -L/opt/rocm-6.2.0/lib -lamdhip64 -Wl,-rpath=/opt/rocm-6.2.0/lib -lstdc++ -o tensoradd.exe

This is a problem because in the absence of explicitly defined optimisation flags the default optimisation level for compilers is quite low ("e.g -O0" for gfortran). Users won't be able to benefit from code optimisations when compiling with hipfc. A check of the hipfc script shows that the optimisation level is being read in correctly into the variable FORTOPT, however nothing further is actually done with that variable in passing on the optimisation level to hipcc or flang or gfortran.

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

@cgmb
Copy link
Collaborator

cgmb commented Sep 3, 2024

That's odd. I'll take a look. Thank you for the report.

@cgmb
Copy link
Collaborator

cgmb commented Sep 3, 2024

One thing to note is that we're looking at deprecating hipfc, so we can focus our efforts on the bindings. The general plan is to try to point users towards idiomatic ways of building projects that contain Fortran, C, C++, and HIP (as well as applying those methods to the hipfort project itself).

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

No branches or pull requests

2 participants