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
228 lines
9.1 KiB
C++
228 lines
9.1 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include "ContextFixture.hpp"
|
|
#include <rocRoller/Context.hpp>
|
|
#include <rocRoller/GPUArchitecture/GPUArchitectureLibrary.hpp>
|
|
#include <rocRoller/GPUArchitecture/GPUArchitectureTarget.hpp>
|
|
#include <rocRoller/Utilities/Utils.hpp>
|
|
|
|
#ifdef ROCROLLER_USE_HIP
|
|
#include <hip/hip_ext.h>
|
|
#include <hip/hip_runtime.h>
|
|
#endif /* ROCROLLER_USE_HIP */
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield every GPU ISA supported by rocRoller.
|
|
*
|
|
* Useful if you want to parameterize a test with combinations of each ISA with other
|
|
* parameters. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* ::testing::Combine(supportedISAValues(),
|
|
* ::testing::Values(1, 2, 4, 8, 12, 16, 20, 44)));
|
|
*/
|
|
inline auto supportedISAValues()
|
|
{
|
|
return ::testing::ValuesIn(
|
|
rocRoller::GPUArchitectureLibrary::getInstance()->getAllSupportedISAs());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield every CDNA GPU ISA supported by rocRoller.
|
|
*
|
|
* Useful if you want to parameterize a test with combinations of each ISA with other
|
|
* parameters. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* ::testing::Combine(CDNAISAValues(),
|
|
* ::testing::Values(1, 2, 4, 8, 12, 16, 20, 44)));
|
|
*/
|
|
inline auto CDNAISAValues()
|
|
{
|
|
return ::testing::ValuesIn(rocRoller::GPUArchitectureLibrary::getInstance()->getCDNAISAs());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield every GPU ISA supported by rocRoller, that
|
|
* has MFMA instructions.
|
|
*
|
|
* Useful if you want to parameterize a test with combinations of each ISA with other
|
|
* parameters. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* ::testing::Combine(mfmaSupportedISAValues(),
|
|
* ::testing::Values(1, 2, 4, 8, 12, 16, 20, 44)));
|
|
*/
|
|
inline auto mfmaSupportedISAValues()
|
|
{
|
|
return ::testing::ValuesIn(
|
|
rocRoller::GPUArchitectureLibrary::getInstance()->getMFMASupportedISAs());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield every GPU ISA supported by rocRoller, that
|
|
* has WMMA instructions.
|
|
*
|
|
* Useful if you want to parameterize a test with combinations of each ISA with other
|
|
* parameters. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* ::testing::Combine(wmmaSupportedISAValues(),
|
|
* ::testing::Values(1, 2, 4, 8, 12, 16, 20, 44)));
|
|
*/
|
|
inline auto wmmaSupportedISAValues()
|
|
{
|
|
return ::testing::ValuesIn(
|
|
rocRoller::GPUArchitectureLibrary::getInstance()->getWMMASupportedISAs());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield just the local GPU ISA.
|
|
*
|
|
* Useful if you want to parameterize a test with combinations of each ISA with other parameters. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* ::testing::Combine(currentGPUISA(),
|
|
* ::testing::Values(1, 2, 4, 8, 12, 16, 20, 44)));
|
|
*/
|
|
inline auto currentGPUISA()
|
|
{
|
|
if(rocRoller::GPUArchitectureLibrary::getInstance()->HasHipDevice())
|
|
{
|
|
auto currentDevice
|
|
= rocRoller::GPUArchitectureLibrary::getInstance()->GetDefaultHipDeviceArch();
|
|
return ::testing::Values(currentDevice.target());
|
|
}
|
|
else
|
|
{
|
|
// Give a dummy device
|
|
return ::testing::Values(
|
|
rocRoller::GPUArchitectureTarget{rocRoller::GPUArchitectureGFX::GFX90A});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield a single-item tuple for every GPU ISA supported by rocRoller.
|
|
*
|
|
* Useful if you want to parameterize a test with only each supported ISA. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* supportedISATuples());
|
|
*/
|
|
inline auto supportedISATuples()
|
|
{
|
|
return ::testing::Combine(supportedISAValues());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield a single-item tuple for CDNA GPU ISA supported by rocRoller.
|
|
*
|
|
* Useful if you want to parameterize a test with only each supported ISA. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* CDNAISATuples());
|
|
*/
|
|
inline auto CDNAISATuples()
|
|
{
|
|
return ::testing::Combine(CDNAISAValues());
|
|
}
|
|
|
|
/**
|
|
* Returns a (googletest) Generator that will yield a single-item tuple for every GPU ISA supported by rocRoller.
|
|
*
|
|
* Useful if you want to parameterize a test with only each supported ISA. Example:
|
|
* INSTANTIATE_TEST_SUITE_P(SuiteName,
|
|
* FixtureClass,
|
|
* mfmaSupportedISATuples());
|
|
*/
|
|
inline auto mfmaSupportedISATuples()
|
|
{
|
|
return ::testing::Combine(mfmaSupportedISAValues());
|
|
}
|
|
|
|
inline auto wmmaSupportedISATuples()
|
|
{
|
|
return ::testing::Combine(wmmaSupportedISAValues());
|
|
}
|
|
|
|
class BaseGPUContextFixture : public ContextFixture
|
|
{
|
|
protected:
|
|
void SetUp() override;
|
|
|
|
rocRoller::ContextPtr createContextLocalDevice();
|
|
rocRoller::ContextPtr createContextForArch(rocRoller::GPUArchitectureTarget const& device);
|
|
};
|
|
|
|
class CurrentGPUContextFixture : public BaseGPUContextFixture
|
|
{
|
|
protected:
|
|
virtual rocRoller::ContextPtr createContext() override;
|
|
};
|
|
|
|
template <typename... Ts>
|
|
class GPUContextFixtureParam
|
|
: public BaseGPUContextFixture,
|
|
public ::testing::WithParamInterface<std::tuple<rocRoller::GPUArchitectureTarget, Ts...>>
|
|
{
|
|
protected:
|
|
virtual rocRoller::ContextPtr createContext() override
|
|
{
|
|
rocRoller::GPUArchitectureTarget device = std::get<0>(this->GetParam());
|
|
return this->createContextForArch(device);
|
|
}
|
|
};
|
|
|
|
using GPUContextFixture = GPUContextFixtureParam<>;
|
|
|
|
#define REQUIRE_ARCH_CAP(cap) \
|
|
do \
|
|
{ \
|
|
if(!m_context->targetArchitecture().HasCapability(cap)) \
|
|
{ \
|
|
GTEST_SKIP() << m_context->targetArchitecture().target().toString() \
|
|
<< " has no capability " << cap << std::endl; \
|
|
} \
|
|
} while(0)
|
|
|
|
template <typename... Caps>
|
|
bool hasAnyOfTheseArchCaps(rocRoller::ContextPtr const context, Caps... caps)
|
|
{
|
|
static_assert(sizeof...(caps) > 0);
|
|
return (... || context->targetArchitecture().HasCapability(caps));
|
|
}
|
|
|
|
#define REQUIRE_ANY_OF_ARCH_CAP(...) \
|
|
do \
|
|
{ \
|
|
if(not hasAnyOfTheseArchCaps(m_context, __VA_ARGS__)) \
|
|
{ \
|
|
GTEST_SKIP() << m_context->targetArchitecture().target().toString() \
|
|
<< " has no capability " << concatenate_join(", ", __VA_ARGS__); \
|
|
} \
|
|
} while(0)
|
|
|
|
#define REQUIRE_NOT_ARCH_CAP(cap) \
|
|
do \
|
|
{ \
|
|
if(m_context->targetArchitecture().HasCapability(cap)) \
|
|
{ \
|
|
GTEST_SKIP() << m_context->targetArchitecture().target().toString() \
|
|
<< " has capability " << cap << std::endl; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define REQUIRE_ARCH_REVISION_ID(id) \
|
|
do \
|
|
{ \
|
|
int targetRevId = m_context->targetArchitecture().target().asicRevisionId; \
|
|
if(targetRevId != id) \
|
|
{ \
|
|
GTEST_SKIP() << "Test requires revision id " << id \
|
|
<< " but current gpu has revision id " << targetRevId << std::endl; \
|
|
} \
|
|
} while(0)
|