Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions projects/hip-tests/catch/unit/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ if(HIP_PLATFORM MATCHES "amd")
set(TEST_SRC
${TEST_SRC}
hipExtModuleLaunchKernel.cc
hipHccModuleLaunchKernel.cc
hipGetProcAddressModuleApis.cc)
hipHccModuleLaunchKernel.cc)

if(BUILD_SHARED_LIBS)
set(TEST_SRC
${TEST_SRC}
hipGetProcAddressModuleApis.cc)
endif()

add_custom_target(empty_module.code
COMMAND ${CMAKE_CXX_COMPILER} --genco ${OFFLOAD_ARCH_STR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_UniformWorkGroup") {

TEST_CASE("Unit_hipExtModuleLaunchKernel_Positive_Parameters") {
ModuleLaunchKernelPositiveParameters<hipExtModuleLaunchKernel>();

auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
SECTION("Pass only start event") {
hipEvent_t start_event = nullptr;
HIP_CHECK(hipEventCreate(&start_event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ THE SOFTWARE.
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Positive_Basic") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down Expand Up @@ -89,6 +90,7 @@ TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Positive_Basic") {
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Positive_Parameters") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down Expand Up @@ -124,6 +126,7 @@ TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Positive_Parameters") {
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernel_Negative_Parameters") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ THE SOFTWARE.
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernelMultiDevice_Positive_Basic") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down Expand Up @@ -106,6 +107,7 @@ TEST_CASE("Unit_hipModuleLaunchCooperativeKernelMultiDevice_Positive_Basic") {
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernelMultiDevice_Negative_Parameters") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down Expand Up @@ -229,6 +231,7 @@ TEST_CASE("Unit_hipModuleLaunchCooperativeKernelMultiDevice_Negative_Parameters"
* - HIP_VERSION >= 5.5
*/
TEST_CASE("Unit_hipModuleLaunchCooperativeKernelMultiDevice_Negative_MultiKernelSameDevice") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
if (!DeviceAttributesSupport(0, hipDeviceAttributeCooperativeLaunch)) {
HipTest::HIP_SKIP_TEST("CooperativeLaunch not supported");
return;
Expand Down
5 changes: 5 additions & 0 deletions projects/hip-tests/catch/unit/module/hip_module_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ ModuleGuard ModuleGuard::LoadModule(const char* fname) {
return ModuleGuard{module};
}

ModuleGuard ModuleGuard::InitModule(const char* fname) {
HIP_CHECK(hipFree(nullptr));
return LoadModule(fname);
}

ModuleGuard ModuleGuard::LoadModuleDataFile(const char* fname) {
const auto loaded_module = LoadModuleIntoBuffer(fname);
hipModule_t module = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions projects/hip-tests/catch/unit/module/hip_module_common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ModuleGuard {

static ModuleGuard LoadModule(const char* fname);

static ModuleGuard InitModule(const char* fname);

static ModuleGuard LoadModuleDataFile(const char* fname);

static ModuleGuard LoadModuleDataRTC(const char* code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ THE SOFTWARE.
#include <resource_guards.hh>
#include <utils.hh>

inline ModuleGuard InitModule() {
HIP_CHECK(hipFree(nullptr));
return ModuleGuard::LoadModule("launch_kernel_module.code");
}

inline ModuleGuard mg{InitModule()};

using ExtModuleLaunchKernelSig = hipError_t(hipFunction_t, uint32_t, uint32_t, uint32_t, uint32_t,
uint32_t, uint32_t, size_t, hipStream_t, void**, void**,
hipEvent_t, hipEvent_t, uint32_t);

template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelPositiveBasic() {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
SECTION("Kernel with no arguments") {
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
HIP_CHECK(func(f, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u));
Expand Down Expand Up @@ -81,6 +75,7 @@ template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelPositiveParamet
const auto LaunchNOPKernel = [=](unsigned int gridDimX, unsigned int gridDimY,
unsigned int gridDimZ, unsigned int blockDimX,
unsigned int blockDimY, unsigned int blockDimZ) {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
HIP_CHECK(func(f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, 0, nullptr,
nullptr, nullptr, nullptr, nullptr, 0u));
Expand Down Expand Up @@ -120,6 +115,7 @@ template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelPositiveParamet

template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelNegativeParameters(
bool extLaunch = false) {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
hipError_t expectedErrorLaunchParam = (extLaunch == true) ? hipErrorInvalidConfiguration
: hipErrorInvalidValue;
Expand Down Expand Up @@ -213,6 +209,7 @@ template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelNegativeParamet
}

SECTION("Passing kernel_args and extra simultaneously") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
hipFunction_t f = GetKernel(mg.module(), "Kernel42");
LinearAllocGuard<int> result_dev(LinearAllocs::hipMalloc, sizeof(int));
int* result_ptr = result_dev.ptr();
Expand Down Expand Up @@ -248,6 +245,7 @@ template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelNegativeParamet
}

SECTION("Invalid extra") {
auto mg = ModuleGuard::InitModule("launch_kernel_module.code");
hipFunction_t f = GetKernel(mg.module(), "Kernel42");
void* extra[0] = {};
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, extra, nullptr, nullptr, 0u),
Expand Down