Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Pack_size is meant to return the upper bound of the size.
[simgrid.git] / src / smpi / bindings / smpi_pmpi_type.cpp
index 8bf129a..7155047 100644 (file)
@@ -1,10 +1,11 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.hpp"
 #include "smpi_datatype_derived.hpp"
+#include "smpi_comm.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
 
@@ -46,11 +47,28 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent
   return datatype->extent(lb, extent);
 }
 
+int PMPI_Type_get_extent_x(MPI_Datatype datatype, MPI_Count * lb, MPI_Count * extent)
+{
+  MPI_Aint tmplb;
+  MPI_Aint tmpext;
+  int ret = PMPI_Type_get_extent(datatype, &tmplb, &tmpext);
+  if(ret == MPI_SUCCESS){
+    *lb = static_cast<MPI_Count>(tmplb);
+    *extent = static_cast<MPI_Count>(tmpext);
+  }
+  return ret;
+}
+
 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
 {
   return PMPI_Type_get_extent(datatype, lb, extent);
 }
 
+int PMPI_Type_get_true_extent_x(MPI_Datatype datatype, MPI_Count * lb, MPI_Count * extent)
+{
+  return PMPI_Type_get_extent_x(datatype, lb, extent);
+}
+
 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
 {
   CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
@@ -320,6 +338,6 @@ int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size)
   CHECK_NEGATIVE(1, MPI_ERR_COUNT, incount)
   CHECK_TYPE(2, datatype)
   CHECK_COMM(3)
-  *size=incount*datatype->size();
+  *size = incount * std::max<long>(datatype->size(), datatype->get_extent());
   return MPI_SUCCESS;
 }