[libc-commits] [libc] [libc] NVPTX Profiling Draft (PR #92009)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed May 22 13:14:29 PDT 2024


================
@@ -0,0 +1,92 @@
+#include "LibcGpuBenchmark.h"
+#include "src/__support/CPP/algorithm.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/time/gpu/time_utils.h"
+
+namespace LIBC_NAMESPACE {
+namespace libc_gpu_benchmarks {
+
+Benchmark *Benchmark::start = nullptr;
+Benchmark *Benchmark::end = nullptr;
+
+void Benchmark::add_benchmark(Benchmark *benchmark) {
+  if (end == nullptr) {
+    start = benchmark;
+    end = benchmark;
+    return;
+  }
+  end->next = benchmark;
+  end = benchmark;
+}
+
+int Benchmark::run_benchmarks() {
+  for (Benchmark *b = start; b != nullptr; b = b->next)
+    b->run();
+  return 0;
+}
+
+BenchmarkResult benchmark(const BenchmarkOptions &options,
+                          cpp::function<uint64_t(void)> wrapper_func) {
+  BenchmarkResult result;
+  RuntimeEstimationProgression rep;
+  size_t total_iterations = 0;
+  size_t iterations = options.initial_iterations;
+  if (iterations < (uint32_t)1)
----------------
jhuber6 wrote:

```suggestion
  if (iterations < 1u)
```

https://github.com/llvm/llvm-project/pull/92009


More information about the libc-commits mailing list