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
115 lines
3.3 KiB
C++
115 lines
3.3 KiB
C++
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <flatbuffers/flatbuffers.h>
|
|
#include <memory>
|
|
#include <miopen/miopen.h>
|
|
#include <unordered_map>
|
|
|
|
#include <hipdnn_plugin_sdk/EngineManager.hpp>
|
|
#include <hipdnn_plugin_sdk/PluginBaseTypes.hpp>
|
|
#include <hipdnn_plugin_sdk/PluginException.hpp>
|
|
#include <hipdnn_plugin_sdk/PluginLogging.hpp>
|
|
|
|
#include "HipdnnMiopenContext.hpp"
|
|
#include "HipdnnMiopenSettings.hpp"
|
|
#include "MiopenUtils.hpp"
|
|
|
|
namespace miopen_plugin
|
|
{
|
|
class MiopenContainer;
|
|
}
|
|
|
|
/**
|
|
* @brief MIOpen plugin handle.
|
|
*
|
|
* Inherits from HipdnnEnginePluginHandle for opaque pointer compatibility.
|
|
* Manages the MIOpen library handle, HIP stream, and plugin container.
|
|
*/
|
|
// NOLINTBEGIN
|
|
struct HipdnnMiopenHandle : HipdnnEnginePluginHandle
|
|
{
|
|
public:
|
|
HipdnnMiopenHandle(const HipdnnMiopenHandle&) = delete;
|
|
HipdnnMiopenHandle& operator=(const HipdnnMiopenHandle&) = delete;
|
|
HipdnnMiopenHandle(HipdnnMiopenHandle&&) = delete;
|
|
HipdnnMiopenHandle& operator=(HipdnnMiopenHandle&&) = delete;
|
|
|
|
HipdnnMiopenHandle()
|
|
{
|
|
miopenStatus_t status = miopenCreate(&miopenHandle);
|
|
if(status != miopenStatusSuccess)
|
|
{
|
|
throw hipdnn_plugin_sdk::HipdnnPluginException(HIPDNN_PLUGIN_STATUS_INTERNAL_ERROR,
|
|
"Failed to create MIOpen handle");
|
|
}
|
|
}
|
|
|
|
~HipdnnMiopenHandle() override
|
|
{
|
|
if(miopenHandle != nullptr)
|
|
{
|
|
miopenStatus_t status = miopenDestroy(miopenHandle);
|
|
if(status != miopenStatusSuccess)
|
|
{
|
|
HIPDNN_PLUGIN_LOG_ERROR("Failed to destroy MIOpen handle");
|
|
}
|
|
}
|
|
}
|
|
|
|
miopenHandle_t miopenHandle = nullptr;
|
|
|
|
void setStream(hipStream_t stream)
|
|
{
|
|
THROW_ON_MIOPEN_FAILURE(miopenSetStream(miopenHandle, stream));
|
|
_stream = stream;
|
|
}
|
|
|
|
hipStream_t getStream() const
|
|
{
|
|
return _stream;
|
|
}
|
|
|
|
std::shared_ptr<miopen_plugin::MiopenContainer> container;
|
|
|
|
// Defined in HipdnnMiopenHandle.cpp to avoid circular dependency
|
|
hipdnn_plugin_sdk::EngineManager<HipdnnMiopenHandle, HipdnnMiopenSettings, HipdnnMiopenContext>&
|
|
getEngineManager();
|
|
|
|
void storeEngineDetailsDetachedBuffer(const void* ptr,
|
|
std::unique_ptr<flatbuffers::DetachedBuffer> buffer)
|
|
{
|
|
HIPDNN_PLUGIN_LOG_INFO("Storing detached buffer at address: " << ptr);
|
|
_engineDetailsBuffers[ptr] = std::move(buffer);
|
|
}
|
|
|
|
void removeEngineDetailsDetachedBuffer(const void* ptr)
|
|
{
|
|
HIPDNN_PLUGIN_LOG_INFO("Removing detached buffer at address: " << ptr);
|
|
|
|
auto it = _engineDetailsBuffers.find(ptr);
|
|
if(it != _engineDetailsBuffers.end())
|
|
{
|
|
_engineDetailsBuffers.erase(it);
|
|
}
|
|
else
|
|
{
|
|
HIPDNN_PLUGIN_LOG_WARN(
|
|
"No detached buffer found at address: "
|
|
<< ptr
|
|
<< ". Could not remove engine "
|
|
"details. Ensure you "
|
|
"are using the same hipdnn handle you used for engine details creation");
|
|
}
|
|
}
|
|
|
|
private:
|
|
hipStream_t _stream = nullptr;
|
|
std::unordered_map<const void*, std::unique_ptr<flatbuffers::DetachedBuffer>>
|
|
_engineDetailsBuffers;
|
|
};
|
|
|
|
// NOLINTEND
|