diff --git a/CMakeLists.txt b/CMakeLists.txt index 1525dea56..07e16509f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,10 @@ list(APPEND CMAKE_INSTALL_RPATH $ENV{CONDA_PREFIX}/lib) list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}") list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}/Library") -add_subdirectory(catkit_core) +find_package(catkit2-core QUIET) +if (NOT catkit2-core_FOUND) + message(STATUS "catkit2-core not found, building from source") + add_subdirectory(catkit2-core) +endif() + add_subdirectory(catkit2) -add_subdirectory(benchmarks) diff --git a/catkit2-core/CMakeLists.txt b/catkit2-core/CMakeLists.txt new file mode 100644 index 000000000..fb43ba1c5 --- /dev/null +++ b/catkit2-core/CMakeLists.txt @@ -0,0 +1,124 @@ +cmake_minimum_required(VERSION 3.21) + +project(catkit2_core) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED on) + +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt.") +endif() + +add_compile_options($<$:/MP1>) + +file(GLOB_RECURSE SOURCES "./src/*.cpp") +file(GLOB_RECURSE HEADERS "./src/*.h") + +add_library(catkit2_core STATIC) +target_sources(catkit2_core PRIVATE "${SOURCES}") +target_include_directories( + catkit2_core + INTERFACE + $ + $ +) + +set_property(TARGET catkit2_core PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_definitions(catkit2_core PUBLIC PROTOBUF_USE_DLLS) + +if (MSVC) + # disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' + target_compile_options(catkit2_core PUBLIC /wd4251) +endif() + +# Link ZeroMQ +find_package(ZeroMQ REQUIRED) +target_include_directories(catkit2_core PUBLIC ${ZeroMQ_INCLUDE_DIR}) +target_link_libraries(catkit2_core PUBLIC libzmq) +if (WIN32) + target_link_libraries(catkit2_core PUBLIC wsock32 ws2_32 Iphlpapi) +else() + target_link_libraries(catkit2_core PUBLIC pthread) + if (NOT APPLE) + target_link_libraries(catkit2_core PUBLIC rt) + endif (NOT APPLE) +endif (WIN32) + +# Add includes for cppzmq +find_package(cppzmq REQUIRED) +target_include_directories(catkit2_core PUBLIC ${CPPZMQ_INCLUDE_DIR}) + +# Link Eigen +find_package(Eigen3 REQUIRED NO_MODULE) +target_link_libraries (catkit2_core PUBLIC Eigen3::Eigen) + +# Link nlohmann JSON +find_package(nlohmann_json) +target_include_directories(catkit2_core PRIVATE ${JSON_INCLUDE_DIR}) + +# Link protobuf +INCLUDE(FindProtobuf) +find_package(Protobuf REQUIRED) +target_include_directories(catkit2_core PUBLIC ${PROTOBUF_INCLUDE_DIR}) +target_link_libraries(catkit2_core PUBLIC ${PROTOBUF_LIBRARY}) + +set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/") +message("Proto binary dir: ${PROTO_BINARY_DIR}") +file(MAKE_DIRECTORY "${PROTO_BINARY_DIR}") +protobuf_generate( + TARGET catkit2_core + IMPORT_DIRS proto + PROTOC_OUT_DIR "${PROTO_BINARY_DIR}" + PROTOS + proto/core.proto + proto/logging.proto + proto/service.proto + proto/testbed.proto + proto/tracing.proto +) +target_include_directories(catkit2_core PUBLIC "$") +# Generate and install CatkitCoreConfig.cmake +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CatkitCoreConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" + INSTALL_DESTINATION lib/cmake/catkit2_core +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" + DESTINATION "lib/cmake/catkit2_core" +) + +install( + TARGETS catkit2_core + EXPORT CatkitCoreTargets + LIBRARY DESTINATION lib +) + +# Generate and install CatkitCoreTargets.cmake +install( + EXPORT CatkitCoreTargets + FILE CatkitCoreTargets.cmake + DESTINATION "lib/cmake/catkit2_core" +) + +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" + DESTINATION include/catkit2_core + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.inl" +) +install(DIRECTORY "${PROTO_BINARY_DIR}" + DESTINATION include/catkit2_core + FILES_MATCHING + PATTERN "*.h" +) +install(DIRECTORY "${PROTO_SOURCE_DIR}" + DESTINATION include/catkit2_core/proto + FILES_MATCHING + PATTERN "*.proto" +) + +add_subdirectory(benchmarks) diff --git a/benchmarks/CMakeLists.txt b/catkit2-core/benchmarks/CMakeLists.txt similarity index 51% rename from benchmarks/CMakeLists.txt rename to catkit2-core/benchmarks/CMakeLists.txt index 4ed3b2d82..f2b741883 100644 --- a/benchmarks/CMakeLists.txt +++ b/catkit2-core/benchmarks/CMakeLists.txt @@ -11,53 +11,63 @@ endif() # DataStream latency benchmark add_executable(datastream_latency datastream_latency.cpp) -target_include_directories(datastream_latency PUBLIC ../catkit_core) -target_link_libraries(datastream_latency PUBLIC catkit_core) +target_include_directories(datastream_latency PUBLIC ../catkit2_core) +target_link_libraries(datastream_latency PUBLIC catkit2_core) # Datastream submit benchmark add_executable(datastream_submit datastream_submit.cpp) -target_include_directories(datastream_submit PUBLIC ../catkit_core) -target_link_libraries(datastream_submit PUBLIC catkit_core) +target_include_directories(datastream_submit PUBLIC ../catkit2_core) +target_link_libraries(datastream_submit PUBLIC catkit2_core) # Timestamp benchmark add_executable(timestamp timestamp.cpp) -target_include_directories(timestamp PUBLIC ../catkit_core) -target_link_libraries(timestamp PUBLIC catkit_core) +target_include_directories(timestamp PUBLIC ../catkit2_core) +target_link_libraries(timestamp PUBLIC catkit2_core) + +# Free list allocator benchmark +add_executable(free_list_allocator free_list_allocator.cpp) +target_include_directories(free_list_allocator PUBLIC ../catkit2_core) +target_link_libraries(free_list_allocator PUBLIC catkit2_core) # Pool allocator benchmark add_executable(pool_allocator pool_allocator.cpp) -target_include_directories(pool_allocator PUBLIC ../catkit_core) -target_link_libraries(pool_allocator PUBLIC catkit_core) +target_include_directories(pool_allocator PUBLIC ../catkit2_core) +target_link_libraries(pool_allocator PUBLIC catkit2_core) # Hash map benchmark add_executable(hash_map hash_map.cpp) -target_include_directories(hash_map PUBLIC ../catkit_core) -target_link_libraries(hash_map PUBLIC catkit_core) +target_include_directories(hash_map PUBLIC ../catkit2_core) +target_link_libraries(hash_map PUBLIC catkit2_core) # Uuid generator benchmark add_executable(uuid_generator uuid_generator.cpp) -target_include_directories(uuid_generator PUBLIC ../catkit_core) -target_link_libraries(uuid_generator PUBLIC catkit_core) +target_include_directories(uuid_generator PUBLIC ../catkit2_core) +target_link_libraries(uuid_generator PUBLIC catkit2_core) # MessageBroker benchmark add_executable(message_broker message_broker.cpp) -target_include_directories(message_broker PUBLIC ../catkit_core) -target_link_libraries(message_broker PUBLIC catkit_core) +target_include_directories(message_broker PUBLIC ../catkit2_core) +target_link_libraries(message_broker PUBLIC catkit2_core) # BuddyAllocator benchmark add_executable(buddy_allocator buddy_allocator.cpp) -target_include_directories(buddy_allocator PUBLIC ../catkit_core) -target_link_libraries(buddy_allocator PUBLIC catkit_core) +target_include_directories(buddy_allocator PUBLIC ../catkit2_core) +target_link_libraries(buddy_allocator PUBLIC catkit2_core) # HybridPoolAllocator benchmark add_executable(hybrid_pool_allocator hybrid_pool_allocator.cpp) -target_include_directories(hybrid_pool_allocator PUBLIC ../catkit_core) -target_link_libraries(hybrid_pool_allocator PUBLIC catkit_core) +target_include_directories(hybrid_pool_allocator PUBLIC ../catkit2_core) +target_link_libraries(hybrid_pool_allocator PUBLIC catkit2_core) # Event latency benchmark add_executable(event_latency event_latency.cpp) -target_include_directories(event_latency PUBLIC ../catkit_core) -target_link_libraries(event_latency PUBLIC catkit_core) +target_include_directories(event_latency PUBLIC ../catkit2_core) +target_link_libraries(event_latency PUBLIC catkit2_core) + +# Free list benchmark +add_executable(free_list free_list_allocator.cpp) +target_include_directories(free_list PUBLIC ../catkit2_core) +target_link_libraries(free_list PUBLIC catkit2_core) # Add install files install(TARGETS datastream_latency DESTINATION bin) @@ -70,3 +80,4 @@ install(TARGETS message_broker DESTINATION bin) install(TARGETS buddy_allocator DESTINATION bin) install(TARGETS hybrid_pool_allocator DESTINATION bin) install(TARGETS event_latency DESTINATION bin) +install(TARGETS free_list DESTINATION bin) \ No newline at end of file diff --git a/benchmarks/buddy_allocator.cpp b/catkit2-core/benchmarks/buddy_allocator.cpp similarity index 100% rename from benchmarks/buddy_allocator.cpp rename to catkit2-core/benchmarks/buddy_allocator.cpp diff --git a/benchmarks/datastream_latency.cpp b/catkit2-core/benchmarks/datastream_latency.cpp similarity index 100% rename from benchmarks/datastream_latency.cpp rename to catkit2-core/benchmarks/datastream_latency.cpp diff --git a/benchmarks/datastream_submit.cpp b/catkit2-core/benchmarks/datastream_submit.cpp similarity index 100% rename from benchmarks/datastream_submit.cpp rename to catkit2-core/benchmarks/datastream_submit.cpp diff --git a/benchmarks/event_latency.cpp b/catkit2-core/benchmarks/event_latency.cpp similarity index 100% rename from benchmarks/event_latency.cpp rename to catkit2-core/benchmarks/event_latency.cpp diff --git a/catkit2-core/benchmarks/free_list_allocator.cpp b/catkit2-core/benchmarks/free_list_allocator.cpp new file mode 100644 index 000000000..f1fc939e4 --- /dev/null +++ b/catkit2-core/benchmarks/free_list_allocator.cpp @@ -0,0 +1,145 @@ +#include "BuddyAllocator.h" +#include "Timing.h" +#include "LocalMemory.h" + +#include + +void benchmark_linux_scalability() +{ + const size_t N = 10000000; + const size_t BLOCK_SIZE = 32; + const size_t MAX_SIZE = BLOCK_SIZE * (1 << 25); + + auto *handles = new BuddyAllocator::Handle[N]; + + size_t buffer_size = BuddyAllocator::GetSharedStateSize(MAX_SIZE, BLOCK_SIZE); + auto buffer = LocalMemory::Create(buffer_size); + + auto stream = StructStream(buffer); + auto allocator = BuddyAllocator::Create(stream, MAX_SIZE, BLOCK_SIZE); + + auto start = GetTimeStamp(); + + for (size_t i = 0; i < N; ++i) + { + handles[i] = allocator->Allocate(16); + } + + for (size_t i = 0; i < N; ++i) + { + allocator->Release(handles[i]); + } + + auto end = GetTimeStamp(); + + std::cout << "Linux Scalability:" << std::endl; + std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; + std::cout << "Throughput: " << 2 * N / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N) << " ns" << std::endl; + + delete[] handles; +} + +void benchmark_threadtest() +{ + const size_t N = 100; + const size_t M = 100000; + const size_t BLOCK_SIZE = 32; + const size_t DEPTH = 24; + const size_t MAX_SIZE = BLOCK_SIZE * (1 << DEPTH); + + auto *handles = new BuddyAllocator::Handle[M]; + + size_t buffer_size = BuddyAllocator::GetSharedStateSize(MAX_SIZE, BLOCK_SIZE); + auto buffer = LocalMemory::Create(buffer_size); + + auto stream = StructStream(buffer); + auto allocator = BuddyAllocator::Create(stream, MAX_SIZE, BLOCK_SIZE); + + auto start = GetTimeStamp(); + + for (size_t i = 0; i < M; ++i) + { + for (size_t j = 0; j < N; ++j) + { + handles[j] = allocator->Allocate(16); + } + + for (size_t j = 0; j < N; ++j) + { + allocator->Release(handles[j]); + } + } + + auto end = GetTimeStamp(); + + std::cout << "Threadtest:" << std::endl; + std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; + std::cout << "Throughput: " << 2 * N * M / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N * M) << " ns" << std::endl; + + delete[] handles; +} + +void benchmark_larson() +{ + const size_t ALIGNMENT = 32; + + const size_t N = 10000000; + const size_t M = 1000; + const size_t MIN_SIZE = 1; + const size_t MAX_SIZE = 16; + const size_t BLOCK_SIZE = 16; + const size_t DEPTH = 20; + const size_t SIZE = BLOCK_SIZE * (1 << DEPTH); + + auto *handles = new BuddyAllocator::Handle[M]; + for (size_t i = 0; i < M; ++i) + handles[i] = BuddyAllocator::INVALID_HANDLE; + + size_t buffer_size = BuddyAllocator::GetSharedStateSize(SIZE, BLOCK_SIZE); + auto buffer = LocalMemory::Create(buffer_size); + + auto stream = StructStream(buffer); + auto allocator = BuddyAllocator::Create(stream, SIZE, BLOCK_SIZE); + + auto *indices = new size_t[N]; + auto *sizes = new size_t[N]; + for (size_t i = 0; i < N; ++i) + { + indices[i] = rand() % M; + sizes[i] = (MIN_SIZE + (rand() % (MAX_SIZE - MIN_SIZE))) * BLOCK_SIZE; + } + + auto start = GetTimeStamp(); + + for (size_t i = 0; i < N; ++i) + { + size_t index = indices[i]; + size_t size = sizes[i]; + + if (handles[index] != BuddyAllocator::INVALID_HANDLE) + { + allocator->Release(handles[index]); + } + + handles[index] = allocator->Allocate(size); + } + + auto end = GetTimeStamp(); + std::cout << "Larson benchmark:" << std::endl; + std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; + std::cout << "Throughput: " << (N * 2 - M) / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N - M) << " ns" << std::endl; + + delete[] handles; +} + +int main(int argc, char **argv) +{ + benchmark_linux_scalability(); + benchmark_threadtest(); + benchmark_larson(); + + return 0; +} diff --git a/benchmarks/hash_map.cpp b/catkit2-core/benchmarks/hash_map.cpp similarity index 100% rename from benchmarks/hash_map.cpp rename to catkit2-core/benchmarks/hash_map.cpp diff --git a/benchmarks/hybrid_pool_allocator.cpp b/catkit2-core/benchmarks/hybrid_pool_allocator.cpp similarity index 100% rename from benchmarks/hybrid_pool_allocator.cpp rename to catkit2-core/benchmarks/hybrid_pool_allocator.cpp diff --git a/benchmarks/latency_histogram.py b/catkit2-core/benchmarks/latency_histogram.py similarity index 100% rename from benchmarks/latency_histogram.py rename to catkit2-core/benchmarks/latency_histogram.py diff --git a/benchmarks/message_broker.cpp b/catkit2-core/benchmarks/message_broker.cpp similarity index 100% rename from benchmarks/message_broker.cpp rename to catkit2-core/benchmarks/message_broker.cpp diff --git a/benchmarks/pool_allocator.cpp b/catkit2-core/benchmarks/pool_allocator.cpp similarity index 100% rename from benchmarks/pool_allocator.cpp rename to catkit2-core/benchmarks/pool_allocator.cpp diff --git a/benchmarks/timestamp.cpp b/catkit2-core/benchmarks/timestamp.cpp similarity index 100% rename from benchmarks/timestamp.cpp rename to catkit2-core/benchmarks/timestamp.cpp diff --git a/benchmarks/uuid_generator.cpp b/catkit2-core/benchmarks/uuid_generator.cpp similarity index 100% rename from benchmarks/uuid_generator.cpp rename to catkit2-core/benchmarks/uuid_generator.cpp diff --git a/catkit_core/cmake/CatkitCoreConfig.cmake.in b/catkit2-core/cmake/CatkitCoreConfig.cmake.in similarity index 100% rename from catkit_core/cmake/CatkitCoreConfig.cmake.in rename to catkit2-core/cmake/CatkitCoreConfig.cmake.in diff --git a/proto/core.proto b/catkit2-core/proto/core.proto similarity index 100% rename from proto/core.proto rename to catkit2-core/proto/core.proto diff --git a/proto/logging.proto b/catkit2-core/proto/logging.proto similarity index 100% rename from proto/logging.proto rename to catkit2-core/proto/logging.proto diff --git a/proto/service.proto b/catkit2-core/proto/service.proto similarity index 100% rename from proto/service.proto rename to catkit2-core/proto/service.proto diff --git a/proto/testbed.proto b/catkit2-core/proto/testbed.proto similarity index 100% rename from proto/testbed.proto rename to catkit2-core/proto/testbed.proto diff --git a/proto/tracing.proto b/catkit2-core/proto/tracing.proto similarity index 100% rename from proto/tracing.proto rename to catkit2-core/proto/tracing.proto diff --git a/catkit2-core/recipe/bld.bat b/catkit2-core/recipe/bld.bat new file mode 100644 index 000000000..0d26b3cec --- /dev/null +++ b/catkit2-core/recipe/bld.bat @@ -0,0 +1,6 @@ +mkdir build +cd build + +cmake .. -A x64 +cmake --build . --config Release +cmake --install . --prefix %PREFIX% diff --git a/catkit2-core/recipe/build.sh b/catkit2-core/recipe/build.sh new file mode 100644 index 000000000..efb04c17a --- /dev/null +++ b/catkit2-core/recipe/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +mkdir -p build +cd build + +cmake .. -DCMAKE_BUILD_TYPE=Release +cmake --build . --config Release -v +cmake --install . --prefix=$PREFIX diff --git a/catkit2-core/recipe/meta.yaml b/catkit2-core/recipe/meta.yaml new file mode 100644 index 000000000..3f3674562 --- /dev/null +++ b/catkit2-core/recipe/meta.yaml @@ -0,0 +1,21 @@ +package: + name: catkit2-core + version: "0.0.1" + +source: + path: ../ + +build: + number: 0 + +requirements: + build: + - cmake + - make + - {{ compiler('cxx') }} + - cppzmq=4.8.1 + - eigen=3.4.0 + - nlohmann_json=3.9.1 + host: + - zeromq>=4.0.0 + - libprotobuf diff --git a/catkit_core/ArrayView.cpp b/catkit2-core/src/ArrayView.cpp similarity index 100% rename from catkit_core/ArrayView.cpp rename to catkit2-core/src/ArrayView.cpp diff --git a/catkit_core/ArrayView.h b/catkit2-core/src/ArrayView.h similarity index 100% rename from catkit_core/ArrayView.h rename to catkit2-core/src/ArrayView.h diff --git a/catkit_core/BuddyAllocator.cpp b/catkit2-core/src/BuddyAllocator.cpp similarity index 100% rename from catkit_core/BuddyAllocator.cpp rename to catkit2-core/src/BuddyAllocator.cpp diff --git a/catkit_core/BuddyAllocator.h b/catkit2-core/src/BuddyAllocator.h similarity index 100% rename from catkit_core/BuddyAllocator.h rename to catkit2-core/src/BuddyAllocator.h diff --git a/catkit_core/Client.cpp b/catkit2-core/src/Client.cpp similarity index 100% rename from catkit_core/Client.cpp rename to catkit2-core/src/Client.cpp diff --git a/catkit_core/Client.h b/catkit2-core/src/Client.h similarity index 100% rename from catkit_core/Client.h rename to catkit2-core/src/Client.h diff --git a/catkit_core/Command.cpp b/catkit2-core/src/Command.cpp similarity index 100% rename from catkit_core/Command.cpp rename to catkit2-core/src/Command.cpp diff --git a/catkit_core/Command.h b/catkit2-core/src/Command.h similarity index 100% rename from catkit_core/Command.h rename to catkit2-core/src/Command.h diff --git a/catkit_core/ComplexTraits.h b/catkit2-core/src/ComplexTraits.h similarity index 100% rename from catkit_core/ComplexTraits.h rename to catkit2-core/src/ComplexTraits.h diff --git a/catkit_core/ConcurrentVector.h b/catkit2-core/src/ConcurrentVector.h similarity index 100% rename from catkit_core/ConcurrentVector.h rename to catkit2-core/src/ConcurrentVector.h diff --git a/catkit_core/ConcurrentVector.inl b/catkit2-core/src/ConcurrentVector.inl similarity index 100% rename from catkit_core/ConcurrentVector.inl rename to catkit2-core/src/ConcurrentVector.inl diff --git a/catkit_core/CudaSharedMemory.h b/catkit2-core/src/CudaSharedMemory.h similarity index 100% rename from catkit_core/CudaSharedMemory.h rename to catkit2-core/src/CudaSharedMemory.h diff --git a/catkit_core/DataStream.cpp b/catkit2-core/src/DataStream.cpp similarity index 100% rename from catkit_core/DataStream.cpp rename to catkit2-core/src/DataStream.cpp diff --git a/catkit_core/DataStream.h b/catkit2-core/src/DataStream.h similarity index 100% rename from catkit_core/DataStream.h rename to catkit2-core/src/DataStream.h diff --git a/catkit_core/DeformableMirrorService.cpp b/catkit2-core/src/DeformableMirrorService.cpp similarity index 100% rename from catkit_core/DeformableMirrorService.cpp rename to catkit2-core/src/DeformableMirrorService.cpp diff --git a/catkit_core/DeformableMirrorService.h b/catkit2-core/src/DeformableMirrorService.h similarity index 100% rename from catkit_core/DeformableMirrorService.h rename to catkit2-core/src/DeformableMirrorService.h diff --git a/catkit_core/Event.cpp b/catkit2-core/src/Event.cpp similarity index 100% rename from catkit_core/Event.cpp rename to catkit2-core/src/Event.cpp diff --git a/catkit_core/Event.h b/catkit2-core/src/Event.h similarity index 100% rename from catkit_core/Event.h rename to catkit2-core/src/Event.h diff --git a/catkit_core/EventBase.h b/catkit2-core/src/EventBase.h similarity index 100% rename from catkit_core/EventBase.h rename to catkit2-core/src/EventBase.h diff --git a/catkit_core/EventBase.inl b/catkit2-core/src/EventBase.inl similarity index 100% rename from catkit_core/EventBase.inl rename to catkit2-core/src/EventBase.inl diff --git a/catkit_core/EventConditionVariable.inl b/catkit2-core/src/EventConditionVariable.inl similarity index 100% rename from catkit_core/EventConditionVariable.inl rename to catkit2-core/src/EventConditionVariable.inl diff --git a/catkit_core/EventFutex.inl b/catkit2-core/src/EventFutex.inl similarity index 100% rename from catkit_core/EventFutex.inl rename to catkit2-core/src/EventFutex.inl diff --git a/catkit_core/EventSemaphore.inl b/catkit2-core/src/EventSemaphore.inl similarity index 100% rename from catkit_core/EventSemaphore.inl rename to catkit2-core/src/EventSemaphore.inl diff --git a/catkit_core/EventSpinLock.inl b/catkit2-core/src/EventSpinLock.inl similarity index 100% rename from catkit_core/EventSpinLock.inl rename to catkit2-core/src/EventSpinLock.inl diff --git a/catkit_core/Finally.h b/catkit2-core/src/Finally.h similarity index 100% rename from catkit_core/Finally.h rename to catkit2-core/src/Finally.h diff --git a/catkit_core/FitsFile.cpp b/catkit2-core/src/FitsFile.cpp similarity index 100% rename from catkit_core/FitsFile.cpp rename to catkit2-core/src/FitsFile.cpp diff --git a/catkit_core/FitsFile.h b/catkit2-core/src/FitsFile.h similarity index 100% rename from catkit_core/FitsFile.h rename to catkit2-core/src/FitsFile.h diff --git a/catkit_core/FitsFile.inl b/catkit2-core/src/FitsFile.inl similarity index 100% rename from catkit_core/FitsFile.inl rename to catkit2-core/src/FitsFile.inl diff --git a/catkit_core/HashMap.cpp b/catkit2-core/src/HashMap.cpp similarity index 100% rename from catkit_core/HashMap.cpp rename to catkit2-core/src/HashMap.cpp diff --git a/catkit_core/HashMap.h b/catkit2-core/src/HashMap.h similarity index 100% rename from catkit_core/HashMap.h rename to catkit2-core/src/HashMap.h diff --git a/catkit_core/HostName.cpp b/catkit2-core/src/HostName.cpp similarity index 100% rename from catkit_core/HostName.cpp rename to catkit2-core/src/HostName.cpp diff --git a/catkit_core/HostName.h b/catkit2-core/src/HostName.h similarity index 100% rename from catkit_core/HostName.h rename to catkit2-core/src/HostName.h diff --git a/catkit_core/HybridPoolAllocator.cpp b/catkit2-core/src/HybridPoolAllocator.cpp similarity index 100% rename from catkit_core/HybridPoolAllocator.cpp rename to catkit2-core/src/HybridPoolAllocator.cpp diff --git a/catkit_core/HybridPoolAllocator.h b/catkit2-core/src/HybridPoolAllocator.h similarity index 100% rename from catkit_core/HybridPoolAllocator.h rename to catkit2-core/src/HybridPoolAllocator.h diff --git a/catkit_core/LocalMemory.cpp b/catkit2-core/src/LocalMemory.cpp similarity index 100% rename from catkit_core/LocalMemory.cpp rename to catkit2-core/src/LocalMemory.cpp diff --git a/catkit_core/LocalMemory.h b/catkit2-core/src/LocalMemory.h similarity index 100% rename from catkit_core/LocalMemory.h rename to catkit2-core/src/LocalMemory.h diff --git a/catkit_core/LocalMessageBroker.cpp b/catkit2-core/src/LocalMessageBroker.cpp similarity index 100% rename from catkit_core/LocalMessageBroker.cpp rename to catkit2-core/src/LocalMessageBroker.cpp diff --git a/catkit_core/LocalMessageBroker.h b/catkit2-core/src/LocalMessageBroker.h similarity index 100% rename from catkit_core/LocalMessageBroker.h rename to catkit2-core/src/LocalMessageBroker.h diff --git a/catkit_core/Log.cpp b/catkit2-core/src/Log.cpp similarity index 100% rename from catkit_core/Log.cpp rename to catkit2-core/src/Log.cpp diff --git a/catkit_core/Log.h b/catkit2-core/src/Log.h similarity index 100% rename from catkit_core/Log.h rename to catkit2-core/src/Log.h diff --git a/catkit_core/LogConsole.cpp b/catkit2-core/src/LogConsole.cpp similarity index 100% rename from catkit_core/LogConsole.cpp rename to catkit2-core/src/LogConsole.cpp diff --git a/catkit_core/LogConsole.h b/catkit2-core/src/LogConsole.h similarity index 100% rename from catkit_core/LogConsole.h rename to catkit2-core/src/LogConsole.h diff --git a/catkit_core/LogFile.cpp b/catkit2-core/src/LogFile.cpp similarity index 100% rename from catkit_core/LogFile.cpp rename to catkit2-core/src/LogFile.cpp diff --git a/catkit_core/LogFile.h b/catkit2-core/src/LogFile.h similarity index 100% rename from catkit_core/LogFile.h rename to catkit2-core/src/LogFile.h diff --git a/catkit_core/LogForwarder.cpp b/catkit2-core/src/LogForwarder.cpp similarity index 100% rename from catkit_core/LogForwarder.cpp rename to catkit2-core/src/LogForwarder.cpp diff --git a/catkit_core/LogForwarder.h b/catkit2-core/src/LogForwarder.h similarity index 100% rename from catkit_core/LogForwarder.h rename to catkit2-core/src/LogForwarder.h diff --git a/catkit_core/LoggingProxy.h b/catkit2-core/src/LoggingProxy.h similarity index 100% rename from catkit_core/LoggingProxy.h rename to catkit2-core/src/LoggingProxy.h diff --git a/catkit_core/Memory.h b/catkit2-core/src/Memory.h similarity index 100% rename from catkit_core/Memory.h rename to catkit2-core/src/Memory.h diff --git a/catkit_core/MessageBroker.cpp b/catkit2-core/src/MessageBroker.cpp similarity index 100% rename from catkit_core/MessageBroker.cpp rename to catkit2-core/src/MessageBroker.cpp diff --git a/catkit_core/MessageBroker.h b/catkit2-core/src/MessageBroker.h similarity index 100% rename from catkit_core/MessageBroker.h rename to catkit2-core/src/MessageBroker.h diff --git a/catkit_core/PoolAllocator.cpp b/catkit2-core/src/PoolAllocator.cpp similarity index 100% rename from catkit_core/PoolAllocator.cpp rename to catkit2-core/src/PoolAllocator.cpp diff --git a/catkit_core/PoolAllocator.h b/catkit2-core/src/PoolAllocator.h similarity index 100% rename from catkit_core/PoolAllocator.h rename to catkit2-core/src/PoolAllocator.h diff --git a/catkit_core/ProcessStats.cpp b/catkit2-core/src/ProcessStats.cpp similarity index 100% rename from catkit_core/ProcessStats.cpp rename to catkit2-core/src/ProcessStats.cpp diff --git a/catkit_core/ProcessStats.h b/catkit2-core/src/ProcessStats.h similarity index 100% rename from catkit_core/ProcessStats.h rename to catkit2-core/src/ProcessStats.h diff --git a/catkit_core/RefCounter.h b/catkit2-core/src/RefCounter.h similarity index 100% rename from catkit_core/RefCounter.h rename to catkit2-core/src/RefCounter.h diff --git a/catkit_core/Server.cpp b/catkit2-core/src/Server.cpp similarity index 100% rename from catkit_core/Server.cpp rename to catkit2-core/src/Server.cpp diff --git a/catkit_core/Server.h b/catkit2-core/src/Server.h similarity index 100% rename from catkit_core/Server.h rename to catkit2-core/src/Server.h diff --git a/catkit_core/Service.cpp b/catkit2-core/src/Service.cpp similarity index 100% rename from catkit_core/Service.cpp rename to catkit2-core/src/Service.cpp diff --git a/catkit_core/Service.h b/catkit2-core/src/Service.h similarity index 100% rename from catkit_core/Service.h rename to catkit2-core/src/Service.h diff --git a/catkit_core/ServiceProxy.cpp b/catkit2-core/src/ServiceProxy.cpp similarity index 100% rename from catkit_core/ServiceProxy.cpp rename to catkit2-core/src/ServiceProxy.cpp diff --git a/catkit_core/ServiceProxy.h b/catkit2-core/src/ServiceProxy.h similarity index 100% rename from catkit_core/ServiceProxy.h rename to catkit2-core/src/ServiceProxy.h diff --git a/catkit_core/ServiceState.cpp b/catkit2-core/src/ServiceState.cpp similarity index 100% rename from catkit_core/ServiceState.cpp rename to catkit2-core/src/ServiceState.cpp diff --git a/catkit_core/ServiceState.h b/catkit2-core/src/ServiceState.h similarity index 100% rename from catkit_core/ServiceState.h rename to catkit2-core/src/ServiceState.h diff --git a/catkit_core/Shareable.cpp b/catkit2-core/src/Shareable.cpp similarity index 100% rename from catkit_core/Shareable.cpp rename to catkit2-core/src/Shareable.cpp diff --git a/catkit_core/Shareable.h b/catkit2-core/src/Shareable.h similarity index 100% rename from catkit_core/Shareable.h rename to catkit2-core/src/Shareable.h diff --git a/catkit_core/SharedMemory.cpp b/catkit2-core/src/SharedMemory.cpp similarity index 100% rename from catkit_core/SharedMemory.cpp rename to catkit2-core/src/SharedMemory.cpp diff --git a/catkit_core/SharedMemory.h b/catkit2-core/src/SharedMemory.h similarity index 100% rename from catkit_core/SharedMemory.h rename to catkit2-core/src/SharedMemory.h diff --git a/catkit_core/StructStream.cpp b/catkit2-core/src/StructStream.cpp similarity index 100% rename from catkit_core/StructStream.cpp rename to catkit2-core/src/StructStream.cpp diff --git a/catkit_core/StructStream.h b/catkit2-core/src/StructStream.h similarity index 100% rename from catkit_core/StructStream.h rename to catkit2-core/src/StructStream.h diff --git a/catkit_core/StructStream.inl b/catkit2-core/src/StructStream.inl similarity index 100% rename from catkit_core/StructStream.inl rename to catkit2-core/src/StructStream.inl diff --git a/catkit_core/Tensor.cpp b/catkit2-core/src/Tensor.cpp similarity index 100% rename from catkit_core/Tensor.cpp rename to catkit2-core/src/Tensor.cpp diff --git a/catkit_core/Tensor.h b/catkit2-core/src/Tensor.h similarity index 100% rename from catkit_core/Tensor.h rename to catkit2-core/src/Tensor.h diff --git a/catkit_core/Tensor.inl b/catkit2-core/src/Tensor.inl similarity index 100% rename from catkit_core/Tensor.inl rename to catkit2-core/src/Tensor.inl diff --git a/catkit_core/TestbedProxy.cpp b/catkit2-core/src/TestbedProxy.cpp similarity index 100% rename from catkit_core/TestbedProxy.cpp rename to catkit2-core/src/TestbedProxy.cpp diff --git a/catkit_core/TestbedProxy.h b/catkit2-core/src/TestbedProxy.h similarity index 100% rename from catkit_core/TestbedProxy.h rename to catkit2-core/src/TestbedProxy.h diff --git a/catkit_core/Timing.cpp b/catkit2-core/src/Timing.cpp similarity index 100% rename from catkit_core/Timing.cpp rename to catkit2-core/src/Timing.cpp diff --git a/catkit_core/Timing.h b/catkit2-core/src/Timing.h similarity index 100% rename from catkit_core/Timing.h rename to catkit2-core/src/Timing.h diff --git a/catkit_core/Tracing.cpp b/catkit2-core/src/Tracing.cpp similarity index 100% rename from catkit_core/Tracing.cpp rename to catkit2-core/src/Tracing.cpp diff --git a/catkit_core/Tracing.h b/catkit2-core/src/Tracing.h similarity index 100% rename from catkit_core/Tracing.h rename to catkit2-core/src/Tracing.h diff --git a/catkit_core/Types.cpp b/catkit2-core/src/Types.cpp similarity index 100% rename from catkit_core/Types.cpp rename to catkit2-core/src/Types.cpp diff --git a/catkit_core/Types.h b/catkit2-core/src/Types.h similarity index 100% rename from catkit_core/Types.h rename to catkit2-core/src/Types.h diff --git a/catkit_core/Util.cpp b/catkit2-core/src/Util.cpp similarity index 100% rename from catkit_core/Util.cpp rename to catkit2-core/src/Util.cpp diff --git a/catkit_core/Util.h b/catkit2-core/src/Util.h similarity index 100% rename from catkit_core/Util.h rename to catkit2-core/src/Util.h diff --git a/catkit_core/Util.inl b/catkit2-core/src/Util.inl similarity index 100% rename from catkit_core/Util.inl rename to catkit2-core/src/Util.inl diff --git a/catkit_core/Uuid.cpp b/catkit2-core/src/Uuid.cpp similarity index 100% rename from catkit_core/Uuid.cpp rename to catkit2-core/src/Uuid.cpp diff --git a/catkit_core/Uuid.h b/catkit2-core/src/Uuid.h similarity index 100% rename from catkit_core/Uuid.h rename to catkit2-core/src/Uuid.h diff --git a/catkit2/CMakeLists.txt b/catkit2/CMakeLists.txt index 92665858d..db36972b5 100644 --- a/catkit2/CMakeLists.txt +++ b/catkit2/CMakeLists.txt @@ -11,21 +11,22 @@ find_package(pybind11 REQUIRED) pybind11_add_module(catkit_bindings ${SOURCES}) find_package(pybind11_json REQUIRED) -target_include_directories(catkit_bindings PUBLIC pybind11_json_INCLUDE_DIRS) +find_package(nlohmann_json REQUIRED) -target_include_directories(catkit_bindings PUBLIC ../catkit_core) +target_include_directories(catkit_bindings PUBLIC ${CMAKE_SOURCE_DIR}/catkit2-core/src) -target_link_libraries(catkit_bindings PUBLIC catkit_core) +target_link_libraries(catkit_bindings PUBLIC nlohmann_json::nlohmann_json catkit2_core) # Compile protobuf files. find_package(Protobuf REQUIRED) +set(IMPORT_DIRS ${CMAKE_SOURCE_DIR}/catkit2-core/proto) set(PROTO_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/../proto/core.proto - ${CMAKE_CURRENT_SOURCE_DIR}/../proto/logging.proto - ${CMAKE_CURRENT_SOURCE_DIR}/../proto/service.proto - ${CMAKE_CURRENT_SOURCE_DIR}/../proto/testbed.proto - ${CMAKE_CURRENT_SOURCE_DIR}/../proto/tracing.proto + ${IMPORT_DIRS}/core.proto + ${IMPORT_DIRS}/logging.proto + ${IMPORT_DIRS}/service.proto + ${IMPORT_DIRS}/testbed.proto + ${IMPORT_DIRS}/tracing.proto ) set(PYTHON_OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./proto/) @@ -33,7 +34,7 @@ set(PYTHON_OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./proto/) add_custom_target( catkit2_python_protobuf ALL COMMAND ${Protobuf_PROTOC_EXECUTABLE} - --proto_path=${CMAKE_CURRENT_SOURCE_DIR}/../proto/ + --proto_path=${CMAKE_SOURCE_DIR}/catkit2-core/proto/ --python_out=${PYTHON_OUT_DIR} ${PROTO_FILES} DEPENDS ${PROTO_FILES} diff --git a/catkit_core/CMakeLists.txt b/catkit_core/CMakeLists.txt deleted file mode 100644 index c70e6351d..000000000 --- a/catkit_core/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(catkit_core) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED on) - -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt.") -endif() - -add_compile_options($<$:/MP1>) - -file(GLOB_RECURSE SOURCES "*.cpp") -file(GLOB_RECURSE HEADERS "*.h") - -add_library(catkit_core STATIC "${SOURCES}") - -set_property(TARGET catkit_core PROPERTY POSITION_INDEPENDENT_CODE ON) -target_compile_definitions(catkit_core PUBLIC PROTOBUF_USE_DLLS) - -if (MSVC) - # disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' - target_compile_options(catkit_core PUBLIC /wd4251) -endif() - -# Link ZeroMQ -find_package(ZeroMQ REQUIRED) -target_include_directories(catkit_core PUBLIC ${ZeroMQ_INCLUDE_DIR}) -target_link_libraries(catkit_core PUBLIC libzmq) -if (WIN32) - target_link_libraries(catkit_core PUBLIC wsock32 ws2_32 Iphlpapi) -else() - target_link_libraries(catkit_core PUBLIC pthread) - if (NOT APPLE) - target_link_libraries(catkit_core PUBLIC rt) - endif (NOT APPLE) -endif (WIN32) - -# Add includes for cppzmq -find_package(cppzmq REQUIRED) -target_include_directories(catkit_core PUBLIC ${CPPZMQ_INCLUDE_DIR}) - -# Link Eigen -find_package(Eigen3 REQUIRED NO_MODULE) -target_link_libraries (catkit_core PUBLIC Eigen3::Eigen) - -# Link nlohmann JSON -find_package(nlohmann_json) -target_include_directories(catkit_core PRIVATE ${JSON_INCLUDE_DIR}) - -# Link protobuf -INCLUDE(FindProtobuf) -find_package(Protobuf REQUIRED) -target_include_directories(catkit_core PUBLIC ${PROTOBUF_INCLUDE_DIR}) -target_link_libraries(catkit_core PUBLIC ${PROTOBUF_LIBRARY}) - -set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen/") -file(MAKE_DIRECTORY "${PROTO_BINARY_DIR}") -protobuf_generate( - TARGET catkit_core - IMPORT_DIRS ../proto - PROTOC_OUT_DIR "${PROTO_BINARY_DIR}" - PROTOS - ../proto/core.proto - ../proto/logging.proto - ../proto/service.proto - ../proto/testbed.proto - ../proto/tracing.proto -) -target_include_directories(catkit_core PUBLIC "$") -# Generate and install CatkitCoreConfig.cmake -include(CMakePackageConfigHelpers) - -configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CatkitCoreConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" - INSTALL_DESTINATION lib/cmake/catkit_core -) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" - DESTINATION "${SKBUILD_PLATLIB_DIR}/cmake/catkit_core" -) - -install( - TARGETS catkit_core - EXPORT CatkitCoreTargets - LIBRARY DESTINATION lib -) - -# Generate and install CatkitCoreTargets.cmake -install( - EXPORT CatkitCoreTargets - FILE CatkitCoreTargets.cmake - DESTINATION "${SKBUILD_PLATLIB_DIR}/cmake/catkit_core" -) - -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - DESTINATION "${SKBUILD_HEADERS_DIR}" - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.inl" -) -install(DIRECTORY "${PROTO_BINARY_DIR}" - DESTINATION "${SKBUILD_HEADERS_DIR}/catkit_core" - FILES_MATCHING - PATTERN "*.h" -) diff --git a/docs/catkit_core.rst b/docs/catkit_core.rst index e93ae5cf1..a496ffeeb 100644 --- a/docs/catkit_core.rst +++ b/docs/catkit_core.rst @@ -1,5 +1,5 @@ -catkit_core +catkit2_core =========== .. doxygenindex:: - :project: catkit_core + :project: catkit2_core diff --git a/docs/conf.py b/docs/conf.py index 289ac57a6..99c5df80c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -34,8 +34,8 @@ 'breathe' ] -breathe_projects = {"catkit_core": "./doxygen/xml/"} -breathe_default_project = "catkit_core" +breathe_projects = {"catkit2_core": "./doxygen/xml/"} +breathe_default_project = "catkit2_core" # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 10dd65e8d..4c3a91443 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -119,7 +119,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = "..\..\catkit_core" +INPUT = "..\..\catkit2_core" INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c \ *.cc \ diff --git a/docs/index.rst b/docs/index.rst index 43fd682b1..f62f61492 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -58,4 +58,4 @@ Catkit2 :caption: API Documentation catkit2 - catkit_core + catkit2_core diff --git a/docs/installation.rst b/docs/installation.rst index ca61d0591..b11275453 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -73,7 +73,7 @@ At this point, all C++ and Python dependencies of catkit2 should have been downl pip install -e . -This will use the default CMake generator to compile catkit_core and its Python bindings. If the default generator doesn't support 64bit compilation, this step will return an error and you will need to specify a default generator to use by setting the ``CMAKE_GENERATOR`` environment variable to your preferred generator. You can list all generators installed on your machine with ``cmake --help``. You will have to restart your terminal after changing your environment variables as usual. +This will use the default CMake generator to compile catkit2_core and its Python bindings. If the default generator doesn't support 64bit compilation, this step will return an error and you will need to specify a default generator to use by setting the ``CMAKE_GENERATOR`` environment variable to your preferred generator. You can list all generators installed on your machine with ``cmake --help``. You will have to restart your terminal after changing your environment variables as usual. Some services require manual installation of their respective drivers to access the devices that they operate.