From: Christian Van Wambeke Date: Fri, 4 Jul 2014 14:47:07 +0000 (+0200) Subject: mg-tetra_hpc.exe_Linux_64_avril2014 in sources X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=19554a3d6f62a6a97e2f98e121836b42cdc46907;p=plugins%2Fghs3dprlplugin.git mg-tetra_hpc.exe_Linux_64_avril2014 in sources --- diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index d220062..35de229 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -18,3 +18,15 @@ # SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS}) + +# scripts / static / binaries +# temporary standalone project version of mg-tetra_hpc.exe +SET(_bin_SCRIPTS + mg-tetra_hpc.exe + mg-tetra_hpc.exe_Linux_64_avril2014 + meshgems_mpi.c + meshgems_mpi.h +) + +# --- rules --- +SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_BINS}) diff --git a/bin/meshgems_mpi.c b/bin/meshgems_mpi.c new file mode 100644 index 0000000..5e6075c --- /dev/null +++ b/bin/meshgems_mpi.c @@ -0,0 +1,427 @@ +/* + * Copyright 2009-2013 Distene SAS + * + */ + +#include +#include + +#include "meshgems_mpi.h" + +#include + +static MPI_Datatype *meshgems_mpi_datatype_map = NULL; +static MPI_Op *meshgems_mpi_op_map = NULL; +static int meshgems_mpi_datatype_count = 0; +static int meshgems_mpi_op_count = 0; + +struct meshgems_mpi_handler_ +{ + MPI_Request rq; +}; + +/* note : MPI standard states that a MPI_Datatype is a simple type (pointer or int) */ + +static inline int meshgems_mpi_find_type(meshgems_mpi_datatype datatype, MPI_Datatype *odt) +{ + if(meshgems_mpi_datatype_map && datatype > 0 && datatype <= meshgems_mpi_datatype_count) { + *odt = meshgems_mpi_datatype_map[datatype]; + return MESHGEMS_MPI_SUCCESS; + } + + return MESHGEMS_MPI_ERR; +} + +int meshgems_mpi_type_new(int count, int *array_of_blocklengths, long *array_of_displacements, + meshgems_mpi_datatype *array_of_types, meshgems_mpi_datatype *newtype) +{ + MPI_Datatype nt, *aot; + MPI_Aint *aod; + int ret, r, i; + void *t; + + ret = MESHGEMS_MPI_SUCCESS; + + aot = (MPI_Datatype *) calloc(count, sizeof(MPI_Datatype)); + aod = (MPI_Aint *) calloc(count, sizeof(MPI_Aint)); + if(!aot || !aod) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + for(i = 0;i < count;i++) { + /* + r = meshgems_mpi_find_type(array_of_types[i], aot+i); + if(r != MESHGEMS_MPI_SUCCESS){ + ret = r; + goto out; + } + */ + aot[i] = meshgems_mpi_datatype_map[array_of_types[i]]; + aod[i] = (MPI_Aint) array_of_displacements[i]; + } + + r = MPI_Type_create_struct(count, array_of_blocklengths, aod, aot, &nt); + /* With MPI1 you can use : + r = MPI_Type_struct(count, array_of_blocklengths, + aod, aot, &nt); + */ + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + r = MPI_Type_commit(&nt); + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + meshgems_mpi_datatype_count++; + t = realloc(meshgems_mpi_datatype_map, (meshgems_mpi_datatype_count + 1) * sizeof(MPI_Datatype)); + if(!t) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + meshgems_mpi_datatype_map = (MPI_Datatype *) t; + meshgems_mpi_datatype_map[meshgems_mpi_datatype_count] = nt; + *newtype = meshgems_mpi_datatype_count; + + out: if(aod) + free(aod); + if(aot) + free(aot); + + return ret; +} + +int meshgems_mpi_type_delete(meshgems_mpi_datatype datatype) +{ + /* no op for now */ + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_init(int *argc, char ***argv) +{ + int ret; + + ret = MESHGEMS_MPI_SUCCESS; + + meshgems_mpi_datatype_map = calloc(meshgems_mpi_datatype_enum_count, sizeof(MPI_Datatype)); + meshgems_mpi_op_map = calloc(meshgems_mpi_op_enum_count, sizeof(MPI_Op)); + if(!meshgems_mpi_datatype_map || !meshgems_mpi_op_map) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + meshgems_mpi_datatype_count = meshgems_mpi_datatype_enum_count - 1; + meshgems_mpi_op_count = meshgems_mpi_op_enum_count - 1; + + if(sizeof(int) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i4] = MPI_INT; + } else if(sizeof(int) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i4] = MPI_SHORT; + } else { + fprintf(stderr, "Unable to find mpi type for 4 bytes integer\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(int) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_INT; + } else if(sizeof(long) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_LONG; + } else if(sizeof(long long) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_i8] = MPI_LONG_LONG; + } else { + fprintf(stderr, "Unable to find mpi type for 8 bytes integer\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(float) == 4) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_r4] = MPI_FLOAT; + } else { + fprintf(stderr, "Unable to find mpi type for 4 bytes real\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + if(sizeof(double) == 8) { + meshgems_mpi_datatype_map[meshgems_mpi_datatype_r8] = MPI_DOUBLE; + } else { + fprintf(stderr, "Unable to find mpi type for 8 bytes real\n"); + ret = MESHGEMS_MPI_ERR; + goto out; + } + + meshgems_mpi_op_map[meshgems_mpi_op_max] = MPI_MAX; + meshgems_mpi_op_map[meshgems_mpi_op_sum] = MPI_SUM; + + MPI_Init(argc, argv); + + out: + + if(ret != MESHGEMS_MPI_SUCCESS) { + if(meshgems_mpi_datatype_map) + free(meshgems_mpi_datatype_map); + if(meshgems_mpi_op_map) + free(meshgems_mpi_op_map); + } + + return ret; +} + +int meshgems_mpi_rank(int *r) +{ + MPI_Comm_rank(MPI_COMM_WORLD, r); + + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_size(int *n) +{ + MPI_Comm_size(MPI_COMM_WORLD, n); + + return MESHGEMS_MPI_SUCCESS; +} + +int meshgems_mpi_finalize(void) +{ + MPI_Finalize(); + + return MESHGEMS_MPI_SUCCESS; +} + +meshgems_mpi_handler *meshgems_mpi_handler_new(void) +{ + meshgems_mpi_handler *handler; + + handler = calloc(1, sizeof(meshgems_mpi_handler)); + + return handler; +} + +void meshgems_mpi_handler_delete(meshgems_mpi_handler *handler) +{ + if(handler) + free(handler); +} + +int meshgems_mpi_send(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + r = MPI_Send(buffer, count, dtt, dest, tag, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_isend(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag, + meshgems_mpi_handler *handler) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + r = MPI_Isend(buffer, count, dtt, dest, tag, MPI_COMM_WORLD, &(handler->rq)); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_wait(meshgems_mpi_handler *handler) +{ + int ret; + int r; + + r = MPI_Wait(&(handler->rq), MPI_STATUS_IGNORE ); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_recv(void* buffer, int count, meshgems_mpi_datatype datatype, int src, int tag) +{ + int ret; + int r; + MPI_Datatype dtt; + + dtt = meshgems_mpi_datatype_map[datatype]; + + if(src == MESHGEMS_MPI_ANY_SOURCE) { + src = MPI_ANY_SOURCE; + } + + r = MPI_Recv(buffer, count, dtt, src, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_reduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op, int root) +{ + int ret; + int r; + MPI_Datatype dtt; + MPI_Op mop; + + dtt = meshgems_mpi_datatype_map[datatype]; + mop = meshgems_mpi_op_map[op]; + + r = MPI_Reduce(sendbuf, recvbuf, count, dtt, mop, root, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_allreduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op) +{ + int ret; + int r; + MPI_Datatype dtt; + MPI_Op mop; + + dtt = meshgems_mpi_datatype_map[datatype]; + mop = meshgems_mpi_op_map[op]; + + r = MPI_Allreduce(sendbuf, recvbuf, count, dtt, mop, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_gather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, void *recvbuf, + int recvcount, meshgems_mpi_datatype recvtype, int root) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Gather(sendbuf, sendcount, sdtt, recvbuf, recvcount, rdtt, root, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_allgather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int recvcount, meshgems_mpi_datatype recvtype) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + ret = MESHGEMS_MPI_SUCCESS; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Allgather(sendbuf, sendcount, sdtt, recvbuf, recvcount, rdtt, MPI_COMM_WORLD); + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + goto out; + } + + out: + + return ret; +} + +int meshgems_mpi_allgatherv(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int *recvcount, int *displs, meshgems_mpi_datatype recvtype) +{ + int ret; + int r; + MPI_Datatype sdtt, rdtt; + + sdtt = meshgems_mpi_datatype_map[sendtype]; + rdtt = meshgems_mpi_datatype_map[recvtype]; + + r = MPI_Allgatherv(sendbuf, sendcount, sdtt, recvbuf, recvcount, displs, rdtt, MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_barrier(void) +{ + int ret; + int r; + + r = MPI_Barrier(MPI_COMM_WORLD); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} + +int meshgems_mpi_abort(int errorcode) +{ + int ret; + int r; + + r = MPI_Abort(MPI_COMM_WORLD, errorcode); + + if(r != MPI_SUCCESS) { + ret = MESHGEMS_MPI_ERR; + } else { + ret = MESHGEMS_MPI_SUCCESS; + } + + return ret; +} diff --git a/bin/meshgems_mpi.h b/bin/meshgems_mpi.h new file mode 100644 index 0000000..30f7cc4 --- /dev/null +++ b/bin/meshgems_mpi.h @@ -0,0 +1,72 @@ +/* + * Copyright 2009-2013 Distene SAS + * + */ + +#ifndef __MESHGEMS_MPI_H__ +#define __MESHGEMS_MPI_H__ + +#define MESHGEMS_MPI_SUCCESS 0 +#define MESHGEMS_MPI_ERR 1 + +#define MESHGEMS_MPI_ANY_SOURCE -1 + +/* Declare these as int rather than enum to be able to create dynamic types/operations */ + +typedef int meshgems_mpi_datatype; +typedef int meshgems_mpi_op; + +#define meshgems_mpi_datatype_none 0 +#define meshgems_mpi_datatype_i4 1 +#define meshgems_mpi_datatype_i8 2 +#define meshgems_mpi_datatype_r4 3 +#define meshgems_mpi_datatype_r8 4 +#define meshgems_mpi_datatype_enum_count 5 + +#define meshgems_mpi_op_none 0 +#define meshgems_mpi_op_max 1 +#define meshgems_mpi_op_sum 2 +#define meshgems_mpi_op_enum_count 3 + +int meshgems_mpi_type_new(int count, int *array_of_blocklengths, long *array_of_displacements, + meshgems_mpi_datatype *array_of_types, meshgems_mpi_datatype *newtype); +int meshgems_mpi_type_delete(meshgems_mpi_datatype datatype); + +struct meshgems_mpi_handler_; +typedef struct meshgems_mpi_handler_ meshgems_mpi_handler; + +meshgems_mpi_handler *meshgems_mpi_handler_new(void); +void meshgems_mpi_handler_delete(meshgems_mpi_handler *handler); + +int meshgems_mpi_init(int *argc, char ***argv); +int meshgems_mpi_rank(int *r); +int meshgems_mpi_size(int *n); +int meshgems_mpi_finalize(void); + +int meshgems_mpi_send(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag); +int meshgems_mpi_isend(void* buffer, int count, meshgems_mpi_datatype datatype, int dest, int tag, + meshgems_mpi_handler *handler); +int meshgems_mpi_wait(meshgems_mpi_handler *handler); + +int meshgems_mpi_recv(void* buffer, int count, meshgems_mpi_datatype, int src, int tag); + +int meshgems_mpi_reduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op, int root); + +int meshgems_mpi_allreduce(void *sendbuf, void *recvbuf, int count, meshgems_mpi_datatype datatype, + meshgems_mpi_op op); + +int meshgems_mpi_gather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, void *recvbuf, + int recvcount, meshgems_mpi_datatype recvtype, int root); + +int meshgems_mpi_allgather(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int recvcount, meshgems_mpi_datatype recvtype); + +int meshgems_mpi_allgatherv(void *sendbuf, int sendcount, meshgems_mpi_datatype sendtype, + void *recvbuf, int *recvcount, int *displs, meshgems_mpi_datatype recvtype); + +int meshgems_mpi_barrier(void); + +int meshgems_mpi_abort(int errorcode); + +#endif diff --git a/bin/mg-tetra_hpc.exe b/bin/mg-tetra_hpc.exe new file mode 100755 index 0000000..6276ab3 --- /dev/null +++ b/bin/mg-tetra_hpc.exe @@ -0,0 +1,36 @@ +#!/bin/bash + +#bash script mg-tetra_hpc.exe +#we have renamed binary executable mg-tetra_hpc.exe V1.3.0 as mg-tetra_hpc.exe_Linux_64_avril2014 +#to assume call of other beta-versions of distene mg-tetra_hpc.exe code in standalone plugin GHS3DPRLPLUGIN sources +#and also assume licence file set to overriding licence file of other distene products ( HEXOTIC, GHS3D, etc... ) +#all that for for only one call of mg-tetra_hpc.exe from salome plugin GHS3DPRLPLUGIN + +#echo "mg-tetra_hpc.exe initial parameters are:" $1 $2 $3 $4 +echo "mg-tetra_hpc.exe initial parameters are:" $* +#$0 is ignored + +export DISTENE_LICENSE_FILE="Use global envvar: DLIM8VAR" +export DLIM8VAR="dlim8 1:1:29030@132.166.151.49/84c419b8::87af196ab2a936ab31363624539bff8096fbe1f3c83028c8f6b399b0a904ef85" + +CURRENTDIR=`pwd` +COMPILDIR=`dirname $0` +echo COMPILDIR $COMPILDIR +echo CURRENTDIR $CURRENTDIR +#we need to compile for mg-tetra_hpc.exe +#env openmpi centos6.4 +export WD2=/usr/lib64/openmpi +export PATH=.:$WD2/bin:${PATH} +export LD_LIBRARY_PATH=.:$WD2/lib:${LD_LIBRARY_PATH} +cd $COMPILDIR +mpicc meshgems_mpi.c -shared -fPIC -o libmeshgems_mpi.so +cd $CURRENTDIR + +echo "mg-tetra_hpc.exe assume licence file set:" +env | grep DLIM + +#mg-tetra_hpc.exe_Linux_64_avril2014 --help +ldd `which mg-tetra_hpc.exe_Linux_64_avril2014` +mg-tetra_hpc.exe_Linux_64_avril2014 $* + + diff --git a/bin/mg-tetra_hpc.exe_Linux_64_avril2014 b/bin/mg-tetra_hpc.exe_Linux_64_avril2014 new file mode 100755 index 0000000..0205a41 Binary files /dev/null and b/bin/mg-tetra_hpc.exe_Linux_64_avril2014 differ