Repository navigation
Align the build flags of all SYCL modules with dpnp.tensor - #3198
ndgrigorian wants to merge 3 commits into
Conversation
The directory flags of dpnp/tensor and libtensor/source (no global -fsycl, lld, -Wno-unused-parameter, Debug -g with device -g0) move to the top-level CMakeLists.txt, and every pybind11 module, including those of libtensor/source, is built by build_dpnp_pybind11_ext. It compiles the whole module with -fno-fast-math and adds the hardening linker flags and DPNP_TENSOR_OFFLOAD_COMPRESS, which the extensions lacked. Device-only flags go only to SYCL targets, and coverage builds pass -g1 to the host only, so neither warns.
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3198/index.html |
libmkl_sycl_* don't record their dependency on the oneMKL interface, threading and core libraries. With lld, the --as-needed of the conda LDFLAGS dropped them from the oneMKL modules, so importing dpnp failed with an undefined fftw3_mkl. Link the MKL::MKL_SYCL domain targets with --no-as-needed.
|
Array API standard conformance tests for dpnp=0.22.0dev3=np2py314h8d9cdd5_134 ran successfully. |
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
Everything passes, results match the base apart from a sinc fix, and the benchmarks show no slowdown on any device.
Two small comments below:
| * Improved performance of `dpnp.top_k` and `dpnp.tensor.top_k` on a GPU for batches of rows of 65536 to about 10^6 elements that occupy it with a work-group per row [#3138](https://github.com/IntelPython/dpnp/pull/3138) | ||
| * Reimplemented `dpnp.random.RandomState` and the `dpnp.random` functions on device kernels, drawing on the queue of the generator. `device`, `usm_type` and `sycl_queue` are now keyword-only, `usm_type` defaults to the USM type of the array parameters, `randint(dtype=int)` returns `int64` and `shuffle` requires a `dpnp.ndarray` or `usm_ndarray` [#3162](https://github.com/IntelPython/dpnp/pull/3162) | ||
| * Moved the vendored CMake modules of `IntelSYCL`, `MKL`, `TBB` and `oneDPL` from `dpnp/backend/cmake/Modules` to `cmake/Modules` [#3163](https://github.com/IntelPython/dpnp/pull/3163) | ||
| * Aligned the build flags of all dpnp SYCL modules with those of `dpnp.tensor`, so the dpnp kernels and the oneMKL extensions are compiled with `-fno-fast-math` and the extensions get the hardening linker flags and `DPNP_TENSOR_OFFLOAD_COMPRESS` [#3198](https://github.com/IntelPython/dpnp/pull/3198) |
There was a problem hiding this comment.
This change also fixes dpnp.sinc for subnormal float32 on a GPU: with the old fast-math flags it returned inf.
import numpy, dpnp
x = numpy.array([1e-40], dtype=numpy.float32)
print(dpnp.sinc(dpnp.asarray(x))) # GPU: [inf] before this PR, [1.] now; numpy: [1.]Could the entry mention it, and a test in TestSinc keep it fixed?
| foreach( | ||
| python_module_name | ||
| _tensor_impl | ||
| _tensor_accumulation_impl | ||
| _tensor_elementwise_impl | ||
| _tensor_reductions_impl | ||
| _tensor_sorting_impl | ||
| _tensor_linalg_impl | ||
| ) | ||
| target_link_libraries(${python_module_name} PRIVATE ${_static_lib_trgt}) | ||
| endforeach() |
There was a problem hiding this comment.
Nit: This loop repeats six of the eight module names only to link simplify_iteration_space. A module missing here still links and fails only at import (undefined symbol). Linking it in the loop above for every module keeps one list: _statistics_impl and _window_impl relinked with it come out byte-identical.
This PR aligns the compiler and linker flags of all dpnp SYCL modules with those
dpnp.tensorinherited from dpctl. It is stacked on #3163: withdpnp_backend_cremoved, every SYCL target is a pybind11 module indpnp/libtensor.Until now, only
dpnp/tensoranddpnp/libtensor/sourceincludedtensor_build_flags.cmake, and the oneMKL extensions used a separate set of options:-fsycl, lld,-Wno-unused-parameter, Debug-gwith device-g0) move to the top-levelCMakeLists.txt, so every target gets them.tensor_build_flags.cmakekeeps only the coverage strip of the tensor directories; coverage is otherwise unchanged and doesn't overlap Instrument only host code in the coverage build #3193.libtensor/sourceincluded, is now built bybuild_dpnp_pybind11_ext. It compiles the whole module with-fno-fast-mathinstead of-fno-approx-func -fno-finite-math-only, and adds the hardeningDPNP_LDFLAGSandDPNP_TENSOR_OFFLOAD_COMPRESS, which the extensions lacked.-fno-fast-mathon the whole module, not on a list of sources as in dpctl: the sources left out of that list have no floating-point math worth relaxing. Both groups of sources of a libtensor module now share the floating-point flags, so an inline function both instantiate no longer depends on which copy the linker keeps. The dpnp kernels (sinc,i0,interpolate, the statistics functions, ...) and the extensions now keep signed zeros and don't reassociate.The flags also caused compiler warnings in Debug and Coverage builds, which are fixed:
-Xsycl-target-frontend=spir64 -g0was unused for the Cython modules and thesimplify_iteration_spacestatic library, which no longer get-fsycl; it now goes only to the SYCL modules.-g1was ignored forspir64in every SYCL source of a coverage build (also on master);CMAKE_CXX_FLAGS_COVERAGEpasses it to the host only.-fno-sycl-use-footerwas unused for the static library, which now takes the plain coverage flags.Checked locally:
The Release build (234 compiles) has no compiler warnings.
18 test modules (elementwise, statistics, histogram, linalg, fft, random, sort, window, ...) pass on a Level Zero GPU: 53577 passed, 230 skipped. They were not run on a CPU device, and performance was not measured.
Have you provided a meaningful PR description?
Have you added a test, reproducer or referred to an issue with a reproducer?
Have you tested your changes locally for CPU and GPU devices?
Have you made sure that new changes do not introduce compiler warnings?
Have you checked performance impact of proposed changes?
Have you added documentation for your changes, if necessary?
Have you added your changes to the changelog?