diff --git a/CMakeLists.txt b/CMakeLists.txt index a3183d28..3fecd6c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(NOT TARGET GTest::GTest AND NOT TARGET GMock::GMock AND NOT BUILD_ZE_PERF_TES endif() enable_testing() -set(GTEST_HAS_EXCEPTIONS 0) +add_compile_definitions(GTEST_HAS_EXCEPTIONS=0) set(CMAKE_CXX_STANDARD 14) diff --git a/conformance_tests/core/test_cmdlist/src/test_cmdlist_and_functions.cpp b/conformance_tests/core/test_cmdlist/src/test_cmdlist_and_functions.cpp index 1e15d232..86b3aeb7 100644 --- a/conformance_tests/core/test_cmdlist/src/test_cmdlist_and_functions.cpp +++ b/conformance_tests/core/test_cmdlist/src/test_cmdlist_and_functions.cpp @@ -55,6 +55,10 @@ class CaptureOutput { file_name = std::tmpnam(nullptr); file_descriptor = creat(file_name.c_str(), _S_IREAD | _S_IWRITE); #endif + if (file_descriptor < 0) { + LOG_ERROR << "Error creating file" << std::endl; + return; + } fflush(nullptr); dup2(file_descriptor, stream); close(file_descriptor); @@ -67,7 +71,9 @@ class CaptureOutput { close(orig_file_descriptor); orig_file_descriptor = -1; } - remove(file_name.c_str()); + if (remove(file_name.c_str())) { + LOG_WARNING << "Error removing file: " << file_name << std::endl; + } } std::stringstream GetOutput() { diff --git a/conformance_tests/core/test_device/src/test_device.cpp b/conformance_tests/core/test_device/src/test_device.cpp index 54520f85..a9079c29 100644 --- a/conformance_tests/core/test_device/src/test_device.cpp +++ b/conformance_tests/core/test_device/src/test_device.cpp @@ -931,8 +931,8 @@ void RunGivenExecutedKernelWhenGettingGlobalTimestampsTest(bool is_immediate) { auto device_time_0 = std::get<1>(timestamps); auto device_time_1 = std::get<1>(timestamps_1); auto device_properties = lzt::get_device_properties(device); - uint64_t timestamp_max_val = - ~(-1 << device_properties.kernelTimestampValidBits); + uint64_t timestamp_max_val = ~(static_cast(-1) + << device_properties.kernelTimestampValidBits); uint64_t timestamp_freq = device_properties.timerResolution; auto device_diff_ns = diff --git a/conformance_tests/core/test_module/src/test_module.cpp b/conformance_tests/core/test_module/src/test_module.cpp index 8532c573..79eee05e 100644 --- a/conformance_tests/core/test_module/src/test_module.cpp +++ b/conformance_tests/core/test_module/src/test_module.cpp @@ -64,7 +64,9 @@ std::vector create_module_vector_and_log( ZE_MODULE_FORMAT_NATIVE, nullptr, &build_log->at(count))); count++; - std::remove(filename_native.c_str()); + if (std::remove(filename_native.c_str())) { + LOG_WARNING << "FAILED to remove file " << filename_native; + } } } else { for (auto flag : build_flag) { @@ -511,7 +513,9 @@ TEST_F( std::ifstream stream(filename_native, std::ios::in | std::ios::binary); stream.seekg(0, stream.end); EXPECT_EQ(static_cast(stream.tellg()), size); - std::remove(filename_native.c_str()); + if (std::remove(filename_native.c_str())) { + LOG_WARNING << "FAILED to remove file " << filename_native; + } lzt::destroy_module(module); stream.close(); } diff --git a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device.cpp b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device.cpp index f4f98bd4..b5249706 100644 --- a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device.cpp +++ b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device.cpp @@ -170,7 +170,7 @@ TEST_F( (ZE_DEVICE_PROPERTY_FLAG_INTEGRATED | ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE | ZE_DEVICE_PROPERTY_FLAG_ECC | ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING)) && - (properties_initial.core.flags <= + (properties_later.core.flags <= (ZE_DEVICE_PROPERTY_FLAG_INTEGRATED | ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE | ZE_DEVICE_PROPERTY_FLAG_ECC | ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING))) { diff --git a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_helper.cpp b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_helper.cpp index 4f56483b..0561677c 100644 --- a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_helper.cpp +++ b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_helper.cpp @@ -54,8 +54,9 @@ void get_ze_root_uuids(std::vector ze_devices, int main(int argc, char **argv) { char *device_hierarchy = getenv("ZE_FLAT_DEVICE_HIERARCHY"); - LOG_INFO << "Device Hierarchy : " << device_hierarchy; EXPECT_NE(device_hierarchy, nullptr); + LOG_INFO << "Device Hierarchy : " << device_hierarchy ? device_hierarchy + : "NULL"; auto driver = lzt::zeDevice::get_instance()->get_driver(); std::vector ze_devices = lzt::get_ze_devices(driver); diff --git a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_hierarchy_helper.cpp b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_hierarchy_helper.cpp index c6b7a8a0..23357492 100644 --- a/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_hierarchy_helper.cpp +++ b/conformance_tests/sysman/test_sysman_device/src/test_sysman_device_hierarchy_helper.cpp @@ -27,7 +27,9 @@ void get_sysman_devices(const std::string set_device_hierarchy, putenv(sys_env); char *get_device_hierarchy = getenv("ZE_FLAT_DEVICE_HIERARCHY"); EXPECT_NE(get_device_hierarchy, nullptr); - LOG_INFO << "Child Process : Device Hierarchy = " << get_device_hierarchy; + LOG_INFO << "Child Process : Device Hierarchy = " << get_device_hierarchy + ? get_device_hierarchy + : "NULL"; devices = GET_DEVICE_FN(); } diff --git a/perf_tests/cl_image_copy/src/cl_image_copy.cpp b/perf_tests/cl_image_copy/src/cl_image_copy.cpp index ebb972c5..d044600f 100644 --- a/perf_tests/cl_image_copy/src/cl_image_copy.cpp +++ b/perf_tests/cl_image_copy/src/cl_image_copy.cpp @@ -335,9 +335,16 @@ void measure_bandwidth_Host2Device2Host(ClImageCopy &Imagecopy, std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put( - "Name", "Host2Device2Host: Bandwidth copying from Host->Device->Host "); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put( + "Name", + "Host2Device2Host: Bandwidth copying from Host->Device->Host "); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr + << "Error outputting bandwidth host to device to host measurement: " + << e.what() << std::endl; + } } else { std::cout << "Host2Device2Host: Measuring Bandwidth for copying the " "image buffer size " @@ -348,9 +355,15 @@ void measure_bandwidth_Host2Device2Host(ClImageCopy &Imagecopy, Imagecopy.measureHost2Device2Host(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr + << "Error outputting bandwidth host to device to host measurement: " + << e.what() << std::endl; + } } else { if (Imagecopy.data_validation) { std::cout << " Results: Data validation " @@ -365,8 +378,14 @@ void measure_bandwidth_Host2Device(ClImageCopy &Imagecopy, ptree *test_ptree) { std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put("Name", "Host2Device: Bandwidth copying from Host->Device"); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put("Name", + "Host2Device: Bandwidth copying from Host->Device"); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr << "Error outputting bandwidth measurement:" << e.what() + << std::endl; + } } else { std::cout << "Host2Device: Measuring Bandwidth/Latency for copying the image " @@ -378,9 +397,14 @@ void measure_bandwidth_Host2Device(ClImageCopy &Imagecopy, ptree *test_ptree) { Imagecopy.measureParallelHost2Device(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) { - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) { + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } + } catch (const std::exception &e) { + std::cerr << "Error outputting bandwidth measurement:" << e.what() + << std::endl; } } else { if (Imagecopy.data_validation) { @@ -396,8 +420,14 @@ void measure_bandwidth_Device2Host(ClImageCopy &Imagecopy, ptree *test_ptree) { std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put("Name", "Device2Host: Bandwidth copying from Device->Host"); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put("Name", + "Device2Host: Bandwidth copying from Device->Host"); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr << "Error outputting bandwidth measurement:" << e.what() + << std::endl; + } } else { std::cout << "Device2Host: Measurign Bandwidth/Latency for copying the image " @@ -409,9 +439,14 @@ void measure_bandwidth_Device2Host(ClImageCopy &Imagecopy, ptree *test_ptree) { Imagecopy.measureParallelDevice2Host(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting bandwidth measurement:" << e.what() + << std::endl; + } } else { if (Imagecopy.data_validation) { std::cout << " Results: Data validation " @@ -435,9 +470,14 @@ void measure_bandwidth(ClImageCopy &Imagecopy) { Imagecopy.param_array.push_back(std::make_pair("", ptree_Host2Device2Host)); Imagecopy.param_array.push_back(std::make_pair("", ptree_Host2Device)); Imagecopy.param_array.push_back(std::make_pair("", ptree_Device2Host)); - ptree_main.put_child("Performance Benchmark.bandwidth", - Imagecopy.param_array); - pt::write_json(Imagecopy.JsonFileName.c_str(), ptree_main); + try { + ptree_main.put_child("Performance Benchmark.bandwidth", + Imagecopy.param_array); + pt::write_json(Imagecopy.JsonFileName.c_str(), ptree_main); + } catch (const std::exception &e) { + std::cerr << "Error outputting bandwidth measurement:" << e.what() + << std::endl; + } } } @@ -447,14 +487,19 @@ void measure_latency_Host2Device(ClImageCopyLatency &imageCopyLatency, std::stringstream Image_dimensions; Image_dimensions << imageCopyLatency.width << "X" << imageCopyLatency.height << "X" << imageCopyLatency.depth; - test_ptree->put("Name", - "Host2Device: Measuring Latency for copying the image "); - test_ptree->put("Image size", Image_dimensions.str()); - test_ptree->put("Image type", level_zero_tests::to_string( - (cl_uint)imageCopyLatency.clImagetype)); - test_ptree->put("Image Channel order", - level_zero_tests::to_string( - (cl_uint)imageCopyLatency.clImageChannelOrder)); + try { + test_ptree->put("Name", + "Host2Device: Measuring Latency for copying the image "); + test_ptree->put("Image size", Image_dimensions.str()); + test_ptree->put("Image type", level_zero_tests::to_string( + (cl_uint)imageCopyLatency.clImagetype)); + test_ptree->put("Image Channel order", + level_zero_tests::to_string( + (cl_uint)imageCopyLatency.clImageChannelOrder)); + } catch (const std::exception &e) { + std::cerr << "Error outputting latency host to device measurement:" + << e.what() << std::endl; + } } else { std::cout << "Host2Device: Measuring Bandwidth/Latency for copying the image " @@ -471,10 +516,15 @@ void measure_latency_Host2Device(ClImageCopyLatency &imageCopyLatency, imageCopyLatency.measureParallelHost2Device(); if (imageCopyLatency.is_json_output_enabled()) { - test_ptree->put("Latency", imageCopyLatency.latency); - if (imageCopyLatency.data_validation) - test_ptree->put("Result", - (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("Latency", imageCopyLatency.latency); + if (imageCopyLatency.data_validation) + test_ptree->put("Result", + (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting parallel host to device measurement:" + << e.what() << std::endl; + } } } @@ -484,14 +534,19 @@ void measure_latency_Device2Host(ClImageCopyLatency &imageCopyLatency, std::stringstream Image_dimensions; Image_dimensions << imageCopyLatency.width << "X" << imageCopyLatency.height << "X" << imageCopyLatency.depth; - test_ptree->put("Name", - "Device2Host: Measuring Latency for copying the image"); - test_ptree->put("Image size", Image_dimensions.str()); - test_ptree->put("Image type", level_zero_tests::to_string( - (cl_uint)imageCopyLatency.clImagetype)); - test_ptree->put("Image Channel order", - level_zero_tests::to_string( - (cl_uint)imageCopyLatency.clImageChannelOrder)); + try { + test_ptree->put("Name", + "Device2Host: Measuring Latency for copying the image"); + test_ptree->put("Image size", Image_dimensions.str()); + test_ptree->put("Image type", level_zero_tests::to_string( + (cl_uint)imageCopyLatency.clImagetype)); + test_ptree->put("Image Channel order", + level_zero_tests::to_string( + (cl_uint)imageCopyLatency.clImageChannelOrder)); + } catch (const std::exception &e) { + std::cerr << "Error outputting latency device to host measurement:" + << e.what() << std::endl; + } } else { std::cout << "Device2Host: Measuring Bandwidth/Latency for copying the image " @@ -508,10 +563,15 @@ void measure_latency_Device2Host(ClImageCopyLatency &imageCopyLatency, imageCopyLatency.measureParallelDevice2Host(); if (imageCopyLatency.is_json_output_enabled()) { - test_ptree->put("Latency", imageCopyLatency.latency); - if (imageCopyLatency.data_validation) - test_ptree->put("Result", - (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("Latency", imageCopyLatency.latency); + if (imageCopyLatency.data_validation) + test_ptree->put("Result", + (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting parallel device to host measurement:" + << e.what() << std::endl; + } } } diff --git a/perf_tests/cl_image_copy/src/options.cpp b/perf_tests/cl_image_copy/src/options.cpp index f162f37c..b1bf347d 100755 --- a/perf_tests/cl_image_copy/src/options.cpp +++ b/perf_tests/cl_image_copy/src/options.cpp @@ -16,45 +16,51 @@ int ClImageCopy::parse_command_line(int argc, char **argv) { std::string channel_datatype = ""; // Declare the supported options. + po::variables_map vm; po::options_description desc("Allowed options"); - desc.add_options()("help", "produce help message")( - "width,w", po::value(&width)->default_value(2048), - "set image width")("height,h", - po::value(&height)->default_value(2048), - "set image height")( - "depth,d", po::value(&depth)->default_value(1), - "set image depth")("offx", - po::value(&xOffset)->default_value(0), - "set image xoffset")( - "offy", po::value(&yOffset)->default_value(0), - "set image yoffset")("offz", - po::value(&zOffset)->default_value(0), - "set image zoffset")( - "warmup", po::value(&warm_up_iterations)->default_value(10), - "set number of warmup operations")( - "num_image_copies", - po::value(&num_image_copy)->default_value(100), - "set number of image copies ")( - "iter", po::value(&number_iterations)->default_value(50), - "set number of iterations")( - "channel_order", po::value(&channel_order), - " image channel_order like " - "R/A/INTENSITY/LUMINANCE/RG/RA/RGB/RGBA/ARGB/BGRA")( - "image_type", po::value(&image_type), - "Image type like BUFFER/1D/2D/3D/1DARRAY/2DARRAY/1DBUFFER")( - "channel_datatype", po::value(&channel_datatype), - "image channel data type like " - "SNORM_INT8/SNORM_INT16/UNORM_INT8/UNORM_INT16/UNORM_SHORT565/" - "UNORM_SHORT555/UNORM_INT_101010/SIGNED_INT8/SIGNED_INT16/SIGNED_INT32/" - "UNSIGNED_INT8/UNSIGNED_INT16/UNSIGNED_INT32/HALF_FLOAT/FLOAT")( - "data-validation", po::value(&data_validation), - "optional param for validating the copied image is correct or not")( - "json-output-file", po::value(&JsonFileName), - "test output format file name to be specified"); + try { + desc.add_options()("help", "produce help message")( + "width,w", po::value(&width)->default_value(2048), + "set image width")("height,h", + po::value(&height)->default_value(2048), + "set image height")( + "depth,d", po::value(&depth)->default_value(1), + "set image depth")("offx", + po::value(&xOffset)->default_value(0), + "set image xoffset")( + "offy", po::value(&yOffset)->default_value(0), + "set image yoffset")("offz", + po::value(&zOffset)->default_value(0), + "set image zoffset")( + "warmup", po::value(&warm_up_iterations)->default_value(10), + "set number of warmup operations")( + "num_image_copies", + po::value(&num_image_copy)->default_value(100), + "set number of image copies ")( + "iter", po::value(&number_iterations)->default_value(50), + "set number of iterations")( + "channel_order", po::value(&channel_order), + " image channel_order like " + "R/A/INTENSITY/LUMINANCE/RG/RA/RGB/RGBA/ARGB/BGRA")( + "image_type", po::value(&image_type), + "Image type like BUFFER/1D/2D/3D/1DARRAY/2DARRAY/1DBUFFER")( + "channel_datatype", po::value(&channel_datatype), + "image channel data type like " + "SNORM_INT8/SNORM_INT16/UNORM_INT8/UNORM_INT16/UNORM_SHORT565/" + "UNORM_SHORT555/UNORM_INT_101010/SIGNED_INT8/SIGNED_INT16/SIGNED_INT32/" + "UNSIGNED_INT8/UNSIGNED_INT16/UNSIGNED_INT32/HALF_FLOAT/FLOAT")( + "data-validation", po::value(&data_validation), + "optional param for validating the copied image is correct or not")( + "json-output-file", po::value(&JsonFileName), + "test output format file name to be specified"); - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + std::cout << desc << "\n"; + return 1; + } if (channel_datatype.size() != 0) clChannelDataType = to_channel_datatype(channel_datatype); diff --git a/perf_tests/ze_image_copy/src/options.cpp b/perf_tests/ze_image_copy/src/options.cpp index d78af420..6f061bff 100644 --- a/perf_tests/ze_image_copy/src/options.cpp +++ b/perf_tests/ze_image_copy/src/options.cpp @@ -16,45 +16,51 @@ int ZeImageCopy::parse_command_line(int argc, char **argv) { std::string format = ""; // Declare the supported options. + po::variables_map vm; po::options_description desc("Allowed options"); - desc.add_options()("help", "produce help message")( - "width,w", po::value(&width)->default_value(2048), - "set image width")("height,h", - po::value(&height)->default_value(2048), - "set image height")( - "depth,d", po::value(&depth)->default_value(1), - "set image depth")("offx", - po::value(&xOffset)->default_value(0), - "set image xoffset")( - "offy", po::value(&yOffset)->default_value(0), - "set image yoffset")("offz", - po::value(&zOffset)->default_value(0), - "set image zoffset")( - "warmup", po::value(&warm_up_iterations)->default_value(10), - "set number of warmup operations")( - "num-iter", po::value(&num_iterations)->default_value(50), - "set number of iterations")( - "noofimg", po::value(&num_image_copies)->default_value(100), - "set number of image copies ")( - "layout", po::value(&layout), - " image layout like " - "8/16/32/8_8/8_8_8_8/16_16/16_16_16_16/32_32/32_32_32_32/10_10_10_2/" - "11_11_10/5_6_5/5_5_5_1/4_4_4_4/Y8/NV12/YUYV/VYUY/YVYU/UYVY/AYUV/YUAV/" - "P010/Y410/P012/Y16/P016/Y216/P216/P416")( - "flags", po::value(&flags), - "image program flags like READ/WRITE/CACHED/UNCACHED")( - "type", po::value(&type), - "Image type like 1D/2D/3D/1DARRAY/2DARRAY")( - "format", po::value(&format), - "image format like UINT/SINT/UNORM/SNORM/FLOAT")( - "data-validation", po::value(&data_validation), - "optional param for validating the copied image is correct or not")( - "json-output-file", po::value(&JsonFileName), - "test output format file name to be specified"); + try { + desc.add_options()("help", "produce help message")( + "width,w", po::value(&width)->default_value(2048), + "set image width")("height,h", + po::value(&height)->default_value(2048), + "set image height")( + "depth,d", po::value(&depth)->default_value(1), + "set image depth")("offx", + po::value(&xOffset)->default_value(0), + "set image xoffset")( + "offy", po::value(&yOffset)->default_value(0), + "set image yoffset")("offz", + po::value(&zOffset)->default_value(0), + "set image zoffset")( + "warmup", po::value(&warm_up_iterations)->default_value(10), + "set number of warmup operations")( + "num-iter", po::value(&num_iterations)->default_value(50), + "set number of iterations")( + "noofimg", po::value(&num_image_copies)->default_value(100), + "set number of image copies ")( + "layout", po::value(&layout), + " image layout like " + "8/16/32/8_8/8_8_8_8/16_16/16_16_16_16/32_32/32_32_32_32/10_10_10_2/" + "11_11_10/5_6_5/5_5_5_1/4_4_4_4/Y8/NV12/YUYV/VYUY/YVYU/UYVY/AYUV/YUAV/" + "P010/Y410/P012/Y16/P016/Y216/P216/P416")( + "flags", po::value(&flags), + "image program flags like READ/WRITE/CACHED/UNCACHED")( + "type", po::value(&type), + "Image type like 1D/2D/3D/1DARRAY/2DARRAY")( + "format", po::value(&format), + "image format like UINT/SINT/UNORM/SNORM/FLOAT")( + "data-validation", po::value(&data_validation), + "optional param for validating the copied image is correct or not")( + "json-output-file", po::value(&JsonFileName), + "test output format file name to be specified"); - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + std::cerr << desc << std::endl; + return 1; + } if (layout.size() != 0) Imagelayout = level_zero_tests::to_layout(layout); diff --git a/perf_tests/ze_image_copy/src/ze_image_copy.cpp b/perf_tests/ze_image_copy/src/ze_image_copy.cpp index 5e5e12b7..0699800d 100644 --- a/perf_tests/ze_image_copy/src/ze_image_copy.cpp +++ b/perf_tests/ze_image_copy/src/ze_image_copy.cpp @@ -493,9 +493,15 @@ void measure_bandwidth_Host2Device2Host(ZeImageCopy &Imagecopy, std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put( - "Name", "Host2Device2Host: Bandwidth copying from Host->Device->Host "); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put( + "Name", + "Host2Device2Host: Bandwidth copying from Host->Device->Host "); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device to host bw measurement: " + << e.what() << std::endl; + } } else { std::cout << "Host2Device2Host: Measuring Bandwidth for copying the " "image buffer size " @@ -506,9 +512,14 @@ void measure_bandwidth_Host2Device2Host(ZeImageCopy &Imagecopy, Imagecopy.measureHost2Device2Host(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device to host bw measurement: " + << e.what() << std::endl; + } } else { if (Imagecopy.data_validation) { std::cout << " Results: Data validation " @@ -523,8 +534,14 @@ void measure_bandwidth_Host2Device(ZeImageCopy &Imagecopy, ptree *test_ptree) { std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put("Name", "Host2Device: Bandwidth copying from Host->Device"); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put("Name", + "Host2Device: Bandwidth copying from Host->Device"); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device bw measurement: " + << e.what() << std::endl; + } } else { std::cout << "Host2Device: Measuring Bandwidth/Latency for copying the image " @@ -536,9 +553,14 @@ void measure_bandwidth_Host2Device(ZeImageCopy &Imagecopy, ptree *test_ptree) { Imagecopy.measureParallelHost2Device(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) { - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) { + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device bw measurement: " + << e.what() << std::endl; } } else { if (Imagecopy.data_validation) { @@ -555,8 +577,14 @@ void measure_bandwidth_Device2Host(ZeImageCopy &Imagecopy, ptree *test_ptree) { std::stringstream Image_dimensions; Image_dimensions << Imagecopy.width << "X" << Imagecopy.height << "X" << Imagecopy.depth; - test_ptree->put("Name", "Device2Host: Bandwidth copying from Device->Host"); - test_ptree->put("Image size", Image_dimensions.str()); + try { + test_ptree->put("Name", + "Device2Host: Bandwidth copying from Device->Host"); + test_ptree->put("Image size", Image_dimensions.str()); + } catch (const std::exception &e) { + std::cerr << "Error outputting device to host bw measurement: " + << e.what() << std::endl; + } } else { std::cout << "Device2Host: Measurign Bandwidth/Latency for copying the image " @@ -568,9 +596,14 @@ void measure_bandwidth_Device2Host(ZeImageCopy &Imagecopy, ptree *test_ptree) { Imagecopy.measureParallelDevice2Host(); if (Imagecopy.is_json_output_enabled()) { - test_ptree->put("GBPS", Imagecopy.gbps); - if (Imagecopy.data_validation) - test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("GBPS", Imagecopy.gbps); + if (Imagecopy.data_validation) + test_ptree->put("Result", (Imagecopy.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting device to host bw measurement: " + << e.what() << std::endl; + } } else { if (Imagecopy.data_validation) { std::cout << " Results: Data validation " @@ -593,12 +626,17 @@ void measure_bandwidth(ZeImageCopy &Imagecopy) { measure_bandwidth_Device2Host(Imagecopy, &ptree_Device2Host); if (Imagecopy.is_json_output_enabled()) { - Imagecopy.param_array.push_back(std::make_pair("", ptree_Host2Device2Host)); - Imagecopy.param_array.push_back(std::make_pair("", ptree_Host2Device)); - Imagecopy.param_array.push_back(std::make_pair("", ptree_Device2Host)); - ptree_main.put_child("Performance Benchmark.bandwidth", - Imagecopy.param_array); - pt::write_json(Imagecopy.JsonFileName.c_str(), ptree_main); + try { + Imagecopy.param_array.push_back( + std::make_pair("", ptree_Host2Device2Host)); + Imagecopy.param_array.push_back(std::make_pair("", ptree_Host2Device)); + Imagecopy.param_array.push_back(std::make_pair("", ptree_Device2Host)); + ptree_main.put_child("Performance Benchmark.bandwidth", + Imagecopy.param_array); + pt::write_json(Imagecopy.JsonFileName.c_str(), ptree_main); + } catch (const std::exception &e) { + std::cerr << "Error writing json output: " << e.what() << std::endl; + } } } @@ -608,11 +646,16 @@ void measure_latency_Host2Device(ZeImageCopyLatency &imageCopyLatency, std::stringstream Image_dimensions; Image_dimensions << imageCopyLatency.width << "X" << imageCopyLatency.height << "X" << imageCopyLatency.depth; - test_ptree->put("Name", - "Host2Device: Measuring Latency for copying the image "); - test_ptree->put("Image size", Image_dimensions.str()); - test_ptree->put("Image format", imageCopyLatency.Imageformat); - test_ptree->put("Image Layout", imageCopyLatency.Imagelayout); + try { + test_ptree->put("Name", + "Host2Device: Measuring Latency for copying the image "); + test_ptree->put("Image size", Image_dimensions.str()); + test_ptree->put("Image format", imageCopyLatency.Imageformat); + test_ptree->put("Image Layout", imageCopyLatency.Imagelayout); + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device latency measurement: " + << e.what() << std::endl; + } } else { std::cout << "Host2Device: Measuring Bandwidth/Latency for copying the image " @@ -628,10 +671,15 @@ void measure_latency_Host2Device(ZeImageCopyLatency &imageCopyLatency, imageCopyLatency.measureParallelHost2Device(); if (imageCopyLatency.is_json_output_enabled()) { - test_ptree->put("Latency", imageCopyLatency.latency); - if (imageCopyLatency.data_validation) - test_ptree->put("Result", - (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("Latency", imageCopyLatency.latency); + if (imageCopyLatency.data_validation) + test_ptree->put("Result", + (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting host to device latency measurement: " + << e.what() << std::endl; + } } } @@ -641,11 +689,16 @@ void measure_latency_Device2Host(ZeImageCopyLatency &imageCopyLatency, std::stringstream Image_dimensions; Image_dimensions << imageCopyLatency.width << "X" << imageCopyLatency.height << "X" << imageCopyLatency.depth; - test_ptree->put("Name", - "Device2Host: Measuring Latency for copying the image"); - test_ptree->put("Image size", Image_dimensions.str()); - test_ptree->put("Image format", imageCopyLatency.Imageformat); - test_ptree->put("Image Layout", imageCopyLatency.Imagelayout); + try { + test_ptree->put("Name", + "Device2Host: Measuring Latency for copying the image"); + test_ptree->put("Image size", Image_dimensions.str()); + test_ptree->put("Image format", imageCopyLatency.Imageformat); + test_ptree->put("Image Layout", imageCopyLatency.Imagelayout); + } catch (const std::exception &e) { + std::cerr << "Error outputting device to host latency measurement: " + << e.what() << std::endl; + } } else { std::cout << "Device2Host: Measuring Bandwidth/Latency for copying the image " @@ -661,10 +714,15 @@ void measure_latency_Device2Host(ZeImageCopyLatency &imageCopyLatency, imageCopyLatency.measureParallelDevice2Host(); if (imageCopyLatency.is_json_output_enabled()) { - test_ptree->put("Latency", imageCopyLatency.latency); - if (imageCopyLatency.data_validation) - test_ptree->put("Result", - (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + try { + test_ptree->put("Latency", imageCopyLatency.latency); + if (imageCopyLatency.data_validation) + test_ptree->put("Result", + (imageCopyLatency.validRet ? "PASSED" : "FAILED")); + } catch (const std::exception &e) { + std::cerr << "Error outputting device to host latency measurement: " + << e.what() << std::endl; + } } } @@ -676,7 +734,11 @@ void measure_latency(ZeImageCopyLatency &imageCopyLatency) { ptree ptree_param_array; if (imageCopyLatency.is_json_output_enabled()) { - pt::read_json(imageCopyLatency.JsonFileName, ptree_main); + try { + pt::read_json(imageCopyLatency.JsonFileName, ptree_main); + } catch (const std::exception &e) { + std::cerr << "Error reading json file: " << e.what() << std::endl; + } } measure_latency_Host2Device(imageCopyLatency, &ptree_Host2Device); measure_latency_Device2Host(imageCopyLatency, &ptree_Device2Host); @@ -684,8 +746,12 @@ void measure_latency(ZeImageCopyLatency &imageCopyLatency) { if (imageCopyLatency.is_json_output_enabled()) { ptree_param_array.push_back(std::make_pair("", ptree_Host2Device)); ptree_param_array.push_back(std::make_pair("", ptree_Device2Host)); - ptree_main.put_child("Performance Benchmark.latency", ptree_param_array); - pt::write_json(imageCopyLatency.JsonFileName.c_str(), ptree_main); + try { + ptree_main.put_child("Performance Benchmark.latency", ptree_param_array); + pt::write_json(imageCopyLatency.JsonFileName.c_str(), ptree_main); + } catch (const std::exception &e) { + std::cerr << "Error writing json output: " << e.what() << std::endl; + } } } diff --git a/perf_tests/ze_peer/src/ze_peer.cpp b/perf_tests/ze_peer/src/ze_peer.cpp index 75520493..36095412 100644 --- a/perf_tests/ze_peer/src/ze_peer.cpp +++ b/perf_tests/ze_peer/src/ze_peer.cpp @@ -103,7 +103,7 @@ void run_ipc_test(int size_to_run, uint32_t remote_device_id, if (pid == 0) { pid_t test_pid = fork(); if (test_pid == 0) { - ZePeer peer(local_device_ids, remote_device_ids, pair_device_ids, + ZePeer peer(remote_device_ids, local_device_ids, pair_device_ids, queues); if (ZePeer::validate_results) { peer.warm_up_iterations = 0; diff --git a/utils/image/src/bmp.cpp b/utils/image/src/bmp.cpp index d8ceddaa..5d2a31cd 100644 --- a/utils/image/src/bmp.cpp +++ b/utils/image/src/bmp.cpp @@ -218,7 +218,10 @@ bool BmpUtils::load_bmp_image(uint8_t *&data, int &width, int &height, } gap = file_header.bf_off_bits_ - sizeof(file_header) - sizeof(info_header); - fseek(stream, gap, SEEK_CUR); + if (fseek(stream, gap, SEEK_CUR)) { + LOG_ERROR << "Failed to seek in BMP file"; + goto error_exit; + } width = info_header.bi_width_; height = info_header.bi_height_ > 0 ? info_header.bi_height_ diff --git a/utils/logging/src/logging.cpp b/utils/logging/src/logging.cpp index a6523e48..3bbfabb9 100644 --- a/utils/logging/src/logging.cpp +++ b/utils/logging/src/logging.cpp @@ -111,16 +111,20 @@ LoggingSettings parse_command_line(std::vector &command_line) { po::value(&settings.level)->default_value(logging_level::info), "minimal logging level to print"); - po::parsed_options parsed = po::command_line_parser(command_line) - .options(desc) - .allow_unregistered() - .run(); - po::variables_map vm; - po::store(parsed, vm); - po::notify(vm); - - command_line = - po::collect_unrecognized(parsed.options, po::include_positional); + try { + po::parsed_options parsed = po::command_line_parser(command_line) + .options(desc) + .allow_unregistered() + .run(); + po::variables_map vm; + po::store(parsed, vm); + po::notify(vm); + + command_line = + po::collect_unrecognized(parsed.options, po::include_positional); + } catch (const po::error &e) { + std::cerr << "Error parsing command line: " << e.what() << std::endl; + } return settings; } diff --git a/utils/test_harness/src/test_harness_cmdlist.cpp b/utils/test_harness/src/test_harness_cmdlist.cpp index 41b24fef..9e53a167 100644 --- a/utils/test_harness/src/test_harness_cmdlist.cpp +++ b/utils/test_harness/src/test_harness_cmdlist.cpp @@ -393,15 +393,17 @@ void append_launch_function(ze_command_list_handle_t hCommandList, auto function_initial = hFunction; auto signal_event_initial = hSignalEvent; std::vector wait_events_initial(numWaitEvents); - std::memcpy(wait_events_initial.data(), phWaitEvents, - sizeof(ze_event_handle_t) * numWaitEvents); + if (phWaitEvents) { + std::memcpy(wait_events_initial.data(), phWaitEvents, + sizeof(ze_event_handle_t) * numWaitEvents); + } EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListAppendLaunchKernel( hCommandList, hFunction, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents)); EXPECT_EQ(hCommandList, command_list_initial); EXPECT_EQ(hFunction, function_initial); EXPECT_EQ(hSignalEvent, signal_event_initial); - for (int i = 0; i < numWaitEvents; i++) { + for (int i = 0; i < numWaitEvents && phWaitEvents; i++) { EXPECT_EQ(phWaitEvents[i], wait_events_initial[i]); } }