This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
207 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -r build; meson setup build -Dbuildtype=debug; ninja -C build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -r build; meson setup build -Dbuildtype=release; ninja -C build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./build/CacheTableBenchmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <unordered_map> | ||
|
||
#include "CacheTable.h" | ||
#include "ProfilerCC.h" | ||
|
||
using std::unordered_map; | ||
|
||
int main() { | ||
const size_t totalItems = 20000000; | ||
|
||
fprintf(stdout, "Allocating test items...\n"); | ||
CacheItemT* items = (CacheItemT*)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 map...\n"); | ||
unordered_map<KeyT, CacheItemT> table; | ||
table.reserve(CACHE_TABLE_CAPACITY); | ||
|
||
fprintf(stdout, "Adding to the map...\n"); | ||
size_t itemCount = 0; | ||
Profiler profiler(totalItems); | ||
|
||
profiler.Start(); | ||
for (size_t i = 0; i != totalItems; i++) { | ||
table[items[i].Key] = items[i]; | ||
itemCount++; | ||
} | ||
profiler.Stop(); | ||
|
||
fprintf(stdout, "%ld / %ld items added to the cache table\n", itemCount, totalItems); | ||
profiler.Report(); | ||
|
||
fprintf(stdout, "Looking up from the cache table...\n"); | ||
itemCount = 0; | ||
CacheItemT* itemQueried; | ||
profiler.Start(); | ||
while (itemCount != totalItems) { | ||
itemQueried = &table.find(items[itemCount].Key)->second; | ||
if (itemQueried->Offset != items[itemCount].Offset) { | ||
fprintf(stderr, "Incorrect result\n"); | ||
} | ||
itemCount++; | ||
} | ||
profiler.Stop(); | ||
|
||
fprintf(stdout, "%ld items looked up\n", itemCount); | ||
profiler.Report(); | ||
|
||
free(items); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/'), | ||
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.cpp', | ||
'../../../Common/Source/DPU/ProfilerCC.cpp', | ||
] | ||
|
||
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <ctime> | ||
#include <chrono> | ||
|
||
using std::chrono::steady_clock; | ||
using std::chrono::duration_cast; | ||
using std::chrono::microseconds; | ||
|
||
/** | ||
* A profiler that counts elapsed time and computes opertions/s. | ||
* | ||
*/ | ||
class Profiler { | ||
public: | ||
Profiler(size_t _operations); | ||
void Start(); | ||
void Stop(); | ||
double Ellapsed(); | ||
void Report(); | ||
void ReportLatency(); | ||
void ReportThroughput(); | ||
|
||
private: | ||
steady_clock::time_point m_start_time; | ||
steady_clock::time_point m_end_time; | ||
size_t m_operations; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <iostream> | ||
|
||
#include "ProfilerCC.h" | ||
|
||
using std::cout; | ||
using std::endl; | ||
|
||
Profiler::Profiler(size_t _operations) { | ||
m_operations = _operations; | ||
} | ||
|
||
void Profiler::Start() { | ||
m_start_time = steady_clock::now(); | ||
} | ||
|
||
void Profiler::Stop() { | ||
m_end_time = steady_clock::now(); | ||
} | ||
|
||
double Profiler::Ellapsed() { | ||
auto dur = duration_cast<microseconds>(m_end_time - m_start_time); | ||
return (double)dur.count(); | ||
} | ||
|
||
void Profiler::Report() { | ||
auto dur = duration_cast<microseconds>(m_end_time - m_start_time); | ||
cout << "Porfiler:" << endl; | ||
cout << "-- latency: " << dur.count() / 1000000.0 << " seconds" << endl; | ||
cout << "-- throughput: " << m_operations * 1.0 / dur.count() << " million op/s" << endl; | ||
} | ||
|
||
void Profiler::ReportLatency() { | ||
auto dur = duration_cast<microseconds>(m_end_time - m_start_time); | ||
cout << "Porfiler:" << endl; | ||
cout << "-- latency: " << dur.count() / 1000000.0 << " seconds" << endl; | ||
} | ||
|
||
void Profiler::ReportThroughput() { | ||
auto dur = duration_cast<microseconds>(m_end_time - m_start_time); | ||
cout << "Porfiler:" << endl; | ||
cout << "-- throughput: " << m_operations * 1.0 / dur.count() << " million op/s" << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#include <iostream> | ||
|
||
#include "profiler.h" | ||
#include "Profiler.h" | ||
|
||
using std::cout; | ||
using std::endl; | ||
|