A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'mc-perf' into mc
[simgrid.git]
/
teshsuite
/
smpi
/
shared.c
diff --git
a/teshsuite/smpi/shared.c
b/teshsuite/smpi/shared.c
index
15b1a3a
..
b1536c5
100644
(file)
--- a/
teshsuite/smpi/shared.c
+++ b/
teshsuite/smpi/shared.c
@@
-1,26
+1,27
@@
-/* Copyright (c) 2009-2012. The SimGrid Team. All rights reserved. */
-
-/* This example should be instructive to learn about SMPI_SAMPLE_LOCAL and
- SMPI_SAMPLE_GLOBAL macros for execution sampling */
+/* Copyright (c) 2009-2013. 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. */
/* 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. */
+/* This example should be instructive to learn about SMPI_SAMPLE_LOCAL and
+ SMPI_SAMPLE_GLOBAL macros for execution sampling */
+
#include <stdio.h>
#include <mpi.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <mpi.h>
#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)
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
+47,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){
//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);
}
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);
SMPI_SHARED_FREE(buf);
+ buf=NULL;
+ free(str);
MPI_Finalize();
return 0;
MPI_Finalize();
return 0;