Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
37111be
[hipDNN] Plugin SDK + Device Properties Infrastructure (RFC 0007 - Pa…
cderb Apr 15, 2026
1e54ffb
Fix RFC references to include RFC 0007 prefix
cderb Apr 15, 2026
1e19a4d
Add missing HipdnnException.hpp include to TestDeviceProperties
cderb Apr 15, 2026
683886a
RFC 0007: Engine Selection Heuristics Framework (Backend + Plugins)
cderb Apr 15, 2026
18d094a
Add RFC 0007 documentation
cderb Apr 15, 2026
909ccfe
Merge PR1: Add RFC 0007 documentation
cderb Apr 15, 2026
f254105
Fix RFC 0007 labels and add missing test files to CMakeLists
cderb Apr 15, 2026
2af1ffe
Fix compilation errors
cderb Apr 15, 2026
4a4abad
compilation fixes
cderb Apr 16, 2026
2a72673
Fix RFC 0007 heuristic plugin ABI compliance and test infrastructure
cderb Apr 16, 2026
c4dc2d3
correct engine name in tests
cderb Apr 16, 2026
49f6188
Apply code quality and ABI fixes to PR1 Plugin SDK infrastructure
cderb Apr 16, 2026
5856d6e
Add unit tests for RFC 0007 Part 1 Plugin SDK infrastructure
cderb Apr 16, 2026
2da1d23
formatting corrections
cderb Apr 16, 2026
853b064
Fix pre-commit hook failures
cderb Apr 16, 2026
05af187
fix generated files
cderb Apr 16, 2026
78bd506
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb Apr 17, 2026
5ff2578
add more coverage tests
cderb Apr 17, 2026
f1c3f8e
format on test files
cderb Apr 17, 2026
98b1892
Add comprehensive HeuristicPlugin test coverage
cderb Apr 17, 2026
e2a17a6
Fixed race condition in heuristic plugin initialization.
cderb Apr 18, 2026
5947d05
format
cderb Apr 20, 2026
35c2155
reorganize heuristic plugin tests, reduce test files, add to plugin m…
cderb Apr 20, 2026
aeb7d54
remove special unicode characters
cderb Apr 20, 2026
359c8aa
Require policy names and compute policy IDs from names
cderb Apr 20, 2026
59a692c
Add architectureName to device properties for LLVM architecture support
cderb Apr 20, 2026
6a24652
revert EngineOrdering changes, will re-investigate need in part 2
cderb Apr 20, 2026
c40cf35
format
cderb Apr 20, 2026
b8c2eda
format
cderb Apr 20, 2026
ad1ec05
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 20, 2026
e98e1a6
fix directory resolution for heuristic plugin ci test
cderb Apr 20, 2026
f14e817
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 20, 2026
0be745e
test fixes
cderb Apr 20, 2026
08429e3
nolints
cderb Apr 20, 2026
4187f50
format
cderb Apr 20, 2026
8d72819
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 20, 2026
c42198f
share sortEngineIds to plugins
cderb Apr 20, 2026
0dde900
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb Apr 21, 2026
1b97bb9
addressing reviews
cderb Apr 21, 2026
cc61d02
use weak ptr to track heuristic plugin manager resources
cderb Apr 21, 2026
6380677
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 21, 2026
c3d4846
format
cderb Apr 21, 2026
59e6ae6
format
cderb Apr 21, 2026
bb298a7
remove heuristicLoggingCallback and use backendLoggingCallback directly
cderb Apr 21, 2026
94b9680
update patch version
cderb Apr 21, 2026
d9763c2
makelist corrections
cderb Apr 21, 2026
ee29b1c
corrections for MockHeuristicPlugin, add virtual to HeuristicPlugin m…
cderb Apr 21, 2026
348e797
review comments
cderb Apr 21, 2026
7e837d2
add PluginResourceManagerBase
cderb Apr 21, 2026
9145dbb
format
cderb Apr 21, 2026
86f19ad
windows test fix
cderb Apr 22, 2026
b21936c
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 22, 2026
45d57b3
refactor HeuristicsPluginApi to extend PluginApi
cderb Apr 22, 2026
9a0dd37
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 22, 2026
e96b5b8
update plugins to match updates from part 1
cderb Apr 22, 2026
f14da60
windows friendly test paths
cderb Apr 22, 2026
72a83c0
fix test
cderb Apr 23, 2026
3eb163b
Fix test for windows path names
jdcampbe Apr 23, 2026
2917710
Fix SharedLibrary move losing _libraryPath after std::move
jdcampbe Apr 23, 2026
8f674e6
format
cderb Apr 23, 2026
4a1bb70
tidy fix
cderb Apr 23, 2026
c506129
Merge branch 'users/cderb/rfc0007/pr1-plugin-sdk-infrastructure' into…
cderb Apr 23, 2026
0b83769
Apply clang-format to PR2 files
claude Apr 23, 2026
9507946
tidy
cderb Apr 23, 2026
2f6830c
Fix heuristic plugin discovery for cross-platform CI
cderb Apr 23, 2026
742c1c6
Clean up HeuristicsPluginApi documentation and naming
cderb Apr 23, 2026
b7e46a2
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb Apr 23, 2026
1bd1f2f
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb Apr 24, 2026
13aed83
remove so suffix for windows build
cderb Apr 24, 2026
e63202e
add plugin dependency for coverage test
cderb Apr 24, 2026
47e691b
copy plugins to build for test
cderb Apr 24, 2026
63de4f6
add test build dependencies
cderb Apr 24, 2026
9e73627
RFC 0007: Improve test coverage and optimize test suite
cderb Apr 27, 2026
5825a60
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb Apr 27, 2026
1058517
Apply clang-format to PR2 test files
cderb Apr 27, 2026
7614d52
Fix all clang-tidy errors from CI (PR2)
cderb Apr 27, 2026
d80fe5e
format
cderb Apr 28, 2026
839ab18
fix paths for windows
cderb Apr 28, 2026
3963fb6
format
cderb Apr 28, 2026
200d921
Fix Windows test failures by unloading plugins before cleanup
cderb Apr 28, 2026
6a9d0a2
addressing reviews
cderb May 1, 2026
93ac99c
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 1, 2026
49937a1
Port engine plugin CMake patterns to heuristic plugins
cderb May 4, 2026
724eb83
Hold shared_ptr to resource manager + policy ID in SelectionHeuristic
cderb May 4, 2026
d055b8b
Switch HIPDNN_ATTR_ENGINEHEUR_POLICY_ORDER_EXT to int64 policy IDs
cderb May 4, 2026
7640e1f
Address heuristic descriptor and SelectionHeuristic review feedback
cderb May 4, 2026
073158b
Move EngineOverrideConfig from frontend into ConfigPlugin
cderb May 5, 2026
85f3da2
Centralize test plugin target names in cmake/TestPluginNames.cmake
cderb May 5, 2026
529b371
Refine heuristic plugin tests: dedup, regroup, rename per CLAUDE.md
cderb May 5, 2026
1c6cd31
Drop fallback heuristic plugin search paths
cderb May 5, 2026
a6aec58
Cover policy order env var, descriptor precedence, and empty list
cderb May 5, 2026
d6f996d
Refactor heuristic plugins to OBJECT/STATIC/SHARED target pattern
cderb May 5, 2026
adfae53
Move heuristic plugin tests into per-plugin tests/ directories
cderb May 5, 2026
af332d4
Share BAD_PARAM checks via HeuristicValidation.hpp; drop loadFromEnv …
cderb May 5, 2026
7211d1f
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 5, 2026
71f998e
Add hipdnnSetHeuristicPluginPaths_ext and isolate backend tests from …
cderb May 6, 2026
883f9a9
Isolate frontend tests from real heuristic plugins
cderb May 6, 2026
aa45628
Drop unused Config/StaticOrdering deps from hipdnn_backend_tests
cderb May 6, 2026
f73ef78
Reset derived plugin-manager state on ABSOLUTE reload
cderb May 6, 2026
0525166
Drop RFC 0007 references from source comments
cderb May 6, 2026
3f5281d
update comments for hipdnnGetHeuristicPolicyInfo_ext
cderb May 6, 2026
d127c92
Apply RAII to heuristic test files
cderb May 6, 2026
c1abb49
Support 1:N heuristic plugin-to-policy ABI
cderb May 6, 2026
1c84598
Cover HeuristicPlugin load-time validation paths
cderb May 6, 2026
544e264
clang-format
cderb May 7, 2026
38f77f5
clang-tidy: use s_ prefix for function-static IDs
cderb May 7, 2026
b9b7405
windows environment var fix
cderb May 7, 2026
d4af347
Migrate default heuristic plugin to backend built-ins
cderb May 8, 2026
2372de6
Move HIPDNN_DEFAULT_ENGINE handling to backend resolver
cderb May 8, 2026
74c95b8
clang-format
cderb May 8, 2026
5eb0b9e
Replace HIPDNN_DEFAULT_ENGINE with HIPDNN_FALLBACK_ENGINE_ORDERING
cderb May 8, 2026
6919163
Move Graph.preferred_engine_id handling back to the frontend
cderb May 8, 2026
03a5caa
Convert engine override resolver into Config built-in policy
cderb May 8, 2026
324a8dc
Rename heuristic-related env vars to HIPDNN_HEUR_* prefix
cderb May 8, 2026
1b803a0
Add coverage tests for Config and StaticOrdering built-in policies
cderb May 8, 2026
7fd084c
clang-format
cderb May 8, 2026
3a480c8
update heuristic policy order setting
cderb May 14, 2026
5a626c9
format
cderb May 14, 2026
985bbd6
Bind real stream to handle in heuristic descriptor tests
cderb May 15, 2026
7018b9a
Skip heuristic plugin tests on no-GPU CI runners
cderb May 15, 2026
ea26800
Make setDeviceProperties failure fail-soft per heuristic plugin
cderb May 15, 2026
c54cdbd
Expose pluginName from hipdnnGetHeuristicPolicyInfo_ext
cderb May 15, 2026
4c62be1
comment correction
cderb May 15, 2026
d112871
Document heuristic policy env vars in Environment.md
cderb May 15, 2026
40426ba
reject stride mismatch for tensor
cderb May 15, 2026
4f92332
Assert PreferNonExistentEngineId succeeds in engine filtering test
cderb May 15, 2026
eb6ad3a
Revert "Assert PreferNonExistentEngineId succeeds in engine filtering…
cderb May 15, 2026
e86f245
Make PreferNonExistentEngineId assertion deterministic
cderb May 16, 2026
9072b87
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 18, 2026
7b7a6ba
Pin heuristic workflow tests to the test good plugin
cderb May 18, 2026
f6b7e26
Pin remaining heuristic plugin tests to a known policy ID
cderb May 18, 2026
593e12f
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 18, 2026
113d02b
RAII leak fixes, heuristic plugin hardening, and shared logging
cderb May 19, 2026
41c61ae
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 19, 2026
00dfbbf
clang-format review-cycle changes
cderb May 19, 2026
8ce4fc2
Merge remote-tracking branch 'origin/develop' into users/cderb/rfc000…
cderb May 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions projects/hipdnn/CMakeLists.txt
Comment thread
cderb marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ set(HIPDNN_RELATIVE_INSTALL_PLUGIN_ENGINE_DIR
"${HIPDNN_PLUGIN_ROOTDIR}/${HIPDNN_PLUGIN_ENGINE_SUBDIR}"
CACHE STRING "Relative install directory for official hipDNN engine plugins"
)
set(HIPDNN_PLUGIN_HEURISTIC_SUBDIR "hipdnn_plugins/heuristics"
CACHE STRING "Subdirectory for official hipDNN heuristic plugins"
)
set(HIPDNN_BUILD_PLUGIN_HEURISTIC_DIR
"${CMAKE_BINARY_DIR}/${HIPDNN_PLUGIN_ROOTDIR}/${HIPDNN_PLUGIN_HEURISTIC_SUBDIR}"
CACHE PATH "Build directory for official hipDNN heuristic plugins"
)
set(HIPDNN_FULL_INSTALL_PLUGIN_HEURISTIC_DIR
"${HIPDNN_PLUGIN_FULL_ROOTDIR}/${HIPDNN_PLUGIN_HEURISTIC_SUBDIR}"
CACHE
STRING
"Full install directory for official hipDNN heuristic plugins. Uses the CMAKE_INSTALL_PREFIX set at configure time (defaults to /opt/rocm/)."
)
set(HIPDNN_RELATIVE_INSTALL_PLUGIN_HEURISTIC_DIR
"${HIPDNN_PLUGIN_ROOTDIR}/${HIPDNN_PLUGIN_HEURISTIC_SUBDIR}"
CACHE STRING "Relative install directory for official hipDNN heuristic plugins"
)
set(HIPDNN_TEST_PLUGIN_DIR "${CMAKE_BINARY_DIR}/${HIPDNN_PLUGIN_ROOTDIR}/test_plugins"
CACHE INTERNAL "Build directory for test plugins"
)
Expand Down Expand Up @@ -182,6 +199,7 @@ include(cmake/ClangCheck.cmake)
include(cmake/ClangTidy.cmake)
include(cmake/Sanitizers.cmake)
include(cmake/Tests.cmake)
include(cmake/TestPluginNames.cmake)
include(cmake/Spdlog.cmake)

# Add global compile options
Expand Down
20 changes: 20 additions & 0 deletions projects/hipdnn/backend/include/HipdnnBackendAttributeName.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ typedef enum
/** @brief Find first mode: stop after finding any applicable engine (bool, extension) */
HIPDNN_ATTR_ENGINEHEUR_FIND_FIRST_EXT = 105,

/**
* @brief Ordered list of heuristic policy IDs for engine selection (array of int64, extension)
*
* Specifies the policy order for the heuristic outer loop. Each element is an int64_t
* policy ID, produced by hashing a policy name (e.g., "SelectionHeuristic::StaticOrdering")
* with hipdnn_data_sdk::utilities::policyNameToId.
* Hashing is performed by the caller before the C ABI; the backend stores and dispatches
* by ID only.
*
* Resolution priority at finalize time (highest first):
* 1. HIPDNN_HEUR_POLICY_ORDER env var (comma-separated tokens; each token is
* either a policy name, which is hashed via policyNameToId, or a raw
* decimal int64 policy ID).
* 2. This descriptor attribute, if set.
* 3. Built-in default: [SelectionHeuristic::Config, SelectionHeuristic::StaticOrdering].
*
* Type: HIPDNN_TYPE_INT64
*/
Comment thread
cderb marked this conversation as resolved.
HIPDNN_ATTR_ENGINEHEUR_POLICY_ORDER_EXT = 106,

/** @} */

/**
Expand Down
88 changes: 88 additions & 0 deletions projects/hipdnn/backend/include/hipdnn_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,28 @@ HIPDNN_BACKEND_EXPORT void hipdnnLoggingCallback_ext(hipdnnSeverity_t severity,
HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnSetEnginePluginPaths_ext(
size_t numPaths, const char* const* pluginPaths, hipdnnPluginLoadingMode_ext_t loadingMode);
Comment thread
BrianHarrisonAMD marked this conversation as resolved.

/**
* @brief Sets the search paths for hipDNN heuristic plugins.
*
* Mirrors @ref hipdnnSetEnginePluginPaths_ext for the heuristic plugin search domain.
* Must be called before creating a hipDNN handle, as heuristic plugins are loaded
* during handle creation.
*
* Paths can be either directories or specific plugin files. Relative paths are resolved
* from the location of the libhipdnn_backend.so file.
*
* @param[in] numPaths The number of paths in the `pluginPaths` array.
* @param[in] pluginPaths An array of relative or absolute path strings.
* @param[in] loadingMode Specifies whether to add paths to or replace the default search paths.
*
* @retval HIPDNN_STATUS_SUCCESS The operation was successful.
* @retval HIPDNN_STATUS_BAD_PARAM_NULL_POINTER `pluginPaths` is nullptr when `numPaths` is greater than 0.
* @retval HIPDNN_STATUS_NOT_SUPPORTED Called with active handle.
* @retval HIPDNN_STATUS_INTERNAL_ERROR An internal error occurred.
*/
HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnSetHeuristicPluginPaths_ext(
size_t numPaths, const char* const* pluginPaths, hipdnnPluginLoadingMode_ext_t loadingMode);

/**
* @brief Sets the plugin unloading mode for hipDNN.
*
Expand Down Expand Up @@ -676,6 +698,72 @@ HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetEngineInfo_ext(hipdnnHandle_t hand
char* type,
size_t* typeLen);

/**
* @brief Gets the count of loaded heuristic policies.
*
* Returns the number of heuristic policy plugins that have been successfully loaded
* and validated by the backend. This count includes all policies available for use
* in the outer loop engine selection.
*
* @param[in] handle A valid hipDNN handle.
* @param[out] numPolicies Pointer where the policy count will be stored.
*
* @retval HIPDNN_STATUS_SUCCESS Success.
* @retval HIPDNN_STATUS_BAD_PARAM Invalid handle or null pointer.
*
* @see hipdnnGetHeuristicPolicyInfo_ext for retrieving individual policy metadata
*/
HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetHeuristicPolicyCount_ext(hipdnnHandle_t handle,
size_t* numPolicies);

/**
* @brief Gets information about a loaded heuristic policy by index.
*
* Retrieves metadata for a heuristic policy plugin, including policy ID, policy
* name, plugin name, plugin version, and API version.
*
* @note The enumeration order is unspecified and may change between calls or
* between backend versions. Callers must not assume a stable ordering across
* indices; use the returned `policyId` as the identity, not `policyIndex`.
*
* This function uses a two-call pattern for string fields:
* 1. First call: Pass all string buffers as `nullptr` to query required sizes.
* - Sets `policyNameLen`, `pluginNameLen`, `pluginVersionLen`, and `apiVersionLen`
* to the required buffer sizes (including null terminator). Note: if any
* string buffer is null, all sizes are updated.
*
* 2. Second call: Pass allocated buffers with sizes set from the first call.
*
* @param[in] handle A valid hipDNN handle.
* @param[in] policyIndex Zero-based index of the policy to query.
* @param[out] policyId Pointer where the policy ID will be stored, or `nullptr` to skip.
* @param[out] policyName Buffer for the policy name, or `nullptr` to query size.
* @param[in,out] policyNameLen Pointer to buffer size; updated with required size.
* @param[out] pluginName Buffer for the plugin name, or `nullptr` to query size.
* @param[in,out] pluginNameLen Pointer to buffer size; updated with required size.
* @param[out] pluginVersion Buffer for the plugin version, or `nullptr` to query size.
* @param[in,out] pluginVersionLen Pointer to buffer size; updated with required size.
* @param[out] apiVersion Buffer for the API version, or `nullptr` to query size.
* @param[in,out] apiVersionLen Pointer to buffer size; updated with required size.
*
* @retval HIPDNN_STATUS_SUCCESS Success.
* @retval HIPDNN_STATUS_BAD_PARAM Invalid handle, null pointers, or out-of-range index.
* @retval HIPDNN_STATUS_INTERNAL_ERROR Internal error.
*
* @see hipdnnGetHeuristicPolicyCount_ext for getting the total policy count
*/
HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetHeuristicPolicyInfo_ext(hipdnnHandle_t handle,
size_t policyIndex,
int64_t* policyId,
char* policyName,
size_t* policyNameLen,
char* pluginName,
size_t* pluginNameLen,
char* pluginVersion,
size_t* pluginVersionLen,
char* apiVersion,
size_t* apiVersionLen);
Comment thread
BrianHarrisonAMD marked this conversation as resolved.
Comment thread
BrianHarrisonAMD marked this conversation as resolved.

/**
* @brief Returns hipdnn backend version string. Returns an error if nullptr is passed
*
Expand Down
4 changes: 4 additions & 0 deletions projects/hipdnn/backend/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ add_library(
logging/GraphLogger.cpp
logging/Logging.cpp
FlatbufferUtilities.cpp
heuristics/BuiltInHeuristics.cpp
heuristics/SelectionHeuristic.cpp
heuristics/config/ConfigBuiltIn.cpp
heuristics/static_ordering/StaticOrderingBuiltIn.cpp
plugin/EnginePlugin.cpp
plugin/EnginePluginResourceManager.cpp
plugin/HeuristicPlugin.cpp
Expand Down
145 changes: 145 additions & 0 deletions projects/hipdnn/backend/src/HipdnnBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "hipdnn_backend.h"
#include "logging/Logging.hpp"
#include "plugin/EnginePluginResourceManager.hpp"
#include "plugin/HeuristicPluginResourceManager.hpp"

#include <hipdnn_backend/version.h>
#include <hipdnn_data_sdk/utilities/StringUtil.hpp>
Expand Down Expand Up @@ -480,13 +481,47 @@ HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnSetEnginePluginPaths_ext(
});
}

HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnSetHeuristicPluginPaths_ext(
size_t numPaths, const char* const* pluginPaths, hipdnnPluginLoadingMode_ext_t loadingMode)
{
LOG_API_ENTRY("numPaths={}, pluginPaths_ptr={:p}, loadingMode={}",
numPaths,
static_cast<const void*>(pluginPaths),
loadingMode);

return hipdnn_backend::tryCatch([&, apiName = __func__] {
if(numPaths > 0)
{
throwIfNull(pluginPaths);
}

std::vector<std::filesystem::path> pathsVec;
pathsVec.reserve(numPaths);

for(size_t i = 0; i < numPaths; ++i)
{
throwIfNull(pluginPaths[i]);
pathsVec.emplace_back(pluginPaths[i]);
}

hipdnn_backend::plugin::HeuristicPluginResourceManager::setPluginPaths(pathsVec,
loadingMode);
LOG_API_SUCCESS(apiName, "set_heuristic_plugin_paths={}", loadingMode);
return HIPDNN_STATUS_SUCCESS;
});
}

HIPDNN_BACKEND_EXPORT hipdnnStatus_t
hipdnnSetPluginUnloadMode_ext(hipdnnPluginUnloadingMode_ext_t unloadingMode)
{
LOG_API_ENTRY("unloadingMode={}", unloadingMode);

return hipdnn_backend::tryCatch([&, apiName = __func__] {
// Apply to both plugin resource managers so the public ABI behaves
// uniformly regardless of plugin kind.
hipdnn_backend::plugin::EnginePluginResourceManager::setPluginUnloadingMode(unloadingMode);
hipdnn_backend::plugin::HeuristicPluginResourceManager::setPluginUnloadingMode(
unloadingMode);
LOG_API_SUCCESS(apiName, "set_plugin_unloading_mode={}", unloadingMode);
return HIPDNN_STATUS_SUCCESS;
});
Expand Down Expand Up @@ -654,6 +689,116 @@ HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetEngineInfo_ext(hipdnnHandle_t hand
});
}

HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetHeuristicPolicyCount_ext(hipdnnHandle_t handle,
size_t* numPolicies)
{
LOG_API_ENTRY("handle={:p}, numPolicies_ptr={:p}",
static_cast<void*>(handle),
static_cast<void*>(numPolicies));

return hipdnn_backend::tryCatch([&, apiName = __func__] {
throwIfNull(handle);
throwIfNull(numPolicies);

auto policyInfos = handle->getHeuristicPluginResourceManager()->getHeuristicPolicyInfos();
*numPolicies = policyInfos.size();

LOG_API_SUCCESS(apiName, "retrieved_numPolicies={}", *numPolicies);
});
}

HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetHeuristicPolicyInfo_ext(hipdnnHandle_t handle,
size_t policyIndex,
int64_t* policyId,
char* policyName,
size_t* policyNameLen,
char* pluginName,
size_t* pluginNameLen,
char* pluginVersion,
size_t* pluginVersionLen,
char* apiVersion,
size_t* apiVersionLen)
{
LOG_API_ENTRY("handle={:p}, policyIndex={}, policyId_ptr={:p}, policyName_ptr={:p}, "
"pluginName_ptr={:p}, pluginVersion_ptr={:p}, apiVersion_ptr={:p}",
static_cast<void*>(handle),
policyIndex,
static_cast<void*>(policyId),
static_cast<void*>(policyName),
static_cast<void*>(pluginName),
static_cast<void*>(pluginVersion),
static_cast<void*>(apiVersion));

return hipdnn_backend::tryCatch([&, apiName = __func__] {
throwIfNull(handle);
throwIfNull(policyNameLen);
throwIfNull(pluginNameLen);
throwIfNull(pluginVersionLen);
throwIfNull(apiVersionLen);

// Built from an unordered_map; ordering is unspecified and may change
// between calls. If a stable enumeration is ever required, an explicit
// ordering must be applied here rather than relied on from the source map.
auto policyInfos = handle->getHeuristicPluginResourceManager()->getHeuristicPolicyInfos();
Comment thread
cderb marked this conversation as resolved.
if(policyIndex >= policyInfos.size())
{
throw HipdnnException(HIPDNN_STATUS_BAD_PARAM,
"Policy index " + std::to_string(policyIndex) + " out of range ("
+ std::to_string(policyInfos.size()) + " policies loaded).");
}

const auto& info = policyInfos[policyIndex];

if(policyId != nullptr)
{
*policyId = info.policyId;
}

const size_t requiredPolicyNameLen = info.policyName.size() + 1;
const size_t requiredPluginNameLen = info.pluginName.size() + 1;
const size_t requiredPluginVersionLen = info.pluginVersion.size() + 1;
const size_t requiredApiVersionLen = info.apiVersion.size() + 1;

// Query mode: return required sizes
if(policyName == nullptr || pluginName == nullptr || pluginVersion == nullptr
|| apiVersion == nullptr)
{
*policyNameLen = requiredPolicyNameLen;
*pluginNameLen = requiredPluginNameLen;
*pluginVersionLen = requiredPluginVersionLen;
*apiVersionLen = requiredApiVersionLen;
return;
}

// Retrieve mode: check buffer sizes
if(*policyNameLen < requiredPolicyNameLen || *pluginNameLen < requiredPluginNameLen
|| *pluginVersionLen < requiredPluginVersionLen
|| *apiVersionLen < requiredApiVersionLen)
{
throw HipdnnException(HIPDNN_STATUS_BAD_PARAM, "Insufficient buffer space provided.");
}

hipdnn_data_sdk::utilities::copyMaxSizeWithNullTerminator(
policyName, info.policyName.c_str(), *policyNameLen);
hipdnn_data_sdk::utilities::copyMaxSizeWithNullTerminator(
pluginName, info.pluginName.c_str(), *pluginNameLen);
hipdnn_data_sdk::utilities::copyMaxSizeWithNullTerminator(
pluginVersion, info.pluginVersion.c_str(), *pluginVersionLen);
hipdnn_data_sdk::utilities::copyMaxSizeWithNullTerminator(
apiVersion, info.apiVersion.c_str(), *apiVersionLen);

LOG_API_SUCCESS(apiName,
"policy[{}]: policyId={}, policyName={}, pluginName={}, "
"pluginVersion={}, apiVersion={}",
policyIndex,
info.policyId,
info.policyName,
info.pluginName,
info.pluginVersion,
info.apiVersion);
});
}

HIPDNN_BACKEND_EXPORT hipdnnStatus_t hipdnnGetVersion_ext(const char** version)
{
return hipdnn_backend::tryCatch([&]() {
Expand Down
Comment thread
BrianHarrisonAMD marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "SdpaFwdOperationDescriptor.hpp"
#include "TensorDescriptor.hpp"
#include "VariantDescriptor.hpp"
// Required: EngineHeuristicDescriptor holds std::unique_ptr<SelectionHeuristic>
// via forward declaration, so the complete type must be visible where
// make_shared<EngineHeuristicDescriptor>() instantiates the destructor.
#include "heuristics/SelectionHeuristic.hpp"
#include "logging/Logging.hpp"

namespace hipdnn_backend
Expand Down
Loading
Loading