Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc
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

103 lines
2.9 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include <hip_test_common.hh>
/**
* @addtogroup hipDeviceSetCacheConfig hipDeviceSetCacheConfig
* @{
* @ingroup DeviceTest
* `hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig)` -
* Set L1/Shared cache partition.
*/
namespace {
constexpr std::array<hipFuncCache_t, 4> kCacheConfigs{
hipFuncCachePreferNone, hipFuncCachePreferShared, hipFuncCachePreferL1,
hipFuncCachePreferEqual};
} // anonymous namespace
/**
* Test Description
* ------------------------
* - Check that `hipSuccess` is returned for all enumerators of `hipFuncCache_t`
* Test source
* ------------------------
* - unit/device/hipDeviceSetGetCacheConfig.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
HIP_TEST_CASE(Unit_hipDeviceSetCacheConfig_Positive_Basic) {
const auto device = GENERATE(range(0, HipTest::getDeviceCount()));
HIP_CHECK(hipSetDevice(device));
INFO("Current device is: " << device);
const auto cache_config =
GENERATE(from_range(std::begin(kCacheConfigs), std::end(kCacheConfigs)));
HIP_CHECK(hipDeviceSetCacheConfig(cache_config));
}
/**
* Test Description
* ------------------------
* - Verifies that hipDeviceSetCacheConfig with each cache config hint
* succeeds on carveout-capable devices and that a subsequent kernel
* launch (without per-function carveout) uses the device-level default
* without error.
* Test source
* ------------------------
* - unit/device/hipDeviceSetGetCacheConfig.cc
*/
__global__ void empty_kernel() {}
HIP_TEST_CASE(Unit_hipDeviceSetCacheConfig_Positive_Carveout) {
const auto cache_config =
GENERATE(from_range(std::begin(kCacheConfigs), std::end(kCacheConfigs)));
HIP_CHECK(hipDeviceSetCacheConfig(cache_config));
// Launch a kernel without per-function carveout to exercise the
// device-level carveout fallback path in the dispatch packet.
empty_kernel<<<1, 1>>>();
HIP_CHECK(hipDeviceSynchronize());
}
/**
* End doxygen group hipDeviceSetCacheConfig.
* @}
*/
/**
* @addtogroup hipDeviceGetCacheConfig hipDeviceGetCacheConfig
* @{
* @ingroup DeviceTest
* `hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig)` -
* Get Cache configuration for a specific Device.
*/
/**
* Test Description
* ------------------------
* - Check that default cache config is returned if set
* has not been called previously.
* Test source
* ------------------------
* - unit/device/hipDeviceSetGetCacheConfig.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
HIP_TEST_CASE(Unit_hipDeviceGetCacheConfig_Positive_Default) {
const auto device = GENERATE(range(0, HipTest::getDeviceCount()));
HIP_CHECK(hipSetDevice(device));
INFO("Current device is: " << device);
hipFuncCache_t cache_config;
HIP_CHECK(hipDeviceGetCacheConfig(&cache_config));
REQUIRE(cache_config == hipFuncCachePreferNone);
}