Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Cache table microbenchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
qizzz committed Sep 30, 2023
1 parent 32abe67 commit da19970
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/Build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -r build; meson build; ninja -C build
1 change: 1 addition & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/Run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./build/CacheTableBenchmark
70 changes: 70 additions & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/Source/Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <stdlib.h>
#include <stdio.h>

#include "CacheTable.h"
#include "Profiler.h"

int main() {
int result = 0;
const size_t totalItems = 2000000;

fprintf(stdout, "Allocating test items...\n");
CacheItemT* items = malloc(totalItems * sizeof(CacheItemT));
if (!items) {
fprintf(stderr, "Failed to allocate items\n");
}

for (size_t i = 0; i != totalItems; i++) {
items[i].Key = i;
items[i].Version = 42;
items[i].FileId = 0;
items[i].Offset = i;
items[i].Size = 1;
}

fprintf(stdout, "Init the cache table...\n");
result = InitCacheTable();
if (result) {
fprintf(stderr, "InitCacheTable failed\n");
}

fprintf(stdout, "Adding to the cache table...\n");
size_t itemCount = 0;
struct Profiler profiler;
InitProfiler(&profiler, totalItems);

StartProfiler(&profiler);
while (!result && itemCount <= totalItems) {
result = AddToCacheTable(&items[itemCount]);
itemCount++;
}
StopProfiler(&profiler);
profiler.Operations = itemCount;

fprintf(stdout, "%ld items added before failure\n");
ReportProfiler(&profiler);

fprintf(stdout, "Testing if added items are correct");
CacheItemT* itemQueried;
for (size_t i = 0; i != itemCount; i++) {
itemQueried = LookUpCacheTable(&items[i].Key)->Offset;
if (itemQueried->Offset != items[i].Offset) {
fprintf(stderr, "Test failed: key = %ld (%ld -> %ld)\n", items[i].Key, items[i].Offset, itemQueried->Offset);
}
}

fprintf(stdout, "Looking up from the cache table...\n");
itemCount = 0;
StartProfiler(&profiler);
while (itemCount <= totalItems) {
result = LookUpCacheTable(&items[itemCount].Key);
itemCount++;
}
StopProfiler(&profiler);
profiler.Operations = itemCount;

fprintf(stdout, "%ld items looked up\n");
ReportProfiler(&profiler);

return 0;
}
58 changes: 58 additions & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
project('DDSFileBackEnd', 'C', 'CPP',
version: '0.1',
license: 'Proprietary',
default_options: ['buildtype=release'],
meson_version: '>= 0.61.2'
)

languages = ['c', 'cpp']

install_apps = false

base_cpp_args = [
'-std=c++11',
]

base_c_args = [
'-flax-vector-conversions',
]

# Resolve irrelevant compiler warnings
add_project_arguments('-Wno-format-zero-length', language: languages)
add_project_arguments('-Wno-address-of-packed-member', language: languages)
add_project_arguments('-Wno-deprecated-declarations', language: languages)

base_app_dependencies = []
base_app_dependencies += dependency('threads')

base_app_inc_dirs = [
include_directories('../../../Common/Include/DPU/'),
]

app_link_args = []
app_link_args += ['-libverbs']
app_link_args += ['-lrdmacm']

APP_NAME = 'CacheTableBenchmark'

app_dependencies = base_app_dependencies
app_inc_dirs = base_app_inc_dirs
app_srcs = []

src = 'Source/'

app_srcs += [
src + 'Main.c',
'../../../Common/Source/DPU/CacheTable.c',
'../../../Common/Source/DPU/Profiler.c',
]

executable(APP_NAME,
app_srcs,
c_args : base_c_args,
cpp_args : base_cpp_args,
dependencies : [app_dependencies],
include_directories : app_inc_dirs,
link_args : app_link_args,
install: install_apps
)

0 comments on commit da19970

Please sign in to comment.