Skip to content

Commit cd84d57

Browse files
committed
add benchmarks
1 parent dce1827 commit cd84d57

File tree

9 files changed

+35
-29
lines changed

9 files changed

+35
-29
lines changed

.github/workflows/cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
- uses: actions/checkout@v3
2323

2424
- name: Install dependencies
25-
run: sudo apt install llvm-dev clang libbpf-dev libclang-dev python3-pip gcc-13 g++-13 libcxxopts-dev libboost-dev nvidia-cuda-dev libfmt-dev libspdlog-dev && git submodule update --init --recursive
25+
run: sudo apt install llvm-dev clang libbpf-dev libclang-dev python3-pip gcc-14 g++-14 libcxxopts-dev libboost-dev nvidia-cuda-dev libfmt-dev libspdlog-dev && git submodule update --init --recursive
2626

2727
- name: Configure CMake
2828
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
2929
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
30-
run: CC=gcc-13 CXX=g++-13 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_POLICY_DEFAULT_CMP0091=NEW && sudo cp -r ${{github.workspace}}/include/vmlinux.h /usr/include
30+
run: CC=gcc-14 CXX=g++-14 cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DSPDLOG_USE_STD_FORMAT=ON && sudo cp -r ${{github.workspace}}/include/vmlinux.h /usr/include
3131

3232
- name: Build
3333
# Build your program with the given configuration

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@
1919
[submodule "workloads/llama.cpp"]
2020
path = workloads/llama.cpp
2121
url = https://github.com/ggml-org/llama.cpp
22+
[submodule "workloads/vsag"]
23+
path = workloads/vsag
24+
url = https://github.com/antgroup/vsag
25+
[submodule "workloads/ann-benchmarks"]
26+
path = workloads/ann-benchmarks
27+
url = https://github.com/erikbern/ann-benchmarks

include/cxlcontroller.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MigrationPolicy : public Policy {
4242
virtual ~MigrationPolicy() = default;
4343

4444
// 基本的compute_once方法,决定是否需要执行迁移
45-
int compute_once(CXLController* controller) override {
45+
int compute_once(CXLController *controller) override {
4646
auto migration_list = get_migration_list(controller);
4747
return migration_list.empty() ? 0 : 1;
4848
}
@@ -54,20 +54,19 @@ class MigrationPolicy : public Policy {
5454
return migration_list;
5555
}
5656
// 判断特定地址是否应该迁移
57-
virtual bool should_migrate(uint64_t addr, uint64_t timestamp, int current_device) {
58-
return false;
59-
}
57+
virtual bool should_migrate(uint64_t addr, uint64_t timestamp, int current_device) { return false; }
6058

6159
// 为给定地址选择最佳的目标设备
62-
virtual int select_target_device(uint64_t addr, int current_device, CXLController* controller) {
63-
return -1; // -1表示不迁移
60+
virtual int select_target_device(uint64_t addr, int current_device, CXLController *controller) {
61+
return -1; // -1表示不迁移
6462
}
6563
};
6664

6765
// need to give a timeout and will be added latency later,
6866
class PagingPolicy : public Policy {
6967
public:
7068
PagingPolicy();
69+
int compute_once(CXLController *) override{};
7170
// paging related
7271
};
7372

@@ -86,7 +85,7 @@ class CachingPolicy : public Policy {
8685
}
8786

8887
// 获取需要失效的地址列表
89-
virtual std::vector<uint64_t> get_invalidation_list(CXLController* controller) {
88+
virtual std::vector<uint64_t> get_invalidation_list(CXLController *controller) {
9089
return {}; // 默认行为,可以被子类覆盖
9190
}
9291
};
@@ -99,7 +98,7 @@ struct LRUCacheEntry {
9998

10099
// LRU缓存
101100
class LRUCache {
102-
public:
101+
public:
103102
int capacity; // 缓存容量
104103
std::unordered_map<uint64_t, LRUCacheEntry> cache; // 缓存映射
105104
std::list<uint64_t> lru_list; // LRU列表,最近使用的在前面
@@ -155,9 +154,7 @@ class LRUCache {
155154
lru_map.clear();
156155
}
157156
// LRU缓存类中添加size()方法
158-
size_t size() const {
159-
return cache.size();
160-
}
157+
size_t size() const { return cache.size(); }
161158

162159
// LRU缓存类中添加remove()方法
163160
bool remove(uint64_t key) {
@@ -198,7 +195,7 @@ class CXLController : public CXLSwitch {
198195
double latency_lat{};
199196
double bandwidth_lat{};
200197
double dramlatency;
201-
std::unordered_map<int, CXLMemExpander*> device_map;
198+
std::unordered_map<int, CXLMemExpander *> device_map;
202199
// ring buffer
203200
std::queue<lbr> ring_buffer;
204201
// rob info
@@ -232,7 +229,7 @@ class CXLController : public CXLSwitch {
232229
void update_cache(uint64_t addr, uint64_t value, uint64_t timestamp) { lru_cache.put(addr, value, timestamp); }
233230
void perform_back_invalidation();
234231
void invalidate_in_expanders(uint64_t addr);
235-
void invalidate_in_switch(CXLSwitch* switch_, uint64_t addr);
232+
void invalidate_in_switch(CXLSwitch *switch_, uint64_t addr);
236233
};
237234

238235
template <> struct std::formatter<CXLController> {

src/cxlcontroller.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ int CXLController::insert(uint64_t timestamp, uint64_t tid, lbr lbrs[32], cntr c
337337
// 从当前controller开始DFS遍历
338338
dfs_calculate(this);
339339

340-
latency_lat += std::max(total_latency, 0.0);
340+
latency_lat += std::max(total_latency + std::get<0>(calculate_congestion()), 0.0);
341341
bandwidth_lat += std::max(calculate_bandwidth(all_access), 0.0);
342342

343343
return 0;
@@ -421,14 +421,15 @@ void CXLController::invalidate_in_expanders(uint64_t addr) {
421421
}
422422

423423
// 在交换机及其子节点中执行失效
424-
void CXLController::invalidate_in_switch(CXLSwitch* switch_, uint64_t addr) {
425-
if (!switch_) return;
424+
void CXLController::invalidate_in_switch(CXLSwitch *switch_, uint64_t addr) {
425+
if (!switch_)
426+
return;
426427

427428
// 处理此交换机连接的扩展器
428429
for (auto expander : switch_->expanders) {
429430
if (expander) {
430431
// 从expander的occupation中移除指定地址
431-
for (auto it = expander->occupation.begin(); it != expander->occupation.end(); ) {
432+
for (auto it = expander->occupation.begin(); it != expander->occupation.end();) {
432433
if (it->address == addr) {
433434
it = expander->occupation.erase(it);
434435
counter.inc_backinv();

src/cxlendpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ double CXLSwitch::get_endpoint_rob_latency(CXLMemExpander *endpoint,
251251
// 使用哈希表快速检查地址是否属于这个endpoint
252252
bool is_endpoint_access = endpoint->is_address_local(addr);
253253

254-
if (!is_endpoint_access)
254+
if (is_endpoint_access)
255255
continue;
256256

257257
double current_latency = base_latency;

src/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
9696

9797
auto *policy1 = new InterleavePolicy();
9898
auto *policy2 = new HeatAwareMigrationPolicy();
99-
auto *policy3 = new HugePagePolicy();
99+
auto *policy3 = new PagingPolicy();
100100
auto *policy4 = new FIFOPolicy();
101101

102102
uint64_t use_cpus = 0;

src/monitor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ int Monitors::terminate(const uint32_t tgid, const uint32_t tid, const int32_t t
207207
double emulated_time =
208208
(double)(mon[target].end_exec_ts.tv_sec - mon[target].start_exec_ts.tv_sec) +
209209
(double)(mon[target].end_exec_ts.tv_nsec - mon[target].start_exec_ts.tv_nsec) / 1000000000;
210-
SPDLOG_INFO("emulated time ={}", emulated_time);
211-
SPDLOG_INFO("total delay ={}", mon[target].total_delay);
212-
213-
SPDLOG_INFO("PEBS sample total {} {}", mon[target].before->pebs.total, mon[target].after->pebs.llcmiss);
214-
SPDLOG_INFO("LBR sample total {}", mon[target].before->lbr.total);
215-
SPDLOG_INFO("bpftime sample total {}", mon[target].before->bpftime.total);
216-
SPDLOG_INFO("{}", *controller);
210+
std::cout << std::format("emulated time ={}", emulated_time) << std::endl;
211+
std::cout << std::format("total delay ={}", mon[target].total_delay) << std::endl;
212+
std::cout << std::format("PEBS sample total {} {}", mon[target].before->pebs.total,
213+
mon[target].after->pebs.llcmiss)
214+
<< std::endl;
215+
std::cout << std::format("LBR sample total {}", mon[target].before->lbr.total) << std::endl;
216+
std::cout << std::format("bpftime sample total {}", mon[target].before->bpftime.total) << std::endl;
217+
std::cout << std::format("{}", *controller) << std::endl;
217218
break;
218219
}
219220

@@ -335,7 +336,6 @@ timespec operator*(const timespec &lhs, const timespec &rhs) {
335336
void Monitor::wait(std::vector<Monitor> *mons, int target) {
336337
auto &mon = (*mons)[target];
337338
uint64_t diff_nsec, target_nsec;
338-
SPDLOG_ERROR("[{}:{}][OFF] total:", mon.tgid, mon.tid);
339339
timespec start_ts{}, end_ts{};
340340
timespec sleep_target{};
341341
// timespec wanted_delay;

workloads/ann-benchmarks

Submodule ann-benchmarks added at 33ecd5f

workloads/vsag

Submodule vsag added at c86bac8

0 commit comments

Comments
 (0)