Skip to content

Commit

Permalink
WIP: Update tests (CPU + SYCL)
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJoube committed Feb 27, 2024
1 parent 871c7fe commit 459864b
Show file tree
Hide file tree
Showing 12 changed files with 1,970 additions and 264 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ doc/conf.py
.vscode/*
.cache/*
.ideas/*


test/sycl_sandbox/obsolete
test/sycl_sandbox/test_templates_include.hpp
test/sycl_sandbox/test_templates.cpp
exec.sh
*.save
*.txt
74 changes: 74 additions & 0 deletions test/algorithm/algos/bench/chrono.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#pragma once

#include <iostream>
#include <chrono>
#include <ctime>

namespace bench
{
struct metrics_t
{
double AccessCount, AccessRate, LoadBytes, LoadBandwidth, ArithmeticIntensity, Time;
void print()
{
std::cout
<< "Time=" << Time << " "
<< "AccessCount=" << AccessCount << " "
<< "AccessRate=" << AccessRate << " "
<< "ArithmeticIntensity=" << ArithmeticIntensity << " "
<< "LoadBandwidth=" << LoadBandwidth << " "
<< "LoadBytes=" << LoadBytes << "\n";

// 72M AccessRate=20.8765M/s ArithmeticIntensity=1.75 LoadBandwidth=250.519M/s LoadBytes=201.327M
}
};

struct chrono_t
{
void Init()
{
elapsed_ = 0;
ResumeTiming();
}

void PauseTiming()
{
auto now = std::chrono::system_clock::now();
std::chrono::duration<double> e = now - last_point_;
elapsed_ += e.count();
}

void ResumeTiming()
{
last_point_ = std::chrono::system_clock::now();
}

double ElapsedTime()
{
PauseTiming();
ResumeTiming();
return elapsed_;
}

std::size_t ElapsedTimeMS()
{
PauseTiming();
ResumeTiming();
return elapsed_ * 1000;
}

std::string Str()
{
// long t = static_cast<long>(elapsed_);
// std::string res =
// std::to_string(t)
// + "." + std::to_string(elapsed_ - t);
std::string res = std::to_string(elapsed_) + "s";
return res;
}

private:
std::chrono::time_point<std::chrono::system_clock> last_point_;
double elapsed_;
};
}
Loading

0 comments on commit 459864b

Please sign in to comment.