Files
TheRock/rocm-systems/projects/clr/rocclr/platform/agent.hpp
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

145 lines
4.7 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#ifndef AGENT_HPP_
#define AGENT_HPP_
#include "top.hpp"
#include "thread/monitor.hpp"
#include "vdi_agent_amd.h"
namespace amd {
class Agent : public _vdi_agent {
private:
//! Linked list of agent instances
static Agent* list_;
//! Agent API entry points
static const vdi_agent entryPoints_;
//! Capabilities supported by this Agent implementation
static vdi_agent_capabilities potentialCapabilities_;
//! Union of all agent's enabled capabilities
static vdi_agent_capabilities enabledCapabilities_;
//! Monitor to protect the global capabilities
static Monitor capabilitiesLock_;
public:
//! Initialize the OpenCL agent
static bool init();
//! Teardown the agent.
static void tearDown();
//! Return the capabilities supported by this agent.
static vdi_agent_capabilities potentialCapabilities() { return potentialCapabilities_; }
#define AGENT_FLAG(name) \
inline static bool shouldPost##name() { return enabledCapabilities_.canGenerate##name != 0; }
AGENT_FLAG(ContextEvents);
AGENT_FLAG(CommandQueueEvents);
AGENT_FLAG(EventEvents);
AGENT_FLAG(MemObjectEvents);
AGENT_FLAG(SamplerEvents);
AGENT_FLAG(ProgramEvents);
AGENT_FLAG(KernelEvents);
#undef AGENT_FLAG
//! Post a context creation event
static void postContextCreate(cl_context context);
//! Post a context destruction event
static void postContextFree(cl_context context);
//! Post a command queue creation event
static void postCommandQueueCreate(cl_command_queue queue);
//! Post a command queue destruction event
static void postCommandQueueFree(cl_command_queue queue);
//! Post an event creation event
static void postEventCreate(cl_event event, cl_command_type type);
//! Post an event destruction event
static void postEventFree(cl_event event);
//! Post and event status change event.
static void postEventStatusChanged(cl_event event, int32_t execution_status,
int64_t epoch_timestamp);
//! Post a memory object creation event
static void postMemObjectCreate(cl_mem memobj);
//! Post a memory object destruction event
static void postMemObjectFree(cl_mem memobj);
//! Post a memory transfer (acquired by device) event
static void postMemObjectAcquired(cl_mem memobj, cl_device_id device, int64_t elapsed_time);
//! Post a sampler creation event
static void postSamplerCreate(cl_sampler sampler);
//! Post a sampler destruction event
static void postSamplerFree(cl_sampler sampler);
//! Post a program creation event
static void postProgramCreate(cl_program program);
//! Post a program destruction event
static void postProgramFree(cl_program program);
//! Post a program build event
static void postProgramBuild(cl_program program);
//! Post a kernel creation event
static void postKernelCreate(cl_kernel kernel);
//! Post a kernel destruction event
static void postKernelFree(cl_kernel kernel);
//! Post a kernel set argument event
static void postKernelSetArg(cl_kernel kernel, int32_t arg_index, size_t size,
const void* value_ptr);
private:
Agent* next_; //!< Next agent in the linked-list.
void* library_; //!< Handle to the loaded module.
bool ready_; //!< Is this instance ready?
//! Callbacks vector.
vdi_agent_callbacks callbacks_;
//! Capabilities for this agent.
vdi_agent_capabilities capabilities_;
#define AGENT_FLAG(name) \
inline bool canGenerate##name() { return capabilities_.canGenerate##name != 0; }
AGENT_FLAG(ContextEvents);
AGENT_FLAG(CommandQueueEvents);
AGENT_FLAG(EventEvents);
AGENT_FLAG(MemObjectEvents);
AGENT_FLAG(SamplerEvents);
AGENT_FLAG(ProgramEvents);
AGENT_FLAG(KernelEvents);
#undef AGENT_FLAG
public:
//! Construct a new agent.
Agent(const char* moduleName);
//! Destroy the agent
~Agent();
//! Return true if this instance is ready for use.
bool isReady() const { return ready_; }
//! Set the callback vector for this agent
int32_t setCallbacks(const vdi_agent_callbacks* callbacks, size_t size);
//! Return the current capabilities.
int32_t getCapabilities(vdi_agent_capabilities* caps);
//! Set the current capabilities.
int32_t setCapabilities(const vdi_agent_capabilities* caps, bool install);
//! Return the Agent instance from the given cl_agent
inline static Agent* get(vdi_agent* agent) {
return const_cast<Agent*>(static_cast<const Agent*>(agent));
}
};
} // namespace amd
#endif // AGENT_HPP_