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
129 lines
5.2 KiB
C++
129 lines
5.2 KiB
C++
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <miopen/miopen.h>
|
|
|
|
#include "get_handle.hpp"
|
|
#include <gtest/gtest.h>
|
|
#include <gmock/gmock.h>
|
|
#include "gtest_common.hpp"
|
|
#include "miopen/db_path.hpp"
|
|
#include "../lib_env_var.hpp"
|
|
|
|
MIOPEN_LIB_ENV_VAR(MIOPEN_USER_DB_PATH)
|
|
MIOPEN_LIB_ENV_VAR(MIOPEN_ENABLE_LOGGING)
|
|
|
|
class CPU_TuningPolicy_NONE : public ::testing::Test
|
|
{
|
|
protected:
|
|
void testSetInvalidValue(const miopenTuningPolicy_t original_policy, int invalid)
|
|
{
|
|
auto&& handle = get_handle();
|
|
miopenTuningPolicy_t test_tuning_policy = miopenTuningPolicy_t::miopenTuningPolicyNone;
|
|
miopenTuningPolicy_t prev_tuning_policy;
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, original_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &prev_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(original_policy, prev_tuning_policy);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, static_cast<miopenTuningPolicy_t>(invalid)),
|
|
miopenStatusBadParm);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(prev_tuning_policy, test_tuning_policy);
|
|
}
|
|
};
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestTuningPolicyGetterAndSetterValidValues)
|
|
{
|
|
auto&& handle = get_handle();
|
|
miopenTuningPolicy_t test_tuning_policy;
|
|
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicyNone);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, miopenTuningPolicy_t::miopenTuningPolicyDbUpdate),
|
|
miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicyDbUpdate);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, miopenTuningPolicy_t::miopenTuningPolicySearch),
|
|
miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicySearch);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, static_cast<miopenTuningPolicy_t>(4)),
|
|
miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicySearchDbUpdate);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, miopenTuningPolicy_t::miopenTuningPolicyDbClean),
|
|
miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicyDbClean);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(&handle, miopenTuningPolicy_t::miopenTuningPolicyNone),
|
|
miopenStatusSuccess);
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, &test_tuning_policy), miopenStatusSuccess);
|
|
EXPECT_EQ(test_tuning_policy, miopenTuningPolicy_t::miopenTuningPolicyNone);
|
|
}
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestTuningPolicyGetterAndSetterErrorHandling)
|
|
{
|
|
testSetInvalidValue(miopenTuningPolicy_t::miopenTuningPolicyDbUpdate, -1);
|
|
testSetInvalidValue(miopenTuningPolicy_t::miopenTuningPolicySearch, 0);
|
|
testSetInvalidValue(miopenTuningPolicy_t::miopenTuningPolicySearchDbUpdate, 6);
|
|
testSetInvalidValue(miopenTuningPolicy_t::miopenTuningPolicyDbClean, 1000);
|
|
}
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestNullHandleForTuningPolicy)
|
|
{
|
|
miopenTuningPolicy_t test_tuning_policy;
|
|
|
|
EXPECT_EQ(miopenGetTuningPolicy(nullptr, &test_tuning_policy), miopenStatusBadParm);
|
|
|
|
EXPECT_EQ(miopenSetTuningPolicy(nullptr, miopenTuningPolicy_t::miopenTuningPolicyNone),
|
|
miopenStatusBadParm);
|
|
}
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestNullPolicyPointer)
|
|
{
|
|
auto&& handle = get_handle();
|
|
|
|
EXPECT_EQ(miopenGetTuningPolicy(&handle, nullptr), miopenStatusBadParm);
|
|
}
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestGetApiLogged)
|
|
{
|
|
ScopedEnvironment<std::string> enable_logging(MIOPEN_ENABLE_LOGGING, "ON");
|
|
miopenTuningPolicy_t policy;
|
|
auto&& handle = get_handle();
|
|
|
|
testing::internal::CaptureStderr();
|
|
auto status = miopenGetTuningPolicy(&handle, &policy);
|
|
ASSERT_EQ(status, miopenStatusSuccess);
|
|
std::string output = testing::internal::GetCapturedStderr();
|
|
EXPECT_THAT(output, testing::HasSubstr(" miopenGetTuningPolicy("));
|
|
}
|
|
|
|
TEST_F(CPU_TuningPolicy_NONE, TestSetApiLogged)
|
|
{
|
|
miopenTuningPolicy_t original_policy;
|
|
auto&& handle = get_handle();
|
|
|
|
auto status = miopenGetTuningPolicy(&handle, &original_policy);
|
|
ASSERT_EQ(status, miopenStatusSuccess);
|
|
|
|
{
|
|
ScopedEnvironment<std::string> enable_logging(MIOPEN_ENABLE_LOGGING, "ON");
|
|
|
|
testing::internal::CaptureStderr();
|
|
status = miopenSetTuningPolicy(&handle, miopenTuningPolicy_t::miopenTuningPolicySearch);
|
|
ASSERT_EQ(status, miopenStatusSuccess);
|
|
std::string output = testing::internal::GetCapturedStderr();
|
|
EXPECT_THAT(output, testing::HasSubstr(" miopenSetTuningPolicy("));
|
|
}
|
|
|
|
status = miopenSetTuningPolicy(&handle, original_policy);
|
|
ASSERT_EQ(status, miopenStatusSuccess);
|
|
}
|