From beaf2aea39582568979bd945f212f7fd863ed705 Mon Sep 17 00:00:00 2001 From: Olli Saarikivi Date: Wed, 10 May 2023 20:46:49 +0000 Subject: [PATCH] Move public headers under include/ --- CMakeLists.txt | 4 ++-- {src/include => include/mscclpp}/channel.hpp | 11 +++++------ src/include/mscclpp.hpp => include/mscclpp/core.hpp | 8 ++++---- {src/include => include/mscclpp}/epoch.hpp | 2 +- {src/include => include/mscclpp}/errors.hpp | 4 +++- .../mscclppfifo.hpp => include/mscclpp/fifo.hpp | 6 +++--- {src/include => include/mscclpp}/proxy.hpp | 2 +- src/bootstrap/bootstrap.cc | 2 +- src/channel.cc | 2 +- src/communicator.cc | 2 +- src/epoch.cc | 2 +- src/errors.cc | 2 +- src/fifo.cc | 2 +- src/ib.cc | 2 +- src/include/basic_proxy_handler.hpp | 2 +- src/include/checks.hpp | 2 +- src/include/communicator.hpp | 4 ++-- src/include/connection.hpp | 2 +- src/include/registered_memory.hpp | 4 ++-- src/proxy_cpp.cc | 4 ++-- test/CMakeLists.txt | 1 + test/allgather_test_cpp.cu | 5 ++--- test/bootstrap_test_cpp.cc | 2 +- test/communicator_test_cpp.cu | 4 ++-- test/ib_test.cc | 2 +- test/unit/core_tests.cc | 2 +- 26 files changed, 43 insertions(+), 42 deletions(-) rename {src/include => include/mscclpp}/channel.hpp (98%) rename src/include/mscclpp.hpp => include/mscclpp/core.hpp (98%) rename {src/include => include/mscclpp}/epoch.hpp (98%) rename {src/include => include/mscclpp}/errors.hpp (96%) rename src/include/mscclppfifo.hpp => include/mscclpp/fifo.hpp (97%) rename {src/include => include/mscclpp}/proxy.hpp (95%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 270a1ed8..5470cd32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,11 +26,11 @@ FetchContent_Declare(googletest URL https://github.com/google/googletest/archive FetchContent_MakeAvailable(googletest) include(GoogleTest) -set(CLANG_FORMAT_SOURCE_DIRS src tests) +set(CLANG_FORMAT_SOURCE_DIRS include src tests) include(${PROJECT_SOURCE_DIR}/cmake/AddClangFormatTargets.cmake) add_library(mscclpp SHARED) -target_include_directories(mscclpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/include) +target_include_directories(mscclpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/include) set_target_properties(mscclpp PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(mscclpp PRIVATE MSCCLPP::ibverbs MSCCLPP::numa CUDA::cudart CUDA::cuda_driver) if(ENABLE_TRACE) diff --git a/src/include/channel.hpp b/include/mscclpp/channel.hpp similarity index 98% rename from src/include/channel.hpp rename to include/mscclpp/channel.hpp index 05582726..9aa50902 100644 --- a/src/include/channel.hpp +++ b/include/mscclpp/channel.hpp @@ -1,11 +1,10 @@ #ifndef MSCCLPP_CHANNEL_HPP_ #define MSCCLPP_CHANNEL_HPP_ -#include "epoch.hpp" -#include "mscclpp.hpp" -#include "mscclppfifo.hpp" -#include "proxy.hpp" -#include "utils.hpp" +#include +#include +#include +#include namespace mscclpp { namespace channel { @@ -148,7 +147,7 @@ struct DeviceChannel __forceinline__ __device__ void flush() { - uint64_t curFifoHead = fifo_.push(ChannelTrigger(mscclppSync, 0, 0, 0, 0, 1, channelId_).value); + uint64_t curFifoHead = fifo_.push(ChannelTrigger(TriggerSync, 0, 0, 0, 0, 1, channelId_).value); // we need to wait for two conditions to be met to ensure the CPU is done flushing. (1) wait for the tail // to go pass by curFifoHead (this is safety net) and (2) wait for the work element value to change to 0. while (*(volatile uint64_t*)&fifo_.triggers[curFifoHead % MSCCLPP_PROXY_FIFO_SIZE] != 0 && diff --git a/src/include/mscclpp.hpp b/include/mscclpp/core.hpp similarity index 98% rename from src/include/mscclpp.hpp rename to include/mscclpp/core.hpp index 7ca8503b..aeb692e6 100644 --- a/src/include/mscclpp.hpp +++ b/include/mscclpp/core.hpp @@ -1,12 +1,12 @@ -#ifndef MSCCLPP_HPP_ -#define MSCCLPP_HPP_ +#ifndef MSCCLPP_CORE_HPP_ +#define MSCCLPP_CORE_HPP_ #define MSCCLPP_MAJOR 0 #define MSCCLPP_MINOR 1 #define MSCCLPP_PATCH 0 #define MSCCLPP_VERSION (MSCCLPP_MAJOR * 10000 + MSCCLPP_MINOR * 100 + MSCCLPP_PATCH) -#include "errors.hpp" +#include #include #include #include @@ -383,4 +383,4 @@ template <> struct hash }; } // namespace std -#endif // MSCCLPP_H_ +#endif // MSCCLPP_CORE_HPP_ diff --git a/src/include/epoch.hpp b/include/mscclpp/epoch.hpp similarity index 98% rename from src/include/epoch.hpp rename to include/mscclpp/epoch.hpp index daba1ec1..cbd3478a 100644 --- a/src/include/epoch.hpp +++ b/include/mscclpp/epoch.hpp @@ -1,7 +1,7 @@ #ifndef MSCCLPP_EPOCH_HPP_ #define MSCCLPP_EPOCH_HPP_ -#include "mscclpp.hpp" +#include namespace mscclpp { diff --git a/src/include/errors.hpp b/include/mscclpp/errors.hpp similarity index 96% rename from src/include/errors.hpp rename to include/mscclpp/errors.hpp index 2425970f..eb18f98f 100644 --- a/src/include/errors.hpp +++ b/include/mscclpp/errors.hpp @@ -50,5 +50,7 @@ public: IbError(std::string message, int errorCode); virtual ~IbError() = default; }; + }; // namespace mscclpp -#endif // MSCCLPP_ERRORS_HPP + +#endif // MSCCLPP_ERRORS_HPP_ diff --git a/src/include/mscclppfifo.hpp b/include/mscclpp/fifo.hpp similarity index 97% rename from src/include/mscclppfifo.hpp rename to include/mscclpp/fifo.hpp index c13e4fb8..e3172dca 100644 --- a/src/include/mscclppfifo.hpp +++ b/include/mscclpp/fifo.hpp @@ -1,5 +1,5 @@ -#ifndef MSCCLPPFIFO_HPP_ -#define MSCCLPPFIFO_HPP_ +#ifndef MSCCLPP_FIFO_HPP_ +#define MSCCLPP_FIFO_HPP_ #include #include @@ -74,4 +74,4 @@ private: } // namespace mscclpp -#endif // MSCCLPPFIFO_H_ +#endif // MSCCLPP_FIFO_HPP_ diff --git a/src/include/proxy.hpp b/include/mscclpp/proxy.hpp similarity index 95% rename from src/include/proxy.hpp rename to include/mscclpp/proxy.hpp index 51ae4752..37decafb 100644 --- a/src/include/proxy.hpp +++ b/include/mscclpp/proxy.hpp @@ -1,7 +1,7 @@ #ifndef MSCCLPP_PROXY_HPP_ #define MSCCLPP_PROXY_HPP_ -#include "mscclppfifo.hpp" +#include #include #include diff --git a/src/bootstrap/bootstrap.cc b/src/bootstrap/bootstrap.cc index 7c884726..b6311948 100644 --- a/src/bootstrap/bootstrap.cc +++ b/src/bootstrap/bootstrap.cc @@ -1,7 +1,7 @@ #include "bootstrap.h" #include "api.h" #include "checks.hpp" -#include "mscclpp.hpp" +#include #include "utils.h" #include diff --git a/src/channel.cc b/src/channel.cc index 33b679c2..bf5e6da6 100644 --- a/src/channel.cc +++ b/src/channel.cc @@ -1,4 +1,4 @@ -#include "channel.hpp" +#include #include "api.h" #include "checks.hpp" #include "debug.h" diff --git a/src/communicator.cc b/src/communicator.cc index c4abf818..1d670fa6 100644 --- a/src/communicator.cc +++ b/src/communicator.cc @@ -6,7 +6,7 @@ #include "communicator.hpp" #include "connection.hpp" #include "debug.h" -#include "mscclpp.hpp" +#include #include "registered_memory.hpp" #include "utils.h" diff --git a/src/epoch.cc b/src/epoch.cc index d358ca40..afdbf8c2 100644 --- a/src/epoch.cc +++ b/src/epoch.cc @@ -1,4 +1,4 @@ -#include "epoch.hpp" +#include #include "alloc.h" #include "api.h" #include "checks.hpp" diff --git a/src/errors.cc b/src/errors.cc index 40c9d9c0..c3a0a7b7 100644 --- a/src/errors.cc +++ b/src/errors.cc @@ -1,4 +1,4 @@ -#include "errors.hpp" +#include #include "api.h" namespace mscclpp { diff --git a/src/fifo.cc b/src/fifo.cc index 49902816..2c4ebf7a 100644 --- a/src/fifo.cc +++ b/src/fifo.cc @@ -1,7 +1,7 @@ #include "alloc.h" #include "api.h" #include "checks.hpp" -#include "mscclppfifo.hpp" +#include #include #include #include diff --git a/src/ib.cc b/src/ib.cc index 9d1c3203..e6c91eb3 100644 --- a/src/ib.cc +++ b/src/ib.cc @@ -11,7 +11,7 @@ #include "comm.h" #include "debug.h" #include "ib.hpp" -#include "mscclpp.hpp" +#include #include #include diff --git a/src/include/basic_proxy_handler.hpp b/src/include/basic_proxy_handler.hpp index 58e41930..c1dc1038 100644 --- a/src/include/basic_proxy_handler.hpp +++ b/src/include/basic_proxy_handler.hpp @@ -2,7 +2,7 @@ #define MSCCLPP_BASIC_PROXY_SERVICE_HPP_ #include "communicator.hpp" -#include "mscclpp.hpp" +#include namespace mscclpp { diff --git a/src/include/checks.hpp b/src/include/checks.hpp index e64c07d1..8332847b 100644 --- a/src/include/checks.hpp +++ b/src/include/checks.hpp @@ -8,7 +8,7 @@ #define MSCCLPP_CHECKS_HPP_ #include "debug.h" -#include "errors.hpp" +#include #include #include diff --git a/src/include/communicator.hpp b/src/include/communicator.hpp index 5b0c7485..cc464618 100644 --- a/src/include/communicator.hpp +++ b/src/include/communicator.hpp @@ -3,8 +3,8 @@ #include "ib.hpp" #include "mscclpp.h" -#include "mscclpp.hpp" -#include "proxy.hpp" +#include +#include #include #include diff --git a/src/include/connection.hpp b/src/include/connection.hpp index 5f764b05..54f9b316 100644 --- a/src/include/connection.hpp +++ b/src/include/connection.hpp @@ -6,7 +6,7 @@ #include "communicator.hpp" #include "ib.hpp" -#include "mscclpp.hpp" +#include #include namespace mscclpp { diff --git a/src/include/registered_memory.hpp b/src/include/registered_memory.hpp index 23b71f50..7c26f4b4 100644 --- a/src/include/registered_memory.hpp +++ b/src/include/registered_memory.hpp @@ -2,10 +2,10 @@ #define MSCCLPP_REGISTERED_MEMORY_HPP_ #include "communicator.hpp" -#include "errors.hpp" +#include #include "ib.hpp" #include "mscclpp.h" -#include "mscclpp.hpp" +#include #include namespace mscclpp { diff --git a/src/proxy_cpp.cc b/src/proxy_cpp.cc index cd005e02..060bbfb0 100644 --- a/src/proxy_cpp.cc +++ b/src/proxy_cpp.cc @@ -1,6 +1,6 @@ #include "api.h" -#include "mscclpp.hpp" -#include "proxy.hpp" +#include +#include #include "utils.h" #include "utils.hpp" #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3eec4226..d7e59bc6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ function(add_test_executable name sources) add_executable(${name} ${sources}) target_link_libraries(${name} mscclpp CUDA::cudart CUDA::cuda_driver) + target_include_directories(${name} PRIVATE ${PROJECT_SOURCE_DIR}/src/include) if(USE_MPI_FOR_TESTS) target_link_libraries(${name} MPI::MPI_CXX) target_compile_definitions(${name} PRIVATE MSCCLPP_USE_MPI_FOR_TESTS) diff --git a/test/allgather_test_cpp.cu b/test/allgather_test_cpp.cu index ddfd51d8..60652a0f 100644 --- a/test/allgather_test_cpp.cu +++ b/test/allgather_test_cpp.cu @@ -1,7 +1,6 @@ -#include "mscclpp.h" -#include "mscclpp.hpp" +#include -#include "channel.hpp" +#include #ifdef MSCCLPP_USE_MPI_FOR_TESTS #include "mpi.h" diff --git a/test/bootstrap_test_cpp.cc b/test/bootstrap_test_cpp.cc index e4fe65bb..b32d83fa 100644 --- a/test/bootstrap_test_cpp.cc +++ b/test/bootstrap_test_cpp.cc @@ -1,4 +1,4 @@ -#include "mscclpp.hpp" +#include #include #include diff --git a/test/communicator_test_cpp.cu b/test/communicator_test_cpp.cu index 74f9aadb..cda4d712 100644 --- a/test/communicator_test_cpp.cu +++ b/test/communicator_test_cpp.cu @@ -1,5 +1,5 @@ -#include "epoch.hpp" -#include "mscclpp.hpp" +#include +#include #include #include diff --git a/test/ib_test.cc b/test/ib_test.cc index 3d99acb2..753d6fa4 100644 --- a/test/ib_test.cc +++ b/test/ib_test.cc @@ -2,7 +2,7 @@ #include "checks.h" #include "ib.hpp" #include "infiniband/verbs.h" -#include "mscclpp.hpp" +#include #include #include diff --git a/test/unit/core_tests.cc b/test/unit/core_tests.cc index df4c165e..e3bf7265 100644 --- a/test/unit/core_tests.cc +++ b/test/unit/core_tests.cc @@ -1,6 +1,6 @@ #include #include -#include "mscclpp.hpp" +#include class LocalCommunicatorTest : public ::testing::Test { protected: