dong-hao / ModEM-GPU

Snapshot Repository for the Manuscript "Hybrid CPU-GPU solution to regularized divergence-free curl-curl equations for electromagnetic inversion problems" submitted to CnG
Other
19 stars 11 forks source link

Intl fortran compilation #1

Open XavierGarcia-pfk opened 4 months ago

XavierGarcia-pfk commented 4 months ago

Hi. I managed to compile the code with gcc but with the intel version I get the following error: MPI/Main_MPI.f90(2414): error #6405: The same named entity from different modules and/or program units cannot be referenced. [KERNELC_GETDEVNUM] size_gpu = kernelc_getDevNum() ------------------------^ compilation aborted for MPI/Main_MPI.f90 (code 1)

I don't know if you have seen it before. A variable that you use has the same name as a variable that gets loaded from a include. Doesn't seem to bother GCC thou. Let me know if you need help with this. I don't mind getting my hands "dirty". Xavi

dong-hao commented 4 months ago

Hi Xavier!

Great to hear from you again. Glad to know that you managed to make things work with the GPU version! Yes, those NVIDIA libs and modules can be quite a hassle to setup.

And thanks a lot for raising the issue - yes, Anna (Kelbert) has experienced a same, or at least similar problem, which I have addressed in the original SVN repo of ModEM:

...to deal with this, one should simply (and completely) remove the cuda-c reference of getDevNum in cudaFortMap.f90, as we already defined that at Declarition_MPI.f90 because currently the GPU is bind to the MPI version of ModEM - still, I will need to think carefully about this and decide where I should put it - as I believe the GPU can be used without MPI in ModEM (there is no direct dependency on any MPI lib for the GPU calculations)...

I hesitated to apply this fix to the GitHub as I described that repo as a “snapshot”, which is expected to be “as is” when we submit the manuscript. But I guess maybe I should at least point people to the right direction.

So yes, if one wants to suppress this problem, just delete the lines from 1391 to 1397 for the fortran-c binding:

! kernelc_getDevNum integer(c_int) function kernelc_getDevNum() & & bind (C, name="kernelc_getDevNum" ) use iso_c_binding implicit none ! get the number of GPU devices end function kernelc_getDevNum

Cheers, Hao

akelbert commented 4 months ago

Hi Hao - thank you for responding to Xavier's question!

I'll be working to get our internal ModEM version to an open-source repository, but it may take another six months to a year for various reasons. Primarily, I will need to integrate Naser's latest version with ours so that I only need to maintain one code, not multiple. In the meantime, maybe it makes sense to incorporate fixes to this release to ensure that it is usable. Any improvements can later be included into the centralized version.

Best wishes, Anna

dong-hao commented 3 months ago

Hi Anna,

Good to know that you are working on an integrated version - yes, It will be the best if we can work from a single version, which probably also reduces your efforts for the maintenance, in the long run. It's no hurry to do it "now", but we may want to discuss a sort of "roadmap" thingy for future plans on the code, licenses, etc.

OK, I can try to incorporate the basic fix. But note that the SVN version is still the most tested and patched one, for now. As ModEM is by far the most popular 3D code in EM geophysics, I would be happy to see more community inputs, from user/developers like Xavier.

Cheers, Hao

pankajkmishra commented 3 months ago

Hi Xavi, I have compiled this with cuda-12.2 and intel and I remember some compilation error with an older cuda. Not sure if it helps but just in case

Cheers, Pankaj