ROCm / hipfort

Fortran interfaces for ROCm libraries
https://rocm.docs.amd.com/projects/hipfort/en/latest/
Other
69 stars 37 forks source link

Compilation errors with Intel compiler #123

Open drtpotter opened 11 months ago

drtpotter commented 11 months ago

Hi there,

I'm trying to compile hipfort using the Intel compiler on the hipfort develop branch and getting a few issues. One of them I cannot get around.

These lines, starting at CMakeLists.txt:113, breaks the cmake configuration because the added flags -std=f2003 and -std=f2008 are not valid arguments on the Intel Fortran compiler. Therefore testing of command line arguments in a later step fails and cmake configuration halts with an error.

IF(CMAKE_Fortran_COMPILER_SUPPORTS_F08)
  set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${HIPFORT_COMPILER_FLAGS} -std=f2008")
ELSE(CMAKE_Fortran_COMPILER_SUPPORTS_F08)
  set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${HIPFORT_COMPILER_FLAGS} -std=f2003")

If I delete the -std flags in CMakeLists.txt and use the following cmake compile options, then I can get past the cmake configuration step.

# Intel compilation flags
FLAGS="-O2 -g -free -cpp -fPIC -fmax-errors=5 -assume nounderscore"
cmake -DCMAKE_INSTALL_PREFIX=/opt/hipfort_intel/5.7.1 -DHIPFORT_COMPILER=ifort -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER="icx" -DCMAKE_C_FLAGS="-O2 -g" -DCMAKE_CXX_COMPILER="icpx" -DCMAKE_CXX_FLAGS="-O2 -g" -DCMAKE_Fortran_COMPILER="ifort" -DCMAKE_Fortran_FLAGS="${FLAGS}" -DHIPFORT_COMPILER_FLAGS="${FLAGS}" -DCMAKE_BUILD_TYPE=RELEASE ..

running make then fails at this point.

[  6%] Building Fortran object lib/CMakeFiles/hipfort-amdgcn.dir/hipfort/hipfort_hipmalloc.f.o
ifort: command line warning #10006: ignoring unknown option '-fno-underscoring'
ifort: command line remark #10148: option '-vec-report0' not supported
/netsoft/src/hipfort/lib/hipfort/hipfort_hipmalloc.f(1007): error #6911: The syntax of this substring is invalid.   [PTR]
        ptr(LBOUND(dsource,1):,LBOUND(dsource,2):) => tmp
--------^
compilation aborted for /netsoft/src/hipfort/lib/hipfort/hipfort_hipmalloc.f (code 1)
make[2]: *** [lib/CMakeFiles/hipfort-amdgcn.dir/build.make:231: lib/CMakeFiles/hipfort-amdgcn.dir/hipfort/hipfort_hipmalloc.f.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: lib/CMakeFiles/hipfort-amdgcn.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
fluidnumerics-joe commented 11 months ago

Hey @drtpotter - Would you be able to give this fork a try : https://github.com/fluidnumerics-joe/hipfort/tree/patch-1

doctorcolinsmith commented 11 months ago

@fluidnumerics-joe Thanks for submitting the patch! We are testing it internally and will update when testing is complete.

drtpotter commented 11 months ago

Hey @fluidnumerics-joe, I gave the patch a try but it needed some additional work to avoid failing at the cmake configure step. I've made some additional cmake fixes in this fork https://github.com/drtpotter/hipfort/tree/patch-2 and submitted a pull request to your patch-1 branch. With the patch-2 branch we are now past the cmake errors with the latest Intel compilers and don't have to manually specify compiler flags, however the compile error still remains.

cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/hipfort_intel/5.7.1 -DHIPFORT_COMPILER=ifort -DCMAKE_C_COMPILER="icx" -DCMAKE_CXX_COMPILER="icpx" -DCMAKE_Fortran_COMPILER="ifort" ..
make
...
[  6%] Building Fortran object lib/CMakeFiles/hipfort-amdgcn.dir/hipfort/hipfort_hipmalloc.f.o
ifort: command line warning #10006: ignoring unknown option '-fno-underscoring'
ifort: command line remark #10148: option '-vec-report0' not supported
/netsoft/src/hipfort/lib/hipfort/hipfort_hipmalloc.f(1007): error #6911: The syntax of this substring is invalid.   [PTR]
        ptr(LBOUND(dsource,1):,LBOUND(dsource,2):) => tmp
--------^
compilation aborted for /netsoft/src/hipfort/lib/hipfort/hipfort_hipmalloc.f (code 1)
make[2]: *** [lib/CMakeFiles/hipfort-amdgcn.dir/build.make:231: lib/CMakeFiles/hipfort-amdgcn.dir/hipfort/hipfort_hipmalloc.f.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: lib/CMakeFiles/hipfort-amdgcn.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

It seems strange to me that gfortan would compile this file ok but ifort does not. Any help or suggestions greatly appreciated!

cgmb commented 11 months ago

The hipfort project does not officially support the Intel Fortran compiler. However, I'm happy to accept patches from the community to fix any issues found on unsupported platforms, as long as they don't negatively impact the library as built with flang or gfortran.

I will wait on merging Joe's PR since it looks like this is still a work-in-progress.

domcharrier commented 9 months ago

@drtpotter Thanks for reporting this issue. @fluidnumerics-joe Thanks for working on the patch for Intel compilers.

@cgmb Just a heads up: Be aware that hipfort_hipmalloc.f is generated by the hipfort code generator from a template file. Joe's patch might thus be overwritten again when the code generator is turned on again.

fluidnumerics-joe commented 9 months ago

Hey @domcharrier , thanks for the heads up here. Where is the hipfort code generator ? If it's not in the repository, care to share it in a util/ directory of this repository ?

domcharrier commented 9 months ago

@fluidnumerics-joe The code generator is currently a private project.

As the owner, it's up to @cgmb to decide if we make it public. He could also consider to option to make you an external collaborator to the project, which is probably the faster option (significantly easier process).

fluidnumerics-joe commented 9 months ago

Either sounds fine.

cgmb commented 8 months ago

My preference is to open-source the generator code. However, it requires a fair bit of work first.

drtpotter commented 5 months ago

My preference is to open-source the generator code. However, it requires a fair bit of work first.

Sounds great Cory, looking forward to it! The ability to use other compilers will most certainly make this library more valuable/useful.

fluidnumerics-joe commented 3 months ago

@cgmb @domcharrier - has the provided patch been integrated into the code generator ?