Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try again and again to be more portable with this test
authorAugustin Degomme <degomme@idpann.imag.fr>
Tue, 25 Jun 2013 15:57:46 +0000 (17:57 +0200)
committerAugustin Degomme <degomme@idpann.imag.fr>
Tue, 25 Jun 2013 15:57:46 +0000 (17:57 +0200)
include/smpi/smpi.h
teshsuite/smpi/shared.c

index 52e112d..035c074 100644 (file)
@@ -516,7 +516,7 @@ XBT_PUBLIC(void*) smpi_shared_get_call(const char* func, const char* input);
 XBT_PUBLIC(void*) smpi_shared_set_call(const char* func, const char* input, void* data);
 #define SMPI_SHARED_CALL(func, input, ...) \
    (smpi_shared_known_call(#func, input) ? smpi_shared_get_call(#func, input) \
-                                         : smpi_shared_set_call(#func, input, (void*)(func(__VA_ARGS__))))
+                                         : smpi_shared_set_call(#func, input, (func(__VA_ARGS__))))
 
 /* Fortran specific stuff */
 XBT_PUBLIC(int) __attribute__((weak)) smpi_simulated_main_(int argc, char** argv);
index 15b1a3a..1a6ac05 100644 (file)
 #include <stdint.h>
 #include <inttypes.h>
 
-uint64_t hash(char *str);
+void* hash(char *str, uint64_t* ans);
 
-uint64_t hash(char *str)
+void* hash(char *str, uint64_t* ans)
 {
-  uint64_t hash = 5381;
+  *ans=5381;
   int c;
   printf("hashing !\n");
   while ((c = *str++)!=0)
-    hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
-  return hash;
+    *ans = ((*ans << 5) + *ans) + c; /* hash * 33 + c */
+  return NULL;
 }
 
 
@@ -46,15 +46,16 @@ int main(int argc, char *argv[])
   //Try SMPI_SHARED_CALL function, which should call hash only once and for all.
   char *str = strdup("onceandforall");
   if(rank==size-1){
-    *buf=(uint64_t)SMPI_SHARED_CALL(hash,str,str);  
+    SMPI_SHARED_CALL(hash,str,str,buf);  
   }
   
   MPI_Barrier(MPI_COMM_WORLD);
   
-  printf("[%d] After change, the value in the shared buffer is: %lu\n", rank, *buf);
-  
+  printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf);
   
   SMPI_SHARED_FREE(buf);  
+  buf=NULL;  
+  free(str);
     
   MPI_Finalize();
   return 0;