From: navarro Date: Fri, 19 Oct 2012 14:31:42 +0000 (-0700) Subject: Compil smpi on win32. X-Git-Tag: v3_8~28 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ccedb07575381e28a3143247e9028fe4f73bcd96 Compil smpi on win32. Need to see why when compiling examples WinMain is not found --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index d257aea992..4f6b7a0146 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -113,7 +113,6 @@ set(SMPI_SRC src/smpi/smpi_c99.c src/smpi/smpi_coll.c src/smpi/smpi_comm.c - src/smpi/smpi_f77.c src/smpi/smpi_global.c src/smpi/smpi_group.c src/smpi/smpi_mpi.c @@ -121,6 +120,13 @@ set(SMPI_SRC src/smpi/smpi_pmpi.c src/smpi/smpi_replay.c ) + +if(SMPI_F2C) + set(SMPI_SRC + ${SMPI_SRC} + src/smpi/smpi_f77.c + ) +endif(SMPI_F2C) set(GRAS_RL_SRC ${XBT_RL_SRC} diff --git a/buildtools/Cmake/MakeLibWin.cmake b/buildtools/Cmake/MakeLibWin.cmake index 69e02272e5..866fe1d9b0 100644 --- a/buildtools/Cmake/MakeLibWin.cmake +++ b/buildtools/Cmake/MakeLibWin.cmake @@ -41,4 +41,12 @@ message(STATUS "pexports: ${PEXPORTS_PATH}") if(PEXPORTS_PATH) add_custom_command(TARGET simgrid POST_BUILD COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/lib/libsimgrid.dll > ${CMAKE_BINARY_DIR}/lib/libsimgrid.def) -endif(PEXPORTS_PATH) \ No newline at end of file +endif(PEXPORTS_PATH) + +if(enable_smpi) + add_library(smpi SHARED ${SMPI_SRC}) + set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version} OUTPUT_NAME "smpi") + + set(SMPI_LDEP "") + target_link_libraries(smpi simgrid ${SMPI_LDEP}) +endif(enable_smpi) \ No newline at end of file diff --git a/buildtools/Cmake/Modules/FindF2c.cmake b/buildtools/Cmake/Modules/FindF2c.cmake index 7ccb9cdb8d..bef6bbc9c5 100644 --- a/buildtools/Cmake/Modules/FindF2c.cmake +++ b/buildtools/Cmake/Modules/FindF2c.cmake @@ -63,5 +63,14 @@ mark_as_advanced(HAVE_F2C_LIB) if(HAVE_F2C_H) include_directories(${HAVE_F2C_H}) else(HAVE_F2C_H) - message(FATAL_ERROR "You should install f2c before use smpi.") -endif(HAVE_F2C_H) \ No newline at end of file + if(WIN32) + message("-- Fortran for smpi is not installed (http://www.netlib.org/f2c/).") + else(WIN32) + message(FATAL_ERROR "You should install f2c before use smpi.") + endif(WIN32) +endif(HAVE_F2C_H) + +set(SMPI_F2C 0) +if(HAVE_F2C_H AND F2C_EXE AND HAVE_F2C_LIB) + set(SMPI_F2C 1) +endif(HAVE_F2C_H AND F2C_EXE AND HAVE_F2C_LIB) \ No newline at end of file diff --git a/buildtools/Cmake/src/gras_config.h.in b/buildtools/Cmake/src/gras_config.h.in index 7aa25e2461..082e1b82d5 100644 --- a/buildtools/Cmake/src/gras_config.h.in +++ b/buildtools/Cmake/src/gras_config.h.in @@ -156,6 +156,9 @@ /* Indicates that we have SMPI support */ #cmakedefine HAVE_SMPI @HAVE_SMPI@ +/* Indicates that we have SMPI F2C support */ +#cmakedefine SMPI_F2C @SMPI_F2C@ + /* Indicates that we have NS3 support */ #cmakedefine HAVE_NS3 @HAVE_NS3@ diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index d1af9c2b70..bc7dc42466 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -114,6 +114,9 @@ typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*, */ typedef struct s_smx_rvpoint *smx_rdv_t; +XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_action_t action); +XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action); + /******************************** Context *************************************/ typedef struct s_smx_context *smx_context_t; typedef struct s_smx_context_factory *smx_context_factory_t; diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index ee5d53b293..54b45bc5aa 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -68,8 +68,6 @@ double SIMIX_comm_get_remains(smx_action_t action); e_smx_state_t SIMIX_comm_get_state(smx_action_t action); void SIMIX_comm_suspend(smx_action_t action); void SIMIX_comm_resume(smx_action_t action); -void* SIMIX_comm_get_src_data(smx_action_t action); -void* SIMIX_comm_get_dst_data(smx_action_t action); smx_process_t SIMIX_comm_get_src_proc(smx_action_t action); smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action); diff --git a/src/smpi/private.h b/src/smpi/private.h index 74b35689e7..71a9ec831e 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -11,7 +11,9 @@ #include "xbt/xbt_os_time.h" #include "simgrid/simix.h" #include "smpi/smpi.h" +#ifdef SMPI_F2C #include "smpi/smpif.h" +#endif #include "smpi/smpi_cocci.h" #include "instr/instr_private.h" diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index f3926a7758..58c8c5a852 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -10,7 +10,9 @@ #include "xbt/ex.h" #include "surf/surf.h" +#ifndef WIN32 #include +#endif #include #include #include @@ -82,6 +84,7 @@ static size_t shm_size(int fd) { return (size_t)st.st_size; } +#ifndef WIN32 static void* shm_map(int fd, size_t size, shared_data_t* data) { void* mem; char loc[PTR_STRLEN]; @@ -92,6 +95,7 @@ static void* shm_map(int fd, size_t size, shared_data_t* data) { xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno)); } } + mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(mem == MAP_FAILED) { xbt_die("Could not map fd %d: %s", fd, strerror(errno)); @@ -107,6 +111,7 @@ static void* shm_map(int fd, size_t size, shared_data_t* data) { XBT_DEBUG("MMAP %zu to %p", size, mem); return mem; } +#endif void smpi_bench_destroy(void) { @@ -171,7 +176,11 @@ int smpi_gettimeofday(struct timeval *tv, struct timezone *tz) now = SIMIX_get_clock(); if (tv) { tv->tv_sec = (time_t)now; +#ifdef WIN32 + tv->tv_usec = (useconds_t)((now - tv->tv_sec) * 1e6); +#else tv->tv_usec = (suseconds_t)((now - tv->tv_sec) * 1e6); +#endif } smpi_bench_begin(); return 0; @@ -331,6 +340,7 @@ void smpi_sample_3(int global, const char *file, int line) data->benching = 0; } +#ifndef WIN32 void *smpi_shared_malloc(size_t size, const char *file, int line) { char *loc = bprintf("%zu_%s_%d", (size_t)getpid(), file, line); @@ -377,7 +387,6 @@ void *smpi_shared_malloc(size_t size, const char *file, int line) XBT_DEBUG("Malloc %zu in %p (metadata at %p)", size, mem, data); return mem; } - void smpi_shared_free(void *ptr) { char loc[PTR_STRLEN]; @@ -412,6 +421,7 @@ void smpi_shared_free(void *ptr) free(data->loc); } } +#endif int smpi_shared_known_call(const char* func, const char* input) { char* loc = bprintf("%s:%s", func, input); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index f7c6132517..95d44578c6 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -95,6 +95,7 @@ int smpi_process_argc(void) { return data->argc ? *(data->argc) - 1 : 0; } +#ifdef SMPI_F2C int smpi_process_getarg(integer* index, char* dst, ftnlen len) { smpi_process_data_t data = smpi_process_data(); char* arg; @@ -113,6 +114,7 @@ int smpi_process_getarg(integer* index, char* dst, ftnlen len) { } return 0; } +#endif int smpi_global_size(void) { char* value = getenv("SMPI_GLOBAL_SIZE"); @@ -288,6 +290,23 @@ int __attribute__((weak)) main(int argc, char** argv) { return MAIN__(); } +#ifdef WIN32 +#include + +int __attribute__((weak)) smpi_simulated_main(int argc, char** argv) { + xbt_die("Should not be in this smpi_simulated_main"); + return 1; +} + +/* TODO FOR WIN32 */ +/* Dummy prototype to make gcc happy */ +int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hInst2,LPSTR lpstr01,int nCmdShow) +{ + return MAIN__(); +} + +#endif + int MAIN__(void) { srand(SMPI_RAND_SEED); diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index c8b868cf64..dc00903ec1 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -21,7 +21,7 @@ typedef struct s_dyn_light { int size; } s_dyn_light_t, *dyn_light_t; -double sg_maxmin_precision = 0.00001; +XBT_PUBLIC(double) sg_maxmin_precision = 0.00001; static void *lmm_variable_mallocator_new_f(void); static void lmm_variable_mallocator_free_f(void *var);