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

Commit

Permalink
Cache table tested
Browse files Browse the repository at this point in the history
  • Loading branch information
qizzz committed Oct 1, 2023
1 parent da19970 commit 8ed16f3
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 1,146 deletions.
1 change: 0 additions & 1 deletion DPDPU/Benchmarks/Micro/CacheTable/Build.sh

This file was deleted.

1 change: 1 addition & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/BuildDebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -r build; meson setup build -Dbuildtype=debug; ninja -C build
1 change: 1 addition & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/BuildRelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -r build; meson setup build -Dbuildtype=release; ninja -C build
32 changes: 20 additions & 12 deletions DPDPU/Benchmarks/Micro/CacheTable/Source/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

fprintf(stdout, "Allocating test items...\n");
CacheItemT* items = malloc(totalItems * sizeof(CacheItemT));
Expand Down Expand Up @@ -34,37 +34,45 @@ int main() {
InitProfiler(&profiler, totalItems);

StartProfiler(&profiler);
while (!result && itemCount <= totalItems) {
result = AddToCacheTable(&items[itemCount]);
itemCount++;
for (size_t i = 0; i != totalItems; i++) {
result = AddToCacheTable(&items[i]);
if (!result) {
itemCount++;
// printf("itemCount = %ld\n", itemCount);
}
}
StopProfiler(&profiler);
profiler.Operations = itemCount;

fprintf(stdout, "%ld items added before failure\n");
fprintf(stdout, "%ld / %ld items added to the cache table\n", itemCount, totalItems);
ReportProfiler(&profiler);

fprintf(stdout, "Testing if added items are correct");
CacheItemT* itemQueried;
fprintf(stdout, "Testing if added items are correct\n");
for (size_t i = 0; i != itemCount; i++) {
itemQueried = LookUpCacheTable(&items[i].Key)->Offset;
itemQueried = LookUpCacheTable(&items[i].Key);
if (!itemQueried) {
fprintf(stderr, "Test failed: Key %ld doesn't exist\n", items[i].Key);
}
if (itemQueried->Offset != items[i].Offset) {
fprintf(stderr, "Test failed: key = %ld (%ld -> %ld)\n", items[i].Key, items[i].Offset, itemQueried->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);
while (itemCount != totalItems) {
itemQueried = LookUpCacheTable(&items[itemCount].Key);
itemCount++;
}
StopProfiler(&profiler);
profiler.Operations = itemCount;

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

DestroyCacheTable();

return 0;
}
}
1 change: 1 addition & 0 deletions DPDPU/Benchmarks/Micro/CacheTable/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ base_app_dependencies = []
base_app_dependencies += dependency('threads')

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

Expand Down
4 changes: 2 additions & 2 deletions DPDPU/Common/Include/DPU/CacheTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ DestroyCacheTable();

AssertStaticCacheTable(CACHE_TABLE_CAPACITY == CACHE_TABLE_BUCKET_SIZE * CACHE_TABLE_BUCKET_COUNT, 0);
AssertStaticCacheTable((CACHE_TABLE_BUCKET_SIZE & (CACHE_TABLE_BUCKET_SIZE - 1)) == 0, 1);
AssertStaticCacheTable(1 << CACHE_TABLE_BUCKET_COUNT_POWER == CACHE_TABLE_BUCKET_COUNT, 1);
AssertStaticCacheTable(1 << CACHE_TABLE_BUCKET_COUNT_POWER == CACHE_TABLE_BUCKET_COUNT, 2);

#ifdef __GNUC__
#pragma GCC diagnostic pop
#else
#pragma warning(pop)
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

#ifndef HASH_FUNCTION1
#define HASH_FUNCTION1(keyptr,keylen,hashv) HASH_SAX(keyptr, keylen, hashv)
#define HASH_FUNCTION1(keyptr,keylen,hashv) HASH_SFH(keyptr, keylen, hashv)
#endif

#ifndef HASH_FUNCTION2
Expand Down Expand Up @@ -165,4 +165,5 @@ do {
hashv += hashv >> 17; \
hashv ^= hashv << 25; \
hashv += hashv >> 6; \
} while (0)
} while (0)

2 changes: 1 addition & 1 deletion DPDPU/Common/Include/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ AssertStaticProtocol(DDS_RESPONSE_RING_BYTES % DDS_CACHE_LINE_SIZE == 0, 5);
#pragma warning(pop)
#endif

#define DDS_BACKEND_ADDR "172.16.1.6"
#define DDS_BACKEND_ADDR "172.16.1.8"
#define DDS_BACKEND_PORT 4242
Loading

0 comments on commit 8ed16f3

Please sign in to comment.