CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
155 lines
5.6 KiB
C++
155 lines
5.6 KiB
C++
//===---- OmptTracing.h - Target independent OMPT callbacks --*- 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Interface used by target-independent runtimes to coordinate registration and
|
|
// invocation of OMPT tracing functionality.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OPENMP_LIBOMPTARGET_INCLUDE_OMPTTRACING_H
|
|
#define OPENMP_LIBOMPTARGET_INCLUDE_OMPTTRACING_H
|
|
|
|
#ifdef OMPT_SUPPORT
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "OmptCommonDefs.h"
|
|
#include "OmptTracingBuffer.h"
|
|
|
|
#pragma push_macro("DEBUG_PREFIX")
|
|
#undef DEBUG_PREFIX
|
|
#define DEBUG_PREFIX "OMPT"
|
|
|
|
namespace llvm {
|
|
namespace omp {
|
|
namespace target {
|
|
namespace ompt {
|
|
|
|
/// After a timestamp has been read, reset it.
|
|
void resetTimestamp(uint64_t *T);
|
|
|
|
/// A tool may register unique buffer-request and buffer-completion
|
|
/// callback functions for a device. The following are utility functions to
|
|
/// manage those functions.
|
|
|
|
/// Given a device-id, return the corresponding buffer-request callback
|
|
/// function.
|
|
ompt_callback_buffer_request_t getBufferRequestFn(int DeviceId);
|
|
|
|
/// Give a device-id, return the corresponding buffer-completion callback
|
|
/// function.
|
|
ompt_callback_buffer_complete_t getBufferCompleteFn(int DeviceId);
|
|
|
|
/// Given a device-id, set the corresponding buffer-request and
|
|
/// buffer-completion callback functions.
|
|
void setBufferManagementFns(int DeviceId, ompt_callback_buffer_request_t ReqFn,
|
|
ompt_callback_buffer_complete_t CmpltFn);
|
|
|
|
/// Given a device-id, remove the corresponding buffer-request and
|
|
/// buffer-completion callback functions.
|
|
void removeBufferManagementFns(int DeviceId);
|
|
|
|
/// Is device tracing stopped for all devices?
|
|
bool isAllDeviceTracingStopped();
|
|
|
|
/// Invoke callback function for buffer request events
|
|
void ompt_callback_buffer_request(int DeviceId, ompt_buffer_t **BufferPtr,
|
|
size_t *Bytes);
|
|
|
|
/// Invoke callback function for buffer complete events
|
|
void ompt_callback_buffer_complete(int DeviceId, ompt_buffer_t *Buffer,
|
|
size_t Bytes,
|
|
ompt_buffer_cursor_t BeginCursor,
|
|
int BufferOwned);
|
|
|
|
/// Set 'start' and 'stop' for the current trace record
|
|
void setOmptTimestamp(uint64_t StartTime, uint64_t EndTime);
|
|
|
|
/// Set the linear function correlation between host and device clocks
|
|
void setOmptHostToDeviceRate(double Slope, double Offset);
|
|
|
|
/// Set / store the number of granted teams
|
|
void setOmptGrantedNumTeams(uint64_t NumTeams);
|
|
|
|
/// Check if (1) tracing is globally active (2) the given device is actively
|
|
/// traced and (3) the given event type is traced on the device
|
|
bool isTracingEnabled(int DeviceId, unsigned int EventTy);
|
|
|
|
/// Check if the given device is actively traced
|
|
bool isTracedDevice(int DeviceId);
|
|
|
|
/// Check if the given device is monitoring the provided tracing type
|
|
bool isTracingTypeEnabled(int DeviceId, unsigned int EventTy);
|
|
|
|
/// Check if the given device is monitoring the provided tracing type 'group'
|
|
/// Where group means we will check for both: EMI and non-EMI event types
|
|
bool isTracingTypeGroupEnabled(int DeviceId, unsigned int EventTy);
|
|
|
|
/// Set whether the given tracing type should be monitored (or not) on the
|
|
/// device
|
|
void setTracingTypeEnabled(uint64_t &TracedEventTy, bool Enable,
|
|
unsigned int EventTy);
|
|
|
|
/// Set / reset the given tracing types (EventTy = 0 corresponds to 'all')
|
|
ompt_set_result_t setTraceEventTy(int DeviceId, unsigned int Enable,
|
|
unsigned int EventTy);
|
|
|
|
/// Return thread id
|
|
uint64_t getThreadId();
|
|
|
|
/// See TracedDevices in OmptDeviceTracing.h
|
|
extern std::map<int32_t, uint64_t> TracedDevices;
|
|
/// Activate tracing on the given device
|
|
void enableDeviceTracing(int DeviceId);
|
|
/// Deactivate tracing on the given device
|
|
void disableDeviceTracing(int DeviceId);
|
|
|
|
/// Mutexes to serialize invocation of device registration and checks
|
|
extern std::mutex DeviceAccessMutex;
|
|
|
|
/// Mutexes to serialize invocation of device-independent entry points
|
|
extern std::mutex TraceAccessMutex;
|
|
extern std::mutex TraceControlMutex;
|
|
|
|
/// Ensure serialization of calls to std::hash
|
|
extern std::mutex TraceHashThreadMutex;
|
|
|
|
/// Protect map from device-id to the corresponding buffer-request and
|
|
/// buffer-completion callback functions.
|
|
extern std::mutex BufferManagementFnMutex;
|
|
|
|
/// Map from device-id to the corresponding buffer-request and buffer-completion
|
|
/// callback functions.
|
|
extern std::unordered_map<int, std::pair<ompt_callback_buffer_request_t,
|
|
ompt_callback_buffer_complete_t>>
|
|
BufferManagementFns;
|
|
|
|
/// Thread local variables used by the plugin to communicate OMPT information
|
|
/// that are then used to populate trace records. This method assumes a
|
|
/// synchronous implementation, otherwise it won't work.
|
|
extern thread_local uint32_t TraceRecordNumGrantedTeams;
|
|
extern thread_local uint64_t TraceRecordStartTime;
|
|
extern thread_local uint64_t TraceRecordStopTime;
|
|
|
|
/// Thread local thread-id.
|
|
extern thread_local uint64_t ThreadId;
|
|
|
|
/// OMPT global tracing status. Indicates if at least one device is traced.
|
|
extern bool TracingActive;
|
|
|
|
} // namespace ompt
|
|
} // namespace target
|
|
} // namespace omp
|
|
} // namespace llvm
|
|
|
|
#pragma pop_macro("DEBUG_PREFIX")
|
|
|
|
#endif // OMPT_SUPPORT
|
|
|
|
#endif // OPENMP_LIBOMPTARGET_INCLUDE_OMPTTRACING_H
|