[Resolve #18] Add C++ allocator#30
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.
… requirements example for the Allocator"](https://en.cppreference.com/w/cpp/named_req/Allocator). Signed-off-by: mou <William-Mou>
63d9da6 to
980aa50
Compare
f7e8e08 to
5273fcf
Compare
- Add a `construct` method in `rdmaAllocator.hpp` to enable allocation with std::vector. - Test demonstrating standard memory allocation practices. - Test demonstrating allocation with our custom allocator. - Test demonstrating allocation with std::vector. - Improve coding style and adhering to clang-tidy standards. Signed-off-by: mou <William-Mou>
5273fcf to
50a2351
Compare
|
@William-Mou Thanks, much appreciated! I like the idea of passing extra information, such as the pointer, to the protection domain (PD) via additional structure - much cleaner and possible to extend with libfabric. I'm a bit confused with one part - when you create an allocator of type |
|
Hi @mcopik, Thank you for your kind words of affirmation! Sample: test demonstrating allocation with our custom allocator.In the second example (line 80 to line 90 in Since the allocator creates and returns a Sample: test demonstrating allocation with std::vector.Similarly, in the third example (line 93 to line 10 in The above explains how |
|
Hi @mcopik, rfaas::RdmaInfo info_v_in(executor, IBV_ACCESS_LOCAL_WRITE, rdmalib::functions::Submission::DATA_HEADER_SIZE);
rfaas::RdmaAllocator<rdmalib::Buffer<char>> allocator_v_in{info_v_in};
std::vector<rdmalib::Buffer<char>, rfaas::RdmaAllocator<rdmalib::Buffer<char>>> v_in(allocator_v_in);Does each element in the vector need to allocate memory for the header? The current implementation is that each element is a complete |
Story
This PR is open for issue #18, including the following features.
I have rewritten a better version to comply with the C++ standard.
Achievements
rdma_allocator.hpp, which provides the allocate and deallocate functions.rfaas::RdmaAllocator<rdmalib::Buffer<char>> allocator_in{info_in};to instantiate the allocator object.allocator_in.allocate(opts.input_size);intuitively allocates memory space for a buffer.Test
reportin the allocator, you can test the program (eg:warm_benchmarker) to run as expected.