This commit is contained in:
2025-11-23 01:15:51 +04:00
parent 0455d9bd5b
commit 8d5a57a8c0
4 changed files with 74 additions and 28 deletions

View File

@@ -7,16 +7,33 @@ OpenCL openCL;
#include "cpu/tensor.hpp"
#endif
#include <chrono>
#include <functional>
#include <iostream>
// TODO: TMult >2
class Profiler {
public:
static void measure(const std::string &operation, std::function<void()> op) {
auto start = std::chrono::high_resolution_clock::now();
op();
auto end = std::chrono::high_resolution_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::microseconds>(end - start);
std::cout << operation << ": " << duration.count() << " μs\n";
}
};
int main() {
#ifdef USE_OPENCL
openCL.init("./");
#endif
Tensor<float, 2> a = Tensor<float, 2>({32, 32}, 2);
Tensor<float, 2> a = Tensor<float, 2>({4096 * 2, 4096 * 2}, 1);
Tensor<float, 2> b = Tensor<float, 2>({4096 * 2, 4096 * 2}, 1);
Profiler::measure("Matrix multiplication", [&]() { auto result = a % b; });
std::cout << a.toString();
return 0;
}