问题
I am trying to write a PMPI library but am not sure of the right steps (new to libraries and linking). I have written a basic file wrapping the MPI_Send function. Say it's a file called lib.c, what all steps should I do so that when I run a c code with MPI_Send, my wrapper code gets executed?
回答1:
On Linux, MPI uses weak links so that MPI_Send gets redirected to PMPI calls. So if you link with your library first and then the MPI library that you are wrapping (i.e. -lmpi
is after -lmylib
), you will be calling MPI through your library, because then libmpi weak links won't be used.
来源:https://stackoverflow.com/questions/55118661/how-to-write-pmpi-library-for-wrapping-mpi-functions