ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
102 stars 27 forks source link

[Meson] Add a compiler for *.cu files #183

Closed amontoison closed 6 months ago

amontoison commented 6 months ago

close #174

amontoison commented 6 months ago

@jfowkes I finally find the time to test the compilation of the GPU version of SPRAL. I found that one file was missing for the GPU version factor.f90 and that we also need to link spral_ssids with CUDA dependencies. All tests passed on the cluster of the GERAD :canada: with an NVIDIA A100. :tada:

The only issue that I have now is that Meson is not happy is it doesn't found the CUDA compiler (it's why all CI builds are failing). I don't how we can say to Meson that the compiler nvcc is optional.

jfowkes commented 6 months ago

Amazing @amontoison, could we ask the Meson team about this? They're normally really helpful with stuff like this...

amontoison commented 6 months ago

@eli-schwartz Do you know how we can optionally provide the CUDA compiler? We could compile SPRAL (CPU version) without it but Meson is not happy if it doesn't find the compiler. Thanks for your help!!

eli-schwartz commented 6 months ago

You have an optional usage of the cuda dependency, which indicates you already try to optionally handle cuda support.

Adding a project language can be done in the project() function, as well as conditionally using add_languages('cuda', required: false). The latter lets you use feature options, if/else, and detect whether cuda support could be found by checking the boolean return value of add_languages. Use this function in this PR, since you need that added fine-grained flexibility.

amontoison commented 6 months ago

@jfowkes I tested with the precompiled binaries of METIS of HWLOC. It's maybe time to drop the old build system ;)


montalex@atlas.gerad.lan:~/git/spral (1058)>meson setup builddir -Dlibmetis_path=~/git/metis/lib \
                                                                 -Dexamples=true -Dtests=true \
                                                                 -Dlibhwloc_path=~/git/hwloc/lib \
                                                                 -Dlibhwloc_include=../hwloc/include
The Meson build system
Version: 1.3.1
Source dir: /home/montalex/git/spral
Build dir: /home/montalex/git/spral/builddir
Build type: native build
Project name: SPRAL
Project version: 2023.11.15
Fortran compiler for the host machine: gfortran (gcc 8.5.0 "GNU Fortran (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18.0.6)")
Fortran linker for the host machine: gfortran ld.bfd 2.30-119
C compiler for the host machine: cc (gcc 8.5.0 "cc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18.0.6)")
C linker for the host machine: cc ld.bfd 2.30-119
C++ compiler for the host machine: c++ (gcc 8.5.0 "c++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18.0.6)")
C++ linker for the host machine: c++ ld.bfd 2.30-119
Host machine cpu family: x86_64
Host machine cpu: x86_64
Cuda compiler for the host machine: nvcc (nvcc 12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0)
Cuda linker for the host machine: nvcc nvlink 12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0
Library blas found: YES
Library lapack found: YES
Library metis found: YES
Library hwloc found: YES
Run-time dependency CUDA (modules: cudart_static, rt, pthread, dl, cublas) found: YES 12.2 (/usr/local/cuda)
Library m found: YES
Has header "cblas.h" : YES 
Has header "hwloc.h" : YES 
Build targets in project: 39

SPRAL 2023.11.15

  User defined options
    examples        : true
    libhwloc_include: ../hwloc/include
    libhwloc_path   : ~/git/hwloc/lib
    libmetis_path   : ~/git/metis/lib
    tests           : true

Found ninja-1.11.1 at /home/montalex/git/ninja/bin/ninja
montalex@atlas.gerad.lan:~/git/spral (1059)>meson compile -C builddir/
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/montalex/git/ninja/bin/ninja -C /home/montalex/git/spral/builddir
ninja: Entering directory `/home/montalex/git/spral/builddir'
[183/183] Linking target ssmfet
montalex@atlas.gerad.lan:~/git/spral (1060)>meson test -C builddir/
ninja: Entering directory `/home/montalex/git/spral/builddir'
ninja: no work to do.
 1/37 ssidst                     OK              18.87s
 2/37 ssmfet                     OK               0.66s
 3/37 lsmrt                      OK               0.06s
 4/37 randomt                    OK               0.04s
 5/37 random_matrixt             OK               0.24s
 6/37 rutherford_boeingt         OK              14.38s
 7/37 scalingt                   OK               6.55s
 8/37 kernelst_cpp               OK               2.90s
 9/37 rb_writes                  OK               0.04s
10/37 rb_reads                   OK               0.04s
11/37 auction_syms               OK               0.03s
12/37 auction_unsyms             OK               0.03s
13/37 equilib_syms               OK               0.03s
14/37 equilib_unsyms             OK               0.03s
15/37 hungarian_syms             OK               0.03s
16/37 hungarian_unsyms           OK               0.03s
17/37 hermitians                 OK               0.05s
18/37 precond_cores              OK               0.04s
19/37 precond_experts            OK               0.05s
20/37 precond_ssmfes             OK               0.06s
21/37 shift_inverts              OK               0.05s
22/37 lsmrs                      OK               0.04s
23/37 randoms                    OK               0.03s
24/37 random_matrixs             OK               0.03s
25/37 ssidss                     OK               0.08s
26/37 rb_reads_c                 OK               0.04s
27/37 rb_writes_c                OK               0.04s
28/37 auction_syms_c             OK               0.03s
29/37 auction_unsyms_c           OK               0.03s
30/37 equilib_syms_c             OK               0.04s
31/37 equilib_unsyms_c           OK               0.03s
32/37 hungarian_syms_c           OK               0.03s
33/37 hungarian_unsyms_c         OK               0.03s
34/37 lsmrs_c                    OK               0.03s
35/37 randoms_c                  OK               0.03s
36/37 random_matrixs_c           OK               0.03s
37/37 ssidss_c                   OK               0.07s

Ok:                 37  
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0  
amontoison commented 6 months ago

@eli-schwartz Thank you!!! It works perfectly :100:

eli-schwartz commented 6 months ago

Fantastic, happy to help.

jfowkes commented 6 months ago

Great stuff, any more changes planned @amontoison or shall I do a new release?

amontoison commented 6 months ago

@jfowkes I don't plan to do additional modifications in the source code of SPRAL. However, we should try to setup what I suggested in #175 such that precompiled versions of SPRAL are automatically generated by CI when we do a new release.