diff --git a/level_zero/core/test/black_box_tests/common/zello_common.cpp b/level_zero/core/test/black_box_tests/common/zello_common.cpp index 752b766e61..21718577f2 100644 --- a/level_zero/core/test/black_box_tests/common/zello_common.cpp +++ b/level_zero/core/test/black_box_tests/common/zello_common.cpp @@ -17,6 +17,8 @@ #include #endif +namespace LevelZeroBlackBoxTests { + bool verbose; bool isParamEnabled(int argc, char *argv[], const char *shortName, const char *longName) { @@ -567,3 +569,54 @@ void setEnvironmentVariable(const char *variableName, const char *variableValue) setenv(variableName, variableValue, 1); #endif } + +ze_result_t CommandHandler::create(ze_context_handle_t context, ze_device_handle_t device, bool immediate) { + isImmediate = immediate; + ze_result_t result; + ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; + cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.index = 0; + + if (isImmediate) { + cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; + result = zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList); + } else { + cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; + result = zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue); + if (result != ZE_RESULT_SUCCESS) { + return result; + } + result = createCommandList(context, device, cmdList); + } + + return result; +} + +ze_result_t CommandHandler::execute() { + auto result = ZE_RESULT_SUCCESS; + + if (!isImmediate) { + result = zeCommandListClose(cmdList); + if (result == ZE_RESULT_SUCCESS) { + result = zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, nullptr); + } + } + return result; +} + +ze_result_t CommandHandler::synchronize() { + if (!isImmediate) { + return zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max()); + } + return ZE_RESULT_SUCCESS; +} + +ze_result_t CommandHandler::destroy() { + auto result = zeCommandListDestroy(cmdList); + if (result == ZE_RESULT_SUCCESS && !isImmediate) { + result = zeCommandQueueDestroy(cmdQueue); + } + return result; +} + +} // namespace LevelZeroBlackBoxTests 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 c2f9a60641..3aed24f367 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 @@ -16,12 +16,24 @@ #include #include +namespace LevelZeroBlackBoxTests { +template +inline void validate(ResulT result, const char *message); +} // namespace LevelZeroBlackBoxTests + +#define SUCCESS_OR_TERMINATE(CALL) LevelZeroBlackBoxTests::validate(CALL, #CALL) +#define SUCCESS_OR_TERMINATE_BOOL(FLAG) LevelZeroBlackBoxTests::validate(!(FLAG), #FLAG) +#define SUCCESS_OR_WARNING(CALL) LevelZeroBlackBoxTests::validate(CALL, #CALL) +#define SUCCESS_OR_WARNING_BOOL(FLAG) LevelZeroBlackBoxTests::validate(!(FLAG), #FLAG) + +namespace LevelZeroBlackBoxTests { + #define QTR(a) #a #define TOSTR(b) QTR(b) extern bool verbose; -template +template inline void validate(ResulT result, const char *message) { if (result == ZE_RESULT_SUCCESS) { if (verbose) { @@ -31,20 +43,15 @@ inline void validate(ResulT result, const char *message) { } if (verbose) { - std::cerr << (TerminateOnFailure ? "ERROR : " : "WARNING : ") << message << " : " << result + std::cerr << (terminateOnFailure ? "ERROR : " : "WARNING : ") << message << " : " << result << std::endl; } - if (TerminateOnFailure) { + if (terminateOnFailure) { std::terminate(); } } -#define SUCCESS_OR_TERMINATE(CALL) validate(CALL, #CALL) -#define SUCCESS_OR_TERMINATE_BOOL(FLAG) validate(!(FLAG), #FLAG) -#define SUCCESS_OR_WARNING(CALL) validate(CALL, #CALL) -#define SUCCESS_OR_WARNING_BOOL(FLAG) validate(!(FLAG), #FLAG) - bool isParamEnabled(int argc, char *argv[], const char *shortName, const char *longName); int getParamValue(int argc, char *argv[], const char *shortName, const char *longName, int defaultValue); @@ -216,58 +223,16 @@ struct CommandHandler { bool isImmediate = false; - ze_result_t create(ze_context_handle_t context, ze_device_handle_t device, bool immediate) { - isImmediate = immediate; - ze_result_t result; - ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); - cmdQueueDesc.index = 0; - - if (isImmediate) { - cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; - result = zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList); - } else { - cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; - result = zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue); - if (result != ZE_RESULT_SUCCESS) { - return result; - } - result = createCommandList(context, device, cmdList); - } - - return result; - } + ze_result_t create(ze_context_handle_t context, ze_device_handle_t device, bool immediate); ze_result_t appendKernel(ze_kernel_handle_t kernel, const ze_group_count_t &dispatchTraits, ze_event_handle_t event = nullptr) { return zeCommandListAppendLaunchKernel(cmdList, kernel, &dispatchTraits, event, 0, nullptr); } - ze_result_t execute() { - auto result = ZE_RESULT_SUCCESS; - - if (!isImmediate) { - result = zeCommandListClose(cmdList); - if (result == ZE_RESULT_SUCCESS) { - result = zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, nullptr); - } - } - return result; - } - - ze_result_t synchronize() { - if (!isImmediate) { - return zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max()); - } - - return ZE_RESULT_SUCCESS; - } - - ze_result_t destroy() { - auto result = zeCommandListDestroy(cmdList); - if (result == ZE_RESULT_SUCCESS && !isImmediate) { - result = zeCommandQueueDestroy(cmdQueue); - } - return result; - } + ze_result_t execute(); + ze_result_t synchronize(); + ze_result_t destroy(); }; + +} // namespace LevelZeroBlackBoxTests diff --git a/level_zero/core/test/black_box_tests/common/zello_compile.cpp b/level_zero/core/test/black_box_tests/common/zello_compile.cpp index c84aaa1914..9ee9d4df17 100644 --- a/level_zero/core/test/black_box_tests/common/zello_compile.cpp +++ b/level_zero/core/test/black_box_tests/common/zello_compile.cpp @@ -11,6 +11,8 @@ #include +namespace LevelZeroBlackBoxTests { + std::vector compileToSpirV(const std::string &src, const std::string &options, std::string &outCompilerLog) { std::vector ret; @@ -145,3 +147,5 @@ __kernel void memcpy_bytes(__global uchar *dst, const __global uchar *src) { } } )=="; + +} // namespace LevelZeroBlackBoxTests diff --git a/level_zero/core/test/black_box_tests/common/zello_compile.h b/level_zero/core/test/black_box_tests/common/zello_compile.h index cb8592b6e8..e7b9a7dde1 100644 --- a/level_zero/core/test/black_box_tests/common/zello_compile.h +++ b/level_zero/core/test/black_box_tests/common/zello_compile.h @@ -11,9 +11,13 @@ #include #include +namespace LevelZeroBlackBoxTests { + std::vector compileToSpirV(const std::string &src, const std::string &options, std::string &outCompilerLog); std::vector compileToNative(const std::string &src, const std::string &deviceName, const std::string &revisionId, const std::string &options, const std::string &internalOptions, std::string &outCompilerLog); extern const char *memcpyBytesTestKernelSrc; extern const char *memcpyBytesWithPrintfTestKernelSrc; + +} // namespace LevelZeroBlackBoxTests diff --git a/level_zero/core/test/black_box_tests/zello_bindless_kernel.cpp b/level_zero/core/test/black_box_tests/zello_bindless_kernel.cpp index a7ecf7cf26..17660d047d 100644 --- a/level_zero/core/test/black_box_tests/zello_bindless_kernel.cpp +++ b/level_zero/core/test/black_box_tests/zello_bindless_kernel.cpp @@ -87,7 +87,7 @@ void createModule(const char *sourceCode, bool bindless, const ze_context_handle if (bindless) { internalOptions = bindlessOptions; } - auto bin = compileToNative(sourceCode, deviceName, revisionId, "", internalOptions, buildLog); + auto bin = LevelZeroBlackBoxTests::compileToNative(sourceCode, deviceName, revisionId, "", internalOptions, buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -112,7 +112,7 @@ void createKernel(const ze_module_handle_t module, ze_kernel_handle_t &kernel, c void run(const ze_kernel_handle_t ©Kernel, const ze_kernel_handle_t &fillKernel, ze_context_handle_t &context, ze_device_handle_t &device, uint32_t id, ExecutionMode mode, bool &outputValidationSuccessful) { - CommandHandler commandHandler; + LevelZeroBlackBoxTests::CommandHandler commandHandler; bool isImmediateCmdList = (mode == ExecutionMode::ImmSyncCmdList); SUCCESS_OR_TERMINATE(commandHandler.create(context, device, isImmediateCmdList)); @@ -223,7 +223,7 @@ bool testBindlessImages(ze_context_handle_t context, ze_device_handle_t device, createModule(source3, true, context, device, deviceId, revisionId, module); createKernel(module, copyKernel, kernelName3.c_str()); - CommandHandler commandHandler; + LevelZeroBlackBoxTests::CommandHandler commandHandler; bool isImmediateCmdList = false; SUCCESS_OR_TERMINATE(commandHandler.create(context, device, isImmediateCmdList)); @@ -333,16 +333,16 @@ bool testBindlessImages(ze_context_handle_t context, ze_device_handle_t device, } int main(int argc, char *argv[]) { - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidated = false; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); std::stringstream ss; ss.setf(std::ios::hex, std::ios::basefield); @@ -352,7 +352,7 @@ int main(int argc, char *argv[]) { std::string revisionId = std::to_string(reinterpret_cast(uuid.id)[2]); int testCase = 0; - testCase = getParamValue(argc, argv, "", "--test-case", 0); + testCase = LevelZeroBlackBoxTests::getParamValue(argc, argv, "", "--test-case", 0); switch (testCase) { default: @@ -364,7 +364,7 @@ int main(int argc, char *argv[]) { case 1: std::cout << "test case: testBindlessImages\n" << std::endl; - auto imageCount = getParamValue(argc, argv, "", "--image-count", 4 * 4096 + 8); + auto imageCount = LevelZeroBlackBoxTests::getParamValue(argc, argv, "", "--image-count", 4 * 4096 + 8); std::cout << "--image-count: " << imageCount << std::endl; outputValidated = testBindlessImages(context, device, ss.str(), revisionId, imageCount); break; diff --git a/level_zero/core/test/black_box_tests/zello_commandlist_immediate.cpp b/level_zero/core/test/black_box_tests/zello_commandlist_immediate.cpp index 3455c57d26..d2cbe5933e 100644 --- a/level_zero/core/test/black_box_tests/zello_commandlist_immediate.cpp +++ b/level_zero/core/test/black_box_tests/zello_commandlist_immediate.cpp @@ -43,9 +43,9 @@ void testAppendMemoryCopy(ze_context_handle_t &context, ze_device_handle_t &devi cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, useSyncCmdQ); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncCmdQ); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { @@ -54,12 +54,12 @@ void testAppendMemoryCopy(ze_context_handle_t &context, ze_device_handle_t &devi if (!useSyncCmdQ) { if (sharedEvent == nullptr) { - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event = sharedEvent; } if (sharedEvent2 == nullptr) { - createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event2 = sharedEvent2; } @@ -110,9 +110,9 @@ void testAppendMemoryCopyRegion(ze_context_handle_t &context, ze_device_handle_t cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, useSyncCmdQ); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncCmdQ); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { @@ -120,21 +120,21 @@ void testAppendMemoryCopyRegion(ze_context_handle_t &context, ze_device_handle_t } void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 16 : 1024; // width of the dst 2D buffer in bytes - uint32_t dstHeight = verbose ? 32 : 512; // height of the dst 2D buffer in bytes - uint32_t dstOriginX = verbose ? 8 : 128; // Offset in bytes - uint32_t dstOriginY = verbose ? 8 : 144; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 16 : 1024; // width of the dst 2D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 32 : 512; // height of the dst 2D buffer in bytes + uint32_t dstOriginX = LevelZeroBlackBoxTests::verbose ? 8 : 128; // Offset in bytes + uint32_t dstOriginY = LevelZeroBlackBoxTests::verbose ? 8 : 144; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 24 : 256; // width of the src 2D buffer in bytes - uint32_t srcHeight = verbose ? 16 : 384; // height of the src 2D buffer in bytes - uint32_t srcOriginX = verbose ? 4 : 64; // Offset in bytes - uint32_t srcOriginY = verbose ? 4 : 128; // Offset in rows - uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 24 : 256; // width of the src 2D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 16 : 384; // height of the src 2D buffer in bytes + uint32_t srcOriginX = LevelZeroBlackBoxTests::verbose ? 4 : 64; // Offset in bytes + uint32_t srcOriginY = LevelZeroBlackBoxTests::verbose ? 4 : 128; // Offset in rows + uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer - uint32_t width = verbose ? 8 : 144; // width of the region to copy - uint32_t height = verbose ? 12 : 96; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 144; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 12 : 96; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, 0, width, height, 0}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, 0, width, height, 0}; @@ -166,12 +166,12 @@ void testAppendMemoryCopyRegion(ze_context_handle_t &context, ze_device_handle_t if (!useSyncCmdQ) { // Create Event Pool and kernel launch event if (sharedEvent == nullptr) { - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event = sharedEvent; } if (sharedEvent2 == nullptr) { - createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event2 = sharedEvent2; } @@ -207,7 +207,7 @@ void testAppendMemoryCopyRegion(ze_context_handle_t &context, ze_device_handle_t } uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "stackBuffer\n"; for (uint32_t i = 0; i < srcHeight; i++) { for (uint32_t j = 0; j < srcWidth; j++) { @@ -271,7 +271,7 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic void *dstBuffer = nullptr; std::string buildLog; - auto moduleBinary = compileToSpirV(memcpyBytesTestKernelSrc, "", buildLog); + auto moduleBinary = LevelZeroBlackBoxTests::compileToSpirV(LevelZeroBlackBoxTests::memcpyBytesTestKernelSrc, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -293,7 +293,7 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel, numThreads, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); SUCCESS_OR_TERMINATE_BOOL(numThreads % groupSizeX == 0); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } @@ -304,9 +304,9 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, useSyncCmdQ); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncCmdQ); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { @@ -338,12 +338,12 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic if (!useSyncCmdQ) { // Create Event Pool and kernel launch event if (sharedEvent == nullptr) { - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event = sharedEvent; } if (sharedEvent2 == nullptr) { - createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { event2 = sharedEvent2; } @@ -373,7 +373,7 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic dispatchTraits.groupCountX = numThreads / groupSizeX; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -399,8 +399,8 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic validRet = (0 == memcmp(initDataSrc, readBackData, sizeof(readBackData))); - if (verbose && (false == validRet)) { - validate(initDataSrc, readBackData, sizeof(readBackData)); + if (LevelZeroBlackBoxTests::verbose && (false == validRet)) { + LevelZeroBlackBoxTests::validate(initDataSrc, readBackData, sizeof(readBackData)); } SUCCESS_OR_TERMINATE(zeMemFree(context, dstBuffer)); @@ -425,11 +425,11 @@ void testAppendGpuKernel(ze_context_handle_t &context, ze_device_handle_t &devic int main(int argc, char *argv[]) { const std::string blackBoxName("Zello Command List Immediate"); - verbose = isVerbose(argc, argv); - bool useSyncQueue = isSyncQueueEnabled(argc, argv); - bool commandListShared = isCommandListShared(argc, argv); - bool commandListCoexist = isParamEnabled(argc, argv, "-o", "--coexists"); - bool eventPoolShared = !isParamEnabled(argc, argv, "-n", "--nopoolshared"); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool useSyncQueue = LevelZeroBlackBoxTests::isSyncQueueEnabled(argc, argv); + bool commandListShared = LevelZeroBlackBoxTests::isCommandListShared(argc, argv); + bool commandListCoexist = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-o", "--coexists"); + bool eventPoolShared = !LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-n", "--nopoolshared"); if (eventPoolShared) { std::cerr << "Event pool shared between tests" << std::endl; } @@ -438,16 +438,16 @@ int main(int argc, char *argv[]) { commandListShared = false; } - bool aubMode = isAubMode(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device0 = devices[0]; ze_device_properties_t device0Properties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device0, &device0Properties)); - printDeviceProperties(device0Properties); + LevelZeroBlackBoxTests::printDeviceProperties(device0Properties); bool outputValidationSuccessful = false; @@ -456,8 +456,8 @@ int main(int argc, char *argv[]) { if (!useSyncQueue && eventPoolShared) { // Create Event Pool and kernel launch event - createEventPoolAndEvents(context, device0, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - createEventPoolAndEvents(context, device0, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device0, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device0, eventPool2, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event2, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } ze_command_list_handle_t cmdList = nullptr; @@ -467,9 +467,9 @@ int main(int argc, char *argv[]) { cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device0); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device0); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, useSyncQueue); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncQueue); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device0, &cmdQueueDesc, &cmdListShared)); cmdList = cmdListShared; } @@ -482,9 +482,9 @@ int main(int argc, char *argv[]) { cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device0); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device0); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, useSyncQueue); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncQueue); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device0, &cmdQueueDesc, &cmdListStandardMemoryCopy)); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device0, &cmdQueueDesc, &cmdListMemoryCopyRegion)); @@ -496,7 +496,7 @@ int main(int argc, char *argv[]) { std::string currentTest; currentTest = "Standard Memory Copy"; testAppendMemoryCopy(context, device0, useSyncQueue, outputValidationSuccessful, cmdList, event, event2); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); if (outputValidationSuccessful || aubMode) { if (commandListCoexist) { @@ -508,7 +508,7 @@ int main(int argc, char *argv[]) { } currentTest = "Memory Copy Region"; testAppendMemoryCopyRegion(context, device0, useSyncQueue, outputValidationSuccessful, cmdList, event, event2); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { @@ -521,7 +521,7 @@ int main(int argc, char *argv[]) { } currentTest = "Launch GPU Kernel"; testAppendGpuKernel(context, device0, useSyncQueue, outputValidationSuccessful, cmdList, event, event2); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (commandListShared) { diff --git a/level_zero/core/test/black_box_tests/zello_copy.cpp b/level_zero/core/test/black_box_tests/zello_copy.cpp index c094ddd298..8678b189c0 100644 --- a/level_zero/core/test/black_box_tests/zello_copy.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy.cpp @@ -19,8 +19,8 @@ void testAppendMemoryCopyFromHeapToDeviceToStack(ze_context_handle_t &context, z ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); ze_device_mem_alloc_desc_t deviceDesc = {}; deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC; @@ -67,8 +67,8 @@ void testAppendMemoryCopyFromHostToDeviceToStack(ze_context_handle_t &context, z ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); ze_host_mem_alloc_desc_t hostDesc = {}; hostDesc.stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC; @@ -118,25 +118,25 @@ void testAppendMemoryCopy2DRegion(ze_context_handle_t &context, ze_device_handle ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 16 : 256; // width of the dst 2D buffer in bytes - uint32_t dstHeight = verbose ? 32 : 128; // height of the dst 2D buffer in bytes - uint32_t dstOriginX = verbose ? 8 : 32; // Offset in bytes - uint32_t dstOriginY = verbose ? 8 : 64; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 16 : 256; // width of the dst 2D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 32 : 128; // height of the dst 2D buffer in bytes + uint32_t dstOriginX = LevelZeroBlackBoxTests::verbose ? 8 : 32; // Offset in bytes + uint32_t dstOriginY = LevelZeroBlackBoxTests::verbose ? 8 : 64; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 24 : 128; // width of the src 2D buffer in bytes - uint32_t srcHeight = verbose ? 16 : 96; // height of the src 2D buffer in bytes - uint32_t srcOriginX = verbose ? 4 : 16; // Offset in bytes - uint32_t srcOriginY = verbose ? 4 : 32; // Offset in rows - uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 24 : 128; // width of the src 2D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 16 : 96; // height of the src 2D buffer in bytes + uint32_t srcOriginX = LevelZeroBlackBoxTests::verbose ? 4 : 16; // Offset in bytes + uint32_t srcOriginY = LevelZeroBlackBoxTests::verbose ? 4 : 32; // Offset in rows + uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer - uint32_t width = verbose ? 8 : 64; // width of the region to copy - uint32_t height = verbose ? 12 : 32; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 12 : 32; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, 0, width, height, 0}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, 0, width, height, 0}; @@ -185,7 +185,7 @@ void testAppendMemoryCopy2DRegion(ze_context_handle_t &context, ze_device_handle SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "srcBufferChar\n"; for (uint32_t i = 0; i < srcHeight; i++) { for (uint32_t j = 0; j < srcWidth; j++) { @@ -229,8 +229,8 @@ void testMemoryFillWithWordSizedPattern(ze_context_handle_t &context, ze_device_ ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Initialize buffers ze_device_mem_alloc_desc_t deviceDesc = {}; @@ -260,7 +260,7 @@ void testMemoryFillWithWordSizedPattern(ze_context_handle_t &context, ze_device_ for (size_t i = 0; i < allocSize; ++i) { if (zeBufferChar[i] != pattern[i % sizeof(pattern)]) { validRet = false; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "dstBufferChar[" << i << " ] " << static_cast(zeBufferChar[i]) << "!= pattern " << pattern[i % sizeof(pattern)] << "\n"; @@ -286,8 +286,8 @@ void testAppendMemoryFillWithSomePattern(ze_context_handle_t &context, ze_device ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Initialize buffers // zeBuffer0 and zeBuffer1 are shared allocations, so they have UVA between host and device @@ -333,7 +333,7 @@ void testAppendMemoryFillWithSomePattern(ze_context_handle_t &context, ze_device for (size_t i = 0; i < allocSize; ++i) { if (zeBufferChar0[i] != pattern0) { validRet = false; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "dstBufferChar0[" << i << " ] " << static_cast(zeBufferChar0[i]) << "!= pattern0 " << pattern0 << "\n"; @@ -347,7 +347,7 @@ void testAppendMemoryFillWithSomePattern(ze_context_handle_t &context, ze_device for (size_t i = 0; i < allocSize; i++) { if (zeBufferChar1[i] != pattern1[i % pattern1Size]) { validRet = false; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "dstBufferChar1[" << i << " ] " << static_cast(zeBufferChar1[i]) << "!= pattern1[" << i % pattern1Size << " ] " @@ -371,30 +371,30 @@ void testAppendMemoryCopy3DRegion(ze_context_handle_t &context, ze_device_handle ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - cmdQueue = createCommandQueue(context, device, nullptr); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 8 : 64; // width of the dst 3D buffer in bytes - uint32_t dstHeight = verbose ? 8 : 64; // height of the dst 3D buffer in bytes - uint32_t dstDepth = verbose ? 2 : 4; // depth of the dst 3D buffer in bytes - uint32_t dstOriginX = 0; // Offset in bytes - uint32_t dstOriginY = 0; // Offset in rows - uint32_t dstOriginZ = 0; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth * dstDepth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the dst 3D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the dst 3D buffer in bytes + uint32_t dstDepth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // depth of the dst 3D buffer in bytes + uint32_t dstOriginX = 0; // Offset in bytes + uint32_t dstOriginY = 0; // Offset in rows + uint32_t dstOriginZ = 0; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth * dstDepth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 8 : 64; // width of the src 3D buffer in bytes - uint32_t srcHeight = verbose ? 8 : 64; // height of the src 3D buffer in bytes - uint32_t srcDepth = verbose ? 2 : 4; // depth of the src 3D buffer in bytes - uint32_t srcOriginX = 0; // Offset in bytes - uint32_t srcOriginY = 0; // Offset in rows - uint32_t srcOriginZ = 0; // Offset in rows - uint32_t srcSize = srcHeight * srcWidth * srcDepth; // Size of the src buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the src 3D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the src 3D buffer in bytes + uint32_t srcDepth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // depth of the src 3D buffer in bytes + uint32_t srcOriginX = 0; // Offset in bytes + uint32_t srcOriginY = 0; // Offset in rows + uint32_t srcOriginZ = 0; // Offset in rows + uint32_t srcSize = srcHeight * srcWidth * srcDepth; // Size of the src buffer - uint32_t width = verbose ? 8 : 64; // width of the region to copy - uint32_t height = verbose ? 8 : 64; // height of the region to copy - uint32_t depth = verbose ? 2 : 4; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the region to copy + uint32_t depth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, dstOriginZ, width, height, depth}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, dstOriginZ, width, height, depth}; @@ -446,7 +446,7 @@ void testAppendMemoryCopy3DRegion(ze_context_handle_t &context, ze_device_handle SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "srcBufferChar\n"; for (uint32_t i = 0; i < srcDepth; i++) { for (uint32_t j = 0; j < srcHeight; j++) { @@ -494,17 +494,17 @@ void testAppendMemoryCopy3DRegion(ze_context_handle_t &context, ze_device_handle int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful = false; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); testAppendMemoryCopyFromHeapToDeviceToStack(context, device, outputValidationSuccessful); if (outputValidationSuccessful || aubMode) { @@ -525,7 +525,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); diff --git a/level_zero/core/test/black_box_tests/zello_copy_fence.cpp b/level_zero/core/test/black_box_tests/zello_copy_fence.cpp index d90d5c879c..6ee8b4420e 100644 --- a/level_zero/core/test/black_box_tests/zello_copy_fence.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy_fence.cpp @@ -59,7 +59,7 @@ void testAppendMemoryCopy(ze_context_handle_t &context, ze_device_handle_t &devi fenceDesc.flags = 0; SUCCESS_OR_TERMINATE(zeFenceCreate(cmdQueue, &fenceDesc, &fence)); for (int i = 0; i < 2; i++) { - if (verbose) + if (LevelZeroBlackBoxTests::verbose) std::cout << "zeFenceHostSynchronize start iter:" << i << std::endl; // Copy from heap to device-allocated memory SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, zeBuffer, heapBuffer, allocSize, @@ -71,7 +71,7 @@ void testAppendMemoryCopy(ze_context_handle_t &context, ze_device_handle_t &devi SUCCESS_OR_TERMINATE(zeCommandListClose(cmdList)); SUCCESS_OR_TERMINATE(zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, fence)); SUCCESS_OR_TERMINATE(zeFenceHostSynchronize(fence, std::numeric_limits::max())); - if (verbose) + if (LevelZeroBlackBoxTests::verbose) std::cout << "zeFenceHostSynchronize success iter:" << i << std::endl; SUCCESS_OR_TERMINATE(zeFenceReset(fence)); SUCCESS_OR_TERMINATE(zeCommandListReset(cmdList)); @@ -88,23 +88,23 @@ void testAppendMemoryCopy(ze_context_handle_t &context, ze_device_handle_t &devi int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy Fence"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); bool outputValidationSuccessful; testAppendMemoryCopy(context, device, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_copy_image.cpp b/level_zero/core/test/black_box_tests/zello_copy_image.cpp index 07e2bb76fd..ce41294ac9 100644 --- a/level_zero/core/test/black_box_tests/zello_copy_image.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy_image.cpp @@ -108,22 +108,22 @@ void testAppendImageCopy(ze_context_handle_t &context, ze_device_handle_t &devic int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy Image"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); testAppendImageCopy(context, device, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); diff --git a/level_zero/core/test/black_box_tests/zello_copy_kernel_printf.cpp b/level_zero/core/test/black_box_tests/zello_copy_kernel_printf.cpp index c9dca9cc06..7c8ee2bc12 100644 --- a/level_zero/core/test/black_box_tests/zello_copy_kernel_printf.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy_kernel_printf.cpp @@ -17,12 +17,12 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy With Printf"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); // X. Prepare spirV std::string buildLog; - auto moduleBinary = compileToSpirV(memcpyBytesWithPrintfTestKernelSrc, "-g", buildLog); + auto moduleBinary = LevelZeroBlackBoxTests::compileToSpirV(LevelZeroBlackBoxTests::memcpyBytesWithPrintfTestKernelSrc, "-g", buildLog); if (!buildLog.empty()) { std::cout << "Build log " << buildLog; } @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) { // 1. Set-up size_t allocSize = 4096; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { allocSize = 32; } constexpr size_t bytesPerThread = sizeof(char); @@ -43,12 +43,12 @@ int main(int argc, char *argv[]) { void *dstBuffer = nullptr; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV; @@ -66,14 +66,14 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel, static_cast(numThreads), 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); SUCCESS_OR_TERMINATE_BOOL(numThreads % groupSizeX == 0); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } SUCCESS_OR_TERMINATE(zeKernelSetGroupSize(kernel, groupSizeX, groupSizeY, groupSizeZ)); - cmdQueue = createCommandQueue(context, device, nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); ze_device_mem_alloc_desc_t deviceDesc = {}; deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC; @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) { dispatchTraits.groupCountX = static_cast(numThreads) / groupSizeX; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) { for (size_t i = 0; i < allocSize; ++i) { uint8_t expectedData = static_cast(initDataSrc[i] + i); outputValidationSuccessful &= (expectedData == readBackData[i]); - if ((verbose || (outputValidationSuccessful == false)) && (aubMode == false)) { + if ((LevelZeroBlackBoxTests::verbose || (outputValidationSuccessful == false)) && (aubMode == false)) { std::cout << "readBackData[" << i << "] = " << static_cast(readBackData[i]) << ", expected " << static_cast(expectedData) << "\n"; @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) { delete[] initDataDst; delete[] readBackData; - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; } diff --git a/level_zero/core/test/black_box_tests/zello_copy_only.cpp b/level_zero/core/test/black_box_tests/zello_copy_only.cpp index c9867fc536..5c50065fa4 100644 --- a/level_zero/core/test/black_box_tests/zello_copy_only.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy_only.cpp @@ -27,7 +27,7 @@ void testCopyBetweenHeapDeviceAndStack(ze_context_handle_t &context, ze_device_h ze_command_list_handle_t cmdList; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); if (copyQueueGroup == std::numeric_limits::max()) { std::cout << "No Copy queue group found. Skipping test run\n"; // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) validRet = true; @@ -102,7 +102,7 @@ void testCopyBetweenHostMemAndDeviceMem(ze_context_handle_t &context, ze_device_ ze_command_list_handle_t cmdList; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); if (copyQueueGroup == std::numeric_limits::max()) { std::cout << "No Copy queue group found. Skipping test run\n"; // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) validRet = true; @@ -173,7 +173,7 @@ void testRegionCopyOf2DSharedMem(ze_context_handle_t &context, ze_device_handle_ ze_command_list_handle_t cmdList; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); if (copyQueueGroup == std::numeric_limits::max()) { std::cout << "No Copy queue group found. Skipping test run\n"; validRet = true; @@ -196,21 +196,21 @@ void testRegionCopyOf2DSharedMem(ze_context_handle_t &context, ze_device_handle_ SUCCESS_OR_TERMINATE(zeCommandListCreate(context, device, &cmdListDesc, &cmdList)); void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 16 : 256; // width of the dst 2D buffer in bytes - uint32_t dstHeight = verbose ? 32 : 128; // height of the dst 2D buffer in bytes - uint32_t dstOriginX = verbose ? 8 : 32; // Offset in bytes - uint32_t dstOriginY = verbose ? 8 : 64; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 16 : 256; // width of the dst 2D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 32 : 128; // height of the dst 2D buffer in bytes + uint32_t dstOriginX = LevelZeroBlackBoxTests::verbose ? 8 : 32; // Offset in bytes + uint32_t dstOriginY = LevelZeroBlackBoxTests::verbose ? 8 : 64; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 16 : 256; // width of the dst 2D buffer in bytes - uint32_t srcHeight = verbose ? 32 : 128; // height of the dst 2D buffer in bytes - uint32_t srcOriginX = verbose ? 8 : 32; // Offset in bytes - uint32_t srcOriginY = verbose ? 8 : 64; // Offset in rows - uint32_t srcSize = dstHeight * dstWidth; // Size of the dst buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 16 : 256; // width of the dst 2D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 32 : 128; // height of the dst 2D buffer in bytes + uint32_t srcOriginX = LevelZeroBlackBoxTests::verbose ? 8 : 32; // Offset in bytes + uint32_t srcOriginY = LevelZeroBlackBoxTests::verbose ? 8 : 64; // Offset in rows + uint32_t srcSize = dstHeight * dstWidth; // Size of the dst buffer - uint32_t width = verbose ? 8 : 64; // width of the region to copy - uint32_t height = verbose ? 12 : 32; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 12 : 32; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, 0, width, height, 0}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, 0, width, height, 0}; @@ -258,7 +258,7 @@ void testRegionCopyOf2DSharedMem(ze_context_handle_t &context, ze_device_handle_ SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "srcBufferChar\n"; for (uint32_t i = 0; i < srcHeight; i++) { for (uint32_t j = 0; j < srcWidth; j++) { @@ -305,7 +305,7 @@ void testSharedMemDataAccessWithoutCopy(ze_context_handle_t &context, ze_device_ ze_command_list_handle_t cmdList; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); if (copyQueueGroup == std::numeric_limits::max()) { std::cout << "No Copy queue group found. Skipping test run\n"; // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) validRet = true; @@ -371,7 +371,7 @@ void testSharedMemDataAccessWithoutCopy(ze_context_handle_t &context, ze_device_ for (size_t i = 0; i < allocSize; ++i) { if (bufferChar0[i] != pattern0) { validRet = false; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "dstBufferChar0[" << i << " ] " << static_cast(bufferChar0[i]) << "!= pattern0 " << pattern0 << "\n"; @@ -386,7 +386,7 @@ void testSharedMemDataAccessWithoutCopy(ze_context_handle_t &context, ze_device_ for (size_t i = 0; i < allocSize; i++) { if (bufferChar1[i] != pattern1[j]) { validRet = false; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "dstBufferChar1[" << i << " ] " << static_cast(bufferChar1[i]) << "!= pattern1[" << j << " ] " @@ -415,7 +415,7 @@ void testRegionCopyOf3DSharedMem(ze_context_handle_t &context, ze_device_handle_ ze_command_list_handle_t cmdList; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); if (copyQueueGroup == std::numeric_limits::max()) { std::cout << "No Copy queue group found. Skipping test run\n"; validRet = true; @@ -438,26 +438,26 @@ void testRegionCopyOf3DSharedMem(ze_context_handle_t &context, ze_device_handle_ SUCCESS_OR_TERMINATE(zeCommandListCreate(context, device, &cmdListDesc, &cmdList)); void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 8 : 64; // width of the dst 3D buffer in bytes - uint32_t dstHeight = verbose ? 8 : 64; // height of the dst 3D buffer in bytes - uint32_t dstDepth = verbose ? 2 : 4; // depth of the dst 3D buffer in bytes - uint32_t dstOriginX = 0; // Offset in bytes - uint32_t dstOriginY = 0; // Offset in rows - uint32_t dstOriginZ = 0; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth * dstDepth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the dst 3D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the dst 3D buffer in bytes + uint32_t dstDepth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // depth of the dst 3D buffer in bytes + uint32_t dstOriginX = 0; // Offset in bytes + uint32_t dstOriginY = 0; // Offset in rows + uint32_t dstOriginZ = 0; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth * dstDepth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 8 : 64; // width of the src 3D buffer in bytes - uint32_t srcHeight = verbose ? 8 : 64; // height of the src 3D buffer in bytes - uint32_t srcDepth = verbose ? 2 : 4; // depth of the src 3D buffer in bytes - uint32_t srcOriginX = 0; // Offset in bytes - uint32_t srcOriginY = 0; // Offset in rows - uint32_t srcOriginZ = 0; // Offset in rows - uint32_t srcSize = srcHeight * srcWidth * srcDepth; // Size of the src buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the src 3D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the src 3D buffer in bytes + uint32_t srcDepth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // depth of the src 3D buffer in bytes + uint32_t srcOriginX = 0; // Offset in bytes + uint32_t srcOriginY = 0; // Offset in rows + uint32_t srcOriginZ = 0; // Offset in rows + uint32_t srcSize = srcHeight * srcWidth * srcDepth; // Size of the src buffer - uint32_t width = verbose ? 8 : 64; // width of the region to copy - uint32_t height = verbose ? 8 : 64; // height of the region to copy - uint32_t depth = verbose ? 2 : 4; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 64; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 8 : 64; // height of the region to copy + uint32_t depth = LevelZeroBlackBoxTests::verbose ? 2 : 4; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, dstOriginZ, width, height, depth}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, dstOriginZ, width, height, depth}; @@ -508,7 +508,7 @@ void testRegionCopyOf3DSharedMem(ze_context_handle_t &context, ze_device_handle_ SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "srcBufferChar\n"; for (uint32_t i = 0; i < srcDepth; i++) { for (uint32_t j = 0; j < srcHeight; j++) { @@ -556,17 +556,17 @@ void testRegionCopyOf3DSharedMem(ze_context_handle_t &context, ze_device_handle_ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy Only"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); bool outputValidationSuccessful = true; testCopyBetweenHeapDeviceAndStack(context, device, outputValidationSuccessful); @@ -585,7 +585,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_copy_tracing.cpp b/level_zero/core/test/black_box_tests/zello_copy_tracing.cpp index 858e7dd7ea..903ce9a93f 100644 --- a/level_zero/core/test/black_box_tests/zello_copy_tracing.cpp +++ b/level_zero/core/test/black_box_tests/zello_copy_tracing.cpp @@ -74,7 +74,7 @@ void onExitInit( UserInstanceData *instanceData = reinterpret_cast(*tracerInstanceUserData); SUCCESS_OR_WARNING_BOOL(instanceData->allocCount = initCount); float time = 1000.f * (endTime - instanceData->startTime) / CLOCKS_PER_SEC; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "zeInit event " << instanceData->allocCount << " " << time << std::endl; } delete instanceData; @@ -129,7 +129,7 @@ void onExitDriverGet( UserInstanceData *instanceData = reinterpret_cast(*tracerInstanceUserData); SUCCESS_OR_WARNING_BOOL(instanceData->allocCount = initCount); float time = 1000.f * (endTime - instanceData->startTime) / CLOCKS_PER_SEC; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "zeDriverGet event " << instanceData->allocCount << " " << time << std::endl; } delete instanceData; @@ -197,7 +197,7 @@ void onExitMemAllocDevice( UserInstanceData *instanceData = reinterpret_cast(*tracerInstanceUserData); SUCCESS_OR_WARNING_BOOL(instanceData->allocCount == memAllocDeviceCount); float time = 1000.f * (endTime - instanceData->startTime) / CLOCKS_PER_SEC; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "zeDriverAllocDeviceMem event " << instanceData->allocCount << " " << time << std::endl; } delete instanceData; @@ -262,7 +262,7 @@ void onExitMemAllocHost( UserInstanceData *instanceData = reinterpret_cast(*tracerInstanceUserData); SUCCESS_OR_WARNING_BOOL(instanceData->allocCount == memAllocHostCount); float time = 1000.f * (endTime - instanceData->startTime) / CLOCKS_PER_SEC; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "zeMemAllocHost event " << instanceData->allocCount << " " << time << std::endl; } delete instanceData; @@ -334,7 +334,7 @@ void onExitMemAllocShared( UserInstanceData *instanceData = reinterpret_cast(*tracerInstanceUserData); SUCCESS_OR_WARNING_BOOL(instanceData->allocCount == memAllocSharedCount); float time = 1000.f * (endTime - instanceData->startTime) / CLOCKS_PER_SEC; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "zeMemAllocShared event " << instanceData->allocCount << " " << time << std::endl; } delete instanceData; @@ -540,21 +540,21 @@ void testAppendMemoryCopy2(ze_context_handle_t &context, ze_device_handle_t &dev SUCCESS_OR_TERMINATE(cmdListDdiTable.pfnCreate(context, device, &cmdListDesc, &cmdList)); void *dstBuffer = nullptr; - uint32_t dstWidth = verbose ? 16 : 1024; // width of the dst 2D buffer in bytes - uint32_t dstHeight = verbose ? 32 : 512; // height of the dst 2D buffer in bytes - uint32_t dstOriginX = verbose ? 8 : 128; // Offset in bytes - uint32_t dstOriginY = verbose ? 8 : 144; // Offset in rows - uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer + uint32_t dstWidth = LevelZeroBlackBoxTests::verbose ? 16 : 1024; // width of the dst 2D buffer in bytes + uint32_t dstHeight = LevelZeroBlackBoxTests::verbose ? 32 : 512; // height of the dst 2D buffer in bytes + uint32_t dstOriginX = LevelZeroBlackBoxTests::verbose ? 8 : 128; // Offset in bytes + uint32_t dstOriginY = LevelZeroBlackBoxTests::verbose ? 8 : 144; // Offset in rows + uint32_t dstSize = dstHeight * dstWidth; // Size of the dst buffer void *srcBuffer = nullptr; - uint32_t srcWidth = verbose ? 24 : 256; // width of the src 2D buffer in bytes - uint32_t srcHeight = verbose ? 16 : 384; // height of the src 2D buffer in bytes - uint32_t srcOriginX = verbose ? 4 : 64; // Offset in bytes - uint32_t srcOriginY = verbose ? 4 : 128; // Offset in rows - uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer + uint32_t srcWidth = LevelZeroBlackBoxTests::verbose ? 24 : 256; // width of the src 2D buffer in bytes + uint32_t srcHeight = LevelZeroBlackBoxTests::verbose ? 16 : 384; // height of the src 2D buffer in bytes + uint32_t srcOriginX = LevelZeroBlackBoxTests::verbose ? 4 : 64; // Offset in bytes + uint32_t srcOriginY = LevelZeroBlackBoxTests::verbose ? 4 : 128; // Offset in rows + uint32_t srcSize = srcHeight * srcWidth; // Size of the src buffer - uint32_t width = verbose ? 8 : 144; // width of the region to copy - uint32_t height = verbose ? 12 : 96; // height of the region to copy + uint32_t width = LevelZeroBlackBoxTests::verbose ? 8 : 144; // width of the region to copy + uint32_t height = LevelZeroBlackBoxTests::verbose ? 12 : 96; // height of the region to copy const ze_copy_region_t dstRegion = {dstOriginX, dstOriginY, 0, width, height, 0}; const ze_copy_region_t srcRegion = {srcOriginX, srcOriginY, 0, width, height, 0}; @@ -594,7 +594,7 @@ void testAppendMemoryCopy2(ze_context_handle_t &context, ze_device_handle_t &dev SUCCESS_OR_TERMINATE(cmdQueueDdiTable.pfnSynchronize(cmdQueue, std::numeric_limits::max())); uint8_t *dstBufferChar = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "stackBuffer\n"; for (uint32_t i = 0; i < srcHeight; i++) { for (uint32_t j = 0; j < srcWidth; j++) { @@ -633,10 +633,10 @@ void testAppendMemoryCopy2(ze_context_handle_t &context, ze_device_handle_t &dev int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Copy Tracing"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); - setEnvironmentVariable("ZET_ENABLE_API_TRACING_EXP", "1"); + LevelZeroBlackBoxTests::setEnvironmentVariable("ZET_ENABLE_API_TRACING_EXP", "1"); ze_api_version_t apiVersion = ZE_API_VERSION_CURRENT; @@ -716,7 +716,7 @@ int main(int argc, char *argv[]) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(deviceDdiTable.pfnGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); bool outputValidationSuccessful; testAppendMemoryCopy0(context, device, outputValidationSuccessful, @@ -734,7 +734,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zetTracerExpSetEnabled(tracer, false)); SUCCESS_OR_TERMINATE(zetTracerExpDestroy(tracer)); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "initCount: " << initCount << " initPrologCount: " << initPrologCount << " initEpilogCount: " << initEpilogCount @@ -774,7 +774,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(contextDdiTable.pfnDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; diff --git a/level_zero/core/test/black_box_tests/zello_debug_info.cpp b/level_zero/core/test/black_box_tests/zello_debug_info.cpp index 93066ae28f..b57d3eb83d 100644 --- a/level_zero/core/test/black_box_tests/zello_debug_info.cpp +++ b/level_zero/core/test/black_box_tests/zello_debug_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -46,19 +46,19 @@ int main(int argc, char *argv[]) { // std::string buildLog; - auto moduleBinary = compileToSpirV(memcpyBytesWithPrintfTestKernelSrc, "-g", buildLog); + auto moduleBinary = LevelZeroBlackBoxTests::compileToSpirV(LevelZeroBlackBoxTests::memcpyBytesWithPrintfTestKernelSrc, "-g", buildLog); if (!buildLog.empty()) { std::cout << "Build log " << buildLog; } SUCCESS_OR_TERMINATE((0 == moduleBinary.size())); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_module_handle_t module; ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; diff --git a/level_zero/core/test/black_box_tests/zello_dp_support.cpp b/level_zero/core/test/black_box_tests/zello_dp_support.cpp index f721bd58c9..a027169783 100644 --- a/level_zero/core/test/black_box_tests/zello_dp_support.cpp +++ b/level_zero/core/test/black_box_tests/zello_dp_support.cpp @@ -5,7 +5,8 @@ * */ -#include "../../../include/ze_intel_gpu.h" +#include "level_zero/include/ze_intel_gpu.h" + #include "zello_common.h" #include @@ -13,19 +14,19 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello DP Support"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = {}; ze_driver_handle_t driverHandle = {}; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; bool outputValidationSuccessful = true; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); // Gather Dot Product (DP) support from driver ze_device_module_properties_t deviceModProps = {ZE_STRUCTURE_TYPE_DEVICE_MODULE_PROPERTIES}; @@ -44,7 +45,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } \ No newline at end of file diff --git a/level_zero/core/test/black_box_tests/zello_dyn_local_arg.cpp b/level_zero/core/test/black_box_tests/zello_dyn_local_arg.cpp index f577e3430e..c852a4992f 100644 --- a/level_zero/core/test/black_box_tests/zello_dyn_local_arg.cpp +++ b/level_zero/core/test/black_box_tests/zello_dyn_local_arg.cpp @@ -52,7 +52,7 @@ void createModule(ze_module_handle_t &module, ze_context_handle_t &context, ze_d // Prepare spirV std::string buildLog; - auto binaryModule = compileToSpirV(clProgram, "", buildLog); + auto binaryModule = LevelZeroBlackBoxTests::compileToSpirV(clProgram, "", buildLog); if (buildLog.size() > 0) { std::cerr << "CL->spirV comilation log : " << buildLog << std::endl; @@ -75,7 +75,7 @@ void createKernel(ze_module_handle_t &module, ze_kernel_handle_t &kernel, size_t // Set group sizes SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel, static_cast(numThreads), 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } @@ -87,7 +87,7 @@ void createCmdQueueAndCmdList(ze_context_handle_t &context, ze_device_handle_t & ze_command_list_handle_t &cmdList, ze_command_queue_desc_t *cmdQueueDesc, ze_command_list_desc_t *cmdListDesc) { - cmdQueueDesc->ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc->ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc->mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, cmdQueueDesc, &cmdqueue)); @@ -140,7 +140,7 @@ bool testLocalBarrier(ze_context_handle_t &context, ze_device_handle_t &device) SUCCESS_OR_TERMINATE(zeCommandListAppendBarrier(cmdList, nullptr, 0, nullptr)); realResult = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Inital Gobal Memory Value " << *realResult << std::endl; } @@ -154,7 +154,7 @@ bool testLocalBarrier(ze_context_handle_t &context, ze_device_handle_t &device) dispatchTraits.groupCountX = 3u; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -168,7 +168,7 @@ bool testLocalBarrier(ze_context_handle_t &context, ze_device_handle_t &device) SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); realResult = reinterpret_cast(dstBuffer); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Final Gobal Memory Value " << *realResult << std::endl; } @@ -190,23 +190,23 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Dyn Local Arg"; bool outputValidationSuccessful; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); outputValidationSuccessful = testLocalBarrier(context, device); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; diff --git a/level_zero/core/test/black_box_tests/zello_dynamic_link.cpp b/level_zero/core/test/black_box_tests/zello_dynamic_link.cpp index da6fc3c7e4..c9b3c0cff6 100644 --- a/level_zero/core/test/black_box_tests/zello_dynamic_link.cpp +++ b/level_zero/core/test/black_box_tests/zello_dynamic_link.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -82,9 +82,9 @@ int lib_func_add5(int x) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Dynamic Link"; bool outputValidationSuccessful = true; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); - bool circularDep = isCircularDepTest(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); + bool circularDep = LevelZeroBlackBoxTests::isCircularDepTest(argc, argv); int numModules = 2; char *exportModuleSrcValue = const_cast(exportModuleSrc); @@ -137,11 +137,11 @@ int main(int argc, char *argv[]) { // Build Import/Export SPIRVs & Modules - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "reading export module for spirv\n"; } std::string buildLog; - auto exportBinaryModule = compileToSpirV(exportModuleSrcValue, "", buildLog); + auto exportBinaryModule = LevelZeroBlackBoxTests::compileToSpirV(exportModuleSrcValue, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -156,17 +156,17 @@ int main(int argc, char *argv[]) { // -library-compliation is required for the non-kernel functions to be listed as exported by the Intel Graphics Compiler exportModuleDesc.pBuildFlags = "-library-compilation"; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "building export module\n"; } SUCCESS_OR_TERMINATE(zeModuleCreate(context, device, &exportModuleDesc, &exportModule, nullptr)); if (circularDep) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "reading export module2 for spirv\n"; } - auto exportBinaryModule2 = compileToSpirV(exportModuleSrc2CircDep, "", buildLog); + auto exportBinaryModule2 = LevelZeroBlackBoxTests::compileToSpirV(exportModuleSrc2CircDep, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -180,17 +180,17 @@ int main(int argc, char *argv[]) { // -library-compliation is required for the non-kernel functions to be listed as exported by the Intel Graphics Compiler exportModuleDesc2.pBuildFlags = "-library-compilation"; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "building export module\n"; } SUCCESS_OR_TERMINATE(zeModuleCreate(context, device, &exportModuleDesc2, &exportModule2, nullptr)); } - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "reading import module for spirv\n"; } - auto importBinaryModule = compileToSpirV(importModuleSrcValue, "", buildLog); + auto importBinaryModule = LevelZeroBlackBoxTests::compileToSpirV(importModuleSrcValue, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -204,14 +204,14 @@ int main(int argc, char *argv[]) { if (circularDep) { importModuleDesc.pBuildFlags = "-library-compilation"; } - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "building import module\n"; } SUCCESS_OR_TERMINATE(zeModuleCreate(context, device, &importModuleDesc, &importModule, nullptr)); // Dynamically linking the two Modules to resolve the symbols - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Dynamically linking modules\n"; } @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) { char *logBuffer = new char[buildLogSize](); SUCCESS_OR_TERMINATE(zeModuleBuildLogGetString(dynLinkLog, &buildLogSize, logBuffer)); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Dynamically linked modules\n"; std::cout << logBuffer << "\n"; } @@ -271,11 +271,11 @@ int main(int argc, char *argv[]) { // Execute the Kernel in the Import module which calls the Export Module's functions SUCCESS_OR_TERMINATE(zeCommandListClose(cmdList)); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "execute kernel in import module\n"; } SUCCESS_OR_TERMINATE(zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, nullptr)); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "sync results from kernel\n"; } SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); @@ -290,7 +290,7 @@ int main(int argc, char *argv[]) { std::cout << "Result:" << *(int *)resultBuffer << " invalid\n"; outputValidationSuccessful = false; } else { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Result Buffer is correct with a value of:" << *(int *)resultBuffer << "\n"; } } @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) { } SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); diff --git a/level_zero/core/test/black_box_tests/zello_events.cpp b/level_zero/core/test/black_box_tests/zello_events.cpp index 66efc1eadf..36bcaa51d5 100644 --- a/level_zero/core/test/black_box_tests/zello_events.cpp +++ b/level_zero/core/test/black_box_tests/zello_events.cpp @@ -20,8 +20,8 @@ void createCmdQueueAndCmdList(ze_device_handle_t &device, ze_command_queue_handle_t &cmdqueue, ze_command_list_handle_t &cmdList) { // Create commandQueue and cmdList - cmdqueue = createCommandQueue(context, device, nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + cmdqueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); } void createCmdQueueAndCmdListWithOrdinal(ze_device_handle_t &device, @@ -29,8 +29,8 @@ void createCmdQueueAndCmdListWithOrdinal(ze_device_handle_t &device, ze_command_queue_handle_t &cmdqueue, ze_command_list_handle_t &cmdList) { // Create commandQueue and cmdList - cmdqueue = createCommandQueueWithOrdinal(context, device, ordinal, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList, ordinal)); + cmdqueue = LevelZeroBlackBoxTests::createCommandQueueWithOrdinal(context, device, ordinal, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList, ordinal)); } // Test Device Signal and Device wait followed by Host Wait @@ -60,16 +60,16 @@ bool testEventsDeviceSignalDeviceWait(ze_context_handle_t &context, ze_device_ha ze_event_pool_handle_t eventPoolDevice, eventPoolHost; uint32_t numEvents = 2; std::vector deviceEvents(numEvents), hostEvents(numEvents); - createEventPoolAndEvents(context, device, eventPoolDevice, - (ze_event_pool_flag_t)0, - numEvents, deviceEvents.data(), - ZE_EVENT_SCOPE_FLAG_SUBDEVICE, - (ze_event_scope_flag_t)0); - createEventPoolAndEvents(context, device, eventPoolHost, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, hostEvents.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPoolDevice, + (ze_event_pool_flag_t)0, + numEvents, deviceEvents.data(), + ZE_EVENT_SCOPE_FLAG_SUBDEVICE, + (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPoolHost, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, hostEvents.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); // Initialize memory uint8_t dstValue = 0; @@ -151,11 +151,11 @@ bool testEventsDeviceSignalHostWait(ze_context_handle_t &context, ze_device_hand ze_event_pool_handle_t eventPool; uint32_t numEvents = 2; std::vector events(numEvents); - createEventPoolAndEvents(context, device, eventPool, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, events.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, events.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, dstBuffer, srcBuffer, allocSize, events[0], 0, nullptr)); @@ -198,7 +198,7 @@ bool testEventsDeviceSignalHostWait(ze_context_handle_t &context, ze_device_hand bool testEventsDeviceSignalHostWaitWithNonZeroOrdinal(ze_context_handle_t &context, ze_device_handle_t &device) { ze_command_queue_handle_t cmdQueue; ze_command_list_handle_t cmdList; - auto ordinals = getComputeQueueOrdinals(device); + auto ordinals = LevelZeroBlackBoxTests::getComputeQueueOrdinals(device); if (ordinals.size() <= 1) { return true; @@ -210,11 +210,11 @@ bool testEventsDeviceSignalHostWaitWithNonZeroOrdinal(ze_context_handle_t &conte ze_event_pool_handle_t eventPool; uint32_t numEvents = 2; std::vector events(numEvents); - createEventPoolAndEvents(context, device, eventPool, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, events.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, events.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); bool outputValidationSuccessful = true; @@ -270,11 +270,11 @@ bool testEventsHostSignalHostWait(ze_context_handle_t &context, ze_device_handle ze_event_pool_handle_t eventPool; uint32_t numEvents = 2; std::vector events(numEvents); - createEventPoolAndEvents(context, device, eventPool, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, events.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, events.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); SUCCESS_OR_TERMINATE(zeCommandListAppendWaitOnEvents(cmdList, 1, &events[0])); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, dstBuffer, srcBuffer, allocSize, events[1], 0, nullptr)); @@ -319,41 +319,40 @@ int main(int argc, char *argv[]) { const std::string blackBoxName("Zello Events"); bool outputValidationSuccessful = true; - ; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); std::string currentTest; currentTest = "Device signal and host wait test"; outputValidationSuccessful = testEventsDeviceSignalHostWait(context, device); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); if (outputValidationSuccessful || aubMode) { currentTest = "Device signal and device wait test"; outputValidationSuccessful = testEventsDeviceSignalDeviceWait(context, device); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { currentTest = "Host signal and host wait test"; outputValidationSuccessful = testEventsHostSignalHostWait(context, device); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { currentTest = "Device signal and host wait with non-zero ordinal"; outputValidationSuccessful = testEventsDeviceSignalHostWaitWithNonZeroOrdinal(context, device); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } SUCCESS_OR_TERMINATE(zeContextDestroy(context)); diff --git a/level_zero/core/test/black_box_tests/zello_export_import_memory.cpp b/level_zero/core/test/black_box_tests/zello_export_import_memory.cpp index 06a28ce9f7..4714bff42a 100644 --- a/level_zero/core/test/black_box_tests/zello_export_import_memory.cpp +++ b/level_zero/core/test/black_box_tests/zello_export_import_memory.cpp @@ -241,7 +241,7 @@ void runServer(bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Export Import"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; for (uint32_t i = 0; i < CHILDPROCESSES; i++) { @@ -267,6 +267,6 @@ int main(int argc, char *argv[]) { runServer(outputValidationSuccessful); - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_fabric.cpp b/level_zero/core/test/black_box_tests/zello_fabric.cpp index 57ab626cc1..00692ec1fa 100644 --- a/level_zero/core/test/black_box_tests/zello_fabric.cpp +++ b/level_zero/core/test/black_box_tests/zello_fabric.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -140,14 +140,14 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Fabric"; ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); - const bool isSubDeviceDisplayEnabled = isParamEnabled(argc, argv, "-s", "--subDeviceEnable"); + const bool isSubDeviceDisplayEnabled = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-s", "--subDeviceEnable"); bool status = true; status &= showFabricConnectivityMatrix(driverHandle, isSubDeviceDisplayEnabled); status &= showFabricConnectivityProperties(driverHandle); - printResult(false, status, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, status, blackBoxName); return (status ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_fence.cpp b/level_zero/core/test/black_box_tests/zello_fence.cpp index 5b58f13a0d..90e08e8074 100644 --- a/level_zero/core/test/black_box_tests/zello_fence.cpp +++ b/level_zero/core/test/black_box_tests/zello_fence.cpp @@ -25,7 +25,7 @@ __kernel void increment_by_one(__global uchar *dst, __global uchar *src) { void createModule(ze_context_handle_t &context, ze_module_handle_t &module, ze_device_handle_t &device) { // Prepare spirV std::string buildLog; - auto spirV = compileToSpirV(clProgram, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(clProgram, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -63,14 +63,14 @@ void createKernel(ze_module_handle_t &module, ze_kernel_handle_t &kernel, SUCCESS_OR_TERMINATE(zeKernelCreate(module, &kernelDesc, &kernel)); ze_kernel_properties_t kernProps{ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES}; SUCCESS_OR_TERMINATE(zeKernelGetProperties(kernel, &kernProps)); - printKernelProperties(kernProps, kernelDesc.pKernelName); + LevelZeroBlackBoxTests::printKernelProperties(kernProps, kernelDesc.pKernelName); uint32_t groupSizeX = sizeX; uint32_t groupSizeY = sizeY; uint32_t groupSizeZ = sizeZ; SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel, numThreads, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); SUCCESS_OR_TERMINATE_BOOL(numThreads % groupSizeX == 0); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } @@ -98,11 +98,11 @@ bool testFence(ze_context_handle_t &context, ze_device_handle_t &device) { // Create commandQueue and cmdList ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Create module and kernel createModule(context, module, device); @@ -140,7 +140,7 @@ bool testFence(ze_context_handle_t &context, ze_device_handle_t &device) { dispatchTraits.groupCountX = numThreads / groupSizeX; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -164,7 +164,7 @@ bool testFence(ze_context_handle_t &context, ze_device_handle_t &device) { // Wait for fence to be signaled SUCCESS_OR_TERMINATE(zeFenceHostSynchronize(fence, std::numeric_limits::max())); - if (verbose) + if (LevelZeroBlackBoxTests::verbose) std::cout << "zeFenceHostSynchronize success" << std::endl; // Tear down @@ -184,23 +184,23 @@ bool testFence(ze_context_handle_t &context, ze_device_handle_t &device) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Fence"; bool outputValidationSuccessful; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); outputValidationSuccessful = testFence(context, device); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_fill.cpp b/level_zero/core/test/black_box_tests/zello_fill.cpp index 775e5c1a44..bd297519ac 100644 --- a/level_zero/core/test/black_box_tests/zello_fill.cpp +++ b/level_zero/core/test/black_box_tests/zello_fill.cpp @@ -41,7 +41,7 @@ void testAppendMemoryCopyFill(ze_context_handle_t &context, ze_device_handle_t & ze_command_list_handle_t cmdListInit = nullptr; if (useInitFill) { - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdListInit)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdListInit)); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryFill(cmdListInit, devBuffer, &initPattern, sizeof(initPattern), devBufferSize, nullptr, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListAppendBarrier(cmdListInit, nullptr, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListClose(cmdListInit)); @@ -50,7 +50,7 @@ void testAppendMemoryCopyFill(ze_context_handle_t &context, ze_device_handle_t & } ze_command_list_handle_t cmdListFill; - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdListFill)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdListFill)); void *dst = reinterpret_cast(reinterpret_cast(devBuffer) + offset); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryFill(cmdListFill, dst, &pattern, sizeof(pattern), (numElements - offset) * sizeof(uint16_t), nullptr, 0, nullptr)); @@ -58,7 +58,7 @@ void testAppendMemoryCopyFill(ze_context_handle_t &context, ze_device_handle_t & SUCCESS_OR_TERMINATE(zeCommandListClose(cmdListFill)); ze_command_list_handle_t cmdListCopy; - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdListCopy)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdListCopy)); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdListCopy, hostBuffer, devBuffer, devBufferSize, nullptr, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListAppendBarrier(cmdListCopy, nullptr, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListClose(cmdListCopy)); @@ -98,29 +98,29 @@ void testAppendMemoryCopyFill(ze_context_handle_t &context, ze_device_handle_t & int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Fill"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); - size_t maxElemenets = static_cast(getParamValue(argc, argv, "-e", "--max-elements", 10)); - bool useInitFill = getParamValue(argc, argv, "-f", "--fill", 1) == 1 ? true : false; + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); + size_t maxElemenets = static_cast(LevelZeroBlackBoxTests::getParamValue(argc, argv, "-e", "--max-elements", 10)); + bool useInitFill = LevelZeroBlackBoxTests::getParamValue(argc, argv, "-f", "--fill", 1) == 1 ? true : false; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful = false; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_command_queue_handle_t cmdQueue; - cmdQueue = createCommandQueue(context, device, nullptr); + cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, device, nullptr); testAppendMemoryCopyFill(context, device, outputValidationSuccessful, cmdQueue, maxElemenets, useInitFill); SUCCESS_OR_TERMINATE(zeCommandQueueDestroy(cmdQueue)); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); diff --git a/level_zero/core/test/black_box_tests/zello_function_pointers_cl.cpp b/level_zero/core/test/black_box_tests/zello_function_pointers_cl.cpp index f92e26d2d5..9fc6d71086 100644 --- a/level_zero/core/test/black_box_tests/zello_function_pointers_cl.cpp +++ b/level_zero/core/test/black_box_tests/zello_function_pointers_cl.cpp @@ -75,20 +75,20 @@ int main(int argc, char *argv[]) { // 1. Setup bool outputValidationSuccessful; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); std::string buildLog; - auto spirV = compileToSpirV(functionPointersProgram, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(functionPointersProgram, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -131,13 +131,13 @@ int main(int argc, char *argv[]) { ze_command_queue_handle_t cmdQueue; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); ze_command_list_handle_t cmdList; - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); ze_device_mem_alloc_desc_t deviceDesc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC}; deviceDesc.ordinal = 0; @@ -212,8 +212,8 @@ int main(int argc, char *argv[]) { // 6. Validate outputValidationSuccessful = (0 == memcmp(initDataSrc, readBackData, sizeof(readBackData))); - if (verbose && (false == outputValidationSuccessful)) { - validate(initDataSrc, readBackData, sizeof(readBackData)); + if (LevelZeroBlackBoxTests::verbose && (false == outputValidationSuccessful)) { + LevelZeroBlackBoxTests::validate(initDataSrc, readBackData, sizeof(readBackData)); } SUCCESS_OR_WARNING_BOOL(outputValidationSuccessful); @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeModuleDestroy(module)); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; } diff --git a/level_zero/core/test/black_box_tests/zello_host_export_import_memory.cpp b/level_zero/core/test/black_box_tests/zello_host_export_import_memory.cpp index ab2fe4b121..666241695e 100644 --- a/level_zero/core/test/black_box_tests/zello_host_export_import_memory.cpp +++ b/level_zero/core/test/black_box_tests/zello_host_export_import_memory.cpp @@ -241,7 +241,7 @@ void runServer(bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Export Import"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; for (uint32_t i = 0; i < CHILDPROCESSES; i++) { @@ -267,6 +267,6 @@ int main(int argc, char *argv[]) { runServer(outputValidationSuccessful); - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_host_ipc_copy_dma_buf.cpp b/level_zero/core/test/black_box_tests/zello_host_ipc_copy_dma_buf.cpp index bd64e73129..16a88f9589 100644 --- a/level_zero/core/test/black_box_tests/zello_host_ipc_copy_dma_buf.cpp +++ b/level_zero/core/test/black_box_tests/zello_host_ipc_copy_dma_buf.cpp @@ -213,7 +213,7 @@ void runServer(bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello IPC"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; for (uint32_t i = 0; i < CHILDPROCESSES; i++) { @@ -239,6 +239,6 @@ int main(int argc, char *argv[]) { runServer(outputValidationSuccessful); - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_host_pointer.cpp b/level_zero/core/test/black_box_tests/zello_host_pointer.cpp index d396e83f8d..4391f54af4 100644 --- a/level_zero/core/test/black_box_tests/zello_host_pointer.cpp +++ b/level_zero/core/test/black_box_tests/zello_host_pointer.cpp @@ -18,11 +18,11 @@ void executeGpuKernelAndValidate(ze_driver_handle_t &driverHandle, ze_context_ha ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; ze_command_list_handle_t cmdList; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Create memory constexpr size_t allocSize = 65536; @@ -82,25 +82,25 @@ void executeGpuKernelAndValidate(ze_driver_handle_t &driverHandle, ze_context_ha int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Host Pointer"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = {}; ze_driver_handle_t driverHandle = {}; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; bool outputValidationSuccessful; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); executeGpuKernelAndValidate(driverHandle, context, device, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_image.cpp b/level_zero/core/test/black_box_tests/zello_image.cpp index 8a90b3c94e..aa0c93e434 100644 --- a/level_zero/core/test/black_box_tests/zello_image.cpp +++ b/level_zero/core/test/black_box_tests/zello_image.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,9 +30,9 @@ void testAppendImageFunction(ze_context_handle_t &context, const size_t channels = 4; - uint32_t hostWidth = verbose ? 5 : 131; - uint32_t hostHeight = verbose ? 4 : 89; - uint32_t hostDepth = verbose ? 3 : 10; + uint32_t hostWidth = LevelZeroBlackBoxTests::verbose ? 5 : 131; + uint32_t hostHeight = LevelZeroBlackBoxTests::verbose ? 4 : 89; + uint32_t hostDepth = LevelZeroBlackBoxTests::verbose ? 3 : 10; // Apply a few pixels of offset to copy-in and copy-out uint32_t inOffsetX = 1; @@ -125,7 +125,7 @@ void testAppendImageFunction(ze_context_handle_t &context, SUCCESS_OR_TERMINATE(zeCommandQueueExecuteCommandLists(cmdQueue, 1, &cmdList, nullptr)); SUCCESS_OR_TERMINATE(zeCommandQueueSynchronize(cmdQueue, std::numeric_limits::max())); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { size_t pixelWidth = channels; size_t rowWidth = pixelWidth * hostWidth; size_t sliceWidth = rowWidth * hostHeight; @@ -201,12 +201,12 @@ void testAppendImageFunction(ze_context_handle_t &context, int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Image"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); - bool do1D = isParamEnabled(argc, argv, "-1", "--1D"); - bool do2D = isParamEnabled(argc, argv, "-2", "--2D"); - bool do3D = isParamEnabled(argc, argv, "-3", "--3D"); + bool do1D = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-1", "--1D"); + bool do2D = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-2", "--2D"); + bool do3D = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-3", "--3D"); // by default, do all tests if (!do1D && !do2D && !do3D) { @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) { ze_device_handle_t device; ze_command_queue_handle_t cmdQueue; uint32_t cmdQueueOrdinal; - initialize(driver, context, device, cmdQueue, cmdQueueOrdinal); + LevelZeroBlackBoxTests::initialize(driver, context, device, cmdQueue, cmdQueueOrdinal); bool success1D = false; bool success2D = false; @@ -228,19 +228,19 @@ int main(int argc, char *argv[]) { if (do1D) { caseName = "1D"; testAppendImageFunction(context, device, cmdQueue, cmdQueueOrdinal, success1D, ZE_IMAGE_TYPE_1D); - printResult(aubMode, success1D, blackBoxName, caseName); + LevelZeroBlackBoxTests::printResult(aubMode, success1D, blackBoxName, caseName); } if (do2D) { caseName = "2D"; testAppendImageFunction(context, device, cmdQueue, cmdQueueOrdinal, success2D, ZE_IMAGE_TYPE_2D); - printResult(aubMode, success1D, blackBoxName, caseName); + LevelZeroBlackBoxTests::printResult(aubMode, success1D, blackBoxName, caseName); } if (do3D) { caseName = "3D"; testAppendImageFunction(context, device, cmdQueue, cmdQueueOrdinal, success3D, ZE_IMAGE_TYPE_3D); - printResult(aubMode, success1D, blackBoxName, caseName); + LevelZeroBlackBoxTests::printResult(aubMode, success1D, blackBoxName, caseName); } - teardown(context, cmdQueue); + LevelZeroBlackBoxTests::teardown(context, cmdQueue); bool outputValidationSuccessful = !((do1D && !success1D) || (do2D && !success2D) || (do3D && !success3D)); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; diff --git a/level_zero/core/test/black_box_tests/zello_image_view.cpp b/level_zero/core/test/black_box_tests/zello_image_view.cpp index ca8cbaaa57..7bc3e1bfc6 100644 --- a/level_zero/core/test/black_box_tests/zello_image_view.cpp +++ b/level_zero/core/test/black_box_tests/zello_image_view.cpp @@ -40,7 +40,7 @@ const char *readNV12Module = R"===( void testAppendImageViewNV12Copy(ze_context_handle_t &context, ze_device_handle_t &device, bool &validRet) { std::string buildLog; - auto spirV = compileToSpirV(readNV12Module, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(readNV12Module, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -534,17 +534,17 @@ void testAppendImageViewRGBPCopy(ze_context_handle_t &context, ze_device_handle_ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Image View"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful = false; ze_device_properties_t deviceProperties = {}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); testAppendImageViewNV12Copy(context, device, outputValidationSuccessful); if (outputValidationSuccessful || aubMode) { @@ -553,7 +553,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_immediate.cpp b/level_zero/core/test/black_box_tests/zello_immediate.cpp index 60c7f9a14e..461b5dcdf8 100644 --- a/level_zero/core/test/black_box_tests/zello_immediate.cpp +++ b/level_zero/core/test/black_box_tests/zello_immediate.cpp @@ -28,7 +28,7 @@ void createImmediateCommandList(ze_device_handle_t &device, cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; cmdQueueDesc.ordinal = queueGroupOrdinal; cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, syncMode); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, syncMode); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } @@ -64,16 +64,16 @@ void testCopyBetweenHostMemAndDeviceMem(ze_context_handle_t &context, ze_device_ ze_event_pool_handle_t eventPoolDevice, eventPoolHost; uint32_t numEvents = 2; std::vector deviceEvents(numEvents), hostEvents(numEvents); - createEventPoolAndEvents(context, device, eventPoolDevice, - (ze_event_pool_flag_t)(0), - numEvents, deviceEvents.data(), - ZE_EVENT_SCOPE_FLAG_SUBDEVICE, - (ze_event_scope_flag_t)0); - createEventPoolAndEvents(context, device, eventPoolHost, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, hostEvents.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPoolDevice, + (ze_event_pool_flag_t)(0), + numEvents, deviceEvents.data(), + ZE_EVENT_SCOPE_FLAG_SUBDEVICE, + (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPoolHost, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, hostEvents.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); // Copy from host-allocated to device-allocated memory SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, deviceBuffer, hostBuffer, allocSize, @@ -117,7 +117,7 @@ void testCopyBetweenHostMemAndDeviceMem(ze_context_handle_t &context, ze_device_ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_device_handle_t &device, bool syncMode, bool &outputValidationSuccessful, bool useEventBasedSync) { ze_command_list_handle_t cmdList; - uint32_t computeOrdinal = getCommandQueueOrdinal(device); + uint32_t computeOrdinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); createImmediateCommandList(device, context, computeOrdinal, syncMode, cmdList); const auto isEventsUsed = useEventBasedSync && !syncMode; @@ -149,11 +149,11 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_device_handle_ ze_event_pool_handle_t eventPoolHost; uint32_t numEvents = 2; std::vector hostEvents(numEvents); - createEventPoolAndEvents(context, device, eventPoolHost, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), - numEvents, hostEvents.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - (ze_event_scope_flag_t)0); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPoolHost, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE), + numEvents, hostEvents.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + (ze_event_scope_flag_t)0); if (file.is_open()) { file.seekg(0, file.end); @@ -258,18 +258,18 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_device_handle_ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Immediate"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); - int useEventBasedSync = getParamValue(argc, argv, "-e", "--useEventsBasedSync", 1); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); + int useEventBasedSync = LevelZeroBlackBoxTests::getParamValue(argc, argv, "-e", "--useEventsBasedSync", 1); ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); bool outputValidationSuccessful = true; if (outputValidationSuccessful || aubMode) { @@ -288,11 +288,11 @@ int main(int argc, char *argv[]) { bool copyQueueFound = false; auto copyQueueDev = devices[0]; for (auto &rd : devices) { - copyQueueGroup = getCopyOnlyCommandQueueOrdinal(rd); + copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(rd); if (copyQueueGroup != std::numeric_limits::max()) { copyQueueFound = true; copyQueueDev = rd; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "\nCopy queue group found in root device\n"; } break; @@ -300,13 +300,13 @@ int main(int argc, char *argv[]) { } if (!copyQueueFound) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "\nNo Copy queue group found in root device. Checking subdevices now...\n"; } copyQueueGroup = 0; for (auto &rd : devices) { uint32_t subDevCount = 0; - auto subdevs = zelloGetSubDevices(rd, subDevCount); + auto subdevs = LevelZeroBlackBoxTests::zelloGetSubDevices(rd, subDevCount); if (!subDevCount) { continue; @@ -314,7 +314,7 @@ int main(int argc, char *argv[]) { // Find subdev that has a copy engine. If not skip tests for (auto &sd : subdevs) { - copyQueueGroup = getCopyOnlyCommandQueueOrdinal(sd); + copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(sd); if (copyQueueGroup != std::numeric_limits::max()) { copyQueueFound = true; copyQueueDev = sd; @@ -323,7 +323,7 @@ int main(int argc, char *argv[]) { } if (copyQueueFound) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "\nCopy queue group found in sub device\n"; } break; @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf.cpp b/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf.cpp index 10f97e9086..82ebc28ed8 100644 --- a/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf.cpp +++ b/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf.cpp @@ -263,7 +263,7 @@ void runServer(bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello IPC"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; for (uint32_t i = 0; i < CHILDPROCESSES; i++) { @@ -289,6 +289,6 @@ int main(int argc, char *argv[]) { runServer(outputValidationSuccessful); - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf_p2p.cpp b/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf_p2p.cpp index 1b73a8b46b..38fd04760d 100644 --- a/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf_p2p.cpp +++ b/level_zero/core/test/black_box_tests/zello_ipc_copy_dma_buf_p2p.cpp @@ -273,10 +273,10 @@ void runServer(int commSocket, bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello IPC P2P"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; - useCopyEngine = isParamEnabled(argc, argv, "-c", "--copyengine"); + useCopyEngine = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-c", "--copyengine"); int sv[2]; if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) { @@ -299,6 +299,6 @@ int main(int argc, char *argv[]) { close(sv[0]); } - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_ipc_event.cpp b/level_zero/core/test/black_box_tests/zello_ipc_event.cpp index 9c3437e202..d417c9e232 100644 --- a/level_zero/core/test/black_box_tests/zello_ipc_event.cpp +++ b/level_zero/core/test/black_box_tests/zello_ipc_event.cpp @@ -259,7 +259,7 @@ void runServer(bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello IPC Event"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful; if (verbose) { @@ -288,6 +288,6 @@ int main(int argc, char *argv[]) { } runServer(outputValidationSuccessful); - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_ipc_p2p_with_ipc_event.cpp b/level_zero/core/test/black_box_tests/zello_ipc_p2p_with_ipc_event.cpp index d7db478056..26b49f435c 100644 --- a/level_zero/core/test/black_box_tests/zello_ipc_p2p_with_ipc_event.cpp +++ b/level_zero/core/test/black_box_tests/zello_ipc_p2p_with_ipc_event.cpp @@ -25,7 +25,7 @@ inline void initializeProcess(ze_context_handle_t &context, ze_command_queue_handle_t &cmdQueueCopy, ze_command_list_handle_t &cmdListCopy, bool isServer) { - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); size_t deviceCount = devices.size(); std::cout << "Number of devices found: " << deviceCount << "\n"; @@ -56,7 +56,7 @@ inline void initializeProcess(ze_context_handle_t &context, // Print some properties ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); // Create command queue uint32_t numQueueGroups = 0; @@ -301,7 +301,7 @@ void runServer(int commSocket, bool &validRet) { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello IPC P2P With Event"; - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); bool outputValidationSuccessful = false; serverDevice = getParamValue(argc, argv, "-s", "--serverdevice", serverDevice); @@ -328,6 +328,6 @@ int main(int argc, char *argv[]) { close(sv[0]); } - printResult(false, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(false, outputValidationSuccessful, blackBoxName); return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_multidev.cpp b/level_zero/core/test/black_box_tests/zello_multidev.cpp index 8b4e8fc039..7873cabcf6 100644 --- a/level_zero/core/test/black_box_tests/zello_multidev.cpp +++ b/level_zero/core/test/black_box_tests/zello_multidev.cpp @@ -15,8 +15,8 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Multidev"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); // Set-up constexpr size_t allocSize = 4096; constexpr size_t bytesPerThread = sizeof(char); @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) { ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - devices = zelloInitContextAndGetDevices(context, driverHandle); + devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); uint32_t deviceCount = (uint32_t)devices.size(); // Get subdevices for each device and add to total count of devices @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) { for (uint32_t i = 0; i < deviceCount; i++) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(devices[i], &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); deviceNames[i].assign(deviceProperties.name, strlen(deviceProperties.name)); @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeDeviceGetCacheProperties(devices[i], &cachePropertiesCount, cacheProperties.data())); for (uint32_t cacheIndex = 0; cacheIndex < cachePropertiesCount; cacheIndex++) { - printCacheProperties(cacheIndex, cacheProperties[cacheIndex]); + LevelZeroBlackBoxTests::printCacheProperties(cacheIndex, cacheProperties[cacheIndex]); } ze_device_p2p_properties_t deviceP2PProperties = {ZE_STRUCTURE_TYPE_DEVICE_P2P_PROPERTIES}; @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeDeviceGetP2PProperties(devices[i], devices[j], &deviceP2PProperties)); ze_bool_t canAccessPeer = false; SUCCESS_OR_TERMINATE(zeDeviceCanAccessPeer(devices[i], devices[j], &canAccessPeer)); - printP2PProperties(deviceP2PProperties, canAccessPeer, i, j); + LevelZeroBlackBoxTests::printP2PProperties(deviceP2PProperties, canAccessPeer, i, j); if (canAccessPeer == false) { std::cout << "Device " << i << " cannot access " << j << "\n"; std::terminate(); @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) { kernel.resize(deviceCount); std::string buildLog; - auto moduleBinary = compileToSpirV(memcpyBytesTestKernelSrc, "", buildLog); + auto moduleBinary = LevelZeroBlackBoxTests::compileToSpirV(LevelZeroBlackBoxTests::memcpyBytesTestKernelSrc, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) { cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(devices[i]); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(devices[i]); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, devices[i], &cmdQueueDesc, &cmdQueue[i])); @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel[i], numThreads, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); SUCCESS_OR_TERMINATE_BOOL(numThreads % groupSizeX == 0); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) { dispatchTraits.groupCountX = numThreads / groupSizeX; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) { std::cout << "\nZello Multidev Results validation " << (outputValidationSuccessful ? "PASSED" : "FAILED") << std::endl; } - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; } diff --git a/level_zero/core/test/black_box_tests/zello_p2p_copy.cpp b/level_zero/core/test/black_box_tests/zello_p2p_copy.cpp index 73383b8316..e2bd97a927 100644 --- a/level_zero/core/test/black_box_tests/zello_p2p_copy.cpp +++ b/level_zero/core/test/black_box_tests/zello_p2p_copy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,18 +21,18 @@ struct DevObjects { int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello P2P Copy"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); // Set-up size_t allocSize = 4096; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { allocSize = 8; } std::vector devObjects; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); bool outputValidationSuccessful = false; uint32_t deviceCount = static_cast(devices.size()); @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { for (uint32_t i = 0; i < deviceCount; i++) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(devices[i], &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_device_p2p_properties_t deviceP2PProperties{}; ze_device_p2p_bandwidth_exp_properties_t expP2Pproperties{}; @@ -55,8 +55,8 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeDeviceGetP2PProperties(devices[i], devices[j], &deviceP2PProperties)); ze_bool_t canAccessPeer = false; SUCCESS_OR_TERMINATE(zeDeviceCanAccessPeer(devices[i], devices[j], &canAccessPeer)); - if (verbose) { - printP2PProperties(deviceP2PProperties, canAccessPeer, i, j); + if (LevelZeroBlackBoxTests::verbose) { + LevelZeroBlackBoxTests::printP2PProperties(deviceP2PProperties, canAccessPeer, i, j); } if (canAccessPeer == false) { std::cout << "Device " << i << " cannot access " << j << "\n"; @@ -70,9 +70,9 @@ int main(int argc, char *argv[]) { devObjects[i].readBackData = new uint8_t[allocSize](); - devObjects[i].cmdQueue = createCommandQueue(context, devices[i], nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); + devObjects[i].cmdQueue = LevelZeroBlackBoxTests::createCommandQueue(context, devices[i], nullptr, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL); - SUCCESS_OR_TERMINATE(createCommandList(context, devices[i], devObjects[i].cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, devices[i], devObjects[i].cmdList)); ze_device_mem_alloc_desc_t deviceDesc = {}; deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC; @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) { if (value != devObjects[i].readBackData[j]) { outputValidationSuccessful = false; } - if ((verbose || (outputValidationSuccessful == false)) && (aubMode == false)) { + if ((LevelZeroBlackBoxTests::verbose || (outputValidationSuccessful == false)) && (aubMode == false)) { std::cout << "readBackData[" << j << "] = " << static_cast(devObjects[i].readBackData[j]) << ", expected " << static_cast(value) << "\n"; @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); int resultOnFailure = aubMode ? 0 : 1; return outputValidationSuccessful ? 0 : resultOnFailure; } diff --git a/level_zero/core/test/black_box_tests/zello_printf.cpp b/level_zero/core/test/black_box_tests/zello_printf.cpp index 699df9a303..dce06383f6 100644 --- a/level_zero/core/test/black_box_tests/zello_printf.cpp +++ b/level_zero/core/test/black_box_tests/zello_printf.cpp @@ -46,7 +46,7 @@ enum class PrintfExecutionMode : uint32_t { void createModule(const ze_context_handle_t context, const ze_device_handle_t device, ze_module_handle_t &module) { std::string buildLog; - auto spirV = compileToSpirV(source, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(source, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -71,7 +71,7 @@ void createKernel(const ze_module_handle_t module, ze_kernel_handle_t &kernel, c void runPrintfKernel(const ze_module_handle_t &module, const ze_kernel_handle_t &kernel, ze_context_handle_t &context, ze_device_handle_t &device, uint32_t id, PrintfExecutionMode mode) { - CommandHandler commandHandler; + LevelZeroBlackBoxTests::CommandHandler commandHandler; bool isImmediateCmdList = (mode == PrintfExecutionMode::ImmSyncCmdList); SUCCESS_OR_TERMINATE(commandHandler.create(context, device, isImmediateCmdList)); @@ -107,19 +107,19 @@ void runPrintfKernel(const ze_module_handle_t &module, const ze_kernel_handle_t } int main(int argc, char *argv[]) { - verbose = isVerbose(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); const char *fileName = "zello_printf_output.txt"; bool validatePrintfOutput = true; bool printfValidated = false; int stdoutFd = -1; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_module_handle_t module = nullptr; createModule(context, device, module); diff --git a/level_zero/core/test/black_box_tests/zello_sandbox.cpp b/level_zero/core/test/black_box_tests/zello_sandbox.cpp index e4da987cc8..b64c3eb728 100644 --- a/level_zero/core/test/black_box_tests/zello_sandbox.cpp +++ b/level_zero/core/test/black_box_tests/zello_sandbox.cpp @@ -26,7 +26,7 @@ void executeImmediateAndRegularCommandLists(ze_context_handle_t &context, ze_dev ze_kernel_handle_t kernel = nullptr; std::string buildLog; - auto spirV = compileToSpirV(addConstModuleSrc, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(addConstModuleSrc, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -64,13 +64,13 @@ void executeImmediateAndRegularCommandLists(ze_context_handle_t &context, ze_dev ze_command_list_handle_t immediateCmdList = nullptr; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, !asyncMode); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, !asyncMode); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &immediateCmdList)); SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); const size_t kernelDataSize = 32; const int numIteration = 5; @@ -118,7 +118,7 @@ void executeImmediateAndRegularCommandLists(ze_context_handle_t &context, ze_dev ze_event_pool_handle_t eventPool; ze_event_handle_t events[3]; - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 3, events, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 3, events, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, deviceMemory, sourceSystemMemory.data(), regularCmdlistBufSize, events[1], 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListAppendMemoryCopy(cmdList, destSystemMemory.data(), deviceMemory, regularCmdlistBufSize, events[2], 1, &events[1])); @@ -198,25 +198,25 @@ void executeMemoryTransferAndValidate(ze_context_handle_t &context, ze_device_ha ze_command_list_handle_t cmdList = nullptr; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, !asyncMode); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, !asyncMode); if (useImmediate) { SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); } ze_event_pool_handle_t eventPool; uint32_t numEvents = 10; std::vector events(numEvents); ze_event_pool_flag_t eventPoolFlags = static_cast(flags); - createEventPoolAndEvents(context, device, eventPool, - eventPoolFlags, - numEvents, events.data(), - ZE_EVENT_SCOPE_FLAG_HOST, - ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, + eventPoolFlags, + numEvents, events.data(), + ZE_EVENT_SCOPE_FLAG_HOST, + ZE_EVENT_SCOPE_FLAG_HOST); constexpr size_t allocSize = 10000; const uint8_t value = 0x55; @@ -346,33 +346,33 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device eventPoolDevices.push_back(device); - uint32_t queueGroup = getCommandQueueOrdinal(device); - uint32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); + uint32_t queueGroup = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); + uint32_t copyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(device); uint32_t subDeviceCopyQueueGroup = std::numeric_limits::max(); ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; cmdQueueDesc.ordinal = queueGroup; cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, false); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, false); if (useImmediate) { SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList, queueGroup)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList, queueGroup)); } uint32_t subDevCount = 0; - auto subDevices = zelloGetSubDevices(device, subDevCount); + auto subDevices = LevelZeroBlackBoxTests::zelloGetSubDevices(device, subDevCount); if (subDevCount == 0) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Skipping multi-tile - subdevice compute sync" << std::endl; } } else { subDevice = subDevices[0]; eventPoolDevices.push_back(subDevice); - uint32_t subDeviceQueueGroup = getCommandQueueOrdinal(subDevice); + uint32_t subDeviceQueueGroup = LevelZeroBlackBoxTests::getCommandQueueOrdinal(subDevice); - subDeviceCopyQueueGroup = getCopyOnlyCommandQueueOrdinal(subDevice); + subDeviceCopyQueueGroup = LevelZeroBlackBoxTests::getCopyOnlyCommandQueueOrdinal(subDevice); if (subDeviceCopyQueueGroup != std::numeric_limits::max()) { copyQueueGroup = subDeviceCopyQueueGroup; } @@ -382,19 +382,19 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, subDevice, &cmdQueueDesc, &cmdListSubDevice)); } else { SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, subDevice, &cmdQueueDesc, &cmdQueueSubDevice)); - SUCCESS_OR_TERMINATE(createCommandList(context, subDevice, cmdListSubDevice, subDeviceQueueGroup)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, subDevice, cmdListSubDevice, subDeviceQueueGroup)); } } if (copyQueueGroup == std::numeric_limits::max()) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Skipping compute - copy sync" << std::endl; } } else { copyDevice = device; if (subDeviceCopyQueueGroup != std::numeric_limits::max()) { copyDevice = subDevice; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Using subdevice for copy engine" << std::endl; } } @@ -404,7 +404,7 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, copyDevice, &cmdQueueDesc, &cmdListCopy)); } else { SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, copyDevice, &cmdQueueDesc, &cmdQueueCopy)); - SUCCESS_OR_TERMINATE(createCommandList(context, copyDevice, cmdListCopy, copyQueueGroup)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, copyDevice, cmdListCopy, copyQueueGroup)); } } @@ -424,7 +424,7 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device } if (subDevice) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Running multi-tile - subdevice compute sync" << std::endl; } auto fromRootToSubEvent = events[eventIndex++]; @@ -476,7 +476,7 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device } if (copyDevice) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Running compute - copy sync" << std::endl; } auto fromComputeToCopyEvent = events[eventIndex++]; @@ -568,7 +568,7 @@ std::string testEventSyncForMultiTileAndCopy(bool immediate, bool tsEvent) { using TestBitMask = std::bitset<32>; TestBitMask getTestMask(int argc, char *argv[], uint32_t defaultValue) { - uint32_t value = static_cast(getParamValue(argc, argv, "-m", "-mask", static_cast(defaultValue))); + uint32_t value = static_cast(LevelZeroBlackBoxTests::getParamValue(argc, argv, "-m", "-mask", static_cast(defaultValue))); std::cerr << "Test mask "; if (value != defaultValue) { std::cerr << "override "; @@ -588,21 +588,21 @@ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Sandbox"; std::string currentTest; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); - bool asyncMode = !isSyncQueueEnabled(argc, argv); - bool immediateFirst = isImmediateFirst(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); + bool asyncMode = !LevelZeroBlackBoxTests::isSyncQueueEnabled(argc, argv); + bool immediateFirst = LevelZeroBlackBoxTests::isImmediateFirst(argc, argv); TestBitMask testMask = getTestMask(argc, argv, std::numeric_limits::max()); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful = true; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); uint32_t testFlag = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; if (testMask.test(bitNumberTestMemoryTransfer5x)) { @@ -612,7 +612,7 @@ int main(int argc, char *argv[]) { executeMemoryTransferAndValidate(context, device, testFlag, useImmediate, asyncMode, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); if (outputValidationSuccessful || aubMode) { currentTest = testMemoryTransfer5xString(asyncMode, useImmediate, true); @@ -620,7 +620,7 @@ int main(int argc, char *argv[]) { executeMemoryTransferAndValidate(context, device, testFlag, useImmediate, asyncMode, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } useImmediate = !useImmediate; @@ -630,7 +630,7 @@ int main(int argc, char *argv[]) { executeMemoryTransferAndValidate(context, device, testFlag, useImmediate, asyncMode, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { @@ -639,7 +639,7 @@ int main(int argc, char *argv[]) { executeMemoryTransferAndValidate(context, device, testFlag, useImmediate, asyncMode, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } } @@ -649,13 +649,13 @@ int main(int argc, char *argv[]) { currentTest = testEventSyncForMultiTileAndCopy(useImmediate, false); testFlag = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; executeEventSyncForMultiTileAndCopy(context, device, testFlag, useImmediate, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { currentTest = testEventSyncForMultiTileAndCopy(useImmediate, true); testFlag = ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; executeEventSyncForMultiTileAndCopy(context, device, testFlag, useImmediate, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } useImmediate = false; @@ -663,13 +663,13 @@ int main(int argc, char *argv[]) { currentTest = testEventSyncForMultiTileAndCopy(useImmediate, false); testFlag = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; executeEventSyncForMultiTileAndCopy(context, device, testFlag, useImmediate, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { currentTest = testEventSyncForMultiTileAndCopy(useImmediate, true); testFlag = ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; executeEventSyncForMultiTileAndCopy(context, device, testFlag, useImmediate, outputValidationSuccessful); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } } @@ -677,13 +677,13 @@ int main(int argc, char *argv[]) { if (outputValidationSuccessful || aubMode) { currentTest = testNameImmediateAndRegularCommandLists(asyncMode); executeImmediateAndRegularCommandLists(context, device, outputValidationSuccessful, aubMode, asyncMode); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } if (outputValidationSuccessful || aubMode) { currentTest = testNameImmediateAndRegularCommandLists(!asyncMode); executeImmediateAndRegularCommandLists(context, device, outputValidationSuccessful, aubMode, !asyncMode); - printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, currentTest); } } diff --git a/level_zero/core/test/black_box_tests/zello_scratch.cpp b/level_zero/core/test/black_box_tests/zello_scratch.cpp index 9c430c7333..8879a729ef 100644 --- a/level_zero/core/test/black_box_tests/zello_scratch.cpp +++ b/level_zero/core/test/black_box_tests/zello_scratch.cpp @@ -46,11 +46,11 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_event_handle_t event = nullptr; ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; if (useAsync) { cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 1, &event, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); } else { cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; } @@ -59,7 +59,7 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } else { SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); } // Create two shared buffers @@ -148,7 +148,7 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, if (srcCharBuffer[i] != dstCharBuffer[i]) { std::cout << "srcBuffer[" << i << "] = " << static_cast(srcCharBuffer[i]) << " not equal to " << "dstBuffer[" << i << "] = " << static_cast(dstCharBuffer[i]) << "\n"; - if (!verbose) { + if (!LevelZeroBlackBoxTests::verbose) { break; } } @@ -175,7 +175,7 @@ void createModuleKernel(ze_context_handle_t &context, ze_module_handle_t &module, ze_kernel_handle_t &kernel) { std::string buildLog; - auto spirV = compileToSpirV(moduleSrc, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(moduleSrc, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -215,20 +215,20 @@ void createModuleKernel(ze_context_handle_t &context, int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello Scratch"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); - bool immediateFirst = isImmediateFirst(argc, argv); - bool useAsync = isAsyncQueueEnabled(argc, argv); - int allocFlagValue = getAllocationFlag(argc, argv, 0); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); + bool immediateFirst = LevelZeroBlackBoxTests::isImmediateFirst(argc, argv); + bool useAsync = LevelZeroBlackBoxTests::isAsyncQueueEnabled(argc, argv); + int allocFlagValue = LevelZeroBlackBoxTests::getAllocationFlag(argc, argv, 0); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); ze_module_handle_t module = nullptr; ze_kernel_handle_t kernel = nullptr; @@ -250,13 +250,13 @@ int main(int argc, char *argv[]) { executeGpuKernelAndValidate(context, device, module, kernel, outputValidationSuccessful, immediateFirst, useAsync, allocFlagValue); caseName = selectCaseName(immediateFirst); - printResult(aubMode, outputValidationSuccessful, blackBoxName, caseName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, caseName); if (outputValidationSuccessful || aubMode) { immediateFirst = !immediateFirst; executeGpuKernelAndValidate(context, device, module, kernel, outputValidationSuccessful, immediateFirst, useAsync, allocFlagValue); caseName = selectCaseName(immediateFirst); - printResult(aubMode, outputValidationSuccessful, blackBoxName, caseName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName, caseName); } SUCCESS_OR_TERMINATE(zeKernelDestroy(kernel)); diff --git a/level_zero/core/test/black_box_tests/zello_timestamp.cpp b/level_zero/core/test/black_box_tests/zello_timestamp.cpp index 8de9cdf862..69ec6ae1c3 100644 --- a/level_zero/core/test/black_box_tests/zello_timestamp.cpp +++ b/level_zero/core/test/black_box_tests/zello_timestamp.cpp @@ -36,9 +36,9 @@ void createImmediateCommandList(ze_device_handle_t &device, cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, syncMode); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, syncMode); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } @@ -85,7 +85,7 @@ void createImmediateCommandList(ze_device_handle_t &device, cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; cmdQueueDesc.ordinal = queueGroupOrdinal; cmdQueueDesc.index = 0; - selectQueueMode(cmdQueueDesc, syncMode); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, syncMode); SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } @@ -228,7 +228,7 @@ bool testKernelTimestampHostQuery(int argc, char *argv[], ze_event_pool_handle_t eventPool; ze_event_handle_t kernelTsEvent; - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); SUCCESS_OR_TERMINATE(zeCommandListAppendLaunchKernel(cmdList, kernel, &dispatchTraits, kernelTsEvent, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListClose(cmdList)); @@ -336,7 +336,7 @@ bool testKernelTimestampAppendQuery(ze_context_handle_t &context, ze_event_pool_handle_t eventPool; ze_event_handle_t kernelTsEvent; - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); SUCCESS_OR_TERMINATE(zeCommandListAppendLaunchKernel(cmdList, kernel, &dispatchTraits, kernelTsEvent, 0, nullptr)); SUCCESS_OR_TERMINATE(zeCommandListAppendBarrier(cmdList, nullptr, 0u, nullptr)); @@ -390,11 +390,11 @@ bool testKernelTimestampAppendQueryWithDeviceProperties(int argc, char *argv[], ze_device_handle_t &device) { bool result; std::string currentTest; - bool aubMode = isAubMode(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); currentTest = "Test Append Write of Global Timestamp: Default Device Properties Structure"; deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; @@ -424,8 +424,8 @@ bool testKernelTimestampMapToHostTimescale(int argc, char *argv[], ze_event_pool_handle_t eventPool; ze_event_handle_t kernelTsEvent; - bool runTillDeviceTsOverflows = isParamEnabled(argc, argv, "-d", "--runTillDeviceTsOverflow"); - bool runTillKernelTsOverflows = isParamEnabled(argc, argv, "-k", "--runTillKernelTsOverflow"); + bool runTillDeviceTsOverflows = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-d", "--runTillDeviceTsOverflow"); + bool runTillKernelTsOverflows = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-k", "--runTillKernelTsOverflow"); // Create commandQueue and cmdList createCmdQueueAndCmdList(context, device, cmdQueue, cmdList); @@ -485,7 +485,7 @@ bool testKernelTimestampMapToHostTimescale(int argc, char *argv[], dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP, 1, &kernelTsEvent, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); SUCCESS_OR_TERMINATE(zeCommandListAppendLaunchKernel(cmdList, kernel, &dispatchTraits, kernelTsEvent, 0, nullptr)); return true; @@ -608,20 +608,20 @@ bool testKernelMappedTimestampMap(int argc, char *argv[], constexpr size_t allocSize = 4096; ze_group_count_t dispatchTraits; - bool runTillDeviceTsOverflows = isParamEnabled(argc, argv, "-o", "--runTillOverflow"); - bool useSingleCommand = isParamEnabled(argc, argv, "-s", "--useSingleCommand"); - bool useImmediate = isParamEnabled(argc, argv, "-i", "--useImmediate"); + bool runTillDeviceTsOverflows = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-o", "--runTillOverflow"); + bool useSingleCommand = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-s", "--useSingleCommand"); + bool useImmediate = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "-i", "--useImmediate"); int defaultVerboseLevel = 1; - int verboseLevel = getParamValue(argc, argv, "-l", "--verboseLevel", defaultVerboseLevel); + int verboseLevel = LevelZeroBlackBoxTests::getParamValue(argc, argv, "-l", "--verboseLevel", defaultVerboseLevel); if (useSingleCommand) { eventUsageCount = 1; } ze_event_handle_t kernelTsEvent[maxEventUsageCount]; - createEventPoolAndEvents(context, device, eventPool, - (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP), maxEventUsageCount, kernelTsEvent, - ZE_EVENT_SCOPE_FLAG_DEVICE, ZE_EVENT_SCOPE_FLAG_HOST); + LevelZeroBlackBoxTests::createEventPoolAndEvents(context, device, eventPool, + (ze_event_pool_flag_t)(ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP), maxEventUsageCount, kernelTsEvent, + ZE_EVENT_SCOPE_FLAG_DEVICE, ZE_EVENT_SCOPE_FLAG_HOST); // Create commandQueue and cmdList if (useImmediate) { @@ -802,8 +802,8 @@ bool testKernelMappedTimestampMap(int argc, char *argv[], int main(int argc, char *argv[]) { const std::string blackBoxName("Zello Timestamp"); - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); using testFunction = std::function 0) { std::cout << "Build log " << buildLog; } @@ -98,7 +98,7 @@ void executeKernelAndValidate(ze_context_handle_t &context, SUCCESS_OR_TERMINATE(zeKernelCreate(module, &kernelDesc, &kernel)); ze_kernel_properties_t kernProps = {ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES}; SUCCESS_OR_TERMINATE(zeKernelGetProperties(kernel, &kernProps)); - printKernelProperties(kernProps, kernelDesc.pKernelName); + LevelZeroBlackBoxTests::printKernelProperties(kernProps, kernelDesc.pKernelName); uint32_t groupSizeX = 32u; uint32_t groupSizeY = 1u; @@ -163,12 +163,12 @@ void executeKernelAndValidate(ze_context_handle_t &context, int main(int argc, char *argv[]) { const std::string blackBoxName("Zello World Global Work Offset"); - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_driver_handle_t driverHandle; ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_api_version_t apiVersion = ZE_API_VERSION_CURRENT; @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) { bool globalOffsetExtensionFound = false; std::string globalOffsetName = "ZE_experimental_global_offset"; for (uint32_t i = 0; i < extensionsSupported.size(); i++) { - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Extension #" << i << " name : " << extensionsSupported[i].name << " version : " << extensionsSupported[i].version << std::endl; } if (strncmp(extensionsSupported[i].name, globalOffsetName.c_str(), globalOffsetName.size()) == 0) { @@ -206,13 +206,13 @@ int main(int argc, char *argv[]) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); executeKernelAndValidate(context, device, kernelExpDdiTable, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return (outputValidationSuccessful ? 0 : 1); } diff --git a/level_zero/core/test/black_box_tests/zello_world_gpu.cpp b/level_zero/core/test/black_box_tests/zello_world_gpu.cpp index 4e24753985..6e508cb67b 100644 --- a/level_zero/core/test/black_box_tests/zello_world_gpu.cpp +++ b/level_zero/core/test/black_box_tests/zello_world_gpu.cpp @@ -14,11 +14,11 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_device_handle_ ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; ze_command_list_handle_t cmdList; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Create two shared buffers constexpr size_t allocSize = 4096; @@ -143,25 +143,25 @@ void executeGpuKernelAndValidate(ze_context_handle_t &context, ze_device_handle_ int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello World"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); - printCommandQueueGroupsProperties(device); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printCommandQueueGroupsProperties(device); executeGpuKernelAndValidate(context, device, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return outputValidationSuccessful ? 0 : 1; } diff --git a/level_zero/core/test/black_box_tests/zello_world_jitc_ocloc.cpp b/level_zero/core/test/black_box_tests/zello_world_jitc_ocloc.cpp index 3ab24c87ce..169dcb0333 100644 --- a/level_zero/core/test/black_box_tests/zello_world_jitc_ocloc.cpp +++ b/level_zero/core/test/black_box_tests/zello_world_jitc_ocloc.cpp @@ -22,11 +22,11 @@ void executeKernelAndValidate(ze_context_handle_t &context, ze_device_handle_t & ze_command_queue_desc_t cmdQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; ze_command_list_handle_t cmdList; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); // Create two shared buffers constexpr size_t allocSize = 4096; ze_device_mem_alloc_desc_t deviceDesc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC}; @@ -48,7 +48,7 @@ void executeKernelAndValidate(ze_context_handle_t &context, ze_device_handle_t & memset(dstBuffer, 0, allocSize); std::string buildLog; - auto spirV = compileToSpirV(moduleSrc, "", buildLog); + auto spirV = LevelZeroBlackBoxTests::compileToSpirV(moduleSrc, "", buildLog); if (buildLog.size() > 0) { std::cout << "Build log " << buildLog; } @@ -85,7 +85,7 @@ void executeKernelAndValidate(ze_context_handle_t &context, ze_device_handle_t & SUCCESS_OR_TERMINATE(zeKernelCreate(module, &kernelDesc, &kernel)); ze_kernel_properties_t kernProps{ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES}; SUCCESS_OR_TERMINATE(zeKernelGetProperties(kernel, &kernProps)); - printKernelProperties(kernProps, kernelDesc.pKernelName); + LevelZeroBlackBoxTests::printKernelProperties(kernProps, kernelDesc.pKernelName); uint32_t groupSizeX = 32u; uint32_t groupSizeY = 1u; @@ -136,24 +136,24 @@ void executeKernelAndValidate(ze_context_handle_t &context, ze_device_handle_t & int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello World JIT"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); ze_context_handle_t context = nullptr; - auto devices = zelloInitContextAndGetDevices(context); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context); auto device = devices[0]; bool outputValidationSuccessful; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); executeKernelAndValidate(context, device, outputValidationSuccessful); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return outputValidationSuccessful ? 0 : 1; } 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 dd4dd27720..070ef77ec9 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 @@ -18,16 +18,16 @@ bool useSyncQueue = false; int main(int argc, char *argv[]) { const std::string blackBoxName = "Zello World USM"; - verbose = isVerbose(argc, argv); - bool aubMode = isAubMode(argc, argv); + LevelZeroBlackBoxTests::verbose = LevelZeroBlackBoxTests::isVerbose(argc, argv); + bool aubMode = LevelZeroBlackBoxTests::isAubMode(argc, argv); - useSyncQueue = isSyncQueueEnabled(argc, argv); + useSyncQueue = LevelZeroBlackBoxTests::isSyncQueueEnabled(argc, argv); bool outputValidationSuccessful = false; // 1. Set-up constexpr char srcInitValue = 7; constexpr char dstInitValue = 3; constexpr size_t bytesPerThread = sizeof(char); - uint32_t allocSize = getBufferLength(argc, argv, 4096 + 7); + uint32_t allocSize = LevelZeroBlackBoxTests::getBufferLength(argc, argv, 4096 + 7); uint32_t numThreads = allocSize / bytesPerThread; ze_module_handle_t module; ze_kernel_handle_t kernel; @@ -44,12 +44,12 @@ int main(int argc, char *argv[]) { ze_context_handle_t context = nullptr; ze_driver_handle_t driverHandle = nullptr; - auto devices = zelloInitContextAndGetDevices(context, driverHandle); + auto devices = LevelZeroBlackBoxTests::zelloInitContextAndGetDevices(context, driverHandle); auto device = devices[0]; ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; SUCCESS_OR_TERMINATE(zeDeviceGetProperties(device, &deviceProperties)); - printDeviceProperties(deviceProperties); + LevelZeroBlackBoxTests::printDeviceProperties(deviceProperties); file.seekg(0, file.end); auto length = file.tellg(); @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeKernelSuggestGroupSize(kernel, numThreads, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ)); SUCCESS_OR_TERMINATE_BOOL(numThreads % groupSizeX == 0); - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cout << "Group size : (" << groupSizeX << ", " << groupSizeY << ", " << groupSizeZ << ")" << std::endl; } @@ -99,15 +99,15 @@ int main(int argc, char *argv[]) { cmdQueueDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC; cmdQueueDesc.pNext = nullptr; cmdQueueDesc.flags = 0; - selectQueueMode(cmdQueueDesc, useSyncQueue); + LevelZeroBlackBoxTests::selectQueueMode(cmdQueueDesc, useSyncQueue); cmdQueueDesc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; - cmdQueueDesc.ordinal = getCommandQueueOrdinal(device); + cmdQueueDesc.ordinal = LevelZeroBlackBoxTests::getCommandQueueOrdinal(device); cmdQueueDesc.index = 0; SUCCESS_OR_TERMINATE(zeCommandQueueCreate(context, device, &cmdQueueDesc, &cmdQueue)); ze_command_list_handle_t cmdList; - SUCCESS_OR_TERMINATE(createCommandList(context, device, cmdList)); + SUCCESS_OR_TERMINATE(LevelZeroBlackBoxTests::createCommandList(context, device, cmdList)); ze_device_mem_alloc_desc_t deviceDesc = {}; deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC; @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) { dispatchTraits.groupCountX = numThreads / groupSizeX; dispatchTraits.groupCountY = 1u; dispatchTraits.groupCountZ = 1u; - if (verbose) { + if (LevelZeroBlackBoxTests::verbose) { std::cerr << "Number of groups : (" << dispatchTraits.groupCountX << ", " << dispatchTraits.groupCountY << ", " << dispatchTraits.groupCountZ << ")" << std::endl; @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) { SUCCESS_OR_TERMINATE(zeModuleDestroy(module)); SUCCESS_OR_TERMINATE(zeContextDestroy(context)); - printResult(aubMode, outputValidationSuccessful, blackBoxName); + LevelZeroBlackBoxTests::printResult(aubMode, outputValidationSuccessful, blackBoxName); outputValidationSuccessful = aubMode ? true : outputValidationSuccessful; return outputValidationSuccessful ? 0 : 1; }