Skip to content
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

Windows support #4

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9e108f4
First stab - doesn't seem work properly with the old WinOFED code
lucasz93 Jan 4, 2022
6680216
Moving to CMake
lucasz93 Jan 5, 2022
d0c7308
Small fix
lucasz93 Jan 5, 2022
6915176
Fixes
lucasz93 Jan 5, 2022
7170516
Converted hdrdmacp into a static library and application
lucasz93 Jan 5, 2022
2950f4b
Missed the header...
lucasz93 Jan 5, 2022
e590ba4
Fixes for Linux
lucasz93 Jan 5, 2022
5786089
Propagating errors
lucasz93 Jan 6, 2022
6fec050
Oopsie
lucasz93 Jan 6, 2022
5bed6a1
Default config
lucasz93 Jan 6, 2022
612a0ea
Moving to exceptions because having exit() kill your server isn't fun…
lucasz93 Jan 7, 2022
5f236ef
Fixed async ack thread causing problems in Windows - needed to patch …
lucasz93 Jan 7, 2022
8af8dc3
Fixed ZLIB include on Windows.
lucasz93 Jul 11, 2022
69f38e7
Downgrade to CMake 3.16 to match the default Ubuntu 20.04 LTS version
lucasz93 Jul 13, 2022
dc0ddc7
Fixed compiler warnings
lucasz93 Sep 27, 2022
9ffecae
Ubuntu 20.04 was refusing to deregister memory windows larger than 2G…
lucasz93 Nov 17, 2022
8f5e0ab
More truthful logging
lucasz93 Nov 17, 2022
faf37d4
Config buffer size and buffer section counts are now respected when g…
lucasz93 Nov 17, 2022
4699e91
Fix warning
lucasz93 Nov 17, 2022
f0a5734
Clients will now wait for buffers, instead of failing
lucasz93 Nov 17, 2022
ddb1a6c
Fixed pause on disconnect
lucasz93 Nov 18, 2022
b3ab2ef
Fixing Linux sockets being claimed, even after a process restart
lucasz93 Nov 18, 2022
b102605
Removed remote_addr from Config
lucasz93 Nov 21, 2022
3db5628
Windows fixes
lucasz93 Nov 21, 2022
064400d
Added Good() method to determine if the interface is good for use.
lucasz93 Nov 21, 2022
10fb3e6
Fix dangling pointer
lucasz93 Nov 21, 2022
b7ad058
Fixed resource leak
lucasz93 Nov 22, 2022
47f2a3e
shared_ptr -> unique_ptr
lucasz93 Nov 22, 2022
e4312fd
Fixed resource leak introduced by last
lucasz93 Nov 22, 2022
d5c4e75
Added support for custom file path decoding
lucasz93 Nov 28, 2022
10207d6
Fixed crash on quit
lucasz93 Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "modules/libwinibverbs"]
path = modules/libwinibverbs
url = https://github.com/lucasz93/libwinibverbs
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.16)
project (hdrdmacp)
set(CMAKE_CXX_STANDARD 20)

#
# Add submodules
#
if(WIN32)
add_subdirectory(modules/libwinibverbs)
set(winibverbs_include "modules/libwinibverbs/include")
set(iverbs_lib winibverbs)
else()
set(iverbs_lib ibverbs)
endif()

find_package(ZLIB REQUIRED)

#===============================================================================
# LIBRARY
#===============================================================================
add_library(libhdrdmacp SHARED
IhdRDMA.h
hdRDMA.cc
hdRDMA.h
hdRDMAThread.cc
hdRDMAThread.h
)
if(WIN32)
add_dependencies(libhdrdmacp winibverbs)
endif()
target_compile_definitions(libhdrdmacp PRIVATE _CRT_SECURE_NO_WARNINGS BUILDING_HDRDMA)
target_link_libraries(libhdrdmacp ${iverbs_lib} ${ZLIB_LIBRARY})
target_include_directories(libhdrdmacp PRIVATE ${ZLIB_INCLUDE_DIRS} ${winibverbs_include})

set_target_properties(libhdrdmacp PROPERTIES OUTPUT_NAME hdrdmacp)

install(TARGETS libhdrdmacp DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
IhdRDMA.h
DESTINATION include)

#===============================================================================
# APPLICATION
#===============================================================================
add_executable(hdrdmacp
hdrdmacp.cc
)
add_dependencies(hdrdmacp libhdrdmacp)
target_link_libraries(hdrdmacp libhdrdmacp)

if (WIN32)
add_custom_command(TARGET hdrdmacp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:hdrdmacp> $<TARGET_FILE_DIR:hdrdmacp>
COMMAND_EXPAND_LISTS
)
endif()
74 changes: 74 additions & 0 deletions IhdRDMA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#pragma once

#include <memory>
#include <string>

#ifdef _MSC_VER
# define HDRMDA_DLL_EXPORT __declspec(dllexport)
# define HDRMDA_DLL_IMPORT __declspec(dllimport)
#else
# define HDRMDA_DLL_EXPORT __attribute__((__visibility__("default")))
# define HDRMDA_DLL_IMPORT
#endif

#ifdef BUILDING_HDRDMA
# define HDRDMA_DLL HDRMDA_DLL_EXPORT
#else
# define HDRDMA_DLL HDRMDA_DLL_IMPORT
#endif

namespace hdrdma
{
class IhdRDMA;
class IPathDecoder;

struct config
{
config(size_t buffer_section_sz, int buffer_section_count, const std::shared_ptr<IPathDecoder>& path_decoder = nullptr) : BufferSectionSize(buffer_section_sz), BufferSectionCount(buffer_section_count), PathDecoder(path_decoder) {}

const size_t BufferSectionSize;
const size_t BufferSectionCount;

std::shared_ptr<IPathDecoder> PathDecoder;
};
}

extern "C"
{
// Raw pointers. You probably don't want to use these.
HDRDMA_DLL hdrdma::IhdRDMA* hdrdma_allocate(const hdrdma::config& config);
HDRDMA_DLL void hdrdma_free(hdrdma::IhdRDMA*);
}

namespace hdrdma
{
class IPathDecoder {
public:
virtual ~IPathDecoder() {}

virtual std::string Decode(const std::string_view& path) const = 0;
};

class IhdRDMA {
public:
virtual ~IhdRDMA() {}

virtual bool Good() const = 0;
virtual void Listen(int port) = 0;
virtual void StopListening(void) = 0;
virtual void Connect(std::string host, int port) = 0;
virtual void SendFile(std::string srcfilename, std::string dstfilename, bool delete_after_send = false, bool calculate_checksum = false, bool makeparentdirs = false) = 0;
virtual void Poll(void) = 0;
virtual void Join(void) = 0;

virtual uint64_t TotalBytesReceived() const = 0;
};

using Ptr = std::unique_ptr<IhdRDMA, decltype(&hdrdma_free)>;

// Wrappers. You probably want to use these.
static auto Create(const hdrdma::config& config)
{
return Ptr(hdrdma_allocate(config), hdrdma_free);
}
}
Loading