diff --git a/configure.ac b/configure.ac index 6823526b032ca0a1ddb1312db40e83a58a69f00f..b22c35bf127f5ad8e680ebdc672962108c5c63dd 100755 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.59) -AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) +AC_INIT(OpenFPM_vcluster, 0.8.0, BUG-REPORT-ADDRESS) AC_CANONICAL_SYSTEM AC_CONFIG_SRCDIR([src/main.cpp]) @@ -102,6 +102,63 @@ else NVCCFLAGS+="$NVCCFLAGS -O3 " fi +###### Check for se-class1 + +AC_MSG_CHECKING(whether to build with security enhancement class1) +se_class1=no +AC_ARG_ENABLE(se-class1, + AC_HELP_STRING( + [--enable-se-class1], + [enable security enhancement class1] + ), + se_class1="$enableval" +) + + + +AC_MSG_RESULT($se_class1) +if test x"$se_class1" = x"yes"; then + AC_DEFINE([SE_CLASS1],[],[Security enhancement class 1]) +fi + + +###### Check for se-class 2 + +AC_MSG_CHECKING(whether to build with security enhancement class 2) +se_class2=no +AC_ARG_ENABLE(se-class2, + AC_HELP_STRING( + [--enable-se-class2], + [enable security enhancement class 2] + ), + se_class2="$enableval" +) + + +AC_MSG_RESULT($se_class2) +if test x"$se_class2" = x"yes"; then + AC_DEFINE([SE_CLASS2],[],[Security enhancement class 2]) +fi + +###### Check for se-class 3 + +AC_MSG_CHECKING(whether to build with security enhancement class 3) +se_class3=no +AC_ARG_ENABLE(se-class3, + AC_HELP_STRING( + [--enable-se-class3], + [enable security enhancement class 3] + ), + se_class3="$enableval" +) + + + +AC_MSG_RESULT($se_class3) +if test x"$se_class3" = x"yes"; then + AC_DEFINE([SE_CLASS3],[],[Security enhancement class 3]) +fi + ####### include openfpm_devices include path diff --git a/src/Makefile.am b/src/Makefile.am index 6c6af872120e45afc0ac33d03a6c5762bb310d6b..dcd5095a113c9dc439429dd0efcf16c5153f3fae 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ LINKLIBS = $(DEFAULT_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(HDF5_LDFLAGS) $(HDF5_LIBS) $(BOOST_LDFLAGS) noinst_PROGRAMS = vcluster_test -vcluster_test_SOURCES = main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp +vcluster_test_SOURCES = main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp vcluster_test_CXXFLAGS = $(AM_CXXFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS) vcluster_test_CFLAGS = $(CUDA_CFLAGS) vcluster_test_LDADD = $(LINKLIBS) diff --git a/src/VCluster/VCluster.cpp b/src/VCluster/VCluster.cpp index b75d24bb65a0977ff50b0d0d8984b796a7815278..26c1129954e4a42a4e2ff87d2af7c44b0185ae3d 100644 --- a/src/VCluster/VCluster.cpp +++ b/src/VCluster/VCluster.cpp @@ -1,4 +1,5 @@ #include "VCluster.hpp" +#include Vcluster * global_v_cluster_private = NULL; @@ -8,3 +9,31 @@ bool ofp_initialized = false; size_t tot_sent = 0; size_t tot_recv = 0; + +std::string program_name; + +// Segmentation fault signal handler +void bt_sighandler(int sig, siginfo_t * info, void * ctx_p) +{ + void *trace[16]; + char **messages = NULL; + int i, trace_size = 0; + + if (sig == SIGSEGV) + std::cout << "Got signal " << sig << " faulty address is %p, " << info->si_addr << " from " << info->si_pid << std::endl; + else + std:: cout << "Got signal " << sig << std::endl; + + trace_size = backtrace(trace, 16); + /* overwrite sigaction with caller's address */ + trace[1] = (void *)info->si_addr; + messages = backtrace_symbols(trace, trace_size); + /* skip first stack frame (points here) */ + printf("[bt] Execution path:\n"); + for (i=1; i #include "VCluster_base.hpp" #include "VCluster_meta_function.hpp" +void bt_sighandler(int sig, siginfo_t * info, void * ctx); /*! \brief Implementation of VCluster class * @@ -47,7 +49,7 @@ class Vcluster: public Vcluster_base } }; - /*! \brief Prepare the send buffer and send the message to other processots + /*! \brief Prepare the send buffer and send the message to other processors * * \tparam op Operation to execute in merging the receiving data * \tparam T sending object @@ -57,16 +59,20 @@ class Vcluster: public Vcluster_base * of the operation is defined by op * * \param send sending buffer - * \param recv receiving buffer + * \param recv receiving object * \param prc_send each object T in the vector send is sent to one processor specified in this list. * This mean that prc_send.size() == send.size() - * \param recv Receiving object * \param prc_recv list of processor from where we receive (output), in case of RECEIVE_KNOWN muts be filled - * \param recv_sz size of each receiving message (output), in case of RECEICE_KNOWN must be filled + * \param sz_recv size of each receiving message (output), in case of RECEICE_KNOWN must be filled * \param opt Options using RECEIVE_KNOWN enable patters with less latencies, in case of RECEIVE_KNOWN * */ - template void prepare_send_buffer(openfpm::vector & send, S & recv, openfpm::vector & prc_send, openfpm::vector & prc_recv, openfpm::vector & sz_recv, size_t opt) + template void prepare_send_buffer(openfpm::vector & send, + S & recv, + openfpm::vector & prc_send, + openfpm::vector & prc_recv, + openfpm::vector & sz_recv, + size_t opt) { openfpm::vector sz_recv_byte(sz_recv.size()); @@ -248,14 +254,22 @@ class Vcluster: public Vcluster_base /*! \brief Process the receive buffer * + * \tparam op operation to do in merging the received data * \tparam T type of sending object * \tparam S type of receiving object * \tparam prp properties to receive * * \param recv receive object + * \param sz vector that store how many element has been added per processors on S + * \param sz_byte byte received on a per processor base + * \param op_param operation to do in merging the received information with recv * */ - template void process_receive_buffer_with_prp(S & recv, openfpm::vector * sz, openfpm::vector * sz_byte, op & op_param) + template + void process_receive_buffer_with_prp(S & recv, + openfpm::vector * sz, + openfpm::vector * sz_byte, + op & op_param) { if (sz != NULL) sz->resize(recv_buf.size()); @@ -296,8 +310,8 @@ class Vcluster: public Vcluster_base * \tparam T type of sending object * \tparam S type of receiving object * - * \param Object to send - * \param Object to receive + * \param send Object to send + * \param recv Object to receive * \param root witch node should collect the information * * \return true if the function completed succefully @@ -311,6 +325,7 @@ class Vcluster: public Vcluster_base return SGather(send,recv,prc,sz,root); } + //! metafunction template struct MetaFuncOrd { enum { value = index }; }; @@ -335,8 +350,8 @@ class Vcluster: public Vcluster_base * \tparam T type of sending object * \tparam S type of receiving object * - * \param Object to send - * \param Object to receive + * \param send Object to send + * \param recv Object to receive * \param root witch node should collect the information * \param prc processors from witch we received the information * \param sz size of the received information for each processor @@ -344,7 +359,11 @@ class Vcluster: public Vcluster_base * \return true if the function completed succefully * */ - template bool SGather(T & send, S & recv, openfpm::vector & prc, openfpm::vector & sz,size_t root) + template bool SGather(T & send, + S & recv, + openfpm::vector & prc, + openfpm::vector & sz, + size_t root) { // Reset the receive buffer reset_recv_buf(); @@ -438,8 +457,8 @@ class Vcluster: public Vcluster_base * \tparam T type of sending object * \tparam S type of receiving object * - * \param Object to send - * \param Object to receive + * \param send Object to send + * \param recv Object to receive * \param prc processor involved in the scatter * \param sz size of each chunks * \param root which processor should scatter the information @@ -511,6 +530,7 @@ class Vcluster: public Vcluster_base /*! \brief reorder the receiving buffer * * \param prc list of the receiving processors + * \param sz_recv list of size of the receiving messages (in byte) * */ void reorder_buffer(openfpm::vector & prc, openfpm::vector & sz_recv) @@ -586,21 +606,27 @@ class Vcluster: public Vcluster_base * In order to work S must implement the interface S.add(T). * * ### Example scatter a vector of structures, to other processors - * \snippet VCluster_semantic_unit_tests.hpp Scatter the data from master + * \snippet VCluster_semantic_unit_tests.hpp dsde with complex objects1 * * \tparam T type of sending object * \tparam S type of receiving object * - * \param Object to send - * \param Object to receive - * \param prc processor involved in the scatter - * \param sz size of each chunks - * \param root which processor should scatter the information + * \param send Object to send + * \param recv Object to receive + * \param prc_send destination processors + * \param prc_recv list of the receiving processors + * \param sz_recv number of elements added + * \param opt options * * \return true if the function completed succefully * */ - template bool SSendRecv(openfpm::vector & send, S & recv, openfpm::vector & prc_send, openfpm::vector & prc_recv, openfpm::vector & sz_recv, size_t opt = NONE) + template bool SSendRecv(openfpm::vector & send, + S & recv, + openfpm::vector & prc_send, + openfpm::vector & prc_recv, + openfpm::vector & sz_recv, + size_t opt = NONE) { prepare_send_buffer,T,S>(send,recv,prc_send,prc_recv,sz_recv,opt); @@ -633,16 +659,22 @@ class Vcluster: public Vcluster_base * \tparam S type of receiving object * \tparam prp properties for merging * - * \param Object to send - * \param Object to receive - * \param prc processor involved in the scatter - * \param sz size of each chunks - * \param root which processor should scatter the information + * \param send Object to send + * \param recv Object to receive + * \param prc_send destination processors + * \param prc_recv processors from which we received + * \param sz_recv number of elements added per processor + * \param sz_recv_byte message received from each processor in byte * - * \return true if the function completed succefully + * \return true if the function completed successful * */ - template bool SSendRecvP(openfpm::vector & send, S & recv, openfpm::vector & prc_send, openfpm::vector & prc_recv, openfpm::vector & sz_recv, openfpm::vector & sz_recv_byte) + template bool SSendRecvP(openfpm::vector & send, + S & recv, + openfpm::vector & prc_send, + openfpm::vector & prc_recv, + openfpm::vector & sz_recv, + openfpm::vector & sz_recv_byte) { prepare_send_buffer,T,S>(send,recv,prc_send,prc_recv,sz_recv,NONE); @@ -674,16 +706,20 @@ class Vcluster: public Vcluster_base * \tparam S type of receiving object * \tparam prp properties for merging * - * \param Object to send - * \param Object to receive - * \param prc processor involved in the scatter - * \param sz size of each chunks - * \param root which processor should scatter the information + * \param send Object to send + * \param recv Object to receive + * \param prc_send destination processors + * \param prc_recv list of the processors from which we receive + * \param sz_recv number of elements added per processors * * \return true if the function completed succefully * */ - template bool SSendRecvP(openfpm::vector & send, S & recv, openfpm::vector & prc_send, openfpm::vector & prc_recv, openfpm::vector & sz_recv) + template bool SSendRecvP(openfpm::vector & send, + S & recv, + openfpm::vector & prc_send, + openfpm::vector & prc_recv, + openfpm::vector & sz_recv) { prepare_send_buffer,T,S>(send,recv,prc_send,prc_recv,sz_recv,NONE); @@ -715,11 +751,11 @@ class Vcluster: public Vcluster_base * \tparam S type of receiving object * \tparam prp properties for merging * - * \param Object to send - * \param Object to receive - * \param prc processor involved in the send and receive - * \param op_param operation object - * \param sz_recv size of each receiving buffer. This parameters are output + * \param send Object to send + * \param recv Object to receive + * \param prc_send destination processors + * \param op_param operation object (operation to do im merging the information) + * \param recv_sz size of each receiving buffer. This parameters are output * with RECEIVE_KNOWN you must feed this parameter * \param prc_recv from which processor we receive messages * with RECEIVE_KNOWN you must feed this parameter @@ -729,10 +765,16 @@ class Vcluster: public Vcluster_base * but must be input. * * - * \return true if the function completed succeful + * \return true if the function completed successful * */ - template bool SSendRecvP_op(openfpm::vector & send, S & recv, openfpm::vector & prc_send,op & op_param, openfpm::vector & prc_recv, openfpm::vector & recv_sz, size_t opt = NONE) + template bool SSendRecvP_op(openfpm::vector & send, + S & recv, + openfpm::vector & prc_send, + op & op_param, + openfpm::vector & prc_recv, + openfpm::vector & recv_sz, + size_t opt = NONE) { prepare_send_buffer(send,recv,prc_send,prc_recv,recv_sz,opt); @@ -807,20 +849,34 @@ static inline void openfpm_init(int *argc, char ***argv) init_global_v_cluster_private(argc,argv); #ifdef SE_CLASS1 - std::cout << "OpenFPM is compiled with debug mode LEVEL:1. Remember to remove SE_CLASS1 when you go in production" << std::endl; - #endif #ifdef SE_CLASS2 - std::cout << "OpenFPM is compiled with debug mode LEVEL:2. Remember to remove SE_CLASS2 when you go in production" << std::endl; +#endif +#ifdef SE_CLASS3 + std::cout << "OpenFPM is compiled with debug mode LEVEL:3. Remember to remove SE_CLASS3 when you go in production" << std::endl; #endif + // install segmentation fault signal handler + + struct sigaction sa; + + sa.sa_sigaction = bt_sighandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + + sigaction(SIGSEGV, &sa, NULL); + + if (*argc != 0) + program_name = std::string(*argv[0]); + ofp_initialized = true; } + /*! \brief Finalize the library * * This function MUST be called at the end of the program diff --git a/src/VCluster/VCluster_semantic_unit_tests.hpp b/src/VCluster/VCluster_semantic_unit_tests.hpp index 386629715ea05604d4bfa070adbf2b0c097f6c75..4e6e1de44cdb3c9d7fb521e9fe61290968f241db 100644 --- a/src/VCluster/VCluster_semantic_unit_tests.hpp +++ b/src/VCluster/VCluster_semantic_unit_tests.hpp @@ -39,6 +39,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather) if (vcl.getProcessingUnits() >= 32) return; + //! [Gather the data on master] + openfpm::vector v1; v1.resize(vcl.getProcessUnitID()); @@ -49,6 +51,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather) vcl.SGather(v1,v2,(i%vcl.getProcessingUnits())); + //! [Gather the data on master] + if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits())) { size_t n = vcl.getProcessingUnits(); @@ -72,6 +76,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_2) if (vcl.getProcessingUnits() >= 32) return; + //! [Gather the data on master complex] + openfpm::vector v1; v1.resize(vcl.getProcessUnitID()); @@ -82,6 +88,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather_2) vcl.SGather(v1,v2,0); + //! [Gather the data on master complex] + if (vcl.getProcessUnitID() == 0) { size_t n = vcl.getProcessingUnits(); @@ -550,6 +558,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_scatter) for(size_t i = 0 ; i < n_elements ; i++) v1.get(i) = 5; + //! [Scatter the data from master] + openfpm::vector v2; openfpm::vector prc; @@ -564,6 +574,8 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_scatter) vcl.SScatter(v1,v2,prc,sz,(i%vcl.getProcessingUnits())); + //! [Scatter the data from master] + BOOST_REQUIRE_EQUAL(v2.size(),vcl.getProcessUnitID() % SSCATTER_MAX); bool is_five = true; diff --git a/src/main.cpp b/src/main.cpp index 1e4f0f0055dcb1bbc96073abf7582ff46b5d2c14..bcf2b7cffa9b3b2933d5d0aebd4830b1f5dd8081 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ -#include "config.h" #define BOOST_TEST_MODULE "C++ test module for OpenFPM_vcluster project" #include +#include "config.h" #include "VCluster/VCluster.hpp" #include "unit_test_init_cleanup.hpp"