-
Notifications
You must be signed in to change notification settings - Fork 17
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
[resolve #18] Add C++ allocator (partial) #28
Conversation
- An error occurred while linking the `RdmaAllocator` library to the `warm_benchmark` program. ``` FAILED: benchmarks/warm_benchmarker : && /bin/clang++-15 -Wall -Wextra -g -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG CMakeFiles/warm_benchmarker.dir/benchmarks/warm_benchmark.cpp.o CMakeFiles/warm_benchmarker.dir/benchmarks/warm_benchmark_opts.cpp.o -o benchmarks/warm_benchmarker _deps/spdlog-build/libspdlogd.a librfaaslib.a libbenchmarks.a librfaaslib.a librdmalib.a _deps/spdlog-build/libspdlogd.a /usr/lib/x86_64-linux-gnu/librdmacm.so /usr/lib/x86_64-linux-gnu/libibverbs.so -ldl && : /bin/ld: /bin/ld: DWARF error: invalid or unhandled FORM value: 0x23 CMakeFiles/warm_benchmarker.dir/benchmarks/warm_benchmark.cpp.o: in function `main': warm_benchmark.cpp:(.text+0x493): undefined reference to `rfaas::RdmaAllocator<rdmalib::Buffer<char> >::allocate(unsigned long const&, int const&, unsigned long)' /bin/ld: warm_benchmark.cpp:(.text+0x4e0): undefined reference to `rfaas::RdmaAllocator<rdmalib::Buffer<char> >::allocate(unsigned long const&, int const&, unsigned long)' clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. ``` - Checking the argument and parameter types helped resolve the linking error. - Inline functions are recommended to be merged into header files to allow for their optimization by the compiler.
- Compiled successfully without any errors. - Add allocator implementation in rfaaslib. - Encapsulate the memory registration in rdmalib - Add test demonstrating standard memory allocation.
CMakeLists.txt
Outdated
@@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) | |||
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | |||
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -g -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG ") | |||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG ") | |||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra ") | |||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -std=c++17") |
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.
We should use CXX_STANDARD instead.
#include <rfaas/executor.hpp> | ||
|
||
namespace rfaas { | ||
template<typename T> |
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.
I think the allocator should be of type T
, and then always return rdmalib::Buffer
object. If you look at the C++ allocator concept, then I think we should use A::pointer
as rdmalib::Buffer
.
if (size > std::size_t(-1) / sizeof(T)) | ||
throw std::bad_alloc(); | ||
|
||
auto buffer = new rdmalib::Buffer<char>(size, header); |
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.
I don't think we need dynamic allocation for the buffer object itself :-) Once we properly define the pointer type.
… requirements example for the Allocator"](https://en.cppreference.com/w/cpp/named_req/Allocator). Signed-off-by: mou <William-Mou>
Hi @mcopik, |
@William-Mou Thanks! I will try to test this and merge in the coming days :) |
Story
This PR is open for issue #18, including the following features.
Achievements
rdma_allocator.hpp
, which provides the allocate and deallocate functions.rfaas::RdmaAllocator<rdmalib::Buffer<char> > rdmaAllocator(executor);
to instantiate the allocator object.rdmaAllocator.allocate(size_t size, int access)
intuitively allocates memory space for a buffer.Test
std::cout
in the allocator, you can test the program (eg:warm_benchmarker
) to run as expected.TODO