Skip to content

Commit e0a8e82

Browse files
committed
ajout de la fonction MPI_Isend pour l'interposition fortran et changement du README pour connaitre l'utilisation de la bibliothèque Fortran
1 parent 9ac4524 commit e0a8e82

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,26 @@ To build the library and for it to work properly, please make sure that the foll
3636

3737

3838
## Building
39-
To build the library, it is recommended to use the provided Makefile:
39+
To build the C library, it is recommended to use the provided Makefile:
4040
```sh
4141
make
4242
```
43+
To build the Fortran library, it is recommended to use the provided Makefile:
44+
```sh
45+
make buildf
46+
```
4347
Optionnaly, you can install/uninstall it from your computer (in `/usr/lib/` by default):
4448
```sh
4549
sudo make install
4650
sudo make uninstall
4751
```
4852
This will first call `cargo` to build the Rust back-end in release mode (automatically exported to the `LD_LIBRARY_PATH` environment variable).
4953
Then, it will compile the interposition library into a single `.so` file.
50-
54+
For the Fortran library use
55+
```sh
56+
sudo make installf
57+
sudo make uninstallf
58+
```
5159

5260
## Usage
5361
**IMPORTANT NOTE:** It is mandatory that you compile both the Interpol library and the MPI application that you want to trace using the _same_ `mpicc` compiler. This is because the MPI standard does not enforce any particular ABI, therefore, if the library and your program are not compiled with the same MPI implementation, conflicts may cause the traced program or the library to crash or generate incorrect traces.
@@ -56,6 +64,11 @@ If you've installed the library, the command to preload it when running your MPI
5664
```sh
5765
LD_PRELOAD=libinterpol.so <MPICMD> -n <NB_PROC> <BINARY>
5866
```
59-
Otherwise, you need to provide the absolute path to the `libinterpol.so` file.
67+
And for the Fortran library
68+
```sh
69+
LD_PRELOAD=libinterpolf.so <MPICMD> -n <NB_PROC> <BINARY>
70+
```
71+
72+
Otherwise, you need to provide the absolute path to the `libinterpol.so` or `libinterpolf.so` file.
6073

6174
You can also check the documentation for the Rust back-end with the `make doc` command and run the unit tests with `make test`.

src/interpolf.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,63 @@ _EXTERN_C_ void mpi_recv_(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MP
334334

335335
_EXTERN_C_ void mpi_recv__(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr) {
336336
MPI_Recv_fortran_wrapper(buf, count, datatype, source, tag, comm, status, ierr);
337+
}
338+
339+
340+
static void MPI_Isend_fortran_wrapper(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
341+
int _wrap_py_return_val = 0;
342+
343+
Tsc const tsc = rdtsc();
344+
345+
#if (!defined(MPICH_HAS_C2F) && defined(MPICH_NAME) && (MPICH_NAME == 1)) /* MPICH test */
346+
_wrap_py_return_val = PMPI_Isend((const void*)buf, *count, (MPI_Datatype)(*datatype), *dest, *tag, (MPI_Comm)(*comm), (MPI_Request*)request);
347+
#else /* MPI-2 safe call */
348+
MPI_Request temp_request;
349+
temp_request = MPI_Request_f2c(*request);
350+
_wrap_py_return_val = PMPI_Isend((const void*)buf, *count, MPI_Type_f2c(*datatype), *dest, *tag, MPI_Comm_f2c(*comm), &temp_request);
351+
*request = MPI_Request_c2f(temp_request);
352+
#endif /* MPICH test */
353+
354+
Tsc const duration = rdtsc() - tsc;
355+
356+
int nb_bytes;
357+
PMPI_Type_size(MPI_Type_f2c(*datatype), &nb_bytes);
358+
359+
MpiCall const isend = {
360+
.kind = Isend,
361+
.time = -1.0,
362+
.tsc = tsc,
363+
.duration = duration,
364+
.current_rank = current_rank,
365+
.partner_rank = *dest,
366+
.nb_bytes_s = nb_bytes * (*count),
367+
.nb_bytes_r = 0,
368+
.comm = PMPI_Comm_c2f((MPI_Comm)comm),
369+
.req = *request,
370+
.tag = *tag,
371+
.required_thread_lvl = -1,
372+
.provided_thread_lvl = -1,
373+
.op_type = -1,
374+
.finished = false,
375+
};
376+
377+
register_mpi_call(isend);
378+
379+
*ierr = _wrap_py_return_val;
380+
}
381+
382+
_EXTERN_C_ void MPI_ISEND(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
383+
MPI_Isend_fortran_wrapper(buf, count, datatype, dest, tag, comm, request, ierr);
384+
}
385+
386+
_EXTERN_C_ void mpi_isend(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
387+
MPI_Isend_fortran_wrapper(buf, count, datatype, dest, tag, comm, request, ierr);
388+
}
389+
390+
_EXTERN_C_ void mpi_isend_(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
391+
MPI_Isend_fortran_wrapper(buf, count, datatype, dest, tag, comm, request, ierr);
392+
}
393+
394+
_EXTERN_C_ void mpi_isend__(MPI_Fint *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr) {
395+
MPI_Isend_fortran_wrapper(buf, count, datatype, dest, tag, comm, request, ierr);
337396
}

0 commit comments

Comments
 (0)