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
116 lines
3.7 KiB
C++
116 lines
3.7 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip_test_common.hh>
|
|
#include <utils.hh>
|
|
|
|
HIP_TEST_CASE(Unit_hipKernelGetAttribute_Positive_Basic) {
|
|
hipStream_t stream;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
std::string lib_co = "reverse_kernel.code";
|
|
|
|
hipLibrary_t library;
|
|
hipKernel_t kernel;
|
|
|
|
HIP_CHECK(
|
|
hipLibraryLoadFromFile(&library, lib_co.data(), nullptr, nullptr, 0, nullptr, nullptr, 0));
|
|
HIP_CHECK(hipLibraryGetKernel(&kernel, library, "add_kernel"));
|
|
|
|
int pi;
|
|
int device_id = 0;
|
|
|
|
SECTION("binaryVersion") {
|
|
HIP_CHECK(hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_BINARY_VERSION, kernel, device_id));
|
|
const auto major = GetDeviceAttribute(hipDeviceAttributeComputeCapabilityMajor, 0);
|
|
const auto minor = GetDeviceAttribute(hipDeviceAttributeComputeCapabilityMinor, 0);
|
|
REQUIRE(pi == major * 10 + minor);
|
|
}
|
|
|
|
SECTION("cacheModeCA") {
|
|
HIP_CHECK(hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_CACHE_MODE_CA, kernel, device_id));
|
|
REQUIRE((pi == 0 || pi == 1));
|
|
}
|
|
|
|
SECTION("maxThreadsPerBlock") {
|
|
HIP_CHECK(
|
|
hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, kernel, device_id));
|
|
REQUIRE(pi == GetDeviceAttribute(hipDeviceAttributeMaxThreadsPerBlock, 0));
|
|
}
|
|
|
|
SECTION("numRegs") {
|
|
HIP_CHECK(hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_NUM_REGS, kernel, device_id));
|
|
REQUIRE(pi >= 0);
|
|
}
|
|
|
|
SECTION("ptxVersion") {
|
|
HIP_CHECK(hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_PTX_VERSION, kernel, device_id));
|
|
REQUIRE(pi > 0);
|
|
}
|
|
|
|
#if !defined(ENABLE_ADDRESS_SANITIZER)
|
|
SECTION("sharedSizeBytes") {
|
|
hipKernel_t kernel;
|
|
HIP_CHECK(hipLibraryGetKernel(&kernel, library, "reverse"));
|
|
HIP_CHECK(hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES, kernel, device_id));
|
|
REQUIRE(pi == 256);
|
|
}
|
|
#endif
|
|
|
|
SECTION("dynamicSharedSizeBytes") {
|
|
hipKernel_t addKernel;
|
|
HIP_CHECK(hipLibraryGetKernel(&addKernel, library, "add_kernel"));
|
|
int addKernelMaxDynamicSharedMemorySize;
|
|
HIP_CHECK(hipKernelGetAttribute(&addKernelMaxDynamicSharedMemorySize, HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, addKernel, device_id));
|
|
|
|
hipKernel_t reverseKernel;
|
|
HIP_CHECK(hipLibraryGetKernel(&reverseKernel, library, "reverse"));
|
|
int reverseKernelMaxDynamicSharedMemorySize;
|
|
HIP_CHECK(hipKernelGetAttribute(&reverseKernelMaxDynamicSharedMemorySize, HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, reverseKernel, device_id));
|
|
|
|
REQUIRE(addKernelMaxDynamicSharedMemorySize > reverseKernelMaxDynamicSharedMemorySize);
|
|
}
|
|
|
|
HIP_CHECK(hipLibraryUnload(library));
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipKernelGetAttribute_Negative_Parameters) {
|
|
hipStream_t stream;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
std::string lib_co = "library_code_load.code";
|
|
|
|
hipLibrary_t library;
|
|
hipKernel_t kernel;
|
|
|
|
HIP_CHECK(
|
|
hipLibraryLoadFromFile(&library, lib_co.data(), nullptr, nullptr, 0, nullptr, nullptr, 0));
|
|
HIP_CHECK(hipLibraryGetKernel(&kernel, library, "add_kernel"));
|
|
|
|
int pi;
|
|
int device_id = 0;
|
|
|
|
SECTION("pi == nullptr") {
|
|
HIP_CHECK_ERROR(
|
|
hipKernelGetAttribute(nullptr, HIP_FUNC_ATTRIBUTE_BINARY_VERSION, kernel, device_id),
|
|
hipErrorInvalidValue);
|
|
}
|
|
|
|
SECTION("invalid attribute") {
|
|
HIP_CHECK_ERROR(
|
|
hipKernelGetAttribute(&pi, static_cast<hipFunction_attribute>(-1), kernel, device_id),
|
|
hipErrorInvalidValue);
|
|
}
|
|
|
|
SECTION("kernel == nullptr") {
|
|
HIP_CHECK_ERROR(
|
|
hipKernelGetAttribute(&pi, HIP_FUNC_ATTRIBUTE_BINARY_VERSION, nullptr, device_id),
|
|
hipErrorInvalidHandle);
|
|
}
|
|
|
|
HIP_CHECK(hipLibraryUnload(library));
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
}
|