diff --git a/level_zero/core/test/black_box_tests/common/zello_common.h b/level_zero/core/test/black_box_tests/common/zello_common.h index 77e2d740b8..fe8a2d2276 100644 --- a/level_zero/core/test/black_box_tests/common/zello_common.h +++ b/level_zero/core/test/black_box_tests/common/zello_common.h @@ -102,6 +102,17 @@ inline bool isSyncQueueEnabled(int argc, char *argv[]) { return true; } +inline uint32_t getBufferLength(int argc, char *argv[], uint32_t defaultLength) { + uint32_t length = getParamValue(argc, argv, "-l", "--length", defaultLength); + if (length == defaultLength) { + return defaultLength; + } + + std::cerr << "Buffer length detected = " << length << std::endl; + + return length; +} + uint32_t getCommandQueueOrdinal(ze_device_handle_t &device) { uint32_t numQueueGroups = 0; SUCCESS_OR_TERMINATE(zeDeviceGetCommandQueueGroupProperties(device, &numQueueGroups, nullptr)); diff --git a/level_zero/core/test/black_box_tests/zello_world_usm.cpp b/level_zero/core/test/black_box_tests/zello_world_usm.cpp index 156bf0fe89..13408d6490 100644 --- a/level_zero/core/test/black_box_tests/zello_world_usm.cpp +++ b/level_zero/core/test/black_box_tests/zello_world_usm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,9 +21,11 @@ int main(int argc, char *argv[]) { useSyncQueue = isSyncQueueEnabled(argc, argv); bool outputValidationSuccessful = false; // 1. Set-up - constexpr size_t allocSize = 4096 + 7; + constexpr char srcInitValue = 7; + constexpr char dstInitValue = 3; constexpr size_t bytesPerThread = sizeof(char); - constexpr size_t numThreads = allocSize / bytesPerThread; + uint32_t allocSize = getBufferLength(argc, argv, 4096 + 7); + uint32_t numThreads = allocSize / bytesPerThread; ze_module_handle_t module; ze_kernel_handle_t kernel; ze_command_queue_handle_t cmdQueue; @@ -130,11 +132,11 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE_BOOL(memProperties.type == ZE_MEMORY_TYPE_SHARED); // initialize the src buffer - memset(srcBuffer, 7, allocSize); + memset(srcBuffer, srcInitValue, allocSize); // Encode run user kernel - SUCCESS_OR_TERMINATE(zeKernelSetArgumentValue(kernel, 0, sizeof(dstBuffer), &dstBuffer)); - SUCCESS_OR_TERMINATE(zeKernelSetArgumentValue(kernel, 1, sizeof(srcBuffer), &srcBuffer)); + SUCCESS_OR_TERMINATE(zeKernelSetArgumentValue(kernel, 0, sizeof(srcBuffer), &srcBuffer)); + SUCCESS_OR_TERMINATE(zeKernelSetArgumentValue(kernel, 1, sizeof(dstBuffer), &dstBuffer)); ze_group_count_t dispatchTraits; dispatchTraits.groupCountX = numThreads / groupSizeX; @@ -152,7 +154,7 @@ int main(int argc, char *argv[]) { // initialize the dst buffer after appending the kernel but before executing the lists, to // ensure page-fault manager is correctly making resident the buffers in the GPU at // execution time - memset(dstBuffer, 3, allocSize); + memset(dstBuffer, dstInitValue, allocSize); // Dispatch and wait SUCCESS_OR_TERMINATE(zeCommandListClose(cmdList)); @@ -162,9 +164,30 @@ int main(int argc, char *argv[]) { if (useSyncQueue == false) SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); - // Validate - outputValidationSuccessful = (0 == memcmp(dstBuffer, srcBuffer, allocSize)); - SUCCESS_OR_WARNING_BOOL(outputValidationSuccessful); + // Validate input / output + outputValidationSuccessful = true; + uint8_t *srcCharBuffer = static_cast(srcBuffer); + uint8_t *dstCharBuffer = static_cast(dstBuffer); + for (size_t i = 0; i < allocSize; i++) { + if (dstCharBuffer[i] != srcCharBuffer[i]) { + outputValidationSuccessful = false; + std::cout << "dstBuffer[" << i << "] = " << static_cast(dstCharBuffer[i]) << " not equal to " + << "srcBuffer[" << i << "] = " << static_cast(srcCharBuffer[i]) << "\n"; + } + if (srcCharBuffer[i] != srcInitValue) { + outputValidationSuccessful = false; + std::cout << "srcBuffer[" << i << "] = " << static_cast(srcCharBuffer[i]) << " not equal to " + << "value = " << static_cast(srcInitValue) << "\n"; + } + if (dstCharBuffer[i] != srcInitValue) { + outputValidationSuccessful = false; + std::cout << "dstBuffer[" << i << "] = " << static_cast(dstCharBuffer[i]) << " not equal to " + << "value = " << static_cast(srcInitValue) << "\n"; + } + if (!outputValidationSuccessful) { + break; + } + } // Cleanup SUCCESS_OR_TERMINATE(zeMemFree(context, dstBuffer));