Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implement MPI_Aint_add and MPI_Aint_diff
authorAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 6 Mar 2021 13:37:14 +0000 (14:37 +0100)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 6 Mar 2021 13:37:14 +0000 (14:37 +0100)
include/smpi/smpi.h
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi.cpp

index 5166603..f39fed4 100644 (file)
@@ -459,6 +459,8 @@ MPI_CALL(XBT_PUBLIC int, MPI_Buffer_attach, (void* buffer, int size));
 MPI_CALL(XBT_PUBLIC int, MPI_Buffer_detach, (void* buffer, int* size));
 MPI_CALL(XBT_PUBLIC int, MPI_Address, (const void* location, MPI_Aint* address));
 MPI_CALL(XBT_PUBLIC int, MPI_Get_address, (const void* location, MPI_Aint* address));
+MPI_CALL(XBT_PUBLIC MPI_Aint, MPI_Aint_diff, (MPI_Aint base, MPI_Aint disp));
+MPI_CALL(XBT_PUBLIC MPI_Aint, MPI_Aint_add, (MPI_Aint base, MPI_Aint disp));
 MPI_CALL(XBT_PUBLIC int, MPI_Error_class, (int errorcode, int* errorclass));
 MPI_CALL(XBT_PUBLIC int, MPI_Error_string, (int errorcode, char* string, int* resultlen));
 
index a28cd5f..e8796ea 100644 (file)
@@ -148,6 +148,8 @@ WRAPPED_PMPI_CALL(int,MPI_Finalize,(void),())
 WRAPPED_PMPI_CALL(int,MPI_Free_mem,(void *baseptr),(baseptr))
 WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Gather,(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm),(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm))
 WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Gatherv,(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *displs,MPI_Datatype recvtype, int root, MPI_Comm comm),(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm))
+WRAPPED_PMPI_CALL_NORETURN(MPI_Aint,MPI_Aint_add,(MPI_Aint add, MPI_Aint disp),(add, disp))
+WRAPPED_PMPI_CALL_NORETURN(MPI_Aint,MPI_Aint_diff,(MPI_Aint add, MPI_Aint disp),(add, disp))
 WRAPPED_PMPI_CALL(int,MPI_Get_address,(const void *location, MPI_Aint * address),(location, address))
 WRAPPED_PMPI_CALL(int,MPI_Get_count,(const MPI_Status * status, MPI_Datatype datatype, int *count),(status, datatype, count))
 WRAPPED_PMPI_CALL(int,MPI_Get_library_version ,(char *version,int *len),(version,len))
index 4a07b91..39846ef 100644 (file)
@@ -150,6 +150,20 @@ int PMPI_Get_address(const void *location, MPI_Aint * address)
   return PMPI_Address(location, address);
 }
 
+MPI_Aint PMPI_Aint_add(MPI_Aint address, MPI_Aint disp)
+{
+  if(address > PTRDIFF_MAX - disp)
+    xbt_die("overflow in MPI_Aint_add");
+  return address + disp;
+}
+
+MPI_Aint PMPI_Aint_diff(MPI_Aint address, MPI_Aint disp)
+{
+  if(address < PTRDIFF_MIN + disp)
+    xbt_die("underflow in MPI_Aint_diff");
+  return address - disp;
+}
+
 int PMPI_Get_processor_name(char *name, int *resultlen)
 {
   int len = std::min<int>(sg_host_self()->get_name().size(), MPI_MAX_PROCESSOR_NAME - 1);