Skip to content

[XPTI][INFRA] Sample E2E data collection timing test for XPTI #13045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sycl/doc/design/SYCLInstrumentationUsingXPTI.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions xptifw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project (xptifw VERSION "${XPTI_VERSION}" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

set(XPTIFW_DIR ${CMAKE_CURRENT_LIST_DIR})
set(SAMPLES_DIR ${CMAKE_CURRENT_LIST_DIR}/samples)

# The XPTI framework requires the includes from
# the proxy implementation of XPTI
Expand Down Expand Up @@ -68,6 +69,7 @@ endif()
if (XPTI_BUILD_SAMPLES)
add_subdirectory(samples/basic_collector)
add_subdirectory(samples/syclpi_collector)
add_subdirectory(samples/sycl_perf_collector)
add_subdirectory(basic_test)
endif()

Expand Down
1 change: 1 addition & 0 deletions xptifw/basic_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
file(GLOB SOURCES *.cpp *.hpp)
include_directories(${XPTIFW_DIR}/include)
include_directories(${XPTI_DIR}/include)
include_directories(${SAMPLES_DIR}/include)

add_executable(XPTIFWBasicTests ${SOURCES})
target_link_libraries(XPTIFWBasicTests PRIVATE xptifw ${CMAKE_DL_LIBS})
Expand Down
71 changes: 8 additions & 63 deletions xptifw/basic_test/cl_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include "xpti/xpti_trace_framework.hpp"
#include "xpti_helpers.hpp"

#include <chrono>
#include <iomanip>
Expand All @@ -26,12 +27,6 @@ namespace test {
namespace utils {
enum class OptionType { Boolean, Integer, Float, String, Range };

// We are using C++ 11, hence we cannot use
// std::variant or std::any
using table_row_t = std::map<int, long double>;
using table_t = std::map<int, table_row_t>;
using titles_t = std::vector<std::string>;

class ScopedTimer {
public:
using time_unit_t =
Expand Down Expand Up @@ -301,56 +296,6 @@ class CommandLineParser {
std::string MAppName;
};

class TableModel {
public:
using row_titles_t = std::map<int, std::string>;

TableModel() {}

void setHeaders(titles_t &Titles) { MColumnTitles = Titles; }

table_row_t &addRow(int Row, std::string &RowName) {
if (MRowTitles.count(Row)) {
std::cout << "Warning: Row title already specified!\n";
}
MRowTitles[Row] = RowName;
return MTable[Row];
}

table_row_t &addRow(int Row, const char *RowName) {
if (MRowTitles.count(Row)) {
std::cout << "Warning: Row title already specified!\n";
}
MRowTitles[Row] = RowName;
return MTable[Row];
}

table_row_t &operator[](int Row) { return MTable[Row]; }

void print() {
std::cout << std::setw(14) << " ";
for (auto &Title : MColumnTitles) {
std::cout << std::setw(14) << Title; // Column headers
}
std::cout << "\n";

for (auto &Row : MTable) {
std::cout << std::setw(14) << MRowTitles[Row.first];
for (auto &Data : Row.second) {
std::cout << std::fixed << std::setw(14) << std::setprecision(0)
<< Data.second;
}
std::cout << "\n";
}
std::cout << "\n";
}

private:
titles_t MColumnTitles;
row_titles_t MRowTitles;
table_t MTable;
};

class RangeDecoder {
public:
RangeDecoder(std::string &RangeStr) : MRange(RangeStr) {
Expand Down Expand Up @@ -436,16 +381,16 @@ class TestCorrectness {
private:
void runStringTableTests();
void runStringTableTestThreads(int RunNo, int NThreads,
test::utils::TableModel &Table);
xpti::utils::TableModel &Table);
void runTracepointTests();
void runTracepointTestThreads(int RunNo, int nt,
test::utils::TableModel &Table);
xpti::utils::TableModel &Table);
void runNotificationTests();
void runNotificationTestThreads(int RunNo, int NThreads,
test::utils::TableModel &Table);
xpti::utils::TableModel &Table);

test::utils::CommandLineParser &MParser;
test::utils::TableModel MTable;
xpti::utils::TableModel MTable;
std::set<long> MThreads, MTests;
long MTracepoints;
const char *MSource = "foo.cpp";
Expand Down Expand Up @@ -598,13 +543,13 @@ class TestPerformance {
private:
void runDataStructureTests();
void runDataStructureTestsThreads(int RunNo, int NThreads,
test::utils::TableModel &Table);
xpti::utils::TableModel &Table);
void runInstrumentationTests();
void runInstrumentationTestsThreads(int RunNo, int NThreads,
test::utils::TableModel &Table);
xpti::utils::TableModel &Table);

test::utils::CommandLineParser &MParser;
test::utils::TableModel MTable;
xpti::utils::TableModel MTable;
std::set<long> MThreads, MTests;
long MTracepoints;
long MTracepointInstances;
Expand Down
12 changes: 6 additions & 6 deletions xptifw/basic_test/performance_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum class FWColumns {
};

void TestPerformance::runDataStructureTestsThreads(
int RunNo, int NumThreads, test::utils::TableModel &Model) {
int RunNo, int NumThreads, xpti::utils::TableModel &Model) {
xptiReset();
uint64_t TimeInNS;
double ElapsedTime;
Expand Down Expand Up @@ -402,9 +402,9 @@ void TestPerformance::runDataStructureTestsThreads(
}

void TestPerformance::runDataStructureTests() {
test::utils::TableModel Model;
xpti::utils::TableModel Model;

test::utils::titles_t Columns{"Threads", "Str.Insert", "Str.Lookup",
xpti::utils::titles_t Columns{"Threads", "Str.Insert", "Str.Lookup",
"St.Ins/Lu", "TP Create", "TP Un-Cached",
"TP FW-Cached", "TP Local", "Notify"};
std::cout << std::setw(Columns.size() * 15 / 2)
Expand All @@ -426,7 +426,7 @@ void TestPerformance::runDataStructureTests() {
}

void TestPerformance::runInstrumentationTestsThreads(
int RunNo, int NumThreads, test::utils::TableModel &Model) {
int RunNo, int NumThreads, xpti::utils::TableModel &Model) {
xptiReset();
uint64_t TimeInNS;
double ElapsedTime;
Expand Down Expand Up @@ -535,9 +535,9 @@ void TestPerformance::runInstrumentationTestsThreads(
}

void TestPerformance::runInstrumentationTests() {
test::utils::TableModel Model;
xpti::utils::TableModel Model;

test::utils::titles_t Columns{
xpti::utils::titles_t Columns{
"Threads", "TP LU+Notify(ns)", "TP Create(ns)", "Ev/s,cb=10",
"Ev/s,cb=100", "Ev/s,cb=500", "Ev/s,cb=1000", "Ev/s,cb=2000"};
std::cout << std::setw(Columns.size() * 15 / 2) << "Framework Tests\n";
Expand Down
18 changes: 9 additions & 9 deletions xptifw/basic_test/semantic_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum class TPColumns {
enum class NColumns { Threads, Notifications, PassRate };

void TestCorrectness::runStringTableTestThreads(
int RunNo, int NumThreads, test::utils::TableModel &Model) {
int RunNo, int NumThreads, xpti::utils::TableModel &Model) {
xptiReset();
constexpr int NumStrings = 1000;

Expand Down Expand Up @@ -184,9 +184,9 @@ void TestCorrectness::runStringTableTestThreads(
}

void TestCorrectness::runStringTableTests() {
test::utils::TableModel Model;
xpti::utils::TableModel Model;

test::utils::titles_t Columns{"Threads", "Insert", "Lookup", "Duplicate",
xpti::utils::titles_t Columns{"Threads", "Insert", "Lookup", "Duplicate",
"Pass rate"};
std::cout << std::setw(25) << "String Table Tests\n";
Model.setHeaders(Columns);
Expand All @@ -207,7 +207,7 @@ void TestCorrectness::runStringTableTests() {
}

void TestCorrectness::runTracepointTestThreads(int RunNo, int NumThreads,
test::utils::TableModel &Model) {
xpti::utils::TableModel &Model) {
xptiReset();
constexpr int TracepointCount = 1000;

Expand Down Expand Up @@ -348,9 +348,9 @@ void TestCorrectness::runTracepointTestThreads(int RunNo, int NumThreads,
}

void TestCorrectness::runTracepointTests() {
test::utils::TableModel Model;
xpti::utils::TableModel Model;

test::utils::titles_t Columns{"Threads", "Create", "Lookup",
xpti::utils::titles_t Columns{"Threads", "Create", "Lookup",
"Duplicate", "Payload", "Pass rate"};
std::cout << std::setw(25) << "Tracepoint Tests\n";
Model.setHeaders(Columns);
Expand All @@ -371,7 +371,7 @@ void TestCorrectness::runTracepointTests() {
}

void TestCorrectness::runNotificationTestThreads(
int RunNo, int NumThreads, test::utils::TableModel &Model) {
int RunNo, int NumThreads, xpti::utils::TableModel &Model) {
xptiReset();
int TPCount = 30, CallbackCount = TPCount * 30;
std::vector<xpti::payload_t *> Payloads;
Expand Down Expand Up @@ -502,9 +502,9 @@ void TestCorrectness::runNotificationTestThreads(
}

void TestCorrectness::runNotificationTests() {
test::utils::TableModel Model;
xpti::utils::TableModel Model;

test::utils::titles_t Columns{"Threads", "Notify", "Pass rate"};
xpti::utils::titles_t Columns{"Threads", "Notify", "Pass rate"};
std::cout << std::setw(25) << "Notification Tests\n";
Model.setHeaders(Columns);

Expand Down
8 changes: 4 additions & 4 deletions xptifw/samples/basic_collector/basic_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

static uint8_t GStreamID = 0;
std::mutex GIOMutex;
xpti::ThreadID GThreadIDEnum;

// The lone callback function we are going to use to demonstrate how to attach
// the collector to the running executable
Expand Down Expand Up @@ -111,9 +110,10 @@ XPTI_CALLBACK_API void tpCallback(uint16_t TraceType,
xpti::trace_event_data_t *Event,
uint64_t Instance, const void *UserData) {
auto Payload = xptiQueryPayload(Event);
xpti::timer::tick_t Time = xpti::timer::rdtsc();
auto TID = xpti::timer::getThreadID();
uint32_t CPU = GThreadIDEnum.enumID(TID);
xpti::utils::timer::measurement_t M;
uint64_t Time = M.clock();
auto TID = M.thread();
uint32_t CPU = M.cpu();
std::string Name;

if (Payload->name_sid() != xpti::invalid_id) {
Expand Down
Loading