r-hub / rhub

R-hub API client
https://r-hub.github.io/rhub/
Other
354 stars 53 forks source link

Version of OpenMP on clang-asan? #620

Closed aadler closed 5 months ago

aadler commented 5 months ago

Hi. I am trying to add OpenMP SIMD instructions to the Delaporte package. The clang-asan testbed fails in compilation where the other test beds complete (except for valgrind, which we know has false positives for OpenMP). Is this an issue with the version of the ASAN compiler or is it showing something deeper I need to investigate?

gaborcsardi commented 5 months ago

Is this an issue with the version of the ASAN compiler or is it showing something deeper I need to investigate?

I don't know, sorry.

aadler commented 5 months ago

As it compiles successfully on the six standard Github testbeds and the more exotic ones on rhub, I don't think it's a problem with the code.

aadler commented 5 months ago

Originally, it seemed as if it related to a change that happened between clang-16 and clang-17, as clang 16 passes but the rest do not. However, the clang-16 implementation looks as if it is running gcc:

R was compiled by
    gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
    GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
* running under: Ubuntu 22.04.4 LTS

For that matter, so does the Ubuntu-clang testbed.

I'm very confused, as usual, but it looks like clang has not completely implemented OpenMP 4.5, as it's failing on the uniform declaration for a SIMD function where gcc or mkl or intel do not. Any thoughts, @gaborcsardi ?

gaborcsardi commented 5 months ago

For the record, because the logs will be deleted soon, this is the error:

using Fortran compiler: ‘Ubuntu flang-new version 19.0.0 (++20240609042219+715a5d8d93a8-1~exp1~20240609042339.1734)’
flang-new-19 -fopenmp  -fpic  -g -O2  -c  utils.f90 -o utils.o
error: Semantic errors in utils.f90
./utils.f90:138:53: error: Internal: no symbol found for 'k'
      !$omp declare simd(imk) linear(uval(i)) uniform(k) notinbranch
                                                      ^

I think this is probably a bug or just something that flang-new hasn't implemented yet. I suggest you open an issue in the llvm repo at https://github.com/llvm/llvm-project.

aadler commented 5 months ago

Thanks; done here: https://github.com/llvm/llvm-project/issues/94997.

Edit: My fear is that flang isn't quite completely OpenMP 4.5 compliant even if clang is.

aadler commented 5 months ago

Oh, and before you close this, @gaborcsardi, please check the clang16 and Ubuntu-clang testbeds as they look as if they're running gcc and not clang. Thank you!

gaborcsardi commented 5 months ago

It is clearly using clang:

  * installing *source* package ‘Delaporte’ ...
  ** using staged installation
  ** libs
  using C compiler: ‘Ubuntu clang version 16.0.6 (++20231112100510+7cbf1a259152-1~exp1~20231112100554.106)’
  using Fortran compiler: ‘GNU Fortran (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0’
  gfortran-12 -fopenmp  -fpic  -g -O2  -c  utils.f90 -o utils.o
  gfortran-12 -fopenmp  -fpic  -g -O2  -c  delaporte.f90 -o delaporte.o
  clang-16 -I"/opt/R/devel/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -O3 -Wall -pedantic -c utils_and_wrappers.c -o utils_and_wrappers.o
  clang-16 -shared -L/opt/R/devel/lib/R/lib -L/usr/local/lib -o Delaporte.so delaporte.o utils.o utils_and_wrappers.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -lgfortran -lm -lquadmath -L/opt/R/devel/lib/R/lib -lR
...

https://github.com/aadler/Delaporte/actions/runs/9441435213/job/26002150863#step:6:185

aadler commented 5 months ago

For C. It seems to be using Fortran and not flang for Fortran.

gaborcsardi commented 5 months ago

For C. It seems to he using Fortran and not flang for Fortran.

gfortran yes, just like CRAN.

aadler commented 5 months ago

That’s actually a relief, since gfortran recognizes the uniform keyword for SIMD. It is flang which has the problem. Thanks, Gabor.

gaborcsardi commented 5 months ago

Well, yeah, clang16 is not really used for anything on CRAN any more: https://www.stats.ox.ac.uk/pub/bdr/clang16/