SWDEV-1 - Merge github PRs to amd-staging
- https://github.com/ROCm/hip-tests/pull/119
- https://github.com/ROCm/hip-tests/pull/151
- https://github.com/ROCm/hip-tests/pull/57
- https://github.com/ROCm/hip-tests/pull/58
- https://github.com/ROCm/hip-tests/pull/59
- https://github.com/ROCm/hip-tests/pull/60
- https://github.com/ROCm/hip-tests/pull/99
- https://github.com/ROCm/hip-tests/pull/139
- https://github.com/ROCm/hip-tests/pull/152
- https://github.com/ROCm/hip-tests/pull/48
- https://github.com/ROCm/hip-tests/pull/54
- https://github.com/ROCm/hip-tests/pull/53
- https://github.com/ROCm/hip-tests/pull/24
- https://github.com/ROCm/hip-tests/pull/23
- https://github.com/ROCm/hip-tests/pull/22
- https://github.com/ROCm/hip-tests/pull/21
- https://github.com/ROCm/hip-tests/pull/20
- https://github.com/ROCm/hip-tests/pull/14
- https://github.com/ROCm/hip-tests/pull/8
Change-Id: I1eea54cd1436f3ddbfd5c1b3b2f672eb81d03cd4
[ROCm/hip-tests commit: 96df1fde80]
This commit is contained in:
@@ -19,14 +19,61 @@
|
||||
# SOFTWARE.
|
||||
|
||||
# Common Tests - Test independent of all platforms
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
set(TEST_SRC
|
||||
hipExtModuleLaunchKernel.cc
|
||||
hip_module_common.cc
|
||||
hipModuleLoad.cc
|
||||
hipModuleLoadData.cc
|
||||
hipModuleLoadDataEx.cc
|
||||
hipModuleUnload.cc
|
||||
hipModuleGetFunction.cc
|
||||
hipModuleLaunchKernel.cc
|
||||
hipModuleGetGlobal.cc
|
||||
hipModuleGetTexRef.cc
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_function_module.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/get_function_module.cc
|
||||
-o get_function_module.code
|
||||
-I${ROCM_PATH}/include/ --rocm-path=${ROCM_PATH}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/get_function_module.cc)
|
||||
add_custom_target(get_function_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/get_function_module.code)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/launch_kernel_module.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/launch_kernel_module.cc
|
||||
-o launch_kernel_module.code
|
||||
-I${ROCM_PATH}/include/ --rocm-path=${ROCM_PATH}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/launch_kernel_module.cc)
|
||||
add_custom_target(launch_kernel_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/launch_kernel_module.code)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_global_test_module.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/get_global_test_module.cc
|
||||
-o get_global_test_module.code
|
||||
-I${ROCM_PATH}/include/ --rocm-path=${ROCM_PATH}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/get_global_test_module.cc)
|
||||
add_custom_target(get_global_test_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/get_global_test_module.code)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/get_tex_ref_module.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/get_tex_ref_module.cc
|
||||
-o get_tex_ref_module.code
|
||||
-I${ROCM_PATH}/include/ --rocm-path=${ROCM_PATH}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/get_tex_ref_module.cc)
|
||||
add_custom_target(get_tex_ref_module ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/get_tex_ref_module.code)
|
||||
|
||||
# Note to pass arch use format like -DOFFLOAD_ARCH_STR="--offload-arch=gfx900 --offload-arch=gfx906"
|
||||
# having space at the start/end of OFFLOAD_ARCH_STR can cause build failures
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
set(TEST_SRC
|
||||
${TEST_SRC}
|
||||
hipExtModuleLaunchKernel.cc)
|
||||
|
||||
add_custom_target(empty_module.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} --genco ${OFFLOAD_ARCH_STR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/empty_module.cc
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/../../unit/module/empty_module.code
|
||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../../../../include/
|
||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include --rocm-path=${ROCM_PATH})
|
||||
|
||||
add_custom_target(copyKernel.code
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -mcode-object-version=5 --genco ${OFFLOAD_ARCH_STR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/copyKernel.cc
|
||||
@@ -100,14 +147,30 @@ add_custom_target(copiousArgKernel17.code
|
||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../../../../include/
|
||||
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include --rocm-path=${ROCM_PATH})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
set(RTCLIB "hiprtc")
|
||||
else()
|
||||
set(RTCLIB "nvrtc")
|
||||
endif()
|
||||
hip_add_exe_to_target(NAME ModuleTest
|
||||
TEST_SRC ${TEST_SRC}
|
||||
TEST_TARGET_NAME build_tests COMMON_SHARED_SRC ${COMMON_SHARED_SRC})
|
||||
TEST_TARGET_NAME build_tests
|
||||
LINKER_LIBS ${RTCLIB}
|
||||
COMMON_SHARED_SRC ${COMMON_SHARED_SRC}
|
||||
COMPILE_OPTIONS -std=c++17)
|
||||
|
||||
add_dependencies(ModuleTest get_function_module)
|
||||
add_dependencies(ModuleTest launch_kernel_module)
|
||||
add_dependencies(ModuleTest get_global_test_module)
|
||||
add_dependencies(ModuleTest get_tex_ref_module)
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
add_dependencies(build_tests empty_module.code)
|
||||
add_dependencies(build_tests copyKernel.code copyKernel.s)
|
||||
if(UNIX)
|
||||
add_dependencies(build_tests copiousArgKernel.code copiousArgKernel0.code copiousArgKernel1.code copiousArgKernel2.code
|
||||
copiousArgKernel3.code copiousArgKernel16.code copiousArgKernel17.code)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
extern "C" {
|
||||
__global__ void GlobalKernel() {}
|
||||
|
||||
__device__ void DeviceKernel() {}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip/hip_runtime.h"
|
||||
#include "hip/hip_runtime_api.h"
|
||||
|
||||
#include "hipModuleGetGlobal.hh"
|
||||
|
||||
#define HIP_MODULE_GET_GLOBAL_TEST_DEFINE_DEVICE_GLOBALS(type) \
|
||||
__device__ type type##_var = 0; \
|
||||
__device__ type type##_arr[kArraySize] = {}; \
|
||||
extern "C" { \
|
||||
__global__ void type##_var_address_validation_kernel(void* ptr, bool* out) { \
|
||||
*out = static_cast<void*>(&type##_var) == ptr; \
|
||||
} \
|
||||
__global__ void type##_arr_address_validation_kernel(void* ptr, bool* out) { \
|
||||
*out = static_cast<void*>(type##_arr) == ptr; \
|
||||
} \
|
||||
}
|
||||
|
||||
HIP_MODULE_GET_GLOBAL_TEST_DEFINE_DEVICE_GLOBALS(int)
|
||||
HIP_MODULE_GET_GLOBAL_TEST_DEFINE_DEVICE_GLOBALS(float)
|
||||
HIP_MODULE_GET_GLOBAL_TEST_DEFINE_DEVICE_GLOBALS(char)
|
||||
HIP_MODULE_GET_GLOBAL_TEST_DEFINE_DEVICE_GLOBALS(double)
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
#if CUDA_VERSION < CUDA_12000
|
||||
|
||||
texture<float, 2> tex;
|
||||
|
||||
#endif // CUDA_VERSION < CUDA_12000
|
||||
@@ -50,6 +50,8 @@ THE SOFTWARE.
|
||||
#include "hip/hip_ext.h"
|
||||
#include <regex> // NOLINT
|
||||
|
||||
#include "hip_module_launch_kernel_common.hh"
|
||||
|
||||
static constexpr auto totalWorkGroups{1024};
|
||||
static constexpr auto localWorkSize{512};
|
||||
static constexpr auto lastWorkSizeEven{256};
|
||||
@@ -69,7 +71,7 @@ static bool searchRegExpr(const std::regex& expr, const char* filename) {
|
||||
assemblyfile.seekg(0, assemblyfile.end);
|
||||
int len = assemblyfile.tellg();
|
||||
assemblyfile.seekg(0, assemblyfile.beg);
|
||||
char *fbuf = new char[len + 1];
|
||||
char* fbuf = new char[len + 1];
|
||||
assemblyfile.read(fbuf, len);
|
||||
fbuf[len] = '\0';
|
||||
|
||||
@@ -124,8 +126,7 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_NonUniformWorkGroup") {
|
||||
auto isEven = GENERATE(0, 1);
|
||||
// Calculate size
|
||||
auto lastWorkSize = isEven ? lastWorkSizeEven : lastWorkSizeOdd;
|
||||
size_t arraylength =
|
||||
(totalWorkGroups - 1)*localWorkSize + lastWorkSize;
|
||||
size_t arraylength = (totalWorkGroups - 1) * localWorkSize + lastWorkSize;
|
||||
size_t sizeBytes{arraylength * sizeof(int)};
|
||||
// Get module and function from module
|
||||
hipModule_t Module;
|
||||
@@ -133,9 +134,9 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_NonUniformWorkGroup") {
|
||||
HIP_CHECK(hipModuleLoad(&Module, fileName));
|
||||
HIP_CHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
// Allocate resources
|
||||
int *A = new int[arraylength];
|
||||
int* A = new int[arraylength];
|
||||
REQUIRE(A != nullptr);
|
||||
int *B = new int[arraylength];
|
||||
int* B = new int[arraylength];
|
||||
REQUIRE(B != nullptr);
|
||||
// Inititialize data
|
||||
for (size_t i = 0; i < arraylength; i++) {
|
||||
@@ -155,14 +156,13 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_NonUniformWorkGroup") {
|
||||
args.buffersize = arraylength;
|
||||
size_t size = sizeof(args);
|
||||
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
// Memcpy from A to Ad
|
||||
HIP_CHECK(hipMemcpy(Ad, A, sizeBytes, hipMemcpyDefault));
|
||||
REQUIRE(hipErrorInvalidValue == hipExtModuleLaunchKernel(Function,
|
||||
arraylength, 1, 1, localWorkSize, 1, 1, 0, 0, NULL,
|
||||
reinterpret_cast<void**>(&config), 0));
|
||||
REQUIRE(hipErrorInvalidValue ==
|
||||
hipExtModuleLaunchKernel(Function, arraylength, 1, 1, localWorkSize, 1, 1, 0, 0, NULL,
|
||||
reinterpret_cast<void**>(&config), 0));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipFree(Ad));
|
||||
HIP_CHECK(hipFree(Bd));
|
||||
@@ -194,9 +194,9 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_UniformWorkGroup") {
|
||||
HIP_CHECK(hipModuleLoad(&Module, fileName));
|
||||
HIP_CHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
// Allocate resources
|
||||
int *A = new int[arraylength];
|
||||
int* A = new int[arraylength];
|
||||
REQUIRE(A != nullptr);
|
||||
int *B = new int[arraylength];
|
||||
int* B = new int[arraylength];
|
||||
REQUIRE(B != nullptr);
|
||||
// Inititialize data
|
||||
for (size_t i = 0; i < arraylength; i++) {
|
||||
@@ -216,14 +216,12 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_UniformWorkGroup") {
|
||||
args.buffersize = arraylength;
|
||||
size_t size = sizeof(args);
|
||||
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
// Memcpy from A to Ad
|
||||
HIP_CHECK(hipMemcpy(Ad, A, sizeBytes, hipMemcpyDefault));
|
||||
HIP_CHECK(hipExtModuleLaunchKernel(Function, arraylength, 1, 1,
|
||||
localWorkSize, 1, 1, 0, 0, NULL,
|
||||
reinterpret_cast<void**>(&config), 0));
|
||||
HIP_CHECK(hipExtModuleLaunchKernel(Function, arraylength, 1, 1, localWorkSize, 1, 1, 0, 0, NULL,
|
||||
reinterpret_cast<void**>(&config), 0));
|
||||
// Memcpy results back to host
|
||||
HIP_CHECK(hipMemcpy(B, Bd, sizeBytes, hipMemcpyDefault));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
@@ -237,3 +235,53 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_UniformWorkGroup") {
|
||||
delete[] B;
|
||||
HIP_CHECK(hipModuleUnload(Module));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipExtModuleLaunchKernel_Positive_Basic") {
|
||||
ModuleLaunchKernelPositiveBasic<hipExtModuleLaunchKernel>();
|
||||
|
||||
SECTION("Timed kernel launch with events") {
|
||||
hipEvent_t start_event = nullptr, stop_event = nullptr;
|
||||
HIP_CHECK(hipEventCreate(&start_event));
|
||||
HIP_CHECK(hipEventCreate(&stop_event));
|
||||
const auto kernel = GetKernel(mg.module(), "Delay");
|
||||
int clock_rate = 0;
|
||||
HIP_CHECK(hipDeviceGetAttribute(&clock_rate, hipDeviceAttributeClockRate, 0));
|
||||
uint32_t interval = 100;
|
||||
uint32_t ticks_per_second = clock_rate;
|
||||
void* kernel_params[2] = {&interval, &ticks_per_second};
|
||||
HIP_CHECK(hipExtModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, kernel_params, nullptr,
|
||||
start_event, stop_event));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
auto elapsed = 0.0f;
|
||||
HIP_CHECK(hipEventElapsedTime(&elapsed, start_event, stop_event));
|
||||
REQUIRE(static_cast<uint32_t>(elapsed) >= interval);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipExtModuleLaunchKernel_Positive_Parameters") {
|
||||
ModuleLaunchKernelPositiveParameters<hipExtModuleLaunchKernel>();
|
||||
|
||||
SECTION("Pass only start event") {
|
||||
hipEvent_t start_event = nullptr;
|
||||
HIP_CHECK(hipEventCreate(&start_event));
|
||||
const auto kernel = GetKernel(mg.module(), "NOPKernel");
|
||||
HIP_CHECK(hipExtModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr,
|
||||
start_event, nullptr));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipEventQuery(start_event));
|
||||
}
|
||||
|
||||
SECTION("Pass only stop event") {
|
||||
hipEvent_t stop_event = nullptr;
|
||||
HIP_CHECK(hipEventCreate(&stop_event));
|
||||
const auto kernel = GetKernel(mg.module(), "NOPKernel");
|
||||
HIP_CHECK(hipExtModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr,
|
||||
nullptr, stop_event));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
HIP_CHECK(hipEventQuery(stop_event));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipExtModuleLaunchKernel_Negative_Parameters") {
|
||||
ModuleLaunchKernelNegativeParameters<hipExtModuleLaunchKernel>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
static hipModule_t GetModule() {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
static const auto mg = ModuleGuard::LoadModule("get_function_module.code");
|
||||
return mg.module();
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetFunction_Positive_Basic") {
|
||||
hipFunction_t kernel = nullptr;
|
||||
HIP_CHECK(hipModuleGetFunction(&kernel, GetModule(), "GlobalKernel"));
|
||||
REQUIRE(kernel != nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetFunction_Negative_Parameters") {
|
||||
hipFunction_t kernel = nullptr;
|
||||
|
||||
SECTION("function == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(nullptr, GetModule(), "GlobalKernel"),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-154
|
||||
#if HT_NVIDIA
|
||||
SECTION("module == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(&kernel, nullptr, "GlobalKernel"),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("kname == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(&kernel, GetModule(), nullptr), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-155
|
||||
#if HT_NVIDIA
|
||||
SECTION("kname == empty string") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(&kernel, GetModule(), ""), hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("kname == non existent kernel") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(&kernel, GetModule(), "NonExistentKernel"),
|
||||
hipErrorNotFound);
|
||||
}
|
||||
|
||||
SECTION("kname == __device__ kernel") {
|
||||
HIP_CHECK_ERROR(hipModuleGetFunction(&kernel, GetModule(), "DeviceKernel"), hipErrorNotFound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <resource_guards.hh>
|
||||
#include <utils.hh>
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
#include "hipModuleGetGlobal.hh"
|
||||
|
||||
template <typename T, size_t N>
|
||||
static void HipModuleGetGlobalTest(hipModule_t module, const std::string global_name) {
|
||||
constexpr auto size = N * sizeof(T);
|
||||
|
||||
hipDeviceptr_t global;
|
||||
size_t global_size = 0;
|
||||
HIP_CHECK(hipModuleGetGlobal(&global, &global_size, module, global_name.c_str()));
|
||||
REQUIRE(global != 0);
|
||||
REQUIRE(size == global_size);
|
||||
|
||||
hipFunction_t kernel = nullptr;
|
||||
const auto kernel_name = global_name + "_address_validation_kernel";
|
||||
HIP_CHECK(hipModuleGetFunction(&kernel, module, kernel_name.c_str()));
|
||||
LinearAllocGuard<bool> equal_addresses(LinearAllocs::hipMalloc, sizeof(bool));
|
||||
HIP_CHECK(hipMemset(equal_addresses.ptr(), false, sizeof(*equal_addresses.ptr())));
|
||||
bool* equal_addresses_ptr = equal_addresses.ptr();
|
||||
void* kernel_args[2] = {&global, &equal_addresses_ptr};
|
||||
HIP_CHECK(hipModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, nullptr, kernel_args, nullptr));
|
||||
HIP_CHECK(hipGetLastError());
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
bool ok;
|
||||
HIP_CHECK(hipMemcpy(&ok, equal_addresses_ptr, sizeof(ok), hipMemcpyDeviceToHost));
|
||||
REQUIRE(ok);
|
||||
|
||||
constexpr T expected_value = 42;
|
||||
std::array<T, N> fill_buffer;
|
||||
std::fill_n(fill_buffer.begin(), N, expected_value);
|
||||
HIP_CHECK(hipMemcpyHtoD(global, fill_buffer.data(), size));
|
||||
|
||||
|
||||
std::array<T, N> read_buffer;
|
||||
HIP_CHECK(hipMemcpyDtoH(read_buffer.data(), global, size));
|
||||
ArrayFindIfNot(read_buffer.data(), expected_value, read_buffer.size());
|
||||
}
|
||||
|
||||
#define HIP_MODULE_GET_GLOBAL_S(expr) #expr
|
||||
#define HIP_MODULE_GET_GLOBAL_TEST(type, module) \
|
||||
SECTION("array") { \
|
||||
HipModuleGetGlobalTest<type, kArraySize>(module, HIP_MODULE_GET_GLOBAL_S(type##_arr)); \
|
||||
} \
|
||||
SECTION("scalar") { \
|
||||
HipModuleGetGlobalTest<type, 1>(module, HIP_MODULE_GET_GLOBAL_S(type##_var)); \
|
||||
}
|
||||
|
||||
static inline hipModule_t GetModule() {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
const static auto mg = ModuleGuard::LoadModule("get_global_test_module.code");
|
||||
return mg.module();
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Positive_Basic") {
|
||||
hipModule_t module = GetModule();
|
||||
|
||||
SECTION("int") { HIP_MODULE_GET_GLOBAL_TEST(int, module); }
|
||||
|
||||
SECTION("float") { HIP_MODULE_GET_GLOBAL_TEST(float, module); }
|
||||
|
||||
SECTION("char") { HIP_MODULE_GET_GLOBAL_TEST(char, module); }
|
||||
|
||||
SECTION("double") { HIP_MODULE_GET_GLOBAL_TEST(double, module); }
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Positive_Parameters") {
|
||||
hipModule_t module = GetModule();
|
||||
hipDeviceptr_t global = 0;
|
||||
size_t global_size = 0;
|
||||
|
||||
SECTION("dptr == nullptr") {
|
||||
HIP_CHECK(hipModuleGetGlobal(nullptr, &global_size, module, "int_var"));
|
||||
}
|
||||
|
||||
SECTION("bytes == nullptr") {
|
||||
HIP_CHECK(hipModuleGetGlobal(&global, nullptr, module, "int_var"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Negative_Parameters") {
|
||||
hipModule_t module = GetModule();
|
||||
hipDeviceptr_t global = 0;
|
||||
size_t global_size = 0;
|
||||
|
||||
SECTION("name == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetGlobal(&global, &global_size, module, nullptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("name == invalid name") {
|
||||
HIP_CHECK_ERROR(hipModuleGetGlobal(&global, &global_size, module, "dummy"), hipErrorNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Negative_Hmod_Is_Nullptr") {
|
||||
hipDeviceptr_t global = 0;
|
||||
size_t global_size = 0;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleGetGlobal(&global, &global_size, nullptr, "int_var"),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Negative_Name_Is_Empty_String") {
|
||||
hipModule_t module = GetModule();
|
||||
hipDeviceptr_t global = 0;
|
||||
size_t global_size = 0;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleGetGlobal(&global, &global_size, module, ""), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetGlobal_Negative_Dptr_And_Bytes_Are_Nullptr") {
|
||||
hipModule_t module = GetModule();
|
||||
HIP_CHECK_ERROR(hipModuleGetGlobal(nullptr, nullptr, module, "int_var"), hipErrorInvalidValue);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace {
|
||||
constexpr size_t kArraySize = 5;
|
||||
} // anonymous namespace
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
static hipModule_t GetModule() {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
static const auto mg = ModuleGuard::LoadModule("get_tex_ref_module.code");
|
||||
return mg.module();
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetTexRef_Positive_Basic") {
|
||||
hipTexRef tex_ref = nullptr;
|
||||
HIP_CHECK(hipModuleGetTexRef(&tex_ref, GetModule(), "tex"));
|
||||
REQUIRE(tex_ref != nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetTexRef_Negative_Parameters") {
|
||||
hipModule_t module = GetModule();
|
||||
hipTexRef tex_ref = nullptr;
|
||||
|
||||
SECTION("texRef == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetTexRef(nullptr, module, "tex"), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("name == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, nullptr), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("name == non existent texture") {
|
||||
HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, "non_existent_texture"), hipErrorNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetTexRef_Negative_Hmod_Is_Nullptr") {
|
||||
hipTexRef tex_ref = nullptr;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, nullptr, "tex"), hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleGetTexRef_Negative_Name_Is_Empty_String") {
|
||||
hipModule_t module = GetModule();
|
||||
hipTexRef tex_ref = nullptr;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleGetTexRef(&tex_ref, module, ""), hipErrorInvalidValue);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_launch_kernel_common.hh"
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
static hipError_t hipModuleLaunchKernelWrapper(hipFunction_t f, uint32_t gridX, uint32_t gridY,
|
||||
uint32_t gridZ, uint32_t blockX, uint32_t blockY,
|
||||
uint32_t blockZ, size_t sharedMemBytes,
|
||||
hipStream_t hStream, void** kernelParams,
|
||||
void** extra, hipEvent_t, hipEvent_t, uint32_t) {
|
||||
return hipModuleLaunchKernel(f, gridX, gridY, gridZ, blockX, blockY, blockZ, sharedMemBytes,
|
||||
hStream, kernelParams, extra);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLaunchKernel_Positive_Basic") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
ModuleLaunchKernelPositiveBasic<hipModuleLaunchKernelWrapper>();
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLaunchKernel_Positive_Parameters") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
ModuleLaunchKernelPositiveParameters<hipModuleLaunchKernelWrapper>();
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLaunchKernel_Negative_Parameters") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
ModuleLaunchKernelNegativeParameters<hipModuleLaunchKernelWrapper>();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoad_Positive_Basic") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module = nullptr;
|
||||
HIP_CHECK(hipModuleLoad(&module, "empty_module.code"));
|
||||
REQUIRE(module != nullptr);
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoad_Negative_Parameters") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module;
|
||||
|
||||
SECTION("module == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleLoad(nullptr, "empty_module.code"), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("fname == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleLoad(&module, nullptr), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("fname == empty string") {
|
||||
HIP_CHECK_ERROR(hipModuleLoad(&module, ""), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("fname == non existent file") {
|
||||
HIP_CHECK_ERROR(hipModuleLoad(&module, "non existent file"), hipErrorFileNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoad_Negative_Load_From_A_File_That_Is_Not_A_Module") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleLoad(&module, "not_a_module.txt"), hipErrorInvalidImage);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadData_Positive_Basic") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module = nullptr;
|
||||
|
||||
SECTION("Load compiled module from file") {
|
||||
const auto loaded_module = LoadModuleIntoBuffer("empty_module.code");
|
||||
HIP_CHECK(hipModuleLoadData(&module, loaded_module.data()));
|
||||
REQUIRE(module != nullptr);
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
}
|
||||
|
||||
SECTION("Load RTCd module") {
|
||||
const auto rtc = CreateRTCCharArray(R"(extern "C" __global__ void kernel() {})");
|
||||
HIP_CHECK(hipModuleLoadData(&module, rtc.data()));
|
||||
REQUIRE(module != nullptr);
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadData_Negative_Parameters") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module;
|
||||
|
||||
SECTION("module == nullptr") {
|
||||
const auto loaded_module = LoadModuleIntoBuffer("empty_module.code");
|
||||
HIP_CHECK_ERROR(hipModuleLoadData(nullptr, loaded_module.data()), hipErrorInvalidValue);
|
||||
LoadModuleIntoBuffer("empty_module.code");
|
||||
}
|
||||
|
||||
SECTION("image == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleLoadData(&module, nullptr), hipErrorInvalidValue);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadData_Negative_Image_Is_An_Empty_String") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleLoadData(&module, ""), hipErrorInvalidImage);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadDataEx_Positive_Basic") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module = nullptr;
|
||||
|
||||
SECTION("Load compiled module from file") {
|
||||
const auto loaded_module = LoadModuleIntoBuffer("empty_module.code");
|
||||
HIP_CHECK(hipModuleLoadDataEx(&module, loaded_module.data(), 0, nullptr, nullptr));
|
||||
REQUIRE(module != nullptr);
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
}
|
||||
|
||||
SECTION("Load RTCd module") {
|
||||
const auto rtc = CreateRTCCharArray(R"(extern "C" __global__ void kernel() {})");
|
||||
HIP_CHECK(hipModuleLoadDataEx(&module, rtc.data(), 0, nullptr, nullptr));
|
||||
REQUIRE(module != nullptr);
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadDataEx_Negative_Parameters") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module = nullptr;
|
||||
|
||||
SECTION("module == nullptr") {
|
||||
const auto loaded_module = LoadModuleIntoBuffer("empty_module.code");
|
||||
HIP_CHECK_ERROR(hipModuleLoadDataEx(nullptr, loaded_module.data(), 0, nullptr, nullptr),
|
||||
hipErrorInvalidValue);
|
||||
LoadModuleIntoBuffer("empty_module.code");
|
||||
}
|
||||
|
||||
SECTION("image == nullptr") {
|
||||
HIP_CHECK_ERROR(hipModuleLoadDataEx(&module, nullptr, 0, nullptr, nullptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleLoadDataEx_Negative_Image_Is_An_Empty_String") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
hipModule_t module;
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleLoadDataEx(&module, "", 0, nullptr, nullptr), hipErrorInvalidImage);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
|
||||
TEST_CASE("Unit_hipModuleUnload_Negative_Module_Is_Nullptr") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
|
||||
HIP_CHECK_ERROR(hipModuleUnload(nullptr), hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipModuleUnload_Negative_Double_Unload") {
|
||||
HIP_CHECK(hipFree(nullptr));
|
||||
|
||||
hipModule_t module = nullptr;
|
||||
HIP_CHECK(hipModuleLoad(&module, "empty_module.code"));
|
||||
HIP_CHECK(hipModuleUnload(module));
|
||||
HIP_CHECK_ERROR(hipModuleUnload(module), hipErrorNotFound);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip_test_filesystem.hh>
|
||||
#include <hip/hiprtc.h>
|
||||
|
||||
ModuleGuard ModuleGuard::LoadModule(const char* fname) {
|
||||
hipModule_t module = nullptr;
|
||||
HIP_CHECK(hipModuleLoad(&module, fname));
|
||||
return ModuleGuard{module};
|
||||
}
|
||||
|
||||
ModuleGuard ModuleGuard::LoadModuleDataFile(const char* fname) {
|
||||
const auto loaded_module = LoadModuleIntoBuffer(fname);
|
||||
hipModule_t module = nullptr;
|
||||
HIP_CHECK(hipModuleLoadData(&module, loaded_module.data()));
|
||||
return ModuleGuard{module};
|
||||
}
|
||||
|
||||
ModuleGuard ModuleGuard::LoadModuleDataRTC(const char* code) {
|
||||
const auto rtc = CreateRTCCharArray(code);
|
||||
hipModule_t module = nullptr;
|
||||
HIP_CHECK(hipModuleLoadData(&module, rtc.data()));
|
||||
return ModuleGuard{module};
|
||||
}
|
||||
|
||||
// Load module into buffer instead of mapping file to avoid platform specific mechanisms
|
||||
std::vector<char> LoadModuleIntoBuffer(const char* path_string) {
|
||||
fs::path p(path_string);
|
||||
const auto file_size = fs::file_size(p);
|
||||
std::ifstream f(p, std::ios::binary | std::ios::in);
|
||||
REQUIRE(f);
|
||||
std::vector<char> empty_module(file_size);
|
||||
REQUIRE(f.read(empty_module.data(), file_size));
|
||||
return empty_module;
|
||||
}
|
||||
|
||||
std::vector<char> CreateRTCCharArray(const char* src) {
|
||||
hiprtcProgram prog;
|
||||
HIPRTC_CHECK(hiprtcCreateProgram(&prog, src, "prog", 0, nullptr, nullptr));
|
||||
HIPRTC_CHECK(hiprtcCompileProgram(prog, 0, nullptr));
|
||||
size_t code_size = 0;
|
||||
HIPRTC_CHECK(hiprtcGetCodeSize(prog, &code_size));
|
||||
std::vector<char> code(code_size, '\0');
|
||||
HIPRTC_CHECK(hiprtcGetCode(prog, code.data()));
|
||||
HIPRTC_CHECK(hiprtcDestroyProgram(&prog));
|
||||
return code;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
class ModuleGuard {
|
||||
public:
|
||||
~ModuleGuard() { static_cast<void>(hipModuleUnload(module_)); }
|
||||
|
||||
ModuleGuard(const ModuleGuard&) = delete;
|
||||
ModuleGuard(ModuleGuard&&) = delete;
|
||||
|
||||
static ModuleGuard LoadModule(const char* fname);
|
||||
|
||||
static ModuleGuard LoadModuleDataFile(const char* fname);
|
||||
|
||||
static ModuleGuard LoadModuleDataRTC(const char* code);
|
||||
|
||||
hipModule_t module() const { return module_; }
|
||||
|
||||
private:
|
||||
ModuleGuard(const hipModule_t module) : module_{module} {}
|
||||
hipModule_t module_ = nullptr;
|
||||
};
|
||||
|
||||
// Load module into buffer instead of mapping file to avoid platform specific mechanisms
|
||||
std::vector<char> LoadModuleIntoBuffer(const char* path_string);
|
||||
|
||||
std::vector<char> CreateRTCCharArray(const char* src);
|
||||
|
||||
inline hipFunction_t GetKernel(const hipModule_t module, const char* kname) {
|
||||
hipFunction_t kernel = nullptr;
|
||||
HIP_CHECK(hipModuleGetFunction(&kernel, module, kname));
|
||||
return kernel;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hip_module_common.hh"
|
||||
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#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() {
|
||||
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));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
SECTION("Kernel with arguments using kernelParams") {
|
||||
hipFunction_t f = GetKernel(mg.module(), "Kernel42");
|
||||
LinearAllocGuard<int> result_dev(LinearAllocs::hipMalloc, sizeof(int));
|
||||
HIP_CHECK(hipMemset(result_dev.ptr(), 0, sizeof(*result_dev.ptr())));
|
||||
int* result_ptr = result_dev.ptr();
|
||||
void* kernel_args[1] = {&result_ptr};
|
||||
HIP_CHECK(func(f, 1, 1, 1, 1, 1, 1, 0, nullptr, kernel_args, nullptr, nullptr, nullptr, 0u));
|
||||
int result = 0;
|
||||
HIP_CHECK(hipMemcpy(&result, result_dev.ptr(), sizeof(result), hipMemcpyDefault));
|
||||
REQUIRE(result == 42);
|
||||
}
|
||||
|
||||
SECTION("Kernel with arguments using extra") {
|
||||
hipFunction_t f = GetKernel(mg.module(), "Kernel42");
|
||||
LinearAllocGuard<int> result_dev(LinearAllocs::hipMalloc, sizeof(int));
|
||||
HIP_CHECK(hipMemset(result_dev.ptr(), 0, sizeof(*result_dev.ptr())));
|
||||
int* result_ptr = result_dev.ptr();
|
||||
size_t size = sizeof(result_ptr);
|
||||
// clang-format off
|
||||
void *extra[] = {
|
||||
HIP_LAUNCH_PARAM_BUFFER_POINTER, &result_ptr,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END
|
||||
};
|
||||
// clang-format on
|
||||
HIP_CHECK(func(f, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, extra, nullptr, nullptr, 0u));
|
||||
int result = 0;
|
||||
HIP_CHECK(hipMemcpy(&result, result_dev.ptr(), sizeof(result), hipMemcpyDefault));
|
||||
REQUIRE(result == 42);
|
||||
}
|
||||
}
|
||||
|
||||
template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelPositiveParameters() {
|
||||
const auto LaunchNOPKernel = [=](unsigned int gridDimX, unsigned int gridDimY,
|
||||
unsigned int gridDimZ, unsigned int blockDimX,
|
||||
unsigned int blockDimY, unsigned int blockDimZ) {
|
||||
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
|
||||
HIP_CHECK(func(f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, 0, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, 0u));
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
};
|
||||
|
||||
SECTION("gridDimX == maxGridDimX") {
|
||||
const unsigned int x = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimX);
|
||||
LaunchNOPKernel(x, 1, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
SECTION("gridDimY == maxGridDimY") {
|
||||
const unsigned int y = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimY);
|
||||
LaunchNOPKernel(1, y, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
SECTION("gridDimZ == maxGridDimZ") {
|
||||
const unsigned int z = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimZ);
|
||||
LaunchNOPKernel(1, 1, z, 1, 1, 1);
|
||||
}
|
||||
|
||||
SECTION("blockDimX == maxBlockDimX") {
|
||||
const unsigned int x = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimX);
|
||||
LaunchNOPKernel(1, 1, 1, x, 1, 1);
|
||||
}
|
||||
|
||||
SECTION("blockDimY == maxBlockDimY") {
|
||||
const unsigned int y = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimY);
|
||||
LaunchNOPKernel(1, 1, 1, 1, y, 1);
|
||||
}
|
||||
|
||||
SECTION("blockDimZ == maxBlockDimZ") {
|
||||
const unsigned int z = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimZ);
|
||||
LaunchNOPKernel(1, 1, 1, 1, 1, z);
|
||||
}
|
||||
}
|
||||
|
||||
template <ExtModuleLaunchKernelSig* func> void ModuleLaunchKernelNegativeParameters() {
|
||||
hipFunction_t f = GetKernel(mg.module(), "NOPKernel");
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-157
|
||||
#if HT_NVIDIA
|
||||
SECTION("f == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
func(nullptr, 1, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("gridDimX == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 0, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("gridDimY == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 1, 0, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("gridDimZ == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 0, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("blockDimX == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 0, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("blockDimY == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 0, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("blockDimZ == 0") {
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-158
|
||||
#if HT_NVIDIA
|
||||
SECTION("gridDimX > maxGridDimX") {
|
||||
const unsigned int x = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimX) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, x, 1, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("gridDimY > maxGridDimY") {
|
||||
const unsigned int y = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimY) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, y, 1, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("gridDimZ > maxGridDimZ") {
|
||||
const unsigned int z = GetDeviceAttribute(0, hipDeviceAttributeMaxGridDimZ) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, z, 1, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-156
|
||||
#if HT_NVIDIA
|
||||
SECTION("blockDimX > maxBlockDimX") {
|
||||
const unsigned int x = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimX) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, x, 1, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("blockDimY > maxBlockDimY") {
|
||||
const unsigned int y = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimY) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, y, 1, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("blockDimZ > maxBlockDimZ") {
|
||||
const unsigned int z = GetDeviceAttribute(0, hipDeviceAttributeMaxBlockDimZ) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, z, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-162
|
||||
#if HT_NVIDIA
|
||||
SECTION("blockDimX * blockDimY * blockDimZ > MaxThreadsPerBlock") {
|
||||
const unsigned int max = GetDeviceAttribute(0, hipDeviceAttributeMaxThreadsPerBlock);
|
||||
const unsigned int dim = std::ceil(std::cbrt(max)) + 1;
|
||||
HIP_CHECK_ERROR(
|
||||
func(f, 1, 1, 1, dim, dim, dim, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-159
|
||||
#if HT_NVIDIA
|
||||
SECTION("sharedMemBytes > max shared memory per block") {
|
||||
const unsigned int max = GetDeviceAttribute(0, hipDeviceAttributeMaxSharedMemoryPerBlock) + 1u;
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, 1, max, nullptr, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-160
|
||||
#if HT_NVIDIA
|
||||
SECTION("Invalid stream") {
|
||||
hipStream_t stream = nullptr;
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, 0, 0, stream, nullptr, nullptr, nullptr, nullptr, 0u),
|
||||
hipErrorContextIsDestroyed);
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("Passing kernel_args and extra simultaneously") {
|
||||
hipFunction_t f = GetKernel(mg.module(), "Kernel42");
|
||||
LinearAllocGuard<int> result_dev(LinearAllocs::hipMalloc, sizeof(int));
|
||||
int* result_ptr = result_dev.ptr();
|
||||
size_t size = sizeof(result_ptr);
|
||||
void* kernel_args[1] = {&result_ptr};
|
||||
// clang-format off
|
||||
void *extra[] = {
|
||||
HIP_LAUNCH_PARAM_BUFFER_POINTER, &result_ptr,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END
|
||||
};
|
||||
// clang-format on
|
||||
HIP_CHECK_ERROR(func(f, 1, 1, 1, 1, 1, 1, 0, nullptr, kernel_args, extra, nullptr, nullptr, 0u),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-161
|
||||
#if HT_NVIDIA
|
||||
SECTION("Invalid extra") {
|
||||
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),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
extern "C" {
|
||||
__global__ void NOPKernel() {}
|
||||
|
||||
__global__ void Kernel42(int* out) { *out = 42; }
|
||||
|
||||
// Interval is in millisecond
|
||||
__global__ void Delay(uint32_t interval, const uint32_t ticks_per_ms) {
|
||||
while (interval--) {
|
||||
uint64_t start = clock();
|
||||
while (clock() - start < ticks_per_ms) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Referens i nytt ärende
Block a user