Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make the C and Fortran interfaces of SMPI as extern C also in the code
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 16:27:37 +0000 (17:27 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 16:27:44 +0000 (17:27 +0100)
This is useless because they are also marked as such in the header
files, but sonar only notices if they are marked in the implementation
too.

Also do some tiny changes to please sonar.

src/smpi/smpi_f77.cpp
src/smpi/smpi_mpi.cpp
src/smpi/smpi_pmpi.cpp
teshsuite/smpi/type-vector/type-vector.c

index 8e59d00..17ed153 100644 (file)
@@ -10,7 +10,6 @@
 #include "private.h"
 #include "xbt.h"
 
-
 //TODO : remove all this.
 static xbt_dict_t comm_lookup = nullptr;
 static xbt_dict_t group_lookup = nullptr;
@@ -252,6 +251,8 @@ type smpi_##name##_f2c(int id){\
   return smpi_f2c<type>(id, name##_lookup);\
 }
 
+extern "C" { // This should really use the C linkage to be usable from Fortran
+
 SMPI_F2C_C2F(MPI_Comm, comm)
 SMPI_F2C_C2F(MPI_Group, group)
 SMPI_F2C_C2F(MPI_Request, request)
@@ -1770,3 +1771,4 @@ void mpi_file_write_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status
   *ierr=  MPI_File_write(reinterpret_cast<MPI_File>(*fh), buf, *count, smpi_type_f2c(*datatype), status);
 }
 
+} // extern "C"
index f462a32..2ca0704 100644 (file)
@@ -30,6 +30,7 @@ return P##name args2 ; \
 
 
 /* MPI User level calls */
+extern "C" { // Obviously, the C MPI interface should use the C linkage
 
 WRAPPED_PMPI_CALL(double, MPI_Wtick,(void),())
 WRAPPED_PMPI_CALL(double, MPI_Wtime,(void),())
@@ -316,3 +317,4 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Win_unlock,(int rank, MPI_Win win),(rank
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(MPI_Errhandler, MPI_Errhandler_f2c,(MPI_Fint errhandler),(errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(MPI_Fint, MPI_Errhandler_c2f,(MPI_Errhandler errhandler),(errhandler))
 
+} // extern "C"
index e51c138..0cb559c 100644 (file)
@@ -22,6 +22,7 @@ void TRACE_smpi_set_category(const char *category)
 }
 
 /* PMPI User level calls */
+extern "C" { // Obviously, the C MPI interface should use the C linkage
 
 int PMPI_Init(int *argc, char ***argv)
 {
@@ -3345,3 +3346,4 @@ int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size)
   return MPI_SUCCESS;
 }
 
+} // extern "C"
index 2a9a129..77255ae 100644 (file)
@@ -9,7 +9,7 @@
 #define SIZE 4
 
 int main(int argc, char **argv) {
-  int rank, i, j;
+  int rank;
   double a[SIZE][SIZE] = {{0}};
 
   MPI_Datatype columntype;
@@ -21,16 +21,16 @@ int main(int argc, char **argv) {
   MPI_Type_commit(&columntype);
 
     if (rank == 0) {
-      for(i=0; i <SIZE;i++)
-        for(j=0; j <SIZE;j++)
+      for (int i = 0; i < SIZE; i++)
+        for (int j = 0; j < SIZE; j++)
           a[i][j] = i*SIZE+j;
     }
 
     /* only one column is send this is an exemple for non-contignous data*/
     MPI_Bcast(a, 1, columntype, 0, MPI_COMM_WORLD);
 
-    for(i=0; i<SIZE; i++){
-      for (j=0; j < SIZE; j++) {
+    for (int i = 0; i < SIZE; i++) {
+      for (int j = 0; j < SIZE; j++) {
         printf("rank= %d, a[%d][%d]=%f\n", rank, i, j, a[i][j]);
       }
       printf("\n");