diff --git a/CHANGELOG.md b/CHANGELOG.md index 6332eb14ee0..44189734455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ This release drops support for Python 3.10, making Python 3.11 the minimum requi * Fixed the example of handling duplicate indices in the `dpnp.tensor.put` docstring, which imported `dpctl.tensor`, did not parse and lost writes when `x` is longer than `indices` [#3165](https://github.com/IntelPython/dpnp/pull/3165) * Fixed a segfault when setting `writable` on a `Flags` object created without an array [#3168](https://github.com/IntelPython/dpnp/pull/3168) * Fixed a crash of the OpenCL CPU compiler in `dpnp.sort`, `dpnp.argsort`, `dpnp.tensor.sort` and `dpnp.tensor.argsort` by radix sort of rows of 2049 to 16384 elements [#3191](https://github.com/IntelPython/dpnp/pull/3191) +* Fixed a random segfault of the OpenCL CPU runtime in coverage builds by instrumenting only host code [#3193](https://github.com/IntelPython/dpnp/pull/3193) ### Security diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e45698b116..a07f6a38c03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -375,10 +375,12 @@ mark_as_advanced( ) if(DPNP_GENERATE_COVERAGE) + # Host only: device counters become device globals in every kernel image of + # their module, which crash the OpenCL CPU runtime, and never reach the profile 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 6097cd57e4d..b3418ee66f4 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 d79115eddf5..ad06120e267 100644 --- a/dpnp/libtensor/source/CMakeLists.txt +++ b/dpnp/libtensor/source/CMakeLists.txt @@ -346,9 +346,12 @@ foreach(_src_fn ${_dpnp_sources}) "${_clang_prefix}-fno-finite-math-only" ) 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 ) @@ -413,7 +416,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(