Skip to content

Commit 1827635

Browse files
ChenyuZhu1mag1c-h
andauthored
[Feat] Call scatter gather interface in dramstore (#324)
* refactor: reusable transport abstraction & optimized NSFStore pipeline * add memory pool * rewrite dramstore (1st version) * fix * fix * fix * fix * fix * add comment for later development * fix * fix * fix * fix * fix * complete dramstore_connector.py * fix * fix CMakeLists.txt * fix * fix * fix * fix * rewrite dram test:dump (1/2) * format * fix * rewrite dram test:fetch (2/2) * modify dram test script * fix * fix * naive try: add device intf into memory pool * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * update memPool intf * fix * fix * fix * try reconstruct threadPool in dramstore (naive version) * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * remove redundant comments --------- Co-authored-by: Mag1c.H <hemajun815@163.com>
1 parent 7004ab7 commit 1827635

File tree

14 files changed

+860
-403
lines changed

14 files changed

+860
-403
lines changed

test/test_ucm_dram.py

Lines changed: 0 additions & 250 deletions
This file was deleted.

ucm/store/dramstore/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
file(GLOB_RECURSE UCMSTORE_DRAM_CC_SOURCE_FILES "./cc/*.cc")
22
add_library(dramstore STATIC ${UCMSTORE_DRAM_CC_SOURCE_FILES})
3-
target_include_directories(dramstore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/cc)
4-
target_link_libraries(dramstore PUBLIC storeinfra storetask)
3+
target_include_directories(dramstore PUBLIC
4+
${CMAKE_CURRENT_SOURCE_DIR}/cc/api
5+
${CMAKE_CURRENT_SOURCE_DIR}/cc/domain
6+
)
7+
target_link_libraries(dramstore PUBLIC storeinfra storedevice storetask)
58

69
file(GLOB_RECURSE UCMSTORE_DRAM_CPY_SOURCE_FILES "./cpy/*.cc")
710
pybind11_add_module(ucmdramstore ${UCMSTORE_DRAM_CPY_SOURCE_FILES})

ucm/store/dramstore/cc/api/dramstore.cc

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,70 @@
2424
#include "dramstore.h"
2525
#include "logger/logger.h"
2626
#include "status/status.h"
27+
#include "trans/dram_trans_manager.h"
28+
#include "memory/memory_pool.h"
2729

2830
namespace UC {
2931

3032
class DRAMStoreImpl : public DRAMStore {
3133
public:
32-
int32_t Setup(const size_t ioSize, const size_t capacity, const int32_t deviceId) { return -1; }
33-
int32_t Alloc(const std::string& block) override { return -1; }
34-
bool Lookup(const std::string& block) override { return false; }
35-
void Commit(const std::string& block, const bool success) override {}
34+
int32_t Setup(const Config& config) {
35+
auto status = this->memPool_.Setup(config.deviceId, config.capacity, config.blockSize);
36+
if (status.Failure()) {
37+
UC_ERROR("Failed({}) to setup MemoryPool.", status);
38+
return status.Underlying();
39+
}
40+
status = this->transMgr_.Setup(config.deviceId, config.streamNumber, &this->memPool_, config.timeoutMs);
41+
if (status.Failure()) {
42+
UC_ERROR("Failed({}) to setup TsfTaskManager.", status);
43+
return status.Underlying();
44+
}
45+
return Status::OK().Underlying();
46+
}
47+
int32_t Alloc(const std::string& block) override { return this->memPool_.NewBlock(block).Underlying(); }
48+
bool Lookup(const std::string& block) override { return this->memPool_.LookupBlock(block); }
49+
void Commit(const std::string& block, const bool success) override { this->memPool_.CommitBlock(block, success).Underlying(); }
3650
std::list<int32_t> Alloc(const std::list<std::string>& blocks) override
3751
{
38-
return std::list<int32_t>();
52+
std::list<int32_t> results;
53+
for (const auto &block : blocks) {
54+
results.emplace_back(this->Alloc(block));
55+
}
56+
return results;
3957
}
4058
std::list<bool> Lookup(const std::list<std::string>& blocks) override
4159
{
42-
return std::list<bool>();
60+
std::list<bool> founds;
61+
for (const auto &block : blocks) {
62+
founds.emplace_back(this->Lookup(block));
63+
}
64+
return founds;
65+
}
66+
void Commit(const std::list<std::string>& blocks, const bool success) override {
67+
for (const auto &block : blocks) {
68+
this->Commit(block, success);
69+
}
70+
}
71+
size_t Submit(Task&& task) override {
72+
auto taskId = Task::invalid;
73+
auto status = this->transMgr_.Submit(std::move(task), taskId);
74+
if (status.Failure()) { taskId = Task::invalid; }
75+
return taskId; }
76+
77+
int32_t Wait(const size_t task) override {
78+
return this->transMgr_.Wait(task).Underlying();
79+
}
80+
81+
int32_t Check(const size_t task, bool& finish) override {
82+
return this->transMgr_.Check(task, finish).Underlying();
4383
}
44-
void Commit(const std::list<std::string>& blocks, const bool success) override {}
45-
size_t Submit(Task&& task) override { return 0; }
46-
int32_t Wait(const size_t task) override { return -1; }
47-
int32_t Check(const size_t task, bool& finish) override { return -1; }
84+
85+
86+
private:
87+
88+
DramTransManager transMgr_;
89+
MemoryPool memPool_;
90+
4891
};
4992

5093
int32_t DRAMStore::Setup(const Config& config)
@@ -55,7 +98,7 @@ int32_t DRAMStore::Setup(const Config& config)
5598
return Status::OutOfMemory().Underlying();
5699
}
57100
this->impl_ = impl;
58-
return impl->Setup(config.ioSize, config.capacity, config.deviceId);
101+
return impl->Setup(config);
59102
}
60103

61104
} // namespace UC

ucm/store/dramstore/cc/api/dramstore.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ namespace UC {
3131
class DRAMStore : public CCStore {
3232
public:
3333
struct Config {
34-
size_t ioSize;
3534
size_t capacity;
35+
size_t blockSize;
3636
int32_t deviceId;
37-
Config(const size_t ioSize, const size_t capacity)
38-
: ioSize{ioSize}, capacity{capacity}, deviceId{-1}
37+
size_t streamNumber;
38+
size_t timeoutMs;
39+
Config(const size_t capacity, const size_t blockSize, const int32_t deviceId, const size_t streamNumber, const size_t timeoutMs)
40+
: capacity{capacity}, blockSize{blockSize}, deviceId{deviceId}, streamNumber{streamNumber}, timeoutMs{timeoutMs}
3941
{
4042
}
4143
};

0 commit comments

Comments
 (0)