Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/module/hipHccModuleLaunchKernel.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

133 lines
4.8 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
/**
* @addtogroup hipHccModuleLaunchKernel hipHccModuleLaunchKernel
* @{
* @ingroup KernelTest
* `HIP_PUBLIC_API hipError_t hipHccModuleLaunchKernel (hipFunction_t f,
* uint32_t globalWorkSizeX,
* uint32_t globalWorkSizeY,
* uint32_t globalWorkSizeZ,
* uint32_t localWorkSizeX,
* uint32_t localWorkSizeY,
* uint32_t localWorkSizeZ,
* size_t sharedMemBytes,
* hipStream_t hStream,
* void ** kernelParams,
* void ** extra,
* hipEvent_t startEvent,
* hipEvent_t stopEvent )` -
* This HIP API is deprecated, please use hipExtModuleLaunchKernel() instead.
* Launches kernel with parameters and shared memory on stream with arguments
* passed to kernel params or extra arguments.
*/
#include <hip_test_common.hh>
#include "hip/hip_ext.h"
#define fileName "copyKernel.code"
#define kernel_name "copy_ker"
/**
* Test Description
* ------------------------
* - Basic functional testcase to verify kernel launch
* Test source
* ------------------------
* - catch\unit\module\hipHccModuleLaunchKernel.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
HIP_TEST_CASE(Unit_hipHccModuleLaunchKernel_basic) {
size_t width = GENERATE(3, 4, 100);
size_t widthInBytes = width * sizeof(int);
int *A_d, *B_d;
int* A_h = reinterpret_cast<int*>(malloc(widthInBytes));
int* B_h = reinterpret_cast<int*>(malloc(widthInBytes));
for (int i = 0; i < width; i++) {
A_h[i] = i;
}
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&A_d), widthInBytes));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&B_d), widthInBytes));
void* kernelArgs[3] = {&A_d, &B_d, &widthInBytes};
HIP_CHECK(hipMemcpyHtoD((hipDeviceptr_t)A_d, A_h, widthInBytes));
hipModule_t module;
HIP_CHECK(hipModuleLoad(&module, fileName));
hipFunction_t kernelFunc;
HIP_CHECK(hipModuleGetFunction(&kernelFunc, module, kernel_name));
HIP_CHECK(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, width, 1, 1, 0, 0, kernelArgs,
nullptr, nullptr, nullptr));
HIP_CHECK(hipMemcpyDtoH(B_h, (hipDeviceptr_t)B_d, widthInBytes));
for (int i = 0; i < width; i++) {
REQUIRE(A_h[i] == B_h[i]);
}
HIP_CHECK(hipModuleUnload(module));
HIP_CHECK(hipFree(A_d));
HIP_CHECK(hipFree(B_d));
free(A_h);
free(B_h);
}
/**
* Test Description
* ------------------------
* - Negative testcases
* Test source
* ------------------------
* - catch\unit\module\hipHccModuleLaunchKernel.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
HIP_TEST_CASE(Unit_hipHccModuleLaunchKernel_NegTst) {
size_t width = GENERATE(3, 4, 100);
size_t widthInBytes = width * sizeof(int);
int *A_d, *B_d;
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&A_d), widthInBytes));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&B_d), widthInBytes));
void* kernelArgs[3] = {&A_d, &B_d, &widthInBytes};
hipModule_t module;
HIP_CHECK(hipModuleLoad(&module, fileName));
hipFunction_t kernelFunc;
HIP_CHECK(hipModuleGetFunction(&kernelFunc, module, kernel_name));
SECTION("nullptr to f(first argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(nullptr, width, 1, 1, width, 1, 1, 0, 0, kernelArgs,
nullptr, nullptr, nullptr),
hipErrorInvalidHandle);
}
SECTION("-1 to localWorkSizeX(fifth argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, -1, 1, 1, 0, 0, kernelArgs,
nullptr, nullptr, nullptr),
hipErrorInvalidConfiguration);
}
SECTION("-1 to localWorkSizeY(sixth argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, width, -1, 1, 0, 0,
kernelArgs, nullptr, nullptr, nullptr),
hipErrorInvalidConfiguration);
}
SECTION("-1 to localWorkSizeZ(seventh argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, width, 1, -1, 0, 0,
kernelArgs, nullptr, nullptr, nullptr),
hipErrorInvalidConfiguration);
}
SECTION("-1 to sharedMemBytes(eighth argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, width, 1, 1, -1, 0,
kernelArgs, nullptr, nullptr, nullptr),
hipErrorInvalidValue);
}
SECTION("nullptr to kernelParams(10th argument)") {
HIP_CHECK_ERROR(hipHccModuleLaunchKernel(kernelFunc, width, 1, 1, width, 1, 1, 0, 0, nullptr,
nullptr, nullptr, nullptr),
hipErrorInvalidValue);
}
HIP_CHECK(hipModuleUnload(module));
HIP_CHECK(hipFree(A_d));
HIP_CHECK(hipFree(B_d));
}