[llvm] [System][z/OS] Fix per-thread timing error on z/OS (PR #76947)

Abhina Sree via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 05:12:40 PST 2024


https://github.com/abhina-sree created https://github.com/llvm/llvm-project/pull/76947

This patch calls ProcessCPUUsage() for z/OS because we do not support CLOCK_THREAD_CPUTIME_ID.  This copies the change made to google benchmark here https://github.com/google/benchmark/commit/e3824e7503187993b287ac8c8144a35bf5ccfd44

>From 8a4b8e4771eebd28dc49d1b3e093cced1caa4db3 Mon Sep 17 00:00:00 2001
From: Abhina Sreeskantharajan <Abhina.Sreeskantharajan at ibm.com>
Date: Thu, 4 Jan 2024 08:11:15 -0500
Subject: [PATCH] This patch calls ProcessCPUUsage() for z/OS because we do not
 support CLOCK_THREAD_CPUTIME_ID.

---
 third-party/benchmark/src/timers.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/third-party/benchmark/src/timers.cc b/third-party/benchmark/src/timers.cc
index 21d3db20da9ed3..ed35c01f5540f8 100644
--- a/third-party/benchmark/src/timers.cc
+++ b/third-party/benchmark/src/timers.cc
@@ -168,6 +168,9 @@ double ThreadCPUUsage() {
   // RTEMS doesn't support CLOCK_THREAD_CPUTIME_ID. See
   // https://github.com/RTEMS/rtems/blob/master/cpukit/posix/src/clockgettime.c
   return ProcessCPUUsage();
+#elif defined(BENCHMARK_OS_ZOS)
+  // z/OS doesn't support CLOCK_THREAD_CPUTIME_ID.
+  return ProcessCPUUsage();
 #elif defined(BENCHMARK_OS_SOLARIS)
   struct rusage ru;
   if (getrusage(RUSAGE_LWP, &ru) == 0) return MakeTime(ru);



More information about the llvm-commits mailing list