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

[flang] OpenBLAS 0.3.27 (with openmp) not buildable on windows with flang 18 #86463

Closed
h-vetinari opened this issue Mar 25, 2024 · 10 comments
Closed
Labels
flang:ir question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Mar 25, 2024

I had been under the impression that flang had already been able to compile BLAS/LAPACK and OpenBLAS successfully (c.f. #64750, #67675, #70458).

However, while trying to use flang 19.0.0 (as of edf5782) to compile OpenBLAS 0.3.27, there's a missing omp_lib module

[...]
[3643/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stplqt.f.obj
[3644/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stplqt2.f.obj
[3645/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stpmlqt.f.obj
[3646/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_2stage.f.obj
[3647/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F.obj
FAILED: CMakeFiles/LAPACK_OVERRIDES.dir/lapack-netlib/SRC/ssytrd_sb2st.F.obj 
%BUILD_PREFIX%\Library\bin\flang.exe -I%SRC_DIR%\lapack-netlib\SRC -I%SRC_DIR%\lapack-netlib\LAPACKE\include -fopenmp -fopenmp -ffixed-line-length-72 -o CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F.obj -c CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F-pp.f
error: Semantic errors in CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F-pp.f
D:\\bld\\openblas_1719536014536\\work\\lapack-netlib\\SRC\\ssytrd_sb2st.F:237:11: error: Cannot read module file for module 'omp_lib': Source file 'omp_lib.mod' was not found
        use omp_lib
            ^^^^^^^

Previously:

While trying1 to use flang 18.1.2 to compile the latest OpenBLAS 0.3.26 (aside from from backporting a small fix due to flang 18 being stricter on unknown flags), things fail pretty early with what looks like a parsing problem...

[2005/19090] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj
FAILED: CMakeFiles/LAPACK_OVERRIDES.dir/lapack-netlib/SRC/sgbcon.f.obj 
%BUILD_PREFIX%\Library\bin\flang.exe -I%SRC_DIR%\lapack-netlib\SRC -I%SRC_DIR%\lapack-netlib\LAPACKE\include -ffixed-line-length-72 -o CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj -c CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f-pp.f
error: loc("D:\\bld\\openblas_1711274852957\\work\\lapack-netlib\\SRC\\sgbcon.f":206:7): operation with block successors must terminate its parent block

error: verification of lowering to FIR failed

Looking for the error message, the only open issue I've found is #61281, but that issue explicitly says "This case is OK in OpenMP". There's also #74348 (which got fixed in 18.1) and #72792 (where it's unclear when/what was fixed).

Footnotes

  1. despite the title of the PR, the error here is for the case with USE_OPENMP=0, i.e. no OpenMP; with OpenMP I still have to fix stuff around OpenMP_Fortran

@github-actions github-actions bot added the flang Flang issues not falling into any other category label Mar 25, 2024
@EugeneZelenko EugeneZelenko added flang:ir and removed flang Flang issues not falling into any other category labels Mar 25, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 25, 2024

@llvm/issue-subscribers-flang-ir

Author: None (h-vetinari)

I had been under the impression that flang had already been able to compile BLAS/LAPACK and OpenBLAS successfully (c.f. https://github.com//issues/64750, https://github.com//issues/67675, https://github.com//issues/70458).

However, while trying1 to use flang 18.1.2 to compile the latest OpenBLAS 0.3.26 (aside from from backporting a small fix due to flang 18 being stricter on unknown flags), things fail pretty early with what looks like a parsing problem...

[2005/19090] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj
FAILED: CMakeFiles/LAPACK_OVERRIDES.dir/lapack-netlib/SRC/sgbcon.f.obj 
%BUILD_PREFIX%\Library\bin\flang.exe -I%SRC_DIR%\lapack-netlib\SRC -I%SRC_DIR%\lapack-netlib\LAPACKE\include -ffixed-line-length-72 -o CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj -c CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f-pp.f
error: loc("D:\\bld\\openblas_1711274852957\\work\\lapack-netlib\\SRC\\sgbcon.f":206:7): operation with block successors must terminate its parent block

error: verification of lowering to FIR failed

Looking for the error message, the only open issue I've found is #61281, but that issue explicitly says "This case is OK in OpenMP". There's also #74348 (which got fixed in 18.1) and #72792 (where it's unclear when/what was fixed).

Footnotes

  1. despite the title of the PR, the error here is for the case with USE_OPENMP=0, i.e. no OpenMP; with OpenMP I still have to fix stuff around OpenMP_Fortran

@h-vetinari h-vetinari changed the title [flang] OpenBLAS 0.3.26 not buildable with flang 18 [flang] OpenBLAS 0.3.26 not buildable on windows with flang 18 Mar 25, 2024
@h-vetinari
Copy link
Contributor Author

Hm, this might somehow be related to #86459?

@h-vetinari
Copy link
Contributor Author

h-vetinari commented Jun 28, 2024

While building OpenBLAS with flang built from main still fails, the good news is that this particular failure seems to have been resolved. Now we're failing at:

[...]
[3643/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stplqt.f.obj
[3644/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stplqt2.f.obj
[3645/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\stpmlqt.f.obj
[3646/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_2stage.f.obj
[3647/19184] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F.obj
FAILED: CMakeFiles/LAPACK_OVERRIDES.dir/lapack-netlib/SRC/ssytrd_sb2st.F.obj 
%BUILD_PREFIX%\Library\bin\flang.exe -I%SRC_DIR%\lapack-netlib\SRC -I%SRC_DIR%\lapack-netlib\LAPACKE\include -fopenmp -fopenmp -ffixed-line-length-72 -o CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F.obj -c CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F-pp.f
error: Semantic errors in CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\ssytrd_sb2st.F-pp.f
D:\\bld\\openblas_1719536014536\\work\\lapack-netlib\\SRC\\ssytrd_sb2st.F:237:11: error: Cannot read module file for module 'omp_lib': Source file 'omp_lib.mod' was not found
        use omp_lib
            ^^^^^^^

At first glance, this looks like a problem in OpenBLAS, thus I opened: OpenMathLib/OpenBLAS#4768

@h-vetinari h-vetinari changed the title [flang] OpenBLAS 0.3.26 not buildable on windows with flang 18 [flang] OpenBLAS 0.3.27 not buildable on windows with flang 19 Jun 28, 2024
@h-vetinari
Copy link
Contributor Author

OK, so the missing omp_lib module is apparently flang's responsibility after all.

CC @banach-space @kiranchandramohan

@h-vetinari h-vetinari changed the title [flang] OpenBLAS 0.3.27 not buildable on windows with flang 19 [flang] OpenBLAS 0.3.27 (with openmp) not buildable on windows with flang 19 Jun 28, 2024
@h-vetinari
Copy link
Contributor Author

h-vetinari commented Jun 28, 2024

OK, so the non-openmp build actually passed (even though it generated logs so big that I cannot seem to download them, presuambly from warning spam). So the question reduces to OpenBLAS on windows with openmp enabled.

PS. ~500MB of logs, ~5.3 million lines

@tblah
Copy link
Contributor

tblah commented Jun 28, 2024

How are you building flang and openmp? I wonder if #90888 could be related.

@h-vetinari
Copy link
Contributor Author

How are you building flang and openmp?

Everything is built stand-alone but from a consistent version (or commit, in this case). I'm using indentation to indicate dependency:

I wonder if #90888 could be related.

That definitely sounds plausible! I could test that patch on top of our openmp builds and see if it changes anything, if that helps.

@h-vetinari
Copy link
Contributor Author

Looking a bit closer, it could just be that we need to set -DLIBOMP_FORTRAN_MODULES=ON? 🤔

@h-vetinari
Copy link
Contributor Author

So I managed to build omp_lib.mod and have it be used by the openblas build, so that's nice. Currently failing at the linking stage, but I think that's just a path question. Will report back once this is figured out.

@h-vetinari h-vetinari changed the title [flang] OpenBLAS 0.3.27 (with openmp) not buildable on windows with flang 19 [flang] OpenBLAS 0.3.27 (with openmp) not buildable on windows with flang 18 Jul 8, 2024
@h-vetinari
Copy link
Contributor Author

h-vetinari commented Jul 8, 2024

I'm happy to report that (using a small fix to explicitly link OpenMP::OpenMP_C), a ~2 week old flang 19 (as of edf5782, to be precise) is able to build OpenBLAS also on windows. 🥳

There's some issues with the OpenMP configuration for the Fortran bits not correctly being picked up by CMake's find_package(OpenMP), but that's out of scope here (though follow the link for an explanation, if you're interested). There are also some persistent test failures when run on hardware that has AVX512 instructions, but we'll raise a separate issue for that.

Leaving this open for a little while longer in case there are comments, but otherwise this can be closed now. :)

@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:ir question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

4 participants