ADD_TEST(smpi-struct-thread ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/struct.tesh)
ADD_TEST(smpi-pt2pt-thread ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt.tesh)
ADD_TEST(smpi-compute-thread ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/compute.tesh)
+ ADD_TEST(smpi-shared-thread ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared.tesh)
if(CONTEXT_UCONTEXT)
ADD_TEST(smpi-bcast-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/bcast.tesh)
ADD_TEST(smpi-reduce-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/reduce.tesh)
ADD_TEST(smpi-struct-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/struct.tesh)
ADD_TEST(smpi-pt2pt-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt.tesh)
ADD_TEST(smpi-compute-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/compute.tesh)
+ ADD_TEST(smpi-shared-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared.tesh)
endif()
if(HAVE_RAWCTX)
ADD_TEST(smpi-bcast-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/bcast.tesh)
ADD_TEST(smpi-struct-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/struct.tesh)
ADD_TEST(smpi-pt2pt-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pt2pt.tesh)
ADD_TEST(smpi-compute-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/compute.tesh)
+ ADD_TEST(smpi-shared-raw ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:raw --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared.tesh)
endif()
if(HAVE_TRACING)
ADD_TEST(smpi-tracing-ptp ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd ${CMAKE_BINARY_DIR}/examples/smpi ${CMAKE_HOME_DIRECTORY}/examples/smpi/tracing/smpi_traced.tesh)
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, func(__VA_ARGS__)))
+ : smpi_shared_set_call(#func, input, (void*)(func(__VA_ARGS__))))
/* Fortran specific stuff */
XBT_PUBLIC(int) __attribute__((weak)) smpi_simulated_main_(int argc, char** argv);
add_executable(compute compute.c)
add_executable(compute2 compute2.c)
add_executable(compute3 compute3.c)
+ add_executable(shared shared.c)
add_executable(pingpong pingpong.c)
add_executable(scatter scatter.c)
add_executable(reduce reduce.c)
target_link_libraries(bcast_coll simgrid)
target_link_libraries(barrier_coll simgrid)
target_link_libraries(compute simgrid)
+ target_link_libraries(shared simgrid)
target_link_libraries(compute2 simgrid)
target_link_libraries(compute3 simgrid)
target_link_libraries(pingpong simgrid)
${CMAKE_CURRENT_SOURCE_DIR}/bcast.tesh
${CMAKE_CURRENT_SOURCE_DIR}/bcast_coll.tesh
${CMAKE_CURRENT_SOURCE_DIR}/compute.tesh
+ ${CMAKE_CURRENT_SOURCE_DIR}/shared.tesh
${CMAKE_CURRENT_SOURCE_DIR}/hvector.tesh
${CMAKE_CURRENT_SOURCE_DIR}/indexed.tesh
${CMAKE_CURRENT_SOURCE_DIR}/pt2pt.tesh
${CMAKE_CURRENT_SOURCE_DIR}/sendrecv.c
${CMAKE_CURRENT_SOURCE_DIR}/reduce.c
${CMAKE_CURRENT_SOURCE_DIR}/compute2.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/shared.c
${CMAKE_CURRENT_SOURCE_DIR}/split.c
${CMAKE_CURRENT_SOURCE_DIR}/dsend.c
${CMAKE_CURRENT_SOURCE_DIR}/ttest01.c
--- /dev/null
+/* 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 */
+
+/* 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. */
+
+#include <stdio.h>
+#include <mpi.h>
+
+unsigned long hash(char *str);
+
+unsigned long hash(char *str)
+{
+ unsigned long hash = 5381;
+ int c;
+ printf("hashing !\n");
+ while ((c = *str++)!=0)
+ hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
+ return hash;
+}
+
+
+int main(int argc, char *argv[])
+{
+ MPI_Init(&argc, &argv);
+ int rank, size;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ //Let's Allocate a shared memory buffer
+ unsigned long* buf = SMPI_SHARED_MALLOC(sizeof(unsigned long));
+ //one writes data in it
+ if(rank==0){
+ *buf=size;
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ //everyobne reads from it.
+ printf("[%d] The value in the shared buffer is: %lu\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=(unsigned long)SMPI_SHARED_CALL(hash,str,str);
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ printf("[%d] After change, the value in the shared buffer is: %lu\n", rank, *buf);
+
+
+ SMPI_SHARED_FREE(buf);
+
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+p Test compute
+! setenv LD_LIBRARY_PATH=../../lib
+! output sort
+! timeout 5
+$ ../../bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 4 ./shared
+> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304'
+> [0] After change, the value in the shared buffer is: 16053117601147974045
+> [0] The value in the shared buffer is: 4
+> [1] After change, the value in the shared buffer is: 16053117601147974045
+> [1] The value in the shared buffer is: 4
+> [2] After change, the value in the shared buffer is: 16053117601147974045
+> [2] The value in the shared buffer is: 4
+> [3] After change, the value in the shared buffer is: 16053117601147974045
+> [3] The value in the shared buffer is: 4
+> hashing !
+
+