From 7f795421f51254a46262a1f318f4a47070e6ab64 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 2 Mar 2016 21:58:35 +0100 Subject: [PATCH] wip. revising cmake for smpi. have to be discussed --- teshsuite/smpi/CMakeLists.txt | 21 ++++++++++++++++----- teshsuite/smpi/shared/CMakeLists.txt | 11 +++-------- teshsuite/smpi/shared/shared.c | 24 ++++++++++-------------- teshsuite/smpi/struct/CMakeLists.txt | 12 ++++-------- teshsuite/smpi/struct/struct_test.c | 8 ++------ teshsuite/smpi/vector/CMakeLists.txt | 12 ++++-------- teshsuite/smpi/vector/vector_test.c | 10 ++-------- tools/cmake/Tests.cmake | 7 ------- 8 files changed, 41 insertions(+), 64 deletions(-) diff --git a/teshsuite/smpi/CMakeLists.txt b/teshsuite/smpi/CMakeLists.txt index 00b7004ac6..8c618ea710 100644 --- a/teshsuite/smpi/CMakeLists.txt +++ b/teshsuite/smpi/CMakeLists.txt @@ -4,10 +4,21 @@ if(enable_smpi) else() set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc") endif() + +# include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi") +# foreach(x struct vector) +# add_executable (${x}/${x} ${x}/${x}.c) +# target_link_libraries(${x}/ ${x} simgrid) +# +# set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh) +# set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) +# +# ADD_TESH_FACTORIES(tesh-smpi-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/${x} ${x}.tesh) +# endforeach() + endif() -set(bin_files - ${bin_files} - ${CMAKE_CURRENT_SOURCE_DIR}/hostfile - ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_coll - PARENT_SCOPE) +set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/hostfile + ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_coll PARENT_SCOPE) +# set(teshsuite_src ${teshsuite_src} PARENT_SCOPE) +# set(tesh_files ${tesh_files} PARENT_SCOPE) diff --git a/teshsuite/smpi/shared/CMakeLists.txt b/teshsuite/smpi/shared/CMakeLists.txt index 2c9be7d296..170f5ce311 100644 --- a/teshsuite/smpi/shared/CMakeLists.txt +++ b/teshsuite/smpi/shared/CMakeLists.txt @@ -9,14 +9,9 @@ if(enable_smpi) if(NOT WIN32) add_executable (shared shared.c) target_link_libraries(shared simgrid) + ADD_TESH_FACTORIES(tesh-smpi-shared "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/shared --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/shared shared.tesh) endif() endif() -set(tesh_files - ${tesh_files} - ${CMAKE_CURRENT_SOURCE_DIR}/shared.tesh - PARENT_SCOPE) -set(examples_src - ${examples_src} - ${CMAKE_CURRENT_SOURCE_DIR}/shared.c - PARENT_SCOPE) +set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/shared.tesh PARENT_SCOPE) +set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/shared.c PARENT_SCOPE) diff --git a/teshsuite/smpi/shared/shared.c b/teshsuite/smpi/shared/shared.c index 8636be2836..f3ac8488b5 100644 --- a/teshsuite/smpi/shared/shared.c +++ b/teshsuite/smpi/shared/shared.c @@ -11,9 +11,7 @@ #include #include -void* hash(char *str, uint64_t* ans); - -void* hash(char *str, uint64_t* ans) +static void* hash(char *str, uint64_t* ans) { *ans=5381; int c; @@ -23,7 +21,6 @@ void* hash(char *str, uint64_t* ans) return NULL; } - int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); @@ -34,29 +31,28 @@ int main(int argc, char *argv[]) uint64_t* buf = SMPI_SHARED_MALLOC(sizeof(uint64_t)); //one writes data in it if(rank==0){ - *buf=size; + *buf=size; } - + MPI_Barrier(MPI_COMM_WORLD); //everyone reads from it. 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){ 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); - buf=NULL; + + SMPI_SHARED_FREE(buf); + buf=NULL; free(str); - + MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/struct/CMakeLists.txt b/teshsuite/smpi/struct/CMakeLists.txt index 3f0cb7e900..cd6c90fd16 100644 --- a/teshsuite/smpi/struct/CMakeLists.txt +++ b/teshsuite/smpi/struct/CMakeLists.txt @@ -8,13 +8,9 @@ if(enable_smpi) add_executable (struct_test struct_test.c) target_link_libraries(struct_test simgrid) + + ADD_TESH_FACTORIES(tesh-smpi-struct "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/struct --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/struct struct.tesh) endif() -set(tesh_files - ${tesh_files} - ${CMAKE_CURRENT_SOURCE_DIR}/struct.tesh - PARENT_SCOPE) -set(examples_src - ${examples_src} - ${CMAKE_CURRENT_SOURCE_DIR}/struct_test.c - PARENT_SCOPE) +set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/struct.tesh PARENT_SCOPE) +set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/struct_test.c PARENT_SCOPE) diff --git a/teshsuite/smpi/struct/struct_test.c b/teshsuite/smpi/struct/struct_test.c index f26ebcc321..835b852413 100644 --- a/teshsuite/smpi/struct/struct_test.c +++ b/teshsuite/smpi/struct/struct_test.c @@ -7,9 +7,7 @@ #include #include "mpi.h" -int main( argc, argv ) -int argc; -char **argv; +int main(int argc, char **argv) { int rank; struct { int a;int c; double b;int tab[2][3];} value; @@ -58,14 +56,12 @@ char **argv; MPI_Bcast( &value, 1, mystruct, 0, MPI_COMM_WORLD ); printf( "Process %d got %d (-2?) and %f (8.0?), tab (should be all 0): ", rank, value.a, value.b ); - + for(j=0; j<2;j++ ) for(i=0; i<3;i++ ) printf("%d ", tab[j][i]); - printf("\n"); - /* Clean up the type */ MPI_Type_free( &mystruct ); MPI_Type_free( &type2 ); diff --git a/teshsuite/smpi/vector/CMakeLists.txt b/teshsuite/smpi/vector/CMakeLists.txt index 9d8960cbf9..f9d1285846 100644 --- a/teshsuite/smpi/vector/CMakeLists.txt +++ b/teshsuite/smpi/vector/CMakeLists.txt @@ -8,13 +8,9 @@ if(enable_smpi) add_executable (vector_test vector_test.c) target_link_libraries(vector_test simgrid) + + ADD_TESH_FACTORIES(tesh-smpi-vector "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/vector --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/vector vector.tesh) endif() -set(tesh_files - ${tesh_files} - ${CMAKE_CURRENT_SOURCE_DIR}/vector.tesh - PARENT_SCOPE) -set(examples_src - ${examples_src} - ${CMAKE_CURRENT_SOURCE_DIR}/vector_test.c - PARENT_SCOPE) +set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/vector.tesh PARENT_SCOPE) +set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/vector_test.c PARENT_SCOPE) diff --git a/teshsuite/smpi/vector/vector_test.c b/teshsuite/smpi/vector/vector_test.c index 1025915127..2a9a129e60 100644 --- a/teshsuite/smpi/vector/vector_test.c +++ b/teshsuite/smpi/vector/vector_test.c @@ -9,7 +9,6 @@ #define SIZE 4 int main(int argc, char **argv) { - int rank, i, j; double a[SIZE][SIZE] = {{0}}; @@ -21,28 +20,23 @@ int main(int argc, char **argv) { MPI_Type_vector(SIZE, 1, SIZE, MPI_DOUBLE, &columntype); MPI_Type_commit(&columntype); - if (rank == 0) { for(i=0; i