Skip to content

Commit

Permalink
resolve spcl#18 Add C++ allocator (partial)
Browse files Browse the repository at this point in the history
- Compiled successfully without any errors.
- Add allocator implementation in rfaaslib.
- Encapsulate the memory registration in rdmalib
- Add test demonstrating standard memory allocation.
  • Loading branch information
mou authored and mou committed Apr 2, 2023
1 parent 662d933 commit 4105069
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
15 changes: 13 additions & 2 deletions rfaas/include/rfaas/rdma_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@ namespace rfaas {
public:
inline explicit RdmaAllocator(const executor &executor) noexcept: _executor(executor) {}

inline T *allocate(const std::size_t &, const int &, int = 0);
// inline T *allocate(const std::size_t &, const int &, int = 0);
inline T *allocate(const std::size_t &size, const int &access, int header=0) {
if (size > std::size_t(-1) / sizeof(T))
throw std::bad_alloc();

inline void deallocate(T *p, std::size_t n) noexcept;
auto buffer = new rdmalib::Buffer<char>(size, header);
buffer->register_memory(_executor._state.pd(), access);
std::cout << "allocate memory by RdmaAllocator" << std::endl;
return buffer;
}

inline void deallocate(T *p, std::size_t n) noexcept {
operator delete(p);
}
};
}

Expand Down
25 changes: 0 additions & 25 deletions rfaas/lib/rdma_allocator.cpp

This file was deleted.

0 comments on commit 4105069

Please sign in to comment.