From 08581e49e160aedcc223ec1d690a5d5b5d6f55f4 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Fri, 23 Mar 2018 14:58:19 +0100 Subject: [PATCH] Add BUILD_OFI_TRANSPORT build switch, default OFF --- fairmq/CMakeLists.txt | 84 ++++++++++++++++++++----------- fairmq/FairMQTransportFactory.cxx | 6 +++ fairmq/test/protocols/_pair.cxx | 2 + 3 files changed, 62 insertions(+), 30 deletions(-) diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index d5d88e7b..bd52215b 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -46,6 +46,9 @@ if(NANOMSG_FOUND) add_definitions(-DMSGPACK_FOUND) endif() endif() +if(BUILD_OFI_TRANSPORT) + add_definitions(-DBUILD_OFI_TRANSPORT) +endif() ################## @@ -83,11 +86,6 @@ set(FAIRMQ_HEADER_FILES devices/FairMQProxy.h devices/FairMQSink.h devices/FairMQSplitter.h - ofi/Context.h - ofi/Message.h - ofi/Poller.h - ofi/Socket.h - ofi/TransportFactory.h options/FairMQParser.h options/FairMQProgOptions.h options/FairMQSuboptParser.h @@ -132,6 +130,16 @@ if(NANOMSG_FOUND) ) endif() +if(BUILD_OFI_TRANSPORT) + set(FAIRMQ_HEADER_FILES ${FAIRMQ_HEADER_FILES} + ofi/Context.h + ofi/Message.h + ofi/Poller.h + ofi/Socket.h + ofi/TransportFactory.h + ) +endif() + ########################## # libFairMQ source files # ########################## @@ -151,11 +159,6 @@ set(FAIRMQ_SOURCE_FILES devices/FairMQProxy.cxx # devices/FairMQSink.cxx devices/FairMQSplitter.cxx - ofi/Context.cxx - ofi/Message.cxx - ofi/Poller.cxx - ofi/Socket.cxx - ofi/TransportFactory.cxx options/FairMQParser.cxx options/FairMQProgOptions.cxx options/FairMQSuboptParser.cxx @@ -190,6 +193,17 @@ if(NANOMSG_FOUND) ) endif() +if(BUILD_OFI_TRANSPORT) + set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES} + ofi/Context.cxx + ofi/Message.cxx + ofi/Poller.cxx + ofi/Socket.cxx + ofi/TransportFactory.cxx + ) +endif() + + ################### # configure files # ################### @@ -202,29 +216,37 @@ configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/startConfigExample.sh.in ######################## # compile protobuffers # ######################## -add_custom_target(mkofibuilddir COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ofi) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h - ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc - COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} -I=${CMAKE_CURRENT_SOURCE_DIR}/ofi --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/ofi Control.proto - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS mkofibuilddir ${CMAKE_CURRENT_SOURCE_DIR}/ofi/Control.proto -) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h PROPERTIES GENERATED TRUE) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc PROPERTIES GENERATED TRUE) +if(BUILD_OFI_TRANSPORT) + add_custom_target(mkofibuilddir COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ofi) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h + ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc + COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} -I=${CMAKE_CURRENT_SOURCE_DIR}/ofi --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/ofi Control.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS mkofibuilddir ${CMAKE_CURRENT_SOURCE_DIR}/ofi/Control.proto + ) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h PROPERTIES GENERATED TRUE) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc PROPERTIES GENERATED TRUE) +endif() ################################# # define libFairMQ build target # ################################# -add_library(FairMQ SHARED - ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h - ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc - ${FAIRMQ_SOURCE_FILES} - ${FAIRMQ_HEADER_FILES} # for IDE integration -) - +if(BUILD_OFI_TRANSPORT) + add_library(FairMQ SHARED + ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h + ${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc + ${FAIRMQ_SOURCE_FILES} + ${FAIRMQ_HEADER_FILES} # for IDE integration + ) +else() + add_library(FairMQ SHARED + ${FAIRMQ_SOURCE_FILES} + ${FAIRMQ_HEADER_FILES} # for IDE integration + ) +endif() ####################### # include directories # @@ -242,6 +264,9 @@ target_include_directories(FairMQ ################## # link libraries # ################## +if(BUILD_OFI_TRANSPORT) + set(OFI_DEPS OFI::libfabric protobuf::libprotobuf) +endif() target_link_libraries(FairMQ INTERFACE # only consumers link against interface dependencies @@ -261,10 +286,9 @@ target_link_libraries(FairMQ PRIVATE # only libFairMQ links against private dependencies ZeroMQ - OFI::libfabric - protobuf::libprotobuf Msgpack $<$:nanomsg> + ${OFI_DEPS} ) diff --git a/fairmq/FairMQTransportFactory.cxx b/fairmq/FairMQTransportFactory.cxx index b81ca56d..e61e3de2 100644 --- a/fairmq/FairMQTransportFactory.cxx +++ b/fairmq/FairMQTransportFactory.cxx @@ -12,7 +12,9 @@ #ifdef NANOMSG_FOUND #include #endif /* NANOMSG_FOUND */ +#ifdef BUILD_OFI_TRANSPORT #include +#endif #include #include @@ -51,10 +53,12 @@ auto FairMQTransportFactory::CreateTransportFactory(const std::string& type, con return make_shared(finalId, config); } #endif /* NANOMSG_FOUND */ +#ifdef BUILD_OFI_TRANSPORT else if (type == "ofi") { return make_shared(finalId, config); } +#endif /* BUILD_OFI_TRANSPORT */ else { LOG(error) << "Unavailable transport requested: " << "\"" << type << "\"" << ". Available are: " @@ -63,7 +67,9 @@ auto FairMQTransportFactory::CreateTransportFactory(const std::string& type, con #ifdef NANOMSG_FOUND << ", \"nanomsg\"" #endif /* NANOMSG_FOUND */ +#ifdef BUILD_OFI_TRANSPORT << ", and \"ofi\"" +#endif /* BUILD_OFI_TRANSPORT */ << ". Exiting."; exit(EXIT_FAILURE); } diff --git a/fairmq/test/protocols/_pair.cxx b/fairmq/test/protocols/_pair.cxx index 18acd0d5..cada5cbd 100644 --- a/fairmq/test/protocols/_pair.cxx +++ b/fairmq/test/protocols/_pair.cxx @@ -63,9 +63,11 @@ TEST(Pair, MP_Nanomsg_tcp____SingleMsg) } #endif /* NANOMSG_FOUND */ +#ifdef BUILD_OFI_TRANSPORT TEST(Pair, MP_Ofi_____tcp____SingleMsg) { EXPECT_EXIT(RunPair("ofi"), ::testing::ExitedWithCode(0), "PAIR test successfull"); } +#endif /* BUILD_OFI_TRANSPORT */ } // namespace