diff --git a/CHANGELOG.md b/CHANGELOG.md index 08ddc567b3f3..7ceb1d52d8e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ This release drops support for Python 3.10, making Python 3.11 the minimum requi * Fixed a segfault in `dpnp.from_dlpack` and `dpnp.tensor.from_dlpack` when importing a DLPack tensor on a oneAPI device with NULL strides, which DLPack before 1.2 allows for a C-contiguous tensor [#3183](https://github.com/IntelPython/dpnp/pull/3183) * Fixed `ValueError` in `dpnp.from_dlpack` and `dpnp.tensor.from_dlpack` when copying a 0-d or non-C-contiguous host array to a SYCL device, unless its items are one byte [#3207](https://github.com/IntelPython/dpnp/pull/3207) * Fixed wrong values from `dpnp.from_dlpack` and `dpnp.tensor.from_dlpack` when copying a `float64` or `complex128` host array to a SYCL device without fp64 support, which copied its bytes unchanged into the `float32` or `complex64` result [#3209](https://github.com/IntelPython/dpnp/pull/3209) +* Fixed a random segfault of the OpenCL CPU runtime in coverage builds, and their link failure with `DPNP_TENSOR_GENERATE_COVERAGE_FOR_PYBIND11_EXTENSIONS=ON`, by instrumenting only host code [#3193](https://github.com/IntelPython/dpnp/pull/3193) ### Security diff --git a/CMakeLists.txt b/CMakeLists.txt index b100cc1163c7..31382c6d29aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -375,10 +375,13 @@ mark_as_advanced( ) if(DPNP_GENERATE_COVERAGE) + # Host only: device counters become device globals in every kernel image of + # their module and crash the OpenCL CPU runtime. Their counts are lost anyway: + # libsycl, loaded by dpctl first, never binds __sycl_increment_profile_counters string( CONCAT PROFILE_FLAGS - "-fprofile-instr-generate " - "-fcoverage-mapping " + "-Xarch_host -fprofile-instr-generate " + "-Xarch_host -fcoverage-mapping " "-fno-sycl-use-footer " # "-save-temps=obj " ) diff --git a/dpnp/cmake/tensor_build_flags.cmake b/dpnp/cmake/tensor_build_flags.cmake index 6097cd57e4d1..b3418ee66f42 100644 --- a/dpnp/cmake/tensor_build_flags.cmake +++ b/dpnp/cmake/tensor_build_flags.cmake @@ -45,9 +45,7 @@ endif() # Remove global coverage flags for tensor # use link-time only approach like dpctl if(DPNP_GENERATE_COVERAGE) - string(REPLACE "-fprofile-instr-generate " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "-fcoverage-mapping " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "-fno-sycl-use-footer " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "${PROFILE_FLAGS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() # Tensor-specific debug flags diff --git a/dpnp/libtensor/source/CMakeLists.txt b/dpnp/libtensor/source/CMakeLists.txt index 7cb3a19e2bb2..5de4586a7de8 100644 --- a/dpnp/libtensor/source/CMakeLists.txt +++ b/dpnp/libtensor/source/CMakeLists.txt @@ -344,8 +344,6 @@ endforeach() # An inline function with FP math that both instantiate gets the flags of the # copy the linker keeps (the dpnp one, see above), so keep such helpers out of # shared headers or give them the same flags in both groups. -# dpnp sources of the modules with the libtensor radix select kernels -set(_dpnp_radix_select_sources ${_dpnp_sorting_sources} ${_statistics_impl_sources}) foreach(_src_fn ${_dpnp_sources}) get_source_file_property(_cmpl_options_prop ${_src_fn} COMPILE_OPTIONS) set(_combined_options_prop @@ -353,10 +351,13 @@ foreach(_src_fn ${_dpnp_sources}) "${_clang_prefix}-fno-approx-func" "${_clang_prefix}-fno-finite-math-only" ) - if(DPNP_GENERATE_COVERAGE AND NOT _src_fn IN_LIST _dpnp_radix_select_sources) + if(DPNP_GENERATE_COVERAGE) + # host only, as PROFILE_FLAGS in the top-level CMakeLists.txt list( APPEND _combined_options_prop + -Xarch_host -fprofile-instr-generate + -Xarch_host -fcoverage-mapping -fno-sycl-use-footer ) @@ -370,16 +371,11 @@ endforeach() if(DPNP_GENERATE_COVERAGE) # libtensor code the dpnp functions use, measured like the dpnp sources. # Host only: their device coverage records break sycl-link - # (a source property, unlike target options, keeps the repeated -Xarch_host). - # The radix select modules are host only too: every kernel image of a module - # gets all its device counters as device globals, and their init events - # crash the OpenCL CPU runtime at random in the kernel bundle launches. - # The device counts never reach the profile anyway + # (a source property keeps the repeated -Xarch_host; target options need SHELL:) set_property( SOURCE ${_static_lib_sources} ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/elementwise_functions_type_utils.cpp - ${_dpnp_radix_select_sources} APPEND PROPERTY COMPILE_OPTIONS @@ -426,7 +422,9 @@ foreach(python_module_name ${_py_trgts}) if(DPNP_TENSOR_GENERATE_COVERAGE_FOR_PYBIND11_EXTENSIONS) target_compile_options( ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping + PRIVATE + "SHELL:-Xarch_host -fprofile-instr-generate" + "SHELL:-Xarch_host -fcoverage-mapping" ) endif() target_link_options(