-/* Copyright (c) 2009-2015. The SimGrid Team.
+/* Copyright (c) 2009-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <stdint.h>
#include <inttypes.h>
-static void* hash(char *str, uint64_t* ans)
+static void* hash(const char *str, uint64_t* ans)
{
- char *tohash = str;
+ const char *tohash = str;
*ans=5381;
printf("hashing !\n");
- int c = *(tohash++);
+ int c = *tohash;
while (c != 0) {
*ans = ((*ans << 5) + *ans) + c; /* hash * 33 + c */
- c = *(tohash++);
+ tohash++;
+ c = *tohash;
}
return NULL;
}
MPI_Barrier(MPI_COMM_WORLD);
//Try SMPI_SHARED_CALL function, which should call hash only once and for all.
- char *str = strdup("onceandforall");
+ static const char str[] = "onceandforall";
if(rank==size-1){
- SMPI_SHARED_CALL(hash,str,str,buf);
+ SMPI_SHARED_CALL(hash,str,str,buf);
}
MPI_Barrier(MPI_COMM_WORLD);
printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf);
SMPI_SHARED_FREE(buf);
- free(str);
MPI_Finalize();
return 0;