-
Notifications
You must be signed in to change notification settings - Fork 1.5k
RooFit::MultiProcess & TestStatistics part 2: ZeroMQ #8385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
egpbos
wants to merge
15
commits into
root-project:master
from
roofit-dev:RooFit_MultiProcess_PR_2_ZMQ_MultiProcess
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
25ecebf
Add builtin ZeroMQ for RooFit::MultiProcess (later)
egpbos 856308b
suppress warnings in ZeroMQ builtin build
egpbos 8b59b0b
add cppzmq to ZeroMQ builtin
egpbos 1042726
add RooFitZMQ package
egpbos 4476eb3
add RooFitZMQ tests
egpbos fcb329f
add ppoll to RooFitZMQ
egpbos 81b3ad6
move ZeroMQ builtin to builtins directory and add build option
egpbos 2bddfa4
add ZeroMQPoller::ppoll implementation
egpbos aa83033
address DeepCode issues: properly rethrow exceptions
egpbos c95ee93
pass on ROOT cxx_compiler to ZeroMQ built-in
egpbos 0c0dc78
include header corresponding to implementation file before others
egpbos fe6ed68
add ZeroMQ to CI header copying
egpbos bcdf91e
clang-format on RooFitZMQ
egpbos f8fb2b0
switch cppzmq to version 4.3.0
egpbos 1fde1c3
remove ppoll copyright headers
egpbos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| include(ExternalProject) | ||
|
|
||
| set(ZeroMQ_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/BUILTIN_ZeroMQ-prefix) | ||
| set(ZeroMQ_LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}zmq${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
|
|
||
| set(ZeroMQ_LIBRARY ${ZeroMQ_PREFIX}/lib/${ZeroMQ_LIBNAME} CACHE INTERNAL "" FORCE) | ||
| set(ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} CACHE INTERNAL "" FORCE) | ||
|
|
||
| ExternalProject_Add(BUILTIN_ZeroMQ | ||
| URL https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.2.tar.gz | ||
| URL_HASH SHA256=02ecc88466ae38cf2c8d79f09cfd2675ba299a439680b64ade733e26a349edeb | ||
| CMAKE_ARGS | ||
| -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
| -DWITH_PERF_TOOL=OFF | ||
| -DZMQ_BUILD_TESTS=OFF | ||
| -DPOLLER=select | ||
| -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | ||
| # TODO: remove -w flag when updating to v4.3.5 or higher, current warnings should be gone by then | ||
| -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}\ -w | ||
| BUILD_BYPRODUCTS ${ZeroMQ_LIBRARIES} | ||
| ) | ||
|
|
||
| ExternalProject_Get_Property(BUILTIN_ZeroMQ install_dir) | ||
|
|
||
| set(ZeroMQ_FOUND TRUE CACHE BOOL "" FORCE) | ||
|
|
||
| set(ZeroMQ_INCLUDE_DIR ${ZeroMQ_PREFIX}/include CACHE INTERNAL "" FORCE) | ||
| set(ZeroMQ_INCLUDE_DIRS ${ZeroMQ_PREFIX}/include CACHE INTERNAL "" FORCE) | ||
|
|
||
| add_library(ZeroMQ INTERFACE) | ||
| target_include_directories(ZeroMQ INTERFACE $<BUILD_INTERFACE:${ZeroMQ_INCLUDE_DIR}>) | ||
| target_link_libraries(ZeroMQ INTERFACE $<BUILD_INTERFACE:${ZeroMQ_LIBRARIES}>) | ||
| add_dependencies(ZeroMQ BUILTIN_ZeroMQ) | ||
|
|
||
| add_library(ZeroMQ::ZeroMQ ALIAS ZeroMQ) | ||
| add_library(libzmq ALIAS ZeroMQ) | ||
|
|
||
| set(ZeroMQ_DIR ${ZeroMQ_PREFIX}/share/cmake/ZeroMQ CACHE INTERNAL "" FORCE) | ||
|
|
||
| # also need source and build directories for ppoll in RooFitZMQ | ||
| set(ZeroMQ_SOURCE_DIR ${ZeroMQ_PREFIX}/src/BUILTIN_ZeroMQ/src CACHE INTERNAL "" FORCE) | ||
| set(ZeroMQ_BUILD_DIR ${ZeroMQ_PREFIX}/src/BUILTIN_ZeroMQ-build CACHE INTERNAL "" FORCE) | ||
|
|
||
| ExternalProject_Add(BUILTIN_cppzmq | ||
| URL https://github.com/zeromq/cppzmq/archive/refs/tags/v4.3.0.tar.gz | ||
| URL_HASH SHA256=27d1f56406ba94ee779e639203218820975cf68174f92fbeae0f645df0fcada4 | ||
| CMAKE_ARGS | ||
| -DCMAKE_INSTALL_PREFIX=${install_dir} | ||
| -DCPPZMQ_BUILD_TESTS=OFF | ||
| DEPENDS BUILTIN_ZeroMQ | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ############################################################################ | ||
| # CMakeLists.txt file for building ROOT roofitcore/ZMQ package | ||
| # @author Patrick Bos, NL eScience Center | ||
| ############################################################################ | ||
|
|
||
| #if(NOT ZeroMQ_FOUND) | ||
| # find_package(ZeroMQ REQUIRED) | ||
| #endif() | ||
|
|
||
| ROOT_STANDARD_LIBRARY_PACKAGE(RooFitZMQ | ||
| HEADERS | ||
| RooFit_ZMQ/Utility.h | ||
| RooFit_ZMQ/ZeroMQSvc.h | ||
| RooFit_ZMQ/functions.h | ||
| RooFit_ZMQ/ZeroMQPoller.h | ||
| RooFit_ZMQ/ppoll.h | ||
| SOURCES | ||
| src/ZeroMQSvc.cpp | ||
| src/ZeroMQPoller.cpp | ||
| src/functions.cpp | ||
| src/ppoll.cpp | ||
| DICTIONARY_OPTIONS | ||
| -writeEmptyRootPCM | ||
| DEPENDENCIES | ||
| Core # TVersionCheck, RegisterModule, these are always called from G__RooFitZMQ.cxx.o | ||
| LIBRARIES | ||
| ZeroMQ | ||
| ) | ||
|
|
||
|
|
||
| target_link_libraries(RooFitZMQ PRIVATE ZeroMQ) | ||
| target_include_directories(RooFitZMQ PUBLIC $<BUILD_INTERFACE:${ZeroMQ_INCLUDE_DIR}>) | ||
| target_include_directories(RooFitZMQ PUBLIC $<BUILD_INTERFACE:${ZeroMQ_SOURCE_DIR}>) | ||
| target_include_directories(RooFitZMQ PUBLIC $<BUILD_INTERFACE:${ZeroMQ_BUILD_DIR}>) | ||
|
|
||
| if(testing) | ||
| ROOT_ADD_TEST_SUBDIRECTORY(test) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #ifndef SERIALIZE_UTILITY_H | ||
| #define SERIALIZE_UTILITY_H 1 | ||
|
|
||
| #if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 10)) | ||
| #define HAVE_TRIVIALLY_COPYABLE 1 | ||
| #elif defined(__GNUC__) && __GNUC__ >= 5 | ||
| #define HAVE_TRIVIALLY_COPYABLE 1 | ||
| #else | ||
| #undef HAVE_TRIVIALLY_COPYABLE | ||
| #endif | ||
|
|
||
| #include <type_traits> | ||
|
|
||
| namespace ZMQ { | ||
| namespace Detail { | ||
|
|
||
| #if defined(HAVE_TRIVIALLY_COPYABLE) | ||
| template <class T> | ||
| using simple_object = std::is_trivially_copyable<T>; | ||
| #else | ||
| template <class T> | ||
| using simple_object = std::is_pod<T>; | ||
| #endif | ||
|
|
||
| // is trivial | ||
| template <class T> | ||
| struct is_trivial | ||
| : std::conditional<simple_object<typename std::decay<T>::type>::value, std::true_type, std::false_type>::type { | ||
| }; | ||
|
|
||
| } // namespace Detail | ||
| } // namespace ZMQ | ||
|
|
||
| #endif // SERIALIZE_UTILITY_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #ifndef ZEROMQPOLLER_H | ||
| #define ZEROMQPOLLER_H 1 | ||
| #include <vector> | ||
| #include <deque> | ||
| #include <exception> | ||
| #include <unordered_map> | ||
|
|
||
| #include "RooFit_ZMQ/ZeroMQSvc.h" | ||
| #include "RooFit_ZMQ/functions.h" | ||
|
|
||
| class ZeroMQPoller { | ||
| public: | ||
| using entry_t = std::tuple<size_t, zmq::PollType, const zmq::socket_t *>; | ||
| // The key is what zmq::socket_t stores inside, and what goes into | ||
| // pollitem_t through zmq::socket_t's conversion to void* operator | ||
| using sockets_t = std::unordered_map<void *, entry_t>; | ||
|
|
||
| using fd_entry_t = std::tuple<size_t, zmq::PollType>; | ||
| using fds_t = std::unordered_map<int, fd_entry_t>; | ||
|
|
||
| using free_t = std::deque<int>; | ||
|
|
||
| ZeroMQPoller() = default; | ||
|
|
||
| std::vector<std::pair<size_t, int>> poll(int timeo = -1); | ||
| std::vector<std::pair<size_t, int>> ppoll(int timeo, const sigset_t *sigmask_); | ||
|
|
||
| size_t size() const; | ||
|
|
||
| size_t register_socket(zmq::socket_t &socket, zmq::PollType type); | ||
| size_t register_socket(int fd, zmq::PollType type); | ||
|
|
||
| size_t unregister_socket(zmq::socket_t &socket); | ||
| size_t unregister_socket(int fd); | ||
|
|
||
| private: | ||
| // Vector of (socket, flags) | ||
| std::vector<zmq::pollitem_t> m_items; | ||
| sockets_t m_sockets; | ||
| fds_t m_fds; | ||
|
|
||
| // free slots in items | ||
| free_t m_free; | ||
| }; | ||
|
|
||
| #endif // ZEROMQPOLLER_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}Please also use the same compiler as for the rest of ROOT. Otherwise, the compilation can fail because of incompatibilities.
(A precedent is set in the
davixandpcrebuiltins)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in c95ee93.