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
105 lines
3.4 KiB
C++
105 lines
3.4 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "hip_module_common.hh"
|
|
#include <hip_test_common.hh>
|
|
#include <hip_test_defgroups.hh>
|
|
/**
|
|
* @addtogroup hipModuleGetFunctionCount hipModuleGetFunctionCount
|
|
* @{
|
|
* @ingroup ModuleTest
|
|
* `hipError_t hipModuleGetFunctionCount (unsigned int* count, hipModule_t mod)`
|
|
* - Returns the number of functions within a module
|
|
*/
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test case verifies the below positive cases of hipModuleGetFunctionCount
|
|
* API.
|
|
* - Get the device count from different kinds of modules.
|
|
* 1. Module is built for Single architecture which contain Single global
|
|
* function
|
|
* 2. Module is built for multi architecture which contain Single global
|
|
* function
|
|
* 3. Empty Module which doesn't contain any function.
|
|
* 4. Module which contain both __global__, __device__ functions in it.
|
|
* 5. RTC module.
|
|
* Test source
|
|
* ------------------------
|
|
* - catch/unit/module/hipModuleGetFunctionCount.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 7.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipModuleGetFunctionCount_Functional) {
|
|
CTX_CREATE();
|
|
hipModule_t moduleSingleArch, moduleEmpty, doubleKernelModule, rtcModule;
|
|
unsigned int count = 0;
|
|
SECTION("Single arch, Single global function") {
|
|
HIP_CHECK(hipModuleLoad(&moduleSingleArch, "vcpy_kernel.code"));
|
|
HIP_CHECK(hipModuleGetFunctionCount(&count, moduleSingleArch));
|
|
REQUIRE(count == 1);
|
|
HIP_CHECK(hipModuleUnload(moduleSingleArch));
|
|
}
|
|
#if HT_AMD
|
|
SECTION("Multi arch, Single global function") {
|
|
hipModule_t moduleMultiArch;
|
|
const auto loaded_module =
|
|
LoadModuleIntoBuffer("copyKernelCompressed.code");
|
|
HIP_CHECK(hipModuleLoadData(&moduleMultiArch, loaded_module.data()));
|
|
HIP_CHECK(hipModuleGetFunctionCount(&count, moduleMultiArch));
|
|
REQUIRE(count == 1);
|
|
HIP_CHECK(hipModuleUnload(moduleMultiArch));
|
|
}
|
|
#endif
|
|
SECTION("Empty Module Count") {
|
|
HIP_CHECK(hipModuleLoad(&moduleEmpty, "emptyModuleCount.code"));
|
|
HIP_CHECK(hipModuleGetFunctionCount(&count, moduleEmpty));
|
|
REQUIRE(count == 0);
|
|
HIP_CHECK(hipModuleUnload(moduleEmpty));
|
|
}
|
|
SECTION("__global__, __device__ functions module") {
|
|
HIP_CHECK(hipModuleLoad(&doubleKernelModule, "kernel_count.code"));
|
|
HIP_CHECK(hipModuleGetFunctionCount(&count, doubleKernelModule));
|
|
REQUIRE(count == 1);
|
|
HIP_CHECK(hipModuleUnload(doubleKernelModule));
|
|
}
|
|
|
|
SECTION("Load RTCd module") {
|
|
const auto rtc =
|
|
CreateRTCCharArray(R"(extern "C" __global__ void kernel() {})");
|
|
HIP_CHECK(hipModuleLoadData(&rtcModule, rtc.data()));
|
|
REQUIRE(rtcModule != nullptr);
|
|
HIP_CHECK(hipModuleGetFunctionCount(&count, rtcModule));
|
|
REQUIRE(count == 1);
|
|
HIP_CHECK(hipModuleUnload(rtcModule));
|
|
}
|
|
CTX_DESTROY();
|
|
}
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test case verifies the negative case of hipModuleGetFunctionCount API.
|
|
* Test source
|
|
* ------------------------
|
|
* - catch/unit/module/hipModuleGetFunctionCount.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 7.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipModuleGetFunctionCount_NegativeTsts) {
|
|
unsigned int count = 0;
|
|
SECTION("Input module as nullptr") {
|
|
HIP_CHECK_ERROR(hipModuleGetFunctionCount(&count, nullptr),
|
|
hipErrorInvalidHandle);
|
|
}
|
|
}
|
|
/**
|
|
* End doxygen group ModuleTest.
|
|
* @}
|
|
*/
|