From 1195ab7a480690086a72519e0ed84a8a8242c00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirza=20Halil=C4=8Devi=C4=87?= <109971222+mirza-halilcevic@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:05:35 +0100 Subject: [PATCH] EXSWHTEC-344 - Refactor and extend tests for hipDrvGetErrorName and hipDrvGetErrorString #426 Change-Id: I4eb57eeaff6e5d723e3e236e07d4320430a4582a [ROCm/hip-tests commit: fb9a9a9a03b172377c051b881bba5c0037490f73] --- .../catch/unit/errorHandling/CMakeLists.txt | 7 +- .../errorHandling/error_handling_common.cc | 534 ++++++++++++++++++ ...Enumerators.h => error_handling_common.hh} | 16 +- .../unit/errorHandling/hipDrvGetErrorName.cc | 378 ++----------- .../errorHandling/hipDrvGetErrorString.cc | 278 ++------- .../unit/errorHandling/hipGetErrorName.cc | 6 +- .../unit/errorHandling/hipGetErrorString.cc | 5 +- .../unit/errorHandling/hipPeekAtLastError.cc | 4 +- 8 files changed, 654 insertions(+), 574 deletions(-) create mode 100644 projects/hip-tests/catch/unit/errorHandling/error_handling_common.cc rename projects/hip-tests/catch/unit/errorHandling/{errorEnumerators.h => error_handling_common.hh} (95%) diff --git a/projects/hip-tests/catch/unit/errorHandling/CMakeLists.txt b/projects/hip-tests/catch/unit/errorHandling/CMakeLists.txt index 7dcdb52f4c..b9a6de0afa 100644 --- a/projects/hip-tests/catch/unit/errorHandling/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/errorHandling/CMakeLists.txt @@ -1,14 +1,15 @@ # Common Tests - Test independent of all platforms set(TEST_SRC + error_handling_common.cc hipGetErrorName.cc hipGetErrorString.cc - hipGetLastError.cc - hipPeekAtLastError.cc hipDrvGetErrorName.cc hipDrvGetErrorString.cc + hipGetLastError.cc + hipPeekAtLastError.cc ) hip_add_exe_to_target(NAME ErrorHandlingTest TEST_SRC ${TEST_SRC} TEST_TARGET_NAME build_tests - COMPILE_OPTIONS -std=c++17) \ No newline at end of file + COMPILE_OPTIONS -std=c++17) diff --git a/projects/hip-tests/catch/unit/errorHandling/error_handling_common.cc b/projects/hip-tests/catch/unit/errorHandling/error_handling_common.cc new file mode 100644 index 0000000000..20267e793d --- /dev/null +++ b/projects/hip-tests/catch/unit/errorHandling/error_handling_common.cc @@ -0,0 +1,534 @@ +/* +Copyright (c) 2023 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 "error_handling_common.hh" + +const char* ErrorName(hipError_t enumerator) { + switch (enumerator) { +#if HT_AMD + case hipSuccess: + return "hipSuccess"; + case hipErrorInvalidValue: + return "hipErrorInvalidValue"; + case hipErrorOutOfMemory: + return "hipErrorOutOfMemory"; + case hipErrorNotInitialized: + return "hipErrorNotInitialized"; + case hipErrorDeinitialized: + return "hipErrorDeinitialized"; + case hipErrorProfilerDisabled: + return "hipErrorProfilerDisabled"; + case hipErrorProfilerNotInitialized: + return "hipErrorProfilerNotInitialized"; + case hipErrorProfilerAlreadyStarted: + return "hipErrorProfilerAlreadyStarted"; + case hipErrorProfilerAlreadyStopped: + return "hipErrorProfilerAlreadyStopped"; + case hipErrorInvalidConfiguration: + return "hipErrorInvalidConfiguration"; + case hipErrorInvalidSymbol: + return "hipErrorInvalidSymbol"; + case hipErrorInvalidDevicePointer: + return "hipErrorInvalidDevicePointer"; + case hipErrorInvalidMemcpyDirection: + return "hipErrorInvalidMemcpyDirection"; + case hipErrorInsufficientDriver: + return "hipErrorInsufficientDriver"; + case hipErrorMissingConfiguration: + return "hipErrorMissingConfiguration"; + case hipErrorPriorLaunchFailure: + return "hipErrorPriorLaunchFailure"; + case hipErrorInvalidDeviceFunction: + return "hipErrorInvalidDeviceFunction"; + case hipErrorNoDevice: + return "hipErrorNoDevice"; + case hipErrorInvalidDevice: + return "hipErrorInvalidDevice"; + case hipErrorInvalidPitchValue: + return "hipErrorInvalidPitchValue"; + case hipErrorInvalidImage: + return "hipErrorInvalidImage"; + case hipErrorInvalidContext: + return "hipErrorInvalidContext"; + case hipErrorContextAlreadyCurrent: + return "hipErrorContextAlreadyCurrent"; + case hipErrorMapFailed: + return "hipErrorMapFailed"; + case hipErrorUnmapFailed: + return "hipErrorUnmapFailed"; + case hipErrorArrayIsMapped: + return "hipErrorArrayIsMapped"; + case hipErrorAlreadyMapped: + return "hipErrorAlreadyMapped"; + case hipErrorNoBinaryForGpu: + return "hipErrorNoBinaryForGpu"; + case hipErrorAlreadyAcquired: + return "hipErrorAlreadyAcquired"; + case hipErrorNotMapped: + return "hipErrorNotMapped"; + case hipErrorNotMappedAsArray: + return "hipErrorNotMappedAsArray"; + case hipErrorNotMappedAsPointer: + return "hipErrorNotMappedAsPointer"; + case hipErrorECCNotCorrectable: + return "hipErrorECCNotCorrectable"; + case hipErrorUnsupportedLimit: + return "hipErrorUnsupportedLimit"; + case hipErrorContextAlreadyInUse: + return "hipErrorContextAlreadyInUse"; + case hipErrorPeerAccessUnsupported: + return "hipErrorPeerAccessUnsupported"; + case hipErrorInvalidKernelFile: + return "hipErrorInvalidKernelFile"; + case hipErrorInvalidGraphicsContext: + return "hipErrorInvalidGraphicsContext"; + case hipErrorInvalidSource: + return "hipErrorInvalidSource"; + case hipErrorFileNotFound: + return "hipErrorFileNotFound"; + case hipErrorSharedObjectSymbolNotFound: + return "hipErrorSharedObjectSymbolNotFound"; + case hipErrorSharedObjectInitFailed: + return "hipErrorSharedObjectInitFailed"; + case hipErrorOperatingSystem: + return "hipErrorOperatingSystem"; + case hipErrorInvalidHandle: + return "hipErrorInvalidHandle"; + case hipErrorIllegalState: + return "hipErrorIllegalState"; + case hipErrorNotFound: + return "hipErrorNotFound"; + case hipErrorNotReady: + return "hipErrorNotReady"; + case hipErrorIllegalAddress: + return "hipErrorIllegalAddress"; + case hipErrorLaunchOutOfResources: + return "hipErrorLaunchOutOfResources"; + case hipErrorLaunchTimeOut: + return "hipErrorLaunchTimeOut"; + case hipErrorPeerAccessAlreadyEnabled: + return "hipErrorPeerAccessAlreadyEnabled"; + case hipErrorPeerAccessNotEnabled: + return "hipErrorPeerAccessNotEnabled"; + case hipErrorSetOnActiveProcess: + return "hipErrorSetOnActiveProcess"; + case hipErrorContextIsDestroyed: + return "hipErrorContextIsDestroyed"; + case hipErrorAssert: + return "hipErrorAssert"; + case hipErrorHostMemoryAlreadyRegistered: + return "hipErrorHostMemoryAlreadyRegistered"; + case hipErrorHostMemoryNotRegistered: + return "hipErrorHostMemoryNotRegistered"; + case hipErrorLaunchFailure: + return "hipErrorLaunchFailure"; + case hipErrorNotSupported: + return "hipErrorNotSupported"; + case hipErrorUnknown: + return "hipErrorUnknown"; + case hipErrorRuntimeMemory: + return "hipErrorRuntimeMemory"; + case hipErrorRuntimeOther: + return "hipErrorRuntimeOther"; + case hipErrorCooperativeLaunchTooLarge: + return "hipErrorCooperativeLaunchTooLarge"; + case hipErrorStreamCaptureUnsupported: + return "hipErrorStreamCaptureUnsupported"; + case hipErrorStreamCaptureInvalidated: + return "hipErrorStreamCaptureInvalidated"; + case hipErrorStreamCaptureMerge: + return "hipErrorStreamCaptureMerge"; + case hipErrorStreamCaptureUnmatched: + return "hipErrorStreamCaptureUnmatched"; + case hipErrorStreamCaptureUnjoined: + return "hipErrorStreamCaptureUnjoined"; + case hipErrorStreamCaptureIsolation: + return "hipErrorStreamCaptureIsolation"; + case hipErrorStreamCaptureImplicit: + return "hipErrorStreamCaptureImplicit"; + case hipErrorCapturedEvent: + return "hipErrorCapturedEvent"; + case hipErrorStreamCaptureWrongThread: + return "hipErrorStreamCaptureWrongThread"; + case hipErrorGraphExecUpdateFailure: + return "hipErrorGraphExecUpdateFailure"; + case hipErrorTbd: + return "hipErrorTbd"; + default: + return "hipErrorUnknown"; +#else + case hipSuccess: + return "CUDA_SUCCESS"; + case hipErrorInvalidValue: + return "CUDA_ERROR_INVALID_VALUE"; + case hipErrorOutOfMemory: + return "CUDA_ERROR_OUT_OF_MEMORY"; + case hipErrorNotInitialized: + return "CUDA_ERROR_NOT_INITIALIZED"; + case hipErrorDeinitialized: + return "CUDA_ERROR_DEINITIALIZED"; + case hipErrorProfilerDisabled: + return "CUDA_ERROR_PROFILER_DISABLED"; + case hipErrorProfilerNotInitialized: + return "CUDA_ERROR_PROFILER_NOT_INITIALIZED"; + case hipErrorProfilerAlreadyStarted: + return "CUDA_ERROR_PROFILER_ALREADY_STARTED"; + case hipErrorProfilerAlreadyStopped: + return "CUDA_ERROR_PROFILER_ALREADY_STOPPED"; + case hipErrorInvalidConfiguration: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInvalidSymbol: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInvalidDevicePointer: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInvalidMemcpyDirection: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInsufficientDriver: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorMissingConfiguration: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorPriorLaunchFailure: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInvalidDeviceFunction: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorNoDevice: + return "CUDA_ERROR_NO_DEVICE"; + case hipErrorInvalidDevice: + return "CUDA_ERROR_INVALID_DEVICE"; + case hipErrorInvalidPitchValue: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorInvalidImage: + return "CUDA_ERROR_INVALID_IMAGE"; + case hipErrorInvalidContext: + return "CUDA_ERROR_INVALID_CONTEXT"; + case hipErrorContextAlreadyCurrent: + return "CUDA_ERROR_CONTEXT_ALREADY_CURRENT"; + case hipErrorMapFailed: + return "CUDA_ERROR_MAP_FAILED"; + case hipErrorUnmapFailed: + return "CUDA_ERROR_UNMAP_FAILED"; + case hipErrorArrayIsMapped: + return "CUDA_ERROR_ARRAY_IS_MAPPED"; + case hipErrorAlreadyMapped: + return "CUDA_ERROR_ALREADY_MAPPED"; + case hipErrorNoBinaryForGpu: + return "CUDA_ERROR_NO_BINARY_FOR_GPU"; + case hipErrorAlreadyAcquired: + return "CUDA_ERROR_ALREADY_ACQUIRED"; + case hipErrorNotMapped: + return "CUDA_ERROR_NOT_MAPPED"; + case hipErrorNotMappedAsArray: + return "CUDA_ERROR_NOT_MAPPED_AS_ARRAY"; + case hipErrorNotMappedAsPointer: + return "CUDA_ERROR_NOT_MAPPED_AS_POINTER"; + case hipErrorECCNotCorrectable: + return "CUDA_ERROR_ECC_UNCORRECTABLE"; + case hipErrorUnsupportedLimit: + return "CUDA_ERROR_UNSUPPORTED_LIMIT"; + case hipErrorContextAlreadyInUse: + return "CUDA_ERROR_CONTEXT_ALREADY_IN_USE"; + case hipErrorPeerAccessUnsupported: + return "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"; + case hipErrorInvalidKernelFile: + return "CUDA_ERROR_INVALID_PTX"; + case hipErrorInvalidGraphicsContext: + return "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"; + case hipErrorInvalidSource: + return "CUDA_ERROR_INVALID_SOURCE"; + case hipErrorFileNotFound: + return "CUDA_ERROR_FILE_NOT_FOUND"; + case hipErrorSharedObjectSymbolNotFound: + return "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"; + case hipErrorSharedObjectInitFailed: + return "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"; + case hipErrorOperatingSystem: + return "CUDA_ERROR_OPERATING_SYSTEM"; + case hipErrorInvalidHandle: + return "CUDA_ERROR_INVALID_HANDLE"; + case hipErrorIllegalState: + return "CUDA_ERROR_ILLEGAL_STATE"; + case hipErrorNotFound: + return "CUDA_ERROR_NOT_FOUND"; + case hipErrorNotReady: + return "CUDA_ERROR_NOT_READY"; + case hipErrorIllegalAddress: + return "CUDA_ERROR_ILLEGAL_ADDRESS"; + case hipErrorLaunchOutOfResources: + return "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"; + case hipErrorLaunchTimeOut: + return "CUDA_ERROR_LAUNCH_TIMEOUT"; + case hipErrorPeerAccessAlreadyEnabled: + return "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"; + case hipErrorPeerAccessNotEnabled: + return "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"; + case hipErrorSetOnActiveProcess: + return "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE"; + case hipErrorContextIsDestroyed: + return "CUDA_ERROR_CONTEXT_IS_DESTROYED"; + case hipErrorAssert: + return "CUDA_ERROR_ASSERT"; + case hipErrorHostMemoryAlreadyRegistered: + return "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"; + case hipErrorHostMemoryNotRegistered: + return "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"; + case hipErrorLaunchFailure: + return "CUDA_ERROR_LAUNCH_FAILED"; + case hipErrorNotSupported: + return "CUDA_ERROR_NOT_SUPPORTED"; + case hipErrorUnknown: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorRuntimeMemory: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorRuntimeOther: + return "CUDA_ERROR_UNKNOWN"; + case hipErrorCooperativeLaunchTooLarge: + return "CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE"; + case hipErrorStreamCaptureUnsupported: + return "CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED"; + case hipErrorStreamCaptureInvalidated: + return "CUDA_ERROR_STREAM_CAPTURE_INVALIDATED"; + case hipErrorStreamCaptureMerge: + return "CUDA_ERROR_STREAM_CAPTURE_MERGE"; + case hipErrorStreamCaptureUnmatched: + return "CUDA_ERROR_STREAM_CAPTURE_UNMATCHED"; + case hipErrorStreamCaptureUnjoined: + return "CUDA_ERROR_STREAM_CAPTURE_UNJOINED"; + case hipErrorStreamCaptureIsolation: + return "CUDA_ERROR_STREAM_CAPTURE_ISOLATION"; + case hipErrorStreamCaptureImplicit: + return "CUDA_ERROR_STREAM_CAPTURE_IMPLICIT"; + case hipErrorCapturedEvent: + return "CUDA_ERROR_CAPTURED_EVENT"; + case hipErrorStreamCaptureWrongThread: + return "CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD"; + case hipErrorGraphExecUpdateFailure: + return "CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE"; + default: + return "CUDA_ERROR_UNKNOWN"; +#endif + } +} + +const char* ErrorString(hipError_t enumerator) { + switch (enumerator) { + case hipSuccess: + return "no error"; + case hipErrorInvalidValue: + return "invalid argument"; + case hipErrorOutOfMemory: + return "out of memory"; + case hipErrorNotInitialized: + return "initialization error"; + case hipErrorDeinitialized: + return "driver shutting down"; + case hipErrorProfilerDisabled: + return "profiler disabled while using external profiling tool"; + case hipErrorProfilerNotInitialized: +#if HT_AMD + return "profiler is not initialized"; +#elif HT_NVIDIA + return "profiler not initialized: call cudaProfilerInitialize()"; +#endif + case hipErrorProfilerAlreadyStarted: + return "profiler already started"; + case hipErrorProfilerAlreadyStopped: + return "profiler already stopped"; +#if HT_AMD + case hipErrorInvalidConfiguration: + return "invalid configuration argument"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInvalidPitchValue: + return "invalid pitch argument"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInvalidSymbol: + return "invalid device symbol"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInvalidDevicePointer: + return "invalid device pointer"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInvalidMemcpyDirection: + return "invalid copy direction for memcpy"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInsufficientDriver: + return "driver version is insufficient for runtime version"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorMissingConfiguration: + return "__global__ function call is not configured"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorPriorLaunchFailure: + return "unspecified launch failure in prior launch"; +#elif HT_NVIDIA + return "unknown error"; +#endif +#if HT_AMD + case hipErrorInvalidDeviceFunction: + return "invalid device function"; +#elif HT_NVIDIA + return "unknown error"; +#endif + case hipErrorNoDevice: +#if HT_AMD + return "no ROCm-capable device is detected"; +#elif HT_NVIDIA + return "no CUDA-capable device is detected"; +#endif + case hipErrorInvalidDevice: + return "invalid device ordinal"; + case hipErrorInvalidImage: + return "device kernel image is invalid"; + case hipErrorInvalidContext: + return "invalid device context"; + case hipErrorContextAlreadyCurrent: +#if HT_AMD + return "context is already current context"; +#elif HT_NVIDIA + return "context already current"; +#endif + case hipErrorMapFailed: + return "mapping of buffer object failed"; + case hipErrorUnmapFailed: + return "unmapping of buffer object failed"; + case hipErrorArrayIsMapped: + return "array is mapped"; + case hipErrorAlreadyMapped: + return "resource already mapped"; + case hipErrorNoBinaryForGpu: + return "no kernel image is available for execution on the device"; + case hipErrorAlreadyAcquired: + return "resource already acquired"; + case hipErrorNotMapped: + return "resource not mapped"; + case hipErrorNotMappedAsArray: + return "resource not mapped as array"; + case hipErrorNotMappedAsPointer: + return "resource not mapped as pointer"; + case hipErrorECCNotCorrectable: + return "uncorrectable ECC error encountered"; + case hipErrorUnsupportedLimit: + return "limit is not supported on this architecture"; + case hipErrorContextAlreadyInUse: + return "exclusive-thread device already in use by a different thread"; + case hipErrorPeerAccessUnsupported: + return "peer access is not supported between these two devices"; + case hipErrorInvalidKernelFile: +#if HT_AMD + return "invalid kernel file"; +#elif HT_NVIDIA + return "a PTX JIT compilation failed"; +#endif + case hipErrorInvalidGraphicsContext: + return "invalid OpenGL or DirectX context"; + case hipErrorInvalidSource: + return "device kernel image is invalid"; + case hipErrorFileNotFound: + return "file not found"; + case hipErrorSharedObjectSymbolNotFound: + return "shared object symbol not found"; + case hipErrorSharedObjectInitFailed: + return "shared object initialization failed"; + case hipErrorOperatingSystem: + return "OS call failed or operation not supported on this OS"; + case hipErrorInvalidHandle: + return "invalid resource handle"; + case hipErrorIllegalState: + return "the operation cannot be performed in the present state"; + case hipErrorNotFound: + return "named symbol not found"; + case hipErrorNotReady: + return "device not ready"; + case hipErrorIllegalAddress: + return "an illegal memory access was encountered"; + case hipErrorLaunchOutOfResources: + return "too many resources requested for launch"; + case hipErrorLaunchTimeOut: + return "the launch timed out and was terminated"; + case hipErrorPeerAccessAlreadyEnabled: + return "peer access is already enabled"; + case hipErrorPeerAccessNotEnabled: + return "peer access has not been enabled"; + case hipErrorSetOnActiveProcess: + return "cannot set while device is active in this process"; + case hipErrorContextIsDestroyed: + return "context is destroyed"; + case hipErrorAssert: + return "device-side assert triggered"; + case hipErrorHostMemoryAlreadyRegistered: + return "part or all of the requested memory range is already mapped"; + case hipErrorHostMemoryNotRegistered: + return "pointer does not correspond to a registered memory region"; + case hipErrorLaunchFailure: + return "unspecified launch failure"; + case hipErrorCooperativeLaunchTooLarge: + return "too many blocks in cooperative launch"; + case hipErrorNotSupported: + return "operation not supported"; + case hipErrorStreamCaptureUnsupported: + return "operation not permitted when stream is capturing"; + case hipErrorStreamCaptureInvalidated: + return "operation failed due to a previous error during capture"; + case hipErrorStreamCaptureMerge: + return "operation would result in a merge of separate capture sequences"; + case hipErrorStreamCaptureUnmatched: + return "capture was not ended in the same stream as it began"; + case hipErrorStreamCaptureUnjoined: + return "capturing stream has unjoined work"; + case hipErrorStreamCaptureIsolation: + return "dependency created on uncaptured work in another stream"; + case hipErrorStreamCaptureImplicit: + return "operation would make the legacy stream depend on a capturing blocking stream"; // NOLINT + case hipErrorCapturedEvent: + return "operation not permitted on an event last recorded in a capturing stream"; // NOLINT + case hipErrorStreamCaptureWrongThread: + return "attempt to terminate a thread-local capture sequence from another thread"; // NOLINT + case hipErrorGraphExecUpdateFailure: + return "the graph update was not performed because it included changes which violated " + "constraints specific to instantiated graph update"; // NOLINT + case hipErrorRuntimeMemory: + return "runtime memory call returned error"; + case hipErrorRuntimeOther: + return "runtime call other than memory returned error"; + case hipErrorUnknown: + default: + return "unknown error"; + } +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/errorHandling/errorEnumerators.h b/projects/hip-tests/catch/unit/errorHandling/error_handling_common.hh similarity index 95% rename from projects/hip-tests/catch/unit/errorHandling/errorEnumerators.h rename to projects/hip-tests/catch/unit/errorHandling/error_handling_common.hh index e671938c41..902735a1ed 100644 --- a/projects/hip-tests/catch/unit/errorHandling/errorEnumerators.h +++ b/projects/hip-tests/catch/unit/errorHandling/error_handling_common.hh @@ -1,5 +1,5 @@ /* -Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2023 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 @@ -33,7 +33,7 @@ constexpr hipError_t kErrorEnumerators[] = {hipSuccess, hipErrorProfilerNotInitialized, hipErrorProfilerAlreadyStarted, hipErrorProfilerAlreadyStopped, - #if HT_AMD +#if HT_AMD hipErrorInvalidConfiguration, hipErrorInvalidPitchValue, hipErrorInvalidSymbol, @@ -43,7 +43,7 @@ constexpr hipError_t kErrorEnumerators[] = {hipSuccess, hipErrorMissingConfiguration, hipErrorPriorLaunchFailure, hipErrorInvalidDeviceFunction, - #endif +#endif hipErrorNoDevice, hipErrorInvalidDevice, hipErrorInvalidImage, @@ -97,8 +97,12 @@ constexpr hipError_t kErrorEnumerators[] = {hipSuccess, hipErrorStreamCaptureWrongThread, hipErrorGraphExecUpdateFailure, hipErrorUnknown, - #if HT_AMD +#if HT_AMD hipErrorRuntimeMemory, hipErrorRuntimeOther - #endif - }; +#endif +}; + +const char* ErrorName(hipError_t enumerator); + +const char* ErrorString(hipError_t enumerator); \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorName.cc b/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorName.cc index 367d890be0..b3401cfc5d 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorName.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorName.cc @@ -1,5 +1,5 @@ /* -Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2023 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 @@ -17,347 +17,67 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include #include -#include "errorEnumerators.h" -// Local Function to return the error code in string +#include "error_handling_common.hh" -static const char *ErrorName(hipError_t enumerator) { - switch (enumerator) { - #if HT_AMD - case hipSuccess: - return "hipSuccess"; - case hipErrorInvalidValue: - return "hipErrorInvalidValue"; - case hipErrorOutOfMemory: - return "hipErrorOutOfMemory"; - case hipErrorNotInitialized: - return "hipErrorNotInitialized"; - case hipErrorDeinitialized: - return "hipErrorDeinitialized"; - case hipErrorProfilerDisabled: - return "hipErrorProfilerDisabled"; - case hipErrorProfilerNotInitialized: - return "hipErrorProfilerNotInitialized"; - case hipErrorProfilerAlreadyStarted: - return "hipErrorProfilerAlreadyStarted"; - case hipErrorProfilerAlreadyStopped: - return "hipErrorProfilerAlreadyStopped"; - case hipErrorInvalidConfiguration: - return "hipErrorInvalidConfiguration"; - case hipErrorInvalidSymbol: - return "hipErrorInvalidSymbol"; - case hipErrorInvalidDevicePointer: - return "hipErrorInvalidDevicePointer"; - case hipErrorInvalidMemcpyDirection: - return "hipErrorInvalidMemcpyDirection"; - case hipErrorInsufficientDriver: - return "hipErrorInsufficientDriver"; - case hipErrorMissingConfiguration: - return "hipErrorMissingConfiguration"; - case hipErrorPriorLaunchFailure: - return "hipErrorPriorLaunchFailure"; - case hipErrorInvalidDeviceFunction: - return "hipErrorInvalidDeviceFunction"; - case hipErrorNoDevice: - return "hipErrorNoDevice"; - case hipErrorInvalidDevice: - return "hipErrorInvalidDevice"; - case hipErrorInvalidPitchValue: - return "hipErrorInvalidPitchValue"; - case hipErrorInvalidImage: - return "hipErrorInvalidImage"; - case hipErrorInvalidContext: - return "hipErrorInvalidContext"; - case hipErrorContextAlreadyCurrent: - return "hipErrorContextAlreadyCurrent"; - case hipErrorMapFailed: - return "hipErrorMapFailed"; - case hipErrorUnmapFailed: - return "hipErrorUnmapFailed"; - case hipErrorArrayIsMapped: - return "hipErrorArrayIsMapped"; - case hipErrorAlreadyMapped: - return "hipErrorAlreadyMapped"; - case hipErrorNoBinaryForGpu: - return "hipErrorNoBinaryForGpu"; - case hipErrorAlreadyAcquired: - return "hipErrorAlreadyAcquired"; - case hipErrorNotMapped: - return "hipErrorNotMapped"; - case hipErrorNotMappedAsArray: - return "hipErrorNotMappedAsArray"; - case hipErrorNotMappedAsPointer: - return "hipErrorNotMappedAsPointer"; - case hipErrorECCNotCorrectable: - return "hipErrorECCNotCorrectable"; - case hipErrorUnsupportedLimit: - return "hipErrorUnsupportedLimit"; - case hipErrorContextAlreadyInUse: - return "hipErrorContextAlreadyInUse"; - case hipErrorPeerAccessUnsupported: - return "hipErrorPeerAccessUnsupported"; - case hipErrorInvalidKernelFile: - return "hipErrorInvalidKernelFile"; - case hipErrorInvalidGraphicsContext: - return "hipErrorInvalidGraphicsContext"; - case hipErrorInvalidSource: - return "hipErrorInvalidSource"; - case hipErrorFileNotFound: - return "hipErrorFileNotFound"; - case hipErrorSharedObjectSymbolNotFound: - return "hipErrorSharedObjectSymbolNotFound"; - case hipErrorSharedObjectInitFailed: - return "hipErrorSharedObjectInitFailed"; - case hipErrorOperatingSystem: - return "hipErrorOperatingSystem"; - case hipErrorInvalidHandle: - return "hipErrorInvalidHandle"; - case hipErrorIllegalState: - return "hipErrorIllegalState"; - case hipErrorNotFound: - return "hipErrorNotFound"; - case hipErrorNotReady: - return "hipErrorNotReady"; - case hipErrorIllegalAddress: - return "hipErrorIllegalAddress"; - case hipErrorLaunchOutOfResources: - return "hipErrorLaunchOutOfResources"; - case hipErrorLaunchTimeOut: - return "hipErrorLaunchTimeOut"; - case hipErrorPeerAccessAlreadyEnabled: - return "hipErrorPeerAccessAlreadyEnabled"; - case hipErrorPeerAccessNotEnabled: - return "hipErrorPeerAccessNotEnabled"; - case hipErrorSetOnActiveProcess: - return "hipErrorSetOnActiveProcess"; - case hipErrorContextIsDestroyed: - return "hipErrorContextIsDestroyed"; - case hipErrorAssert: - return "hipErrorAssert"; - case hipErrorHostMemoryAlreadyRegistered: - return "hipErrorHostMemoryAlreadyRegistered"; - case hipErrorHostMemoryNotRegistered: - return "hipErrorHostMemoryNotRegistered"; - case hipErrorLaunchFailure: - return "hipErrorLaunchFailure"; - case hipErrorNotSupported: - return "hipErrorNotSupported"; - case hipErrorUnknown: - return "hipErrorUnknown"; - case hipErrorRuntimeMemory: - return "hipErrorRuntimeMemory"; - case hipErrorRuntimeOther: - return "hipErrorRuntimeOther"; - case hipErrorCooperativeLaunchTooLarge: - return "hipErrorCooperativeLaunchTooLarge"; - case hipErrorStreamCaptureUnsupported: - return "hipErrorStreamCaptureUnsupported"; - case hipErrorStreamCaptureInvalidated: - return "hipErrorStreamCaptureInvalidated"; - case hipErrorStreamCaptureMerge: - return "hipErrorStreamCaptureMerge"; - case hipErrorStreamCaptureUnmatched: - return "hipErrorStreamCaptureUnmatched"; - case hipErrorStreamCaptureUnjoined: - return "hipErrorStreamCaptureUnjoined"; - case hipErrorStreamCaptureIsolation: - return "hipErrorStreamCaptureIsolation"; - case hipErrorStreamCaptureImplicit: - return "hipErrorStreamCaptureImplicit"; - case hipErrorCapturedEvent: - return "hipErrorCapturedEvent"; - case hipErrorStreamCaptureWrongThread: - return "hipErrorStreamCaptureWrongThread"; - case hipErrorGraphExecUpdateFailure: - return "hipErrorGraphExecUpdateFailure"; - case hipErrorTbd: - return "hipErrorTbd"; - default: - return "hipErrorUnknown"; - #endif - #if HT_NVIDIA - case hipSuccess: - return "CUDA_SUCCESS"; - case hipErrorInvalidValue: - return "CUDA_ERROR_INVALID_VALUE"; - case hipErrorOutOfMemory: - return "CUDA_ERROR_OUT_OF_MEMORY"; - case hipErrorNotInitialized: - return "CUDA_ERROR_NOT_INITIALIZED"; - case hipErrorDeinitialized: - return "CUDA_ERROR_DEINITIALIZED"; - case hipErrorProfilerDisabled: - return "CUDA_ERROR_PROFILER_DISABLED"; - case hipErrorProfilerNotInitialized: - return "CUDA_ERROR_PROFILER_NOT_INITIALIZED"; - case hipErrorProfilerAlreadyStarted: - return "CUDA_ERROR_PROFILER_ALREADY_STARTED"; - case hipErrorProfilerAlreadyStopped: - return "CUDA_ERROR_PROFILER_ALREADY_STOPPED"; - case hipErrorInvalidConfiguration: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInvalidSymbol: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInvalidDevicePointer: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInvalidMemcpyDirection: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInsufficientDriver: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorMissingConfiguration: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorPriorLaunchFailure: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInvalidDeviceFunction: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorNoDevice: - return "CUDA_ERROR_NO_DEVICE"; - case hipErrorInvalidDevice: - return "CUDA_ERROR_INVALID_DEVICE"; - case hipErrorInvalidPitchValue: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorInvalidImage: - return "CUDA_ERROR_INVALID_IMAGE"; - case hipErrorInvalidContext: - return "CUDA_ERROR_INVALID_CONTEXT"; - case hipErrorContextAlreadyCurrent: - return "CUDA_ERROR_CONTEXT_ALREADY_CURRENT"; - case hipErrorMapFailed: - return "CUDA_ERROR_MAP_FAILED"; - case hipErrorUnmapFailed: - return "CUDA_ERROR_UNMAP_FAILED"; - case hipErrorArrayIsMapped: - return "CUDA_ERROR_ARRAY_IS_MAPPED"; - case hipErrorAlreadyMapped: - return "CUDA_ERROR_ALREADY_MAPPED"; - case hipErrorNoBinaryForGpu: - return "CUDA_ERROR_NO_BINARY_FOR_GPU"; - case hipErrorAlreadyAcquired: - return "CUDA_ERROR_ALREADY_ACQUIRED"; - case hipErrorNotMapped: - return "CUDA_ERROR_NOT_MAPPED"; - case hipErrorNotMappedAsArray: - return "CUDA_ERROR_NOT_MAPPED_AS_ARRAY"; - case hipErrorNotMappedAsPointer: - return "CUDA_ERROR_NOT_MAPPED_AS_POINTER"; - case hipErrorECCNotCorrectable: - return "CUDA_ERROR_ECC_UNCORRECTABLE"; - case hipErrorUnsupportedLimit: - return "CUDA_ERROR_UNSUPPORTED_LIMIT"; - case hipErrorContextAlreadyInUse: - return "CUDA_ERROR_CONTEXT_ALREADY_IN_USE"; - case hipErrorPeerAccessUnsupported: - return "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"; - case hipErrorInvalidKernelFile: - return "CUDA_ERROR_INVALID_PTX"; - case hipErrorInvalidGraphicsContext: - return "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"; - case hipErrorInvalidSource: - return "CUDA_ERROR_INVALID_SOURCE"; - case hipErrorFileNotFound: - return "CUDA_ERROR_FILE_NOT_FOUND"; - case hipErrorSharedObjectSymbolNotFound: - return "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"; - case hipErrorSharedObjectInitFailed: - return "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"; - case hipErrorOperatingSystem: - return "CUDA_ERROR_OPERATING_SYSTEM"; - case hipErrorInvalidHandle: - return "CUDA_ERROR_INVALID_HANDLE"; - case hipErrorIllegalState: - return "CUDA_ERROR_ILLEGAL_STATE"; - case hipErrorNotFound: - return "CUDA_ERROR_NOT_FOUND"; - case hipErrorNotReady: - return "CUDA_ERROR_NOT_READY"; - case hipErrorIllegalAddress: - return "CUDA_ERROR_ILLEGAL_ADDRESS"; - case hipErrorLaunchOutOfResources: - return "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"; - case hipErrorLaunchTimeOut: - return "CUDA_ERROR_LAUNCH_TIMEOUT"; - case hipErrorPeerAccessAlreadyEnabled: - return "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"; - case hipErrorPeerAccessNotEnabled: - return "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"; - case hipErrorSetOnActiveProcess: - return "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE"; - case hipErrorContextIsDestroyed: - return "CUDA_ERROR_CONTEXT_IS_DESTROYED"; - case hipErrorAssert: - return "CUDA_ERROR_ASSERT"; - case hipErrorHostMemoryAlreadyRegistered: - return "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"; - case hipErrorHostMemoryNotRegistered: - return "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"; - case hipErrorLaunchFailure: - return "CUDA_ERROR_LAUNCH_FAILED"; - case hipErrorNotSupported: - return "CUDA_ERROR_NOT_SUPPORTED"; - case hipErrorUnknown: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorRuntimeMemory: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorRuntimeOther: - return "CUDA_ERROR_UNKNOWN"; - case hipErrorCooperativeLaunchTooLarge: - return "CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE"; - case hipErrorStreamCaptureUnsupported: - return "CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED"; - case hipErrorStreamCaptureInvalidated: - return "CUDA_ERROR_STREAM_CAPTURE_INVALIDATED"; - case hipErrorStreamCaptureMerge: - return "CUDA_ERROR_STREAM_CAPTURE_MERGE"; - case hipErrorStreamCaptureUnmatched: - return "CUDA_ERROR_STREAM_CAPTURE_UNMATCHED"; - case hipErrorStreamCaptureUnjoined: - return "CUDA_ERROR_STREAM_CAPTURE_UNJOINED"; - case hipErrorStreamCaptureIsolation: - return "CUDA_ERROR_STREAM_CAPTURE_ISOLATION"; - case hipErrorStreamCaptureImplicit: - return "CUDA_ERROR_STREAM_CAPTURE_IMPLICIT"; - case hipErrorCapturedEvent: - return "CUDA_ERROR_CAPTURED_EVENT"; - case hipErrorStreamCaptureWrongThread: - return "CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD"; - case hipErrorGraphExecUpdateFailure: - return "CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE"; - default: - return "CUDA_ERROR_UNKNOWN"; - #endif - } -} +/** + * @addtogroup hipDrvGetErrorName hipDrvGetErrorName + * @{ + * @ingroup ErrorTest + * `hipDrvGetErrorName(hipError_t hip_error)` - + * Return hip error as text string form. + */ -// Functional test case -// Test case to verify the returned error name is same as generated error name. - -TEST_CASE("Unit_hipDrvGetErrorName_Functional") { +/** + * Test Description + * ------------------------ + * - Validate that the correct string is returned for each supported + * device error enumeration. + * Test source + * ------------------------ + * - unit/errorHandling/hipDrvGetErrorName.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.4 + */ +TEST_CASE("Unit_hipDrvGetErrorName_Positive_Basic") { const char* error_string = nullptr; - hipError_t error_ret; const auto enumerator = - GENERATE(from_range(std::begin(kErrorEnumerators), - std::end(kErrorEnumerators))); - error_ret = hipDrvGetErrorName(enumerator, &error_string); + GENERATE(from_range(std::begin(kErrorEnumerators), std::end(kErrorEnumerators))); + INFO("Error: " << enumerator); + + HIP_CHECK(hipDrvGetErrorName(enumerator, &error_string)); + REQUIRE(error_string != nullptr); REQUIRE(strcmp(error_string, ErrorName(enumerator)) == 0); - REQUIRE(error_ret == hipSuccess); } -// Negative test cases. - -TEST_CASE("Unit_hipDrvGetErrorName_Negative") { +/** + * Test Description + * ------------------------ + * - Validate handling of invalid arguments: + * -# When error enumerator is invalid (-1) + * - AMD expected output: return "hipErrorUnknown" + * - NVIDIA expected output: return "cudaErrorUnknown" + * -# When nullptr is passed as store location + * - Expected output: return "hipErrorInvalidValue" + * Test source + * ------------------------ + * - unit/errorHandling/hipDrvGetErrorName.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.4 + */ +TEST_CASE("Unit_hipDrvGetErrorName_Negative_Parameters") { const char* error_string = nullptr; SECTION("pass unknown value to hipError") { - REQUIRE((hipDrvGetErrorName(static_cast(-1), &error_string)) - == hipErrorInvalidValue); + HIP_CHECK_ERROR((hipDrvGetErrorName(static_cast(-1), &error_string)), + hipErrorInvalidValue); } - #if HT_AMD +#if HT_AMD // segfaults on NVIDIA SECTION("pass nullptr to error string") { - REQUIRE((hipDrvGetErrorString(static_cast(0), nullptr)) - == hipErrorInvalidValue); + HIP_CHECK_ERROR((hipDrvGetErrorString(hipErrorInvalidValue, nullptr)), hipErrorInvalidValue); } - #endif +#endif } diff --git a/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorString.cc b/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorString.cc index 2b51a82422..5f35c344fe 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorString.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipDrvGetErrorString.cc @@ -1,5 +1,5 @@ /* -Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2023 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 @@ -17,247 +17,67 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include #include -#include "errorEnumerators.h" -// Local Function to return the error string. +#include "error_handling_common.hh" -static const char *ErrorString(hipError_t enumerator) { - switch (enumerator) { - case hipSuccess: - return "no error"; - case hipErrorInvalidValue: - return "invalid argument"; - case hipErrorOutOfMemory: - return "out of memory"; - case hipErrorNotInitialized: - return "initialization error"; - case hipErrorDeinitialized: - return "driver shutting down"; - case hipErrorProfilerDisabled: - return "profiler disabled while using external profiling tool"; - case hipErrorProfilerNotInitialized: - #if HT_AMD - return "profiler is not initialized"; - #elif HT_NVIDIA - return "profiler not initialized: call cudaProfilerInitialize()"; - #endif - case hipErrorProfilerAlreadyStarted: - return "profiler already started"; - case hipErrorProfilerAlreadyStopped: - return "profiler already stopped"; - #if HT_AMD - case hipErrorInvalidConfiguration: - return "invalid configuration argument"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInvalidPitchValue: - return "invalid pitch argument"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInvalidSymbol: - return "invalid device symbol"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInvalidDevicePointer: - return "invalid device pointer"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInvalidMemcpyDirection: - return "invalid copy direction for memcpy"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInsufficientDriver: - return "driver version is insufficient for runtime version"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorMissingConfiguration: - return "__global__ function call is not configured"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorPriorLaunchFailure: - return "unspecified launch failure in prior launch"; - #elif HT_NVIDIA - return "unknown error"; - #endif - #if HT_AMD - case hipErrorInvalidDeviceFunction: - return "invalid device function"; - #elif HT_NVIDIA - return "unknown error"; - #endif - case hipErrorNoDevice: - #if HT_AMD - return "no ROCm-capable device is detected"; - #elif HT_NVIDIA - return "no CUDA-capable device is detected"; - #endif - case hipErrorInvalidDevice: - return "invalid device ordinal"; - case hipErrorInvalidImage: - return "device kernel image is invalid"; - case hipErrorInvalidContext: - return "invalid device context"; - case hipErrorContextAlreadyCurrent: - #if HT_AMD - return "context is already current context"; - #elif HT_NVIDIA - return "context already current"; - #endif - case hipErrorMapFailed: - return "mapping of buffer object failed"; - case hipErrorUnmapFailed: - return "unmapping of buffer object failed"; - case hipErrorArrayIsMapped: - return "array is mapped"; - case hipErrorAlreadyMapped: - return "resource already mapped"; - case hipErrorNoBinaryForGpu: - return "no kernel image is available for execution on the device"; - case hipErrorAlreadyAcquired: - return "resource already acquired"; - case hipErrorNotMapped: - return "resource not mapped"; - case hipErrorNotMappedAsArray: - return "resource not mapped as array"; - case hipErrorNotMappedAsPointer: - return "resource not mapped as pointer"; - case hipErrorECCNotCorrectable: - return "uncorrectable ECC error encountered"; - case hipErrorUnsupportedLimit: - return "limit is not supported on this architecture"; - case hipErrorContextAlreadyInUse: - return "exclusive-thread device already in use by a different thread"; - case hipErrorPeerAccessUnsupported: - return "peer access is not supported between these two devices"; - case hipErrorInvalidKernelFile: - #if HT_AMD - return "invalid kernel file"; - #elif HT_NVIDIA - return "a PTX JIT compilation failed"; - #endif - case hipErrorInvalidGraphicsContext: - return "invalid OpenGL or DirectX context"; - case hipErrorInvalidSource: - return "device kernel image is invalid"; - case hipErrorFileNotFound: - return "file not found"; - case hipErrorSharedObjectSymbolNotFound: - return "shared object symbol not found"; - case hipErrorSharedObjectInitFailed: - return "shared object initialization failed"; - case hipErrorOperatingSystem: - return "OS call failed or operation not supported on this OS"; - case hipErrorInvalidHandle: - return "invalid resource handle"; - case hipErrorIllegalState: - return "the operation cannot be performed in the present state"; - case hipErrorNotFound: - return "named symbol not found"; - case hipErrorNotReady: - return "device not ready"; - case hipErrorIllegalAddress: - return "an illegal memory access was encountered"; - case hipErrorLaunchOutOfResources: - return "too many resources requested for launch"; - case hipErrorLaunchTimeOut: - return "the launch timed out and was terminated"; - case hipErrorPeerAccessAlreadyEnabled: - return "peer access is already enabled"; - case hipErrorPeerAccessNotEnabled: - return "peer access has not been enabled"; - case hipErrorSetOnActiveProcess: - return "cannot set while device is active in this process"; - case hipErrorContextIsDestroyed: - return "context is destroyed"; - case hipErrorAssert: - return "device-side assert triggered"; - case hipErrorHostMemoryAlreadyRegistered: - return "part or all of the requested memory range is already mapped"; - case hipErrorHostMemoryNotRegistered: - return "pointer does not correspond to a registered memory region"; - case hipErrorLaunchFailure: - return "unspecified launch failure"; - case hipErrorCooperativeLaunchTooLarge: - return "too many blocks in cooperative launch"; - case hipErrorNotSupported: - return "operation not supported"; - case hipErrorStreamCaptureUnsupported: - return "operation not permitted when stream is capturing"; - case hipErrorStreamCaptureInvalidated: - return "operation failed due to a previous error during capture"; - case hipErrorStreamCaptureMerge: - return "operation would result in a merge of separate capture sequences"; - case hipErrorStreamCaptureUnmatched: - return "capture was not ended in the same stream as it began"; - case hipErrorStreamCaptureUnjoined: - return "capturing stream has unjoined work"; - case hipErrorStreamCaptureIsolation: - return "dependency created on uncaptured work in another stream"; - case hipErrorStreamCaptureImplicit: - return "operation would make the legacy stream depend on a capturing blocking stream"; //NOLINT - case hipErrorCapturedEvent: - return "operation not permitted on an event last recorded in a capturing stream"; //NOLINT - case hipErrorStreamCaptureWrongThread: - return "attempt to terminate a thread-local capture sequence from another thread"; //NOLINT - case hipErrorGraphExecUpdateFailure: - return "the graph update was not performed because it included changes which violated constraints specific to instantiated graph update"; //NOLINT - case hipErrorRuntimeMemory: - return "runtime memory call returned error"; - case hipErrorRuntimeOther: - return "runtime call other than memory returned error"; - case hipErrorUnknown: - default: - #if HT_AMD - return "unknown error"; - #elif HT_NVIDIA - return "unknown error"; - #endif - } -} +/** + * @addtogroup hipDrvGetErrorString hipDrvGetErrorString + * @{ + * @ingroup ErrorTest + * `hipDrvGetErrorString(hipError_t hipError)` - + * Return handy text string message to explain the error which occurred. + */ -// Test case to verify the returned error string is -// same as generated error string. - -TEST_CASE("Unit_hipDrvGetErrorString_Functional") { +/** + * Test Description + * ------------------------ + * - Validate that the correct string is returned for each supported + * device error enumeration. + * Test source + * ------------------------ + * - unit/errorHandling/hipDrvGetErrorString.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.4 + */ +TEST_CASE("Unit_hipDrvGetErrorString_Positive_Basic") { const char* error_string = nullptr; const auto enumerator = - GENERATE(from_range(std::begin(kErrorEnumerators), - std::end(kErrorEnumerators))); - hipError_t error_ret = hipDrvGetErrorString(enumerator, &error_string); + GENERATE(from_range(std::begin(kErrorEnumerators), std::end(kErrorEnumerators))); + INFO("Error: " << enumerator); + + HIP_CHECK(hipDrvGetErrorString(enumerator, &error_string)); + REQUIRE(error_string != nullptr); REQUIRE(strcmp(error_string, ErrorString(enumerator)) == 0); - REQUIRE(error_ret == hipSuccess); } -// Negative test cases. - -TEST_CASE("Unit_hipDrvGetErrorString_Negative") { +/** + * Test Description + * ------------------------ + * - Validate handling of invalid arguments: + * -# When error enumerator is invalid (-1) + * - Expected output: return "hipErrorInvalidValue" + * -# When nullptr is passed as store location + * - Expected output: return "hipErrorInvalidValue" + * Test source + * ------------------------ + * - unit/errorHandling/hipDrvGetErrorString.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.4 + */ +TEST_CASE("Unit_hipDrvGetErrorString_Negative_Parameters") { const char* error_string = nullptr; SECTION("pass unknown value to hipError") { - REQUIRE((hipDrvGetErrorString(static_cast(-1), &error_string)) - == hipErrorInvalidValue); + HIP_CHECK_ERROR((hipDrvGetErrorString(static_cast(-1), &error_string)), + hipErrorInvalidValue); } - #if HT_AMD +#if HT_AMD // segfaults on NVIDIA SECTION("pass nullptr to error string") { - REQUIRE((hipDrvGetErrorString(static_cast(0), nullptr)) - == hipErrorInvalidValue); + HIP_CHECK_ERROR((hipDrvGetErrorString(static_cast(0), nullptr)), + hipErrorInvalidValue); } - #endif +#endif } diff --git a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc index a498e62387..75d9f4a549 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorName.cc @@ -20,10 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "errorEnumerators.h" #include -#include + +#include "error_handling_common.hh" /** * @addtogroup hipGetErrorName hipGetErrorName @@ -49,6 +48,7 @@ TEST_CASE("Unit_hipGetErrorName_Positive_Basic") { const char* error_string = nullptr; const auto enumerator = GENERATE(from_range(std::begin(kErrorEnumerators), std::end(kErrorEnumerators))); + INFO("Error: " << enumerator); error_string = hipGetErrorName(enumerator); diff --git a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc index e38f0dc54e..6becd9fdb6 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipGetErrorString.cc @@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "errorEnumerators.h" #include -#include + +#include "error_handling_common.hh" /** * @addtogroup hipGetErrorString hipGetErrorString @@ -48,6 +48,7 @@ TEST_CASE("Unit_hipGetErrorString_Positive_Basic") { const char* error_string = nullptr; const auto enumerator = GENERATE(from_range(std::begin(kErrorEnumerators), std::end(kErrorEnumerators))); + INFO("Error: " << enumerator); error_string = hipGetErrorString(enumerator); diff --git a/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc b/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc index ae22a3067a..aac75e41e1 100644 --- a/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc +++ b/projects/hip-tests/catch/unit/errorHandling/hipPeekAtLastError.cc @@ -21,7 +21,6 @@ THE SOFTWARE. */ #include -#include #include /** @@ -56,7 +55,8 @@ TEST_CASE("Unit_hipPeekAtLastError_Positive_Basic") { * Test Description * ------------------------ * - Validate that appropriate error is returned when working with multiple threads. - * - Validate that appropriate error is returned for getting the last erro when working with multiple threads. + * - Validate that appropriate error is returned for getting the last error when working with + * multiple threads. * - Cause error on purpose within one of the threads. * Test source * ------------------------