-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added C++ allocator to manage rdmalib::Buffer
- 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.
- Loading branch information
mou
authored and
mou
committed
Apr 2, 2023
1 parent
aa2f46b
commit 662d933
Showing
4 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Created by mou on 4/2/23. | ||
// | ||
|
||
#ifndef __RFAAS_RDMA_ALLOCATOR_HPP__ | ||
#define __RFAAS_RDMA_ALLOCATOR_HPP__ | ||
|
||
#include <cstddef> | ||
#include <rdmalib/buffer.hpp> | ||
#include <rfaas/executor.hpp> | ||
|
||
namespace rfaas { | ||
template<typename T> | ||
class RdmaAllocator { | ||
private: | ||
const executor &_executor; | ||
|
||
public: | ||
inline explicit RdmaAllocator(const executor &executor) noexcept: _executor(executor) {} | ||
|
||
inline T *allocate(const std::size_t &, const int &, int = 0); | ||
|
||
inline void deallocate(T *p, std::size_t n) noexcept; | ||
}; | ||
} | ||
|
||
#endif //__RFAAS_RDMA_ALLOCATOR_HPP__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Created by mou on 4/2/23. | ||
// | ||
#include <memory> | ||
|
||
#include <rfaas/rdma_allocator.hpp> | ||
|
||
namespace rfaas { | ||
|
||
template<typename T> | ||
inline T *RdmaAllocator<T>::allocate(const std::size_t &size, const int &access, int header) { | ||
if (size > std::size_t(-1) / sizeof(T)) | ||
throw std::bad_alloc(); | ||
|
||
rdmalib::Buffer<char> buffer(size, header); | ||
buffer.register_memory(_executor._state.pd(), access); | ||
|
||
return buffer; | ||
} | ||
|
||
template<typename T> | ||
inline void RdmaAllocator<T>::deallocate(T *p, std::size_t n) noexcept { | ||
operator delete(p); | ||
} | ||
} |