yambo-code / yambo

This is the official GPL repository of the yambo code
http://www.yambo-code.eu/
GNU General Public License v2.0
99 stars 39 forks source link

ydiago solver without mpi #134

Open sangallidavide opened 1 month ago

sangallidavide commented 1 month ago

I would like to ask: is MPI C compiler mandatory for Yambo (even when not compiled with MPI)? As I mentioned in my first PR, Ydiago always needs to be compiled with MPI libraries, which means we always need a MPI C compiler or link with `-libmpi. I know this is not ideally what we want, but I will address this in the future. Another option is to completely skip compiling Ydiago when not using MPI and guard all Ydiago calls with -D_MPI and use the old solver.

@muralidhar-nalabothula yambo can be

a) compiled without mpi: --disable-mpi at configure time, -D_MPI is not defined. Of course scalapck/blacs cannot be linked. Probably it does not make sense to link elpa neither. We can de-activate the ydiago implementation as well in such case.

b) compiled with mpi but mpi disabled at runtime using yambo -nompi. In such case the code can be compiled with all mpi libraries (including sclapack/blacs/etc .. ), but MPI_Init is not called. Moreover, all calls such as call MPI_COMM_SIZE are protected by something like if(ncpu>1) return.

For case (a), we can leave it as an open issue, and work on this in the future.

For case (b) it might be enough to put some if(ncpu>1) then / else inside K_diagonalize to avoid seg-fault at runtime.

muralidhar-nalabothula commented 1 month ago

Honestly, I do not see why -nompi flag is needed? Any specific reason why this is added? According to MPI standard, running mpirun -n 1 yambo must be same as running simply calling yambo and no special care needs to be taken in the code. Here is what is in standard (please note yambo does not call any special functions such as MPI_UNIVERSE_SIZE)

When an application enters MPI_INIT, clearly it must be able to determine if these special steps were taken. If a process enters MPI_INIT and determines that no special steps were taken (i.e., it has not been given the information to form an MPI_COMM_WORLD with other processes) it succeeds and forms a singleton MPI program, that is, one in which MPI_COMM_WORLD has size 1.

sangallidavide commented 1 month ago

In my machine with nvfortran and cuda support

I've reproduced the same behavior with nvfortran on a couple of other machines. No idea of why.

I do not know why -nompi was added either. Just it is there, and I use it sometimes. First time I tested yambo with elpa+gpu I used yambo -nompi and it gave me segmentation fault. :-)