hipfort icon indicating copy to clipboard operation
hipfort copied to clipboard

Compilation errors with Intel compiler

Open drtpotter opened this issue 1 year ago • 11 comments

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

drtpotter avatar Oct 31 '23 03:10 drtpotter

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

fluidnumerics-joe avatar Oct 31 '23 12:10 fluidnumerics-joe

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

doctorcolinsmith avatar Oct 31 '23 21:10 doctorcolinsmith

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!

drtpotter avatar Oct 31 '23 23:10 drtpotter

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.

cgmb avatar Nov 09 '23 18:11 cgmb

@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.

domcharrier avatar Dec 15 '23 09:12 domcharrier

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 ?

fluidnumerics-joe avatar Dec 15 '23 11:12 fluidnumerics-joe

@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).

domcharrier avatar Dec 15 '23 13:12 domcharrier

Either sounds fine.

fluidnumerics-joe avatar Dec 15 '23 13:12 fluidnumerics-joe

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

cgmb avatar Feb 01 '24 00:02 cgmb

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.

drtpotter avatar Apr 08 '24 08:04 drtpotter

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

fluidnumerics-joe avatar Jun 26 '24 15:06 fluidnumerics-joe