From a8f65237ebd51fce0a50769809274239c65e9157 Mon Sep 17 00:00:00 2001 From: milos-mozetic <118800401+milos-mozetic@users.noreply.github.com> Date: Wed, 28 Jun 2023 06:14:00 +0200 Subject: [PATCH] EXSWHTEC-224 - Test cases ID clean up and documentation for Device Management (#70) - Test cases ID clean up and documentation for Device Management - Adjust doxygen comments to fix bugs - Adjust defgroup comments for test modules [ROCm/hip-tests commit: d0295c4295c8af0019b9b948ae79bbaa5c8a1e68] --- .../catch/include/hip_test_defgroups.hh | 9 +- .../catch/multiproc/hipIpcEventHandle.cc | 98 +++++++++--- .../catch/multiproc/hipIpcMemAccessTest.cc | 64 +++++++- .../catch/unit/device/hipChooseDevice.cc | 38 ++++- .../unit/device/hipDeviceGetDefaultMemPool.cc | 36 +++++ .../catch/unit/device/hipDeviceGetLimit.cc | 49 ++++-- .../catch/unit/device/hipDeviceReset.cc | 37 +++++ .../unit/device/hipDeviceSetGetCacheConfig.cc | 98 +++++++++++- .../unit/device/hipDeviceSetGetMemPool.cc | 107 +++++++++++++ .../device/hipDeviceSetGetSharedMemConfig.cc | 95 +++++++++++ .../catch/unit/device/hipDeviceSetLimit.cc | 32 ++-- .../catch/unit/device/hipDeviceSynchronize.cc | 52 +++++- .../device/hipExtGetLinkTypeAndHopCount.cc | 56 ++++++- .../unit/device/hipGetDeviceAttribute.cc | 71 ++++++++- .../catch/unit/device/hipGetDeviceCount.cc | 49 +++++- .../unit/device/hipGetDeviceProperties.cc | 54 ++++++- .../catch/unit/device/hipGetSetDeviceFlags.cc | 150 ++++++++++++++---- .../catch/unit/device/hipIpcCloseMemHandle.cc | 38 +++++ .../catch/unit/device/hipIpcGetMemHandle.cc | 64 ++++++++ .../catch/unit/device/hipIpcOpenMemHandle.cc | 39 +++++ .../catch/unit/device/hipSetGetDevice.cc | 89 ++++++++++- .../unit/graph/hipGraphKernelNodeSetParams.cc | 4 +- .../catch/unit/graph/hipUserObjectCreate.cc | 6 +- 23 files changed, 1195 insertions(+), 140 deletions(-) diff --git a/projects/hip-tests/catch/include/hip_test_defgroups.hh b/projects/hip-tests/catch/include/hip_test_defgroups.hh index 4fa9facedb..360bfe1282 100644 --- a/projects/hip-tests/catch/include/hip_test_defgroups.hh +++ b/projects/hip-tests/catch/include/hip_test_defgroups.hh @@ -32,7 +32,14 @@ THE SOFTWARE. /** * @defgroup GraphTest Graph Management * @{ - * This section describes the graph management types & functions of HIP runtime API. + * This section describes tests for the graph management types & functions of HIP runtime API. + * @} + */ + +/** + * @defgroup DeviceTest Device Management + * @{ + * This section describes tests for device management functions of HIP runtime API. * @} */ diff --git a/projects/hip-tests/catch/multiproc/hipIpcEventHandle.cc b/projects/hip-tests/catch/multiproc/hipIpcEventHandle.cc index 440b00f598..1e16aaf7cb 100644 --- a/projects/hip-tests/catch/multiproc/hipIpcEventHandle.cc +++ b/projects/hip-tests/catch/multiproc/hipIpcEventHandle.cc @@ -17,23 +17,6 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/** - -Testcase Scenarios ------------------- -Functional: -1) Validate usecase of Event handle along with memory handle across multiple -processes with complex scenario. - -Negative/Argument Validation: -1) Get event handle with eventHandle(nullptr). -2) Get event handle with event(nullptr). -3) Get event handle with invalid event object. -4) Get event handle for event allocated without Interprocess flag. -5) Open event handle with event(nullptr). -6) Open event handle with eventHandle as invalid. -*/ - #include #include @@ -42,6 +25,14 @@ Negative/Argument Validation: #include #include +/** + * @addtogroup hipIpcGetEventHandle hipIpcGetEventHandle + * @{ + * @ingroup DeviceTest + * `hipIpcGetEventHandle(hipIpcEventHandle_t* handle, hipEvent_t event)` - + * Gets an opaque interprocess handle for an event. + * This opaque handle may be copied into other processes and opened with hipIpcOpenEventHandle. + */ #define BUF_SIZE 4096 #define MAX_DEVICES 16 @@ -65,7 +56,7 @@ typedef struct ipcBarrier { bool allExit; } ipcBarrier_t; -/** +/* Get device count and list down devices with P2P access with Device 0. */ @@ -118,7 +109,7 @@ static ipcBarrier_t *g_Barrier{}; static bool g_procSense; static int g_processCnt; -/** +/* Calling process waits for other processes to signal/complete. */ void processBarrier() { @@ -147,7 +138,7 @@ __global__ void computeKernel(int *dst, int *src, int num) { dst[idx] = src[idx] / num; } -/** +/* * 1) Process 0 allocates buffer in GPU0 memory and exports the memory handle. * 2) Other processes opens memory handle of GPU0 memory, performs computation * and records event. @@ -235,8 +226,19 @@ void runMultiProcKernel(ipcEventInfo_t *shmEventInfo, int index) { } /** - Functional test demonstrating IPC event usage along with IPC memory handle -*/ + * Test Description + * ------------------------ + * - Validate use case of event handle along with memory handle + * across multiple processes with complex scenario. + * - Utilizes synchronization of processes and events. + * - Lauches kernels and validates computation results. + * Test source + * ------------------------ + * - unit/multiproc/hipIpcEventHandle.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcEventHandle_Functional") { ipcDevices_t *shmDevices; ipcEventInfo_t *shmEventInfo; @@ -300,8 +302,38 @@ TEST_CASE("Unit_hipIpcEventHandle_Functional") { } /** - Performs API Parameter validation. -*/ + * Test Description + * ------------------------ + * - Validates handling of invalid arguments for + * [hipIpcGetEventHandle](@ref hipIpcGetEventHandle): + * -# When pointer to the event handle is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When pointer to the event is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When both pointers are `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When event is not valid + * - Expected output: return `hipErrorInvalidValue` + * -# When event is created without interprocess flag + * - Expected output: return `hipErrorInvalidResourceHandle` or `hipErrorInvalidConfiguration` + * -# When event is created without flags + * - Expected output: return `hipErrorInvalidResourceHandle` + * - Validates handling of invalid arguments for + * [hipIpcOpenEventHandle](@ref hipIpcOpenEventHandle) + * -# When pointer to the event is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When pointer to the event handle is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When attemted to open handle in the process that created it + * - Expected output: return `hipErrorInvalidContext` + * Test source + * ------------------------ + * - unit/multiproc/hipIpcEventHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcEventHandle_ParameterValidation") { hipEvent_t event; hipIpcEventHandle_t eventHandle; @@ -381,4 +413,22 @@ TEST_CASE("Unit_hipIpcEventHandle_ParameterValidation") { #endif } +/** + * End doxygen group hipIpcGetEventHandle. + * @} + */ + +/** + * @addtogroup hipIpcOpenEventHandle hipIpcOpenEventHandle + * @{ + * @ingroup DeviceTest + * `hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle)` - + * Opens an interprocess event handles. + * Opens an interprocess event handle exported from another process with hipIpcGetEventHandle. + * ________________________ + * Test cases from other modules: + * - @ref Unit_hipIpcEventHandle_Functional + * - @ref Unit_hipIpcEventHandle_ParameterValidation + */ + #endif diff --git a/projects/hip-tests/catch/multiproc/hipIpcMemAccessTest.cc b/projects/hip-tests/catch/multiproc/hipIpcMemAccessTest.cc index fee23c1ef4..8750bc4306 100644 --- a/projects/hip-tests/catch/multiproc/hipIpcMemAccessTest.cc +++ b/projects/hip-tests/catch/multiproc/hipIpcMemAccessTest.cc @@ -17,12 +17,6 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - 1)Testcase verifies the hipIpcMemAccess APIs by creating memory handle -in parent process and access it in child process. - 2)Test case performs Parameter validation of hipIpcMemAccess APIs. -*/ - #include #include @@ -34,6 +28,14 @@ in parent process and access it in child process. #include #include +/** + * @addtogroup hipIpcOpenMemHandle hipIpcOpenMemHandle + * @{ + * @ingroup DeviceTest + * `hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags)` - + * Opens an interprocess memory handle exported from another process + * and returns a device pointer usable in the local process. + */ #define NUM_ELMTS 1024 #define NUM_THREADS 10 @@ -58,6 +60,23 @@ typedef struct mem_handle { // and check for data consistencies and close the hipIpcCloseMemHandle // release the parent and wait for parent to release itself(child) +/** + * Test Description + * ------------------------ + * - Verifies that getting and opening mem handle works correctly + * in specific scenarion, and handles the case when the same device + * is used in both processes. + * - Creates memory from the parent process for each device. + * - Spawns child process and waits for it to finish. + * - Child process gets the handle and check data consistencies. + * Test source + * ------------------------ + * - unit/multiproc/hipIpcMemAccessTest.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcMemAccess_Semaphores") { hip_ipc_t *shrd_mem = NULL; pid_t pid; @@ -161,6 +180,39 @@ TEST_CASE("Unit_hipIpcMemAccess_Semaphores") { REQUIRE(shrd_mem->IfTestPassed == true); } +/** + * Test Description + * ------------------------ + * - Validates handling of valid and invalid arguments for + * [hipIpcGetMemHandle](@ref hipIpcGetMemHandle): + * -# When memory handle pointer is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When device pointer is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When both pointers are `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When both pointers are valid + * - Expected output: return `hipSuccess` + * - Validates handling of valid and invalid arguments for + * [hipIpcOpenMemHandle](@ref hipIpcOpenMemHandle): + * -# When device pointer is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When memory handle pointer uninitialized + * - Expected output: return `hipErrorInvalidValue` or `hipErrorInvalidDevicePointer` + * -# When memory handle has random flags + * - Expected output: return `hipErrorInvalidValue` + * - Validates handling of valid and invalid arguments for + * [hipIpcCloseMemHandle](@ref hipIpcCloseMemHandle): + * -# When device pointer is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/multiproc/hipIpcMemAccessTest.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcMemAccess_ParameterValidation") { hipIpcMemHandle_t MemHandle; hipIpcMemHandle_t MemHandleUninit; diff --git a/projects/hip-tests/catch/unit/device/hipChooseDevice.cc b/projects/hip-tests/catch/unit/device/hipChooseDevice.cc index 0cbcc68a4a..d27cddc424 100644 --- a/projects/hip-tests/catch/unit/device/hipChooseDevice.cc +++ b/projects/hip-tests/catch/unit/device/hipChooseDevice.cc @@ -23,8 +23,23 @@ THE SOFTWARE. #include /** - * hipChooseDevice tests - * Scenario: Validates dev id value. + * @addtogroup hipChooseDevice hipChooseDevice + * @{ + * @ingroup DeviceTest + * `hipChooseDevice(int* device, const hipDeviceProp_t* prop)` - + * Device which matches `hipDeviceProp_t` is returned. + */ + +/** + * Test Description + * ------------------------ + * - Validate chosen device against gotten device properties. + * Test source + * ------------------------ + * - unit/device/hipChooseDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipChooseDevice_ValidateDevId") { hipDeviceProp_t prop; @@ -36,21 +51,30 @@ TEST_CASE("Unit_hipChooseDevice_ValidateDevId") { REQUIRE_FALSE(dev < 0); REQUIRE_FALSE(dev >= numDevices); } + /** - * hipChooseDevice tests - * Scenario1: Validates if dev = nullptr returns error code - * Scenario2: Validates if prop = nullptr returns error code + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When pointer to the device is `nullptr` + * - Expected output: do not return `hipSuccess` + * -# When pointer to the properties is `nullptr` + * - Expected output: do not return `hipSuccess` + * Test source + * ------------------------ + * - unit/device/hipChooseDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipChooseDevice_NegTst") { hipDeviceProp_t prop; int dev = -1; - // Scenario1 SECTION("dev is nullptr") { REQUIRE_FALSE(hipSuccess == hipChooseDevice(nullptr, &prop)); } - // Scenario2 SECTION("prop is nullptr") { REQUIRE_FALSE(hipSuccess == hipChooseDevice(&dev, nullptr)); } diff --git a/projects/hip-tests/catch/unit/device/hipDeviceGetDefaultMemPool.cc b/projects/hip-tests/catch/unit/device/hipDeviceGetDefaultMemPool.cc index 822c2ab81c..12d620d6ce 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceGetDefaultMemPool.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceGetDefaultMemPool.cc @@ -23,6 +23,25 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipDeviceGetDefaultMemPool hipDeviceGetDefaultMemPool + * @{ + * @ingroup DeviceTest + * `hipDeviceGetDefaultMemPool(hipMemPool_t* mem_pool, int device)` - + * Returns the default memory pool of the specified device + */ + +/** + * Test Description + * ------------------------ + * - Check that MemPool can be fetched and is not `nullptr`. + * Test source + * ------------------------ + * - unit/device/hipDeviceGetDefaultMemPool.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetDefaultMemPool_Positive_Basic") { const int device = GENERATE(range(0, HipTest::getDeviceCount())); @@ -39,6 +58,23 @@ TEST_CASE("Unit_hipDeviceGetDefaultMemPool_Positive_Basic") { REQUIRE(mem_pool != nullptr); } +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When output pointer to the MemPool is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When device ID is equal to -1 + * - Expected output: return 'hipErrorInvalidDevice' + * -# When device ID is out of bounds + * - Expected output: return 'hipErrorInvalidDevice' + * Test source + * ------------------------ + * - unit/device/hipDeviceGetDefaultMemPool.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetDefaultMemPool_Negative_Parameters") { hipMemPool_t mem_pool; diff --git a/projects/hip-tests/catch/unit/device/hipDeviceGetLimit.cc b/projects/hip-tests/catch/unit/device/hipDeviceGetLimit.cc index cf3de67cdc..24c9b143e0 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceGetLimit.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceGetLimit.cc @@ -17,34 +17,59 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Conformance test for checking functionality of - * hipError_t hipDeviceGetLimit(size_t* pValue, enum hipLimit_t limit); - */ -#include /** - * hipDeviceGetLimit tests - * Scenario1: Validates if pValue = nullptr returns hip error code. - * Scenario2: Validates if *pValue > 0 is returned for limit = hipLimitMallocHeapSize. - * Scenario3: Validates if error code is returned for limit = Invalid Flag = 0xff. + * @addtogroup hipDeviceGetLimit hipDeviceGetLimit + * @{ + * @ingroup DeviceTest + * `hipDeviceGetLimit(size_t* pValue, enum hipLimit_t limit)` - + * Get Resource limits of current device. + */ + +#include + +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When output pointer to the limit value is `nullptr` + * - Expected output: do not return `hipSuccess` + * -# When limit enum is out of bounds + * - Expected output: do not return `hipSuccess` + * Test source + * ------------------------ + * - unit/device/hipDeviceGetLimit.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipDeviceGetLimit_NegTst") { size_t Value = 0; - // Scenario1 + SECTION("NULL check") { REQUIRE_FALSE(hipDeviceGetLimit(nullptr, hipLimitMallocHeapSize) == hipSuccess); } - // Scenario3 + SECTION("Invalid Input Flag") { REQUIRE_FALSE(hipDeviceGetLimit(&Value, static_cast(0xff)) == hipSuccess); } } +/** + * Test Description + * ------------------------ + * - Validate that returned limit value for Malloc Heap size is valid. + * Test source + * ------------------------ + * - unit/device/hipDeviceGetLimit.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetLimit_CheckValidityOfOutputVal") { size_t Value = 0; - // Scenario2 + REQUIRE(hipDeviceGetLimit(&Value, hipLimitMallocHeapSize) == hipSuccess); REQUIRE_FALSE(Value <= 0); diff --git a/projects/hip-tests/catch/unit/device/hipDeviceReset.cc b/projects/hip-tests/catch/unit/device/hipDeviceReset.cc index ad9e6fe0c1..b65155db6f 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceReset.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceReset.cc @@ -22,6 +22,30 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipDeviceReset hipDeviceReset + * @{ + * @ingroup DeviceTest + * `hipDeviceReset(void)` - + * The state of current device is discarded and updated to a fresh state. + * + * Calling this function deletes all streams created, memory allocated, kernels running, events + * created. Make sure that no other thread is using the device or streams, memory, kernels, events + * associated with the current device. + */ + +/** + * Test Description + * ------------------------ + * - Validates that device reset frees allocated memory and + * reverts modified flags and configs to its default values. + * Test source + * ------------------------ + * - unit/device/hipDeviceReset.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceReset_Positive_Basic") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -74,6 +98,19 @@ TEST_CASE("Unit_hipDeviceReset_Positive_Basic") { } } +/** + * Test Description + * ------------------------ + * - Resets device from another thread + * - Validates that device reset frees allocated memory from the main + * thread, and reverts modified flags and configs to its default values. + * Test source + * ------------------------ + * - unit/device/hipDeviceReset.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceReset_Positive_Threaded") { HIP_CHECK(hipSetDevice(0)); INFO("Current device is: " << 0); diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc b/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc index dc82a85fc3..5034bf9d46 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc @@ -24,13 +24,31 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipDeviceSetCacheConfig hipDeviceSetCacheConfig + * @{ + * @ingroup DeviceTest + * `hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig)` - + * Set L1/Shared cache partition. + */ + namespace { constexpr std::array kCacheConfigs{ hipFuncCachePreferNone, hipFuncCachePreferShared, hipFuncCachePreferL1, hipFuncCachePreferEqual}; } // anonymous namespace - +/** + * Test Description + * ------------------------ + * - Check that `hipSuccess` is returned for all enumerators of `hipFuncCache_t` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetCacheConfig_Positive_Basic") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -41,6 +59,21 @@ TEST_CASE("Unit_hipDeviceSetCacheConfig_Positive_Basic") { HIP_CHECK(hipDeviceSetCacheConfig(cache_config)); } +/** + * Test Description + * ------------------------ + * - Handle invalid cache config (-1): + * -# When platform is AMD + * - Expected output: return `hipErrorNotSupported` + * -# When platform is NVIDIA + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetCacheConfig_Negative_Parameters") { #if HT_AMD HIP_CHECK_ERROR(hipDeviceSetCacheConfig(static_cast(-1)), hipSuccess); @@ -49,6 +82,31 @@ TEST_CASE("Unit_hipDeviceSetCacheConfig_Negative_Parameters") { #endif } +/** + * End doxygen group hipDeviceSetCacheConfig. + * @} + */ + +/** + * @addtogroup hipDeviceGetCacheConfig hipDeviceGetCacheConfig + * @{ + * @ingroup DeviceTest + * `hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig)` - + * Get Cache configuration for a specific Device. + */ + +/** + * Test Description + * ------------------------ + * - Check that default cache config is returned if set + * has not been called previously. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Default") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -59,6 +117,19 @@ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Default") { REQUIRE(cache_config == hipFuncCachePreferNone); } +/** + * Test Description + * ------------------------ + * - Check that the returned cache configuration is equal to + * the one that is set previously. + * - Verify for multiple devices. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Basic") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -74,6 +145,18 @@ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Basic") { REQUIRE(returned_cache_config == cache_config); } +/** + * Test Description + * ------------------------ + * - Check that the returned cache configuration from the main thread + * is equal to the one that is set previously from different thread. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Threaded") { class HipDeviceSetGetCacheConfigTest : public ThreadedZigZagTest { public: @@ -99,6 +182,19 @@ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Threaded") { test.run(); } +/** + * Test Description + * ------------------------ + * - Verify handling of invalid arguments: + * -# When cache config is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetCacheConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_HipDeviceGetCacheConfig_Negative_Parameters") { HIP_CHECK_ERROR(hipDeviceGetCacheConfig(nullptr), hipErrorInvalidValue); } diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSetGetMemPool.cc b/projects/hip-tests/catch/unit/device/hipDeviceSetGetMemPool.cc index 089c8003ac..83329146ca 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSetGetMemPool.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSetGetMemPool.cc @@ -24,6 +24,16 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipDeviceSetMemPool hipDeviceSetMemPool + * @{ + * @ingroup DeviceTest + * `hipDeviceSetMemPool(int device, hipMemPool_t mem_pool)` - + * Sets the current memory pool of a device. + * + * The memory pool must be local to the specified device. + */ + static inline bool CheckMemPoolSupport(const int device) { int mem_pool_support = 0; HIP_CHECK( @@ -50,6 +60,18 @@ static inline hipMemPool_t CreateMemPool(const int device) { return mem_pool; } +/** + * Test Description + * ------------------------ + * - Validate behaviour when the valid MemPool is used, for multiple devices. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetMemPool_Positive_Basic") { const int device = GENERATE(range(0, HipTest::getDeviceCount())); @@ -63,6 +85,24 @@ TEST_CASE("Unit_hipDeviceSetMemPool_Positive_Basic") { HIP_CHECK(hipMemPoolDestroy(mem_pool)); } +/** + * Test Description + * ------------------------ + * - Validate handling of invalid arguments: + * -# When pointer to MemPool is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When device ID is equal to -1 + * - Expected output: return `hipErrorInvalidValue` + * -# When device ID is out of bounds + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetMemPool_Negative_Parameters") { hipMemPool_t mem_pool; HIP_CHECK(hipDeviceGetDefaultMemPool(&mem_pool, 0)); @@ -80,6 +120,31 @@ TEST_CASE("Unit_hipDeviceSetMemPool_Negative_Parameters") { } } +/** + * End doxygen group hipDeviceSetMemPool. + * @} + */ + +/** + * @addtogroup hipDeviceGetMemPool hipDeviceGetMemPool + * @{ + * @ingroup DeviceTest + * `hipDeviceGetMemPool(hipMemPool_t* mem_pool, int device)` - + * Gets the current memory pool for the specified device + */ + +/** + * Test Description + * ------------------------ + * - Checks that returned MemPool is the default MemPool. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Default") { const int device = GENERATE(range(0, HipTest::getDeviceCount())); @@ -96,6 +161,18 @@ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Default") { REQUIRE(mem_pool == default_mem_pool); } +/** + * Test Description + * ------------------------ + * - Checks that returned MemPool is equal to the mempool that is set. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Basic") { const int device = GENERATE(range(0, HipTest::getDeviceCount())); @@ -114,6 +191,18 @@ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Basic") { HIP_CHECK(hipMemPoolDestroy(mem_pool)); } +/** + * Test Description + * ------------------------ + * - Checks that returned MemPool is equal to the mempool that is set from a different thread. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Threaded") { class HipDeviceGetMemPoolTest : public ThreadedZigZagTest { public: @@ -141,6 +230,24 @@ TEST_CASE("Unit_hipDeviceGetMemPool_Positive_Threaded") { test.run(); } +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When output pointer to the MemPool is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When device ID is equal to -1 + * - Expected output: return `hipErrorInvalidValue` + * -# When device ID is out of bounds + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetMemPool.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetMemPool_Negative_Parameters") { hipMemPool_t mem_pool; diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSetGetSharedMemConfig.cc b/projects/hip-tests/catch/unit/device/hipDeviceSetGetSharedMemConfig.cc index 9a1230a7c8..ca8df7458c 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSetGetSharedMemConfig.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSetGetSharedMemConfig.cc @@ -24,11 +24,30 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipDeviceSetSharedMemConfig hipDeviceSetSharedMemConfig + * @{ + * @ingroup DeviceTest + * `hipDeviceSetSharedMemConfig(hipSharedMemConfig config)` - + * The bank width of shared memory on current device is set. + */ + namespace { constexpr std::array kMemConfigs{ hipSharedMemBankSizeDefault, hipSharedMemBankSizeFourByte, hipSharedMemBankSizeEightByte}; } // anonymous namespace +/** + * Test Description + * ------------------------ + * - Checks that all shared memory configs can be set. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetSharedMemConfig_Positive_Basic") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); const auto mem_config = GENERATE(from_range(std::begin(kMemConfigs), std::end(kMemConfigs))); @@ -38,11 +57,49 @@ TEST_CASE("Unit_hipDeviceSetSharedMemConfig_Positive_Basic") { HIP_CHECK(hipDeviceSetSharedMemConfig(mem_config)); } +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When shared memory config has ordinal enum number -1: + * - AMD expected output: return `hipErrorNotSupported` + * - NVIDIA expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSetSharedMemConfig_Negative_Parameters") { HIP_CHECK_ERROR(hipDeviceSetSharedMemConfig(static_cast(-1)), hipErrorInvalidValue); } +/** + * End doxygen group hipDeviceSetSharedMemConfig. + * @} + */ + +/** + * @addtogroup hipDeviceGetSharedMemConfig hipDeviceGetSharedMemConfig + * @{ + * @ingroup DeviceTest + * `hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig)` - + * Returns bank width of shared memory for current device. + */ + +/** + * Test Description + * ------------------------ + * - Checks that the returned shared memory configuration is the default one. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Default") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -53,6 +110,18 @@ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Default") { REQUIRE(mem_config == hipSharedMemBankSizeFourByte); } +/** + * Test Description + * ------------------------ + * - Checks that the returned shared memory configuration is equal + * to the one that is set previously. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Basic") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); const auto mem_config = GENERATE(from_range(std::begin(kMemConfigs), std::end(kMemConfigs))); @@ -74,6 +143,19 @@ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Basic") { } } +/** + * Test Description + * ------------------------ + * - Checks that the returned shared memory configuration from + * the main thread is equal to the one that is set in a separate + * thread previously. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Threaded") { class HipDeviceGetSharedMemConfigTest : public ThreadedZigZagTest { @@ -107,6 +189,19 @@ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Positive_Threaded") { test.run(); } +/** + * Test Description + * ------------------------ + * - Verifies handling of invalid arguments: + * -# When pointer to the output shared memory configuration is `nullptr`: + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipDeviceSetGetSharedMemConfig.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceGetSharedMemConfig_Negative_Parameters") { HIP_CHECK_ERROR(hipDeviceGetSharedMemConfig(nullptr), hipErrorInvalidValue); } diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSetLimit.cc b/projects/hip-tests/catch/unit/device/hipDeviceSetLimit.cc index 0007a942e7..4760f22756 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSetLimit.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSetLimit.cc @@ -17,12 +17,16 @@ OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Conformance test for checking functionality of - * hipError_t hipDeviceSetLimit ( enum hipLimit_t limit, size_t value ); - */ #include +/** + * @addtogroup hipDeviceSetLimit hipDeviceSetLimit + * @{ + * @ingroup DeviceTest + * `hipDeviceSetLimit(enum hipLimit_t limit, size_t value)` - + * Set Resource limits of current device. + */ + // Currently the HIGHER_VALUE is fixed to 16 KB based on currently // set maximum value for hipLimitStackSize. In future, this value // might need to change to avoid test case failure. In the same way @@ -51,17 +55,15 @@ static bool testSetLimitFunc(hipLimit_t limit_to_test) { } /** - * hipDeviceSetLimit tests => - * - * Scenario1: Single device Set-Get test for hipLimitStackSize flag. - * - * Scenario2: Single device Set-Get test for hipLimitPrintfFifoSize flag. - * - * Scenario3: Single device Set-Get test for hipLimitMallocHeapSize flag. - * - * Scenario4: Multidevice Set-Get test for all the flags - * - * Scenario5: Negative Scenario - Invalid flag value + * Test Description + * ------------------------ + * - Sets different values for the resource limits. + * Test source + * ------------------------ + * - unit/device/hipDeviceSetLimit.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipDeviceSetLimit_SetGet") { size_t value = 0; diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc b/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc index 4dd3ed0dff..b94ddc39a9 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc @@ -20,14 +20,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Test for checking the functionality of - * hipError_t hipDeviceSynchronize(); - */ - - #include +/** + * @addtogroup hipDeviceSynchronize hipDeviceSynchronize + * @{ + * @ingroup DeviceTest + * `hipDeviceSynchronize(void)` - + * Waits on all active streams on current device. + * When this command is invoked, the host thread gets blocked until all the commands associated + * with streams associated with the device. HIP does not support multiple blocking modes (yet!). + */ + #define _SIZE sizeof(int) * 1024 * 1024 #define NUM_STREAMS 2 #define NUM_ITERS 1 << 30 @@ -44,6 +48,18 @@ static __global__ void Iter(int* Ad, int num) { } } +/** + * Test Description + * ------------------------ + * - Performs synchronization when no work is enqueued on stream, + * utilizing multiple devices. + * Test source + * ------------------------ + * - unit/device/hipDeviceSynchronize.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSynchronize_Positive_Empty_Streams") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -55,6 +71,18 @@ TEST_CASE("Unit_hipDeviceSynchronize_Positive_Empty_Streams") { HIP_CHECK(hipStreamDestroy(stream)); } +/** + * Test Description + * ------------------------ + * - Performs synchronization between large kernel execution + * and asynchronous copying of the array, on default(null) stream. + * Test source + * ------------------------ + * - unit/device/hipDeviceSynchronize.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSynchronize_Positive_Nullstream") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); HIP_CHECK(hipSetDevice(device)); @@ -78,6 +106,18 @@ TEST_CASE("Unit_hipDeviceSynchronize_Positive_Nullstream") { REQUIRE(1 << 30 == A_h[0] - 1); } +/** + * Test Description + * ------------------------ + * - Performs synchronization between large kernel execution + * and asynchronous copying of the array, on multiple streams. + * Test source + * ------------------------ + * - unit/device/hipDeviceSynchronize.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipDeviceSynchronize_Functional") { int* A[NUM_STREAMS]; int* Ad[NUM_STREAMS]; diff --git a/projects/hip-tests/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc b/projects/hip-tests/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc index 7911b133ec..8c10e5976f 100644 --- a/projects/hip-tests/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc +++ b/projects/hip-tests/catch/unit/device/hipExtGetLinkTypeAndHopCount.cc @@ -23,7 +23,28 @@ THE SOFTWARE. #include #include -#if __linux__ && HT_AMD +/** + * @addtogroup hipExtGetLinkTypeAndHopCount hipExtGetLinkTypeAndHopCount + * @{ + * @ingroup DeviceTest + * `hipExtGetLinkTypeAndHopCount(int device1, int device2, uint32_t* linktype, uint32_t* hopcount)` - + * Returns the link type and hop count between two devices. + */ + +#if __linux__ +#if HT_AMD +/** + * Test Description + * ------------------------ + * - Check commutativity of devices for every device combination. + * Test source + * ------------------------ + * - unit/device/hipExtGetLinkTypeAndHopCount.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipExtGetLinkTypeAndHopCount_Positive_Basic") { const auto device1 = GENERATE(range(0, HipTest::getDeviceCount())); const auto device2 = GENERATE(range(0, HipTest::getDeviceCount())); @@ -44,6 +65,38 @@ TEST_CASE("Unit_hipExtGetLinkTypeAndHopCount_Positive_Basic") { REQUIRE(link_type1 == link_type2); } +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When creating the link between the same device + * - Expected output: return `hipErrorInvalidValue` + * -# When device ordinance for the first device is out of bounds + * - Expected output: return `hipErrorInvalidDevice` + * -# When device ordinance for the second device is out of bounds + * - Expected output: return `hipErrorInvalidDevice` + * -# When device ordinance for both devices is out of bounds + * - Expected output: return `hipErrorInvalidDevice` + * -# When device ordinance for the first device is < 0 + * - Expected output: return `hipErrorInvalidValue` + * -# When device ordinance for the second device is < 0 + * - Expected output: return `hipErrorInvalidValue` + * -# When device ordinance for both devices is < 0 + * - Expected output: return `hipErrorInvalidValue` + * -# When pointer to the link type is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When pointer to the hop count is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# When both pointers are `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipExtGetLinkTypeAndHopCount.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipExtGetLinkTypeAndHopCount_Negative_Parameters") { uint32_t link_type, hop_count; SECTION("same device") { @@ -98,3 +151,4 @@ TEST_CASE("Unit_hipExtGetLinkTypeAndHopCount_Negative_Parameters") { } } #endif +#endif diff --git a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc index 208f997e2b..780a1877a4 100644 --- a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc +++ b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc @@ -16,7 +16,6 @@ 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. */ -// Test the device info API extensions for HIP #include #ifdef __linux__ @@ -28,6 +27,14 @@ THE SOFTWARE. #include +/** + * @addtogroup hipDeviceGetAttribute hipDeviceGetAttribute + * @{ + * @ingroup DeviceTest + * `hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int deviceId)` - + * Query for a specific device attribute. + */ + static hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr, int expectedValue = -1) { @@ -64,6 +71,18 @@ static hipError_t test_hipDeviceGetHdpAddress(int deviceId, return hipSuccess; } +/** + * Test Description + * ------------------------ + * - Validate various device attributes against device properties. + * - Matching attribute and property value shall be equal. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceAttribute.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetDeviceAttribute_CheckAttrValues") { int deviceId; HIP_CHECK(hipGetDevice(&deviceId)); @@ -235,7 +254,7 @@ TEST_CASE("Unit_hipGetDeviceAttribute_CheckAttrValues") { hipDeviceAttributeUnifiedAddressing, 1/*true*/)); } -/** +/* * Validate the hipDeviceAttributeFineGrainSupport property in AMD. */ #ifdef __linux__ @@ -264,7 +283,19 @@ static bool isRocmPathSet() { return false; } -// This is AMD specific property test +/** + * Test Description + * ------------------------ + * - Validate fine grain support attribute against + * known values for different AMD architectures + * Test source + * ------------------------ + * - unit/device/hipGetDeviceAttribute.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetDeviceAttribute_CheckFineGrainSupport") { int deviceId; int deviceCount = 0; @@ -326,12 +357,25 @@ TEST_CASE("Unit_hipGetDeviceAttribute_CheckFineGrainSupport") { } #endif #endif + /** - * Validates negative scenarios for hipDeviceGetAttribute - * scenario1: pi = nullptr - * scenario2: device = -1 (Invalid Device) - * scenario3: device = Non Existing Device - * scenario4: attr = Invalid Attribute + * Test Description + * ------------------------ + * - Validates negative scenarios: + * -# When pointer to value is `nullptr` + * - Expected output: do not return `hipSuccess` + * -# When device ID is `-1` + * - Expected output: do not return `hipSuccess` + * -# When device ID is out of bounds + * - Expected output: do not return `hipSuccess` + * -# When attribute is invalid (-1) + * - Expected output: do not return `hipSuccess` + * Test source + * ------------------------ + * - unit/device/hipGetDeviceAttribute.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipDeviceGetAttribute_NegTst") { int deviceCount = 0; @@ -526,6 +570,17 @@ template void printAttributes(const AttributeToStringMap& attribut std::flush(std::cout); } +/** + * Test Description + * ------------------------ + * - Print out all device attributes in agreed upon format. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceAttribute.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Print_Out_Attributes") { const auto device = GENERATE(range(0, HipTest::getDeviceCount())); hipDeviceProp_t properties; diff --git a/projects/hip-tests/catch/unit/device/hipGetDeviceCount.cc b/projects/hip-tests/catch/unit/device/hipGetDeviceCount.cc index 387afc5ff6..d0d77a5e06 100644 --- a/projects/hip-tests/catch/unit/device/hipGetDeviceCount.cc +++ b/projects/hip-tests/catch/unit/device/hipGetDeviceCount.cc @@ -20,23 +20,45 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Conformance test for checking functionality of - * hipError_t hipGetDeviceCount(int* count); - */ - #include #include /** - * hipGetDeviceCount tests - * Scenario: Validates if &numDevices = nullptr returns error code. + * @addtogroup hipGetDeviceCount hipGetDeviceCount + * @{ + * @ingroup DeviceTest + * `hipGetDeviceCount(int* count)` - + * Return number of compute-capable devices. + */ + +/** + * Test Description + * ------------------------ + * - Passes invalid pointer as output parameter for device count - `nullptr` + * Test source + * ------------------------ + * - unit/device/hipGetDeviceCount.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipGetDeviceCount_NegTst") { - // Scenario1 REQUIRE_FALSE(hipGetDeviceCount(nullptr) == hipSuccess); } +/** + * Test Description + * ------------------------ + * - Validates correct functionality when the device visibility + * environment variables are set. Uses unit/device/hipDeviceCount_exe.cc + * to set visibility. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceCount.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetDeviceCount_HideDevices") { int deviceCount = HipTest::getDeviceCount(); if (deviceCount < 2) { @@ -59,6 +81,17 @@ TEST_CASE("Unit_hipGetDeviceCount_HideDevices") { } } +/** + * Test Description + * ------------------------ + * - Prints device count to the standard output. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceCount.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Print_Out_Device_Count") { std::cout << "Device Count: " << HipTest::getDeviceCount() << std::endl; } \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/device/hipGetDeviceProperties.cc b/projects/hip-tests/catch/unit/device/hipGetDeviceProperties.cc index ae8d7db439..05a56dccb0 100644 --- a/projects/hip-tests/catch/unit/device/hipGetDeviceProperties.cc +++ b/projects/hip-tests/catch/unit/device/hipGetDeviceProperties.cc @@ -22,6 +22,13 @@ THE SOFTWARE. #include +/** + * @addtogroup hipGetDeviceProperties hipGetDeviceProperties + * @{ + * @ingroup DeviceTest + * `hipGetDeviceProperties(hipDeviceProp_t* prop, int deviceId)` - + * Returns device properties. + */ #define NUM_OF_ARCHPROP 17 #define HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS_IDX 0 @@ -66,7 +73,7 @@ __global__ void mykernel(int *archProp_d) { getArchValuesFromDevice(archProp_d); } -/** +/* * Internal Functions */ static void validateDeviceMacro(int *archProp_h, hipDeviceProp_t *prop) { @@ -121,7 +128,7 @@ static void validateDeviceMacro(int *archProp_h, hipDeviceProp_t *prop) { CHECK_FALSE(prop->arch.hasDynamicParallelism != archProp_h[HIP_ARCH_HAS_DYNAMIC_PARALLEL_IDX]); } -/** +/* * Validates value of __HIP_ARCH_* with deviceProp.arch.has* as follows * __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ == hasGlobalInt32Atomics * __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ == hasGlobalFloatAtomicExch @@ -142,6 +149,18 @@ static void validateDeviceMacro(int *archProp_h, hipDeviceProp_t *prop) { * __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ == hasDynamicParallelism */ #if HT_AMD +/** + * Test Description + * ------------------------ + * - Compare some device properties against properties derived from device code. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceProperties.cc + * Test requirements + * ------------------------ + * - Platform specific (AMD) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetDeviceProperties_ArchPropertiesTst") { int *archProp_h, *archProp_d; archProp_h = new int[NUM_OF_ARCHPROP]; @@ -174,11 +193,23 @@ TEST_CASE("Unit_hipGetDeviceProperties_ArchPropertiesTst") { delete[] archProp_h; } #endif + /** - * Validates negative scenarios for hipGetDeviceProperties - * scenario1: props = nullptr - * scenario2: device = -1 (Invalid Device) - * scenario3: device = Non Existing Device + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When output pointer to the properties is `nullptr` + * - Expected output: do not return `hipSuccess` + * -# When the device ID is equal to -1 + * - Expected output: do not return `hipSuccess` + * -# When the device ID is out of bounds + * - Expected output: do not return `hipSuccess` + * Test source + * ------------------------ + * - unit/device/hipGetDeviceProperties.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipGetDeviceProperties_NegTst") { hipDeviceProp_t prop; @@ -201,6 +232,17 @@ TEST_CASE("Unit_hipGetDeviceProperties_NegTst") { } } +/** + * Test Description + * ------------------------ + * - Print out all properties in agreed upon format. + * Test source + * ------------------------ + * - unit/device/hipGetDeviceProperties.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Print_Out_Properties") { constexpr int w = 42; const auto device = GENERATE(range(0, HipTest::getDeviceCount())); diff --git a/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc b/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc index c661f4e7ba..68f20ea3e5 100644 --- a/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc +++ b/projects/hip-tests/catch/unit/device/hipGetSetDeviceFlags.cc @@ -22,42 +22,32 @@ THE SOFTWARE. #include #include #include + /** - * Conformance test for checking functionality of - * hipError_t hipGetDeviceFlags(unsigned int* flags); - * hipError_t hipSetDeviceFlags(unsigned flags); - * - * - * hipGetDeviceFlags and hipSetDeviceFlags tests. - * Scenario1: Validates if hipGetDeviceFlags returns hipErrorInvalidValue for flags = nullptr. - * Scenario2: Validates if hipSetDeviceFlags returns hipErrorInvalidValue for invalid flags. - * Scenario3: Validates if flags returned by hipGetDeviceFlags are valid. - * Scenario4: Validates that flags set with hipSetDeviceFlags can be retrieved with - * hipGetDeviceFlags. - * Scenario5: Validates that flags set with hipSetDeviceFlags can be retrieved on a seperate thread - * with hipGetDeviceFlags. + * @addtogroup hipGetDeviceFlags hipGetDeviceFlags + * @{ + * @ingroup DeviceTest + * `hipGetDeviceFlags(unsigned int* flags)` - + * Gets the flags set for current device. + */ + +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When output pointer to the flag is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 */ TEST_CASE("Unit_hipGetSetDeviceFlags_NullptrFlag") { - // Scenario1 HIP_CHECK_ERROR(hipGetDeviceFlags(nullptr), hipErrorInvalidValue); } -TEST_CASE("Unit_hipGetSetDeviceFlags_InvalidFlag") { -#if HT_AMD - HipTest::HIP_SKIP_TEST("EXSWCPHIPT-115"); - return; -#endif - // Scenario2 - const unsigned int invalidFlag = GENERATE(0b011, // schedule flags should not overlap - 0b101, // schedule flags should not overlap - 0b110, // schedule flags should not overlap - 0b111, // schedule flags should not overlap - 0b100000, // out of bounds - 0xFFFF); - CAPTURE(invalidFlag); - HIP_CHECK_ERROR(hipSetDeviceFlags(invalidFlag), hipErrorInvalidValue); -} - std::array getValidFlags() { constexpr std::array scheduleFlags{hipDeviceScheduleAuto, hipDeviceScheduleSpin, hipDeviceScheduleYield, @@ -78,9 +68,19 @@ std::array getValidFlags() { return validFlags; } - +/** + * Test Description + * ------------------------ + * - Check returned flags against Cartesian product of all + * possible valid flag combinations. + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetSetDeviceFlags_ValidFlag") { - // Scenario3 auto validFlags = getValidFlags(); unsigned int flag = 0; @@ -88,8 +88,20 @@ TEST_CASE("Unit_hipGetSetDeviceFlags_ValidFlag") { REQUIRE(std::find(std::begin(validFlags), std::end(validFlags), flag) != std::end(validFlags)); } +/** + * Test Description + * ------------------------ + * - Validate that returned flags are equal to the ones that have + * been previously set. + * - Perform validation for all connected devices and all flag combinations. + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetSetDeviceFlags_SetThenGet") { - // Scenario4 auto validFlags = getValidFlags(); auto devNo = GENERATE(range(0, HipTest::getDeviceCount())); @@ -108,8 +120,19 @@ TEST_CASE("Unit_hipGetSetDeviceFlags_SetThenGet") { REQUIRE((flag & hipDeviceScheduleMask) == getFlag); } +/** + * Test Description + * ------------------------ + * - Validate that the returned flags from the main thread are + * equal to the flags that are set from another thread. + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetSetDeviceFlags_Threaded") { - // Scenario5 auto validFlags = getValidFlags(); auto devNo = GENERATE(range(0, HipTest::getDeviceCount())); @@ -146,6 +169,19 @@ TEST_CASE("Unit_hipGetSetDeviceFlags_Threaded") { HIP_CHECK_THREAD_FINALIZE(); } +/** + * Test Description + * ------------------------ + * - Create context with flags and validate that valid + * flags are returned. + * - Perform validation for all connected devices and all flag combinations. + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetDeviceFlags_Positive_Context") { auto validFlags = getValidFlags(); const unsigned int flags = @@ -163,4 +199,50 @@ TEST_CASE("Unit_hipGetDeviceFlags_Positive_Context") { HIP_CHECK(hipCtxPopCurrent(&ctx)); HIP_CHECK(hipCtxDestroy(ctx)); +} + +/** + * End doxygen group hipGetDeviceFlags. + * @} + */ + +/** + * @addtogroup hipSetDeviceFlags hipSetDeviceFlags + * @{ + * @ingroup DeviceTest + * `hipSetDeviceFlags(unsigned flags)` - + * The current device behavior is changed according the flags passed. + * ________________________ + * Test cases from other modules: + * - @ref Unit_hipGetSetDeviceFlags_SetThenGet + * - @ref Unit_hipGetSetDeviceFlags_Threaded + */ + +/** + * Test Description + * ------------------------ + * - Validates handling of invalid arguments: + * -# When flag combinations are invalid + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipGetSetDeviceFlags.cc + * Test requirements + * ------------------------ + * - Platform specific (NVIDIA) + * - HIP_VERSION >= 5.2 + */ +TEST_CASE("Unit_hipGetSetDeviceFlags_InvalidFlag") { +#if HT_AMD + HipTest::HIP_SKIP_TEST("EXSWCPHIPT-115"); + return; +#endif + const unsigned int invalidFlag = GENERATE(0b011, // schedule flags should not overlap + 0b101, // schedule flags should not overlap + 0b110, // schedule flags should not overlap + 0b111, // schedule flags should not overlap + 0b100000, // out of bounds + 0xFFFF); + CAPTURE(invalidFlag); + HIP_CHECK_ERROR(hipSetDeviceFlags(invalidFlag), hipErrorInvalidValue); } \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/device/hipIpcCloseMemHandle.cc b/projects/hip-tests/catch/unit/device/hipIpcCloseMemHandle.cc index 138ef15e5d..eb81c3f93f 100644 --- a/projects/hip-tests/catch/unit/device/hipIpcCloseMemHandle.cc +++ b/projects/hip-tests/catch/unit/device/hipIpcCloseMemHandle.cc @@ -27,6 +27,32 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipIpcCloseMemHandle hipIpcCloseMemHandle + * @{ + * @ingroup DeviceTest + * `hipIpcCloseMemHandle(void* devPtr)` - + * Close memory mapped with hipIpcOpenMemHandle. + * Unmaps memory returned by hipIpcOpenMemHandle. + * ________________________ + * Test cases from other modules: + * - @ref Unit_hipIpcMemAccess_Semaphores + * - @ref Unit_hipIpcMemAccess_ParameterValidation + */ + +/** + * Test Description + * ------------------------ + * - Checks that memory stays mapped if reference count doesn't reach zero. + * - Checks that memory stays mapped if handle is closed in second process. + * Test source + * ------------------------ + * - unit/device/hipIpcCloseMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcCloseMemHandle_Positive_Reference_Counting") { int fd[2]; REQUIRE(pipe(fd) == 0); @@ -80,6 +106,18 @@ TEST_CASE("Unit_hipIpcCloseMemHandle_Positive_Reference_Counting") { } } +/** + * Test Description + * ------------------------ + * - Closes the memory handle from the process that has created it. + * Test source + * ------------------------ + * - unit/device/hipIpcCloseMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcCloseMemHandle_Negative_Close_In_Originating_Process") { void* ptr; hipIpcMemHandle_t handle; diff --git a/projects/hip-tests/catch/unit/device/hipIpcGetMemHandle.cc b/projects/hip-tests/catch/unit/device/hipIpcGetMemHandle.cc index 76d2c92ffc..72d34fe117 100644 --- a/projects/hip-tests/catch/unit/device/hipIpcGetMemHandle.cc +++ b/projects/hip-tests/catch/unit/device/hipIpcGetMemHandle.cc @@ -25,6 +25,29 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipIpcGetMemHandle hipIpcGetMemHandle + * @{ + * @ingroup DeviceTest + * `hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr)` - + * Gets an interprocess memory handle for an existing device memory allocation. + * ________________________ + * Test cases from other modules: + * - @ref Unit_hipIpcMemAccess_ParameterValidation + */ + +/** + * Test Description + * ------------------------ + * - Check that unique handles are returned in consecutive calls. + * Test source + * ------------------------ + * - unit/device/hipIpcGetMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcGetMemHandle_Positive_Unique_Handles_Separate_Allocations") { void *ptr1, *ptr2; hipIpcMemHandle_t handle1, handle2; @@ -39,6 +62,19 @@ TEST_CASE("Unit_hipIpcGetMemHandle_Positive_Unique_Handles_Separate_Allocations" HIP_CHECK(hipFree(ptr2)); } +/** + * Test Description + * ------------------------ + * - Check that unique handles are returned for the same address, + * but separate allocations. + * Test source + * ------------------------ + * - unit/device/hipIpcGetMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcGetMemHandle_Positive_Unique_Handles_Reused_Memory") { void *ptr1 = nullptr, *ptr2 = nullptr; hipIpcMemHandle_t handle1, handle2; @@ -54,6 +90,20 @@ TEST_CASE("Unit_hipIpcGetMemHandle_Positive_Unique_Handles_Reused_Memory") { HIP_CHECK(hipFree(ptr2)); } +/** + * Test Description + * ------------------------ + * - Test if previously freed memory will generate an invalid handle: + * -# When memory is freed before getting handle + * - Expected output: return `hipErrorInvalidValue + * Test source + * ------------------------ + * - unit/device/hipIpcGetMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcGetMemHandle_Negative_Handle_For_Freed_Memory") { void* ptr; hipIpcMemHandle_t handle; @@ -62,6 +112,20 @@ TEST_CASE("Unit_hipIpcGetMemHandle_Negative_Handle_For_Freed_Memory") { HIP_CHECK_ERROR(hipIpcGetMemHandle(&handle, ptr), hipErrorInvalidValue); } +/** + * Test Description + * ------------------------ + * - Test if out of bounds pointer will generate an error: + * -# When the memory pointer is too large + * - Expected output: return `hipErrorInvalidValue` + * Test source + * ------------------------ + * - unit/device/hipIpcGetMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcGetMemHandle_Negative_Out_Of_Bound_Pointer") { int* ptr; constexpr size_t n = 1024; diff --git a/projects/hip-tests/catch/unit/device/hipIpcOpenMemHandle.cc b/projects/hip-tests/catch/unit/device/hipIpcOpenMemHandle.cc index 4edc7cd616..46329b32c8 100644 --- a/projects/hip-tests/catch/unit/device/hipIpcOpenMemHandle.cc +++ b/projects/hip-tests/catch/unit/device/hipIpcOpenMemHandle.cc @@ -28,6 +28,30 @@ THE SOFTWARE. #include #include +/** + * @addtogroup hipIpcOpenMemHandle hipIpcOpenMemHandle + * @{ + * @ingroup DeviceTest + * `hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags)` - + * Opens an interprocess memory handle exported from another process + * and returns a device pointer usable in the local process. + */ + +/** + * Test Description + * ------------------------ + * - Handle the attempt to open memory handle in the same process + * that has created it. + * -# When the process is the same + * - Expected output: return `hipErrorInvalidContext` + * Test source + * ------------------------ + * - unit/device/hipIpcOpenMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcOpenMemHandle_Negative_Open_In_Creating_Process") { hipDeviceptr_t ptr1, ptr2; hipIpcMemHandle_t handle; @@ -39,6 +63,21 @@ TEST_CASE("Unit_hipIpcOpenMemHandle_Negative_Open_In_Creating_Process") { HIP_CHECK(hipFree(reinterpret_cast(ptr1))); } +/** + * Test Description + * ------------------------ + * - Checks that opening the same memory handle from a different context + * returns error + * -# When different context + * - Expected output: return `hipErrorInvalidResourceHandle` + * Test source + * ------------------------ + * - unit/device/hipIpcOpenMemHandle.cc + * Test requirements + * ------------------------ + * - Host specific (LINUX) + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipIpcOpenMemHandle_Negative_Open_In_Two_Contexts_Same_Device") { int fd[2]; REQUIRE(pipe(fd) == 0); diff --git a/projects/hip-tests/catch/unit/device/hipSetGetDevice.cc b/projects/hip-tests/catch/unit/device/hipSetGetDevice.cc index 62df5f5ac8..6b2f53f6b7 100644 --- a/projects/hip-tests/catch/unit/device/hipSetGetDevice.cc +++ b/projects/hip-tests/catch/unit/device/hipSetGetDevice.cc @@ -19,16 +19,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Verifies functionality of hipSetDevice/hipGetDevice api. - * -- Basic Test to set and get valid device numbers. - */ - #include #include #include +/** + * @addtogroup hipSetDevice hipSetDevice + * @{ + * @ingroup DeviceTest + * `hipSetDevice(int deviceId)` - + * Set default device to be used for subsequent hip API calls from this thread. + */ + +/** + * Test Description + * ------------------------ + * - Performs multiple set/get device operations and verifies + * that the device that is set is the one that is gotten. + * Test source + * ------------------------ + * - unit/device/hipSetGetDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipSetDevice_BasicSetGet") { int numDevices = 0; int device{}; @@ -46,6 +61,18 @@ TEST_CASE("Unit_hipSetDevice_BasicSetGet") { } } +/** + * Test Description + * ------------------------ + * - Performs set/get operations for each detected + * device from multiple threads. + * Test source + * ------------------------ + * - unit/device/hipSetGetDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipGetSetDevice_MultiThreaded") { auto maxThreads = std::thread::hardware_concurrency(); auto deviceCount = HipTest::getDeviceCount(); @@ -87,6 +114,18 @@ TEST_CASE("Unit_hipGetSetDevice_MultiThreaded") { HIP_CHECK_THREAD_FINALIZE(); } +/** + * Test Description + * ------------------------ + * - Performs set/get device for separate devices on two + * threads and validates device ordinance via memory allocation. + * Test source + * ------------------------ + * - unit/device/hipSetGetDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipSetGetDevice_Positive_Threaded_Basic") { class HipSetGetDeviceThreadedTest : public ThreadedZigZagTest { public: @@ -125,6 +164,23 @@ TEST_CASE("Unit_hipSetGetDevice_Positive_Threaded_Basic") { test.run(); } +/** + * Test Description + * ------------------------ + * - Validates that get/set device APIs can handle invalid parameters + * -# Get device when device is `nullptr` + * - Expected output: return `hipErrorInvalidValue` + * -# Set device with ordinal number `-1` + * - Expected output: return `hipErrorInvalidDevice` + * -# Set device to the ID which is out of bounds + * - Expected output: return `hipErrorInvalidDevice` + * Test source + * ------------------------ + * - unit/device/hipSetGetDevice.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ TEST_CASE("Unit_hipSetGetDevice_Negative") { SECTION("Get Device - nullptr") { HIP_CHECK_ERROR(hipGetDevice(nullptr), hipErrorInvalidValue); } @@ -135,6 +191,29 @@ TEST_CASE("Unit_hipSetGetDevice_Negative") { } } +/** + * End doxygen group hipSetDevice. + * @} + */ + +/** + * @addtogroup hipGetDevice hipGetDevice + * @{ + * @ingroup DeviceTest + * `hipGetDevice(int* deviceId)` - + * Return the default device id for the calling host thread. + * ________________________ + * Test cases from other modules: + * - @ref Unit_hipSetDevice_BasicSetGet + * - @ref Unit_hipGetSetDevice_MultiThreaded + * - @ref Unit_hipSetGetDevice_Negative + */ + +/** + * End doxygen group hipGetDevice. + * @} + */ + TEST_CASE("Unit_hipDeviceGet_Negative") { // TODO enable after EXSWCPHIPT-104 is fixed #if HT_NVIDIA diff --git a/projects/hip-tests/catch/unit/graph/hipGraphKernelNodeSetParams.cc b/projects/hip-tests/catch/unit/graph/hipGraphKernelNodeSetParams.cc index 0685b81a76..eb561c05e3 100644 --- a/projects/hip-tests/catch/unit/graph/hipGraphKernelNodeSetParams.cc +++ b/projects/hip-tests/catch/unit/graph/hipGraphKernelNodeSetParams.cc @@ -171,9 +171,7 @@ static __global__ void ker_vec_sub(int* A, int* B) { A[i] = A[i] - B[i]; } -/** - Internal class for creating nested graphs. - */ +// Internal class for creating nested graphs. class GraphKernelNodeGetSetParam { const int N = 1024; size_t Nbytes; diff --git a/projects/hip-tests/catch/unit/graph/hipUserObjectCreate.cc b/projects/hip-tests/catch/unit/graph/hipUserObjectCreate.cc index 6e086aae22..2a22e62d9f 100644 --- a/projects/hip-tests/catch/unit/graph/hipUserObjectCreate.cc +++ b/projects/hip-tests/catch/unit/graph/hipUserObjectCreate.cc @@ -23,8 +23,8 @@ THE SOFTWARE. #include "user_object_common.hh" -/** - * Functional Test for API - hipUserObjectCreate +/* + Functional Test for API - hipUserObjectCreate 1) Call hipUserObjectCreate once and release it by calling hipUserObjectRelease 2) Call hipUserObjectCreate refCount as X and release it by calling hipUserObjectRelease with same refCount. @@ -33,7 +33,7 @@ THE SOFTWARE. 4) Call hipUserObjectCreate with refCount as X, retain it by calling hipUserObjectRetain with count as Y and release it by calling hipUserObjectRelease with count as X+Y. - */ +*/ /* 1) Call hipUserObjectCreate once and release it by calling hipUserObjectRelease */