X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/319a100d7f88e1ce33ca97fe868e796ae61304b9..363c6561b6288c19d8b6e89882c23814981865b5:/teshsuite/smpi/shared.c diff --git a/teshsuite/smpi/shared.c b/teshsuite/smpi/shared.c index 61d244d519..1a6ac0554d 100644 --- a/teshsuite/smpi/shared.c +++ b/teshsuite/smpi/shared.c @@ -9,17 +9,18 @@ #include #include #include +#include -unsigned long 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; } @@ -38,22 +39,23 @@ int main(int argc, char *argv[]) MPI_Barrier(MPI_COMM_WORLD); //everyobne reads from it. - printf("[%d] The value in the shared buffer is: %zu\n", rank, *buf); + printf("[%d] The value in the shared buffer is: %" PRIu64"\n", rank, *buf); MPI_Barrier(MPI_COMM_WORLD); //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;