dpctl icon indicating copy to clipboard operation
dpctl copied to clipboard

Use experimental complex extension for all complex arithmetic

Open ndgrigorian opened this issue 10 months ago • 4 comments

With current nightly compiler, dpctl will fail to link when built for HIP backend due to undefined symbols (i.e., __muldc3).

Since compiler does not support arithmetic with std::complex on HIP backend, this PR takes the steps to refactor complex arithmetic throughout tensor library

  • libtensor/include/kernels/elementwise_functions/sycl_complex.hpp is now moved to libtensor/include/utils/sycl_complex.hpp and refactored to defined sycl_complex_t<T>, aliasing the complex type defined in the extension
  • sycl_complex.hpp still indirectly sets SYCL_EXT_ONEAPI_COMPLEX and includes the header for experimental extension, but no longer defines exprm_ns namespace alias. This is now left to individual files.
  • All uses of std::real, std::imag, etc. have been removed
  • sycl_utils.hpp now defines new custom functors a la Maximum and Minimum, Plus and Multiplies. These structs are used by accumulation operations (sum, cumulative_sum, GEMM, etc.). They perform casting of std::complex inputs to SYCL equivalent, perform operations, and then return as std::complex
  • Several element-wise functions are updated to properly perform operations in SYCL complex type
  • [ ] 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?
  • [ ] If this PR is a work in progress, are you opening the PR as a draft?

ndgrigorian avatar May 01 '25 01:05 ndgrigorian

View rendered docs @ https://intelpython.github.io/dpctl/pulls/2069/index.html

github-actions[bot] avatar May 01 '25 01:05 github-actions[bot]

Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_183 ran successfully. Passed: 1108 Failed: 4 Skipped: 119

github-actions[bot] avatar May 01 '25 02:05 github-actions[bot]

Array API standard conformance tests for dpctl=0.20.0dev0=py310h93fe807_183 ran successfully. Passed: 1109 Failed: 3 Skipped: 119

github-actions[bot] avatar May 01 '25 03:05 github-actions[bot]

Coverage Status

coverage: 86.419%. remained the same when pulling 52bb73e7704d3b73e401b482ee429e4c013a4c54 on use-sycl-complex-conversions into 29eeac75eefbc6cc617a985c3ba384142a9af27a on master.

coveralls avatar May 01 '25 03:05 coveralls