[Openmp-commits] [llvm] [openmp] [Offload] Add logger in Plugin API functions for OpenMP (PR #215582)
Alex Duran via Openmp-commits
openmp-commits at lists.llvm.org
Wed Aug 12 04:37:57 PDT 2026
================
@@ -0,0 +1,162 @@
+//===-- Shared/APITrace.h - Tracing of offload API calls --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Prints one line per offload API call when the OMP_INFOTYPE_API_TRACE bit of
+// LIBOMPTARGET_INFO is set:
+//
+// ---> init_device(.DeviceId = 0)-> OFFLOAD_SUCCESS (1053 us)
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef OMPTARGET_SHARED_API_TRACE_H
+#define OMPTARGET_SHARED_API_TRACE_H
+
+#include "APITypes.h"
+#include "Debug.h"
+#include "omptarget.h"
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <chrono>
+#include <type_traits>
+#include <utility>
+
+namespace llvm::offload::trace {
+
+/// The level is read on every call so that __tgt_set_info_flag can turn tracing
+/// on and off around a region of interest.
+inline bool isTraceEnabled() { return getInfoLevel() & OMP_INFOTYPE_API_TRACE; }
----------------
adurang wrote:
Do we really want to enable tracing at this level by default in all builds? Seems a bit of heavy hammer to me.
https://github.com/llvm/llvm-project/pull/215582
More information about the Openmp-commits
mailing list