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

C/Fortran interface #7

Closed
jacobwilliams opened this issue Feb 10, 2019 · 13 comments
Closed

C/Fortran interface #7

jacobwilliams opened this issue Feb 10, 2019 · 13 comments

Comments

@jacobwilliams
Copy link

A C/Fortran interface to this would be great. I think it could be added in a similar way that Ipopt has done it.

@cnpetra
Copy link
Collaborator

cnpetra commented Feb 11, 2019

it is on my todo list but I am a bit short-handed momentarily. I will keep you posted. Thanks for the interest.

@ashermancinelli
Copy link
Contributor

What is the status of this issue?

@cnpetra
Copy link
Collaborator

cnpetra commented Dec 1, 2020

open :)

ashermancinelli pushed a commit that referenced this issue Jun 22, 2021
…uality constraints, inequality constraints. #7
ashermancinelli pushed a commit that referenced this issue Jun 22, 2021
Shri/scopflow major refactor

Closes #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #14, #17, #18, and #15

See merge request exasgd/frameworks/scopflow!2
@cnpetra
Copy link
Collaborator

cnpetra commented Jul 1, 2022

@nychiang : how stage is the Fortran interface?

@nychiang
Copy link
Collaborator

nychiang commented Jul 1, 2022

On the platform with AMD GPU, some compiling error happened when HIOP_BUILD_SHARED is set to ON.
The error message is
/opt/rocm-4.5.0/amdgcn/bitcode/hip.bc: file not recognized: file format not recognized

This error prevents HiOp creating all the fortran related examples.

@nychiang
Copy link
Collaborator

nychiang commented Jul 2, 2022

More details:
When Cmake links libraries from hip toolchain, e.g.,
target_link_libraries(hiop_hip INTERFACE hip::device Magma) (Asher's approach)
or
target_link_libraries(hiop_hip INTERFACE hip::hiprand roc::rocrand hip::hipfft roc::hipblas roc::rocblas hip::hipcub roc::rocprim_hip Magma ) (my modification due to the usage of hiprand),
the new ROCm bitcode library /opt/rocm-4.5.0/amdgcn/bitcode/hip.bc needs to be linked.
However, it seems that the fortran compiler ftn doesn’t recognize this format and hence we received this error.

A quick solution is that we use flang as the fortran compiler, since this bitcode is build by clang and several llvm development tools (https://github.com/RadeonOpenCompute/ROCm-Device-Libs).
Without any change to the existing hiop files, but just setting cmake flag -DCMAKE_Fortran_COMPILER=/opt/rocm-4.5.0/bin/amdflang, all the unit tests work fine as well as the fortran examples.

@pelesh @cameronrutherford have you ever got similar problem like this? Can we use ftn with bitcode library? (hard to find relevant discussions on google)

@cnpetra

@pelesh
Copy link
Collaborator

pelesh commented Jul 5, 2022

@nychiang, as far as I know we used a combination of clang C++ and gcc Fortran compilers to build HiOp with Fortran interface. My understanding is that ROCm bitcode library is specific to the clang intermediate representation and won't work with gcc. If flang is available and mature enough, one should go with that instead of combining different compilers imho.

@ashermancinelli, please chime in.

@cnpetra
Copy link
Collaborator

cnpetra commented Jul 13, 2022

@nychiang, as far as I know we used a combination of clang C++ and gcc Fortran compilers to build HiOp with Fortran interface. My understanding is that ROCm bitcode library is specific to the clang intermediate representation and won't work with gcc. If flang is available and mature enough, one should go with that instead of combining different compilers imho.

@ashermancinelli, please chime in.

PR #514 adds a partial fix and allows using flang compiler on the problematic AMD/ROCm machine. Some investigation is needed to figure out use of gfortran. Nvidia/CUDA machines work fine with generic Fortran compilers.

@nychiang
Copy link
Collaborator

The following Fortran examples are given:
For sparse linear system:
https://github.com/LLNL/hiop/blob/develop/src/Drivers/Sparse/NlpSparseExHS071.f
https://github.com/LLNL/hiop/blob/develop/src/Drivers/Sparse/NlpSparseFEx1.f
For dense linear system:
https://github.com/LLNL/hiop/blob/develop/src/Drivers/Dense/NlpDenseConsFEx1.f

@jacobwilliams
Copy link
Author

This is great! But can the examples be written in modern Fortran? I don't think there is any reason to use the F77 format nowadays. Do you need some assistance with doing that?

@jacobwilliams
Copy link
Author

@cnpetra
Copy link
Collaborator

cnpetra commented Aug 8, 2022

This is what I have in mind: https://github.com/jacobwilliams/hiop/blob/modern-fortran/src/Drivers/Dense/NlpDenseConsFEx1.f90

We would be supportive of also using more recent Fortran for examples. Please feel free to take a shot and PR, our experience with Fortran is limited.

In the meanwhile I suggest we close this issue and open an issue re: examples in modern Fortran.

@cnpetra
Copy link
Collaborator

cnpetra commented Aug 24, 2022

Will close this and we track the developement of a more modern F examples in isssue #532

@cnpetra cnpetra closed this as completed Aug 24, 2022
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

5 participants