SYCLomatic icon indicating copy to clipboard operation
SYCLomatic copied to clipboard

Use `sycl::bfloat16` class and functions instead of float casts.

Open JackAKirk opened this issue 1 year ago • 9 comments

The bfloat16 class has been non-experimental for a while now, supporting all backends: https://github.com/oneapi-src/SYCLomatic/pull/1286 However SYCLomatic appears to be not be using this, and instead just always casting to float, see e.g.https://github.com/oneapi-src/SYCLomatic/pull/1286. This seems to be a lost opportunity. For example there are native cuda bfloat16 implementations of bfloat16 math functions in DPC++ that make bfloat16 math much faster than using casts to float.

JackAKirk avatar Oct 04 '23 17:10 JackAKirk

Same here: https://github.com/oneapi-src/SYCLomatic/pull/1181/files

JackAKirk avatar Oct 04 '23 17:10 JackAKirk

@JackAKirk the reference PR #1286 for sentence "The bfloat16 class has been non-experimental for a while now, supporting all backends" is incorrect, could you provide the correct PR? So that we can double confirm that bfloat16 class has been non-experimental. Thanks.

tomflinda avatar Oct 09 '23 02:10 tomflinda

@JackAKirk the reference PR #1286 for sentence "The bfloat16 class has been non-experimental for a while now, supporting all backends" is incorrect, could you provide the correct PR? So that we can double confirm that bfloat16 class has been non-experimental. Thanks.

Sorry I meant this one: https://github.com/intel/llvm/pull/6524

Note actually that I forgot bfloat16 math functions are still in the experimental namespace https://github.com/intel/llvm/pull/7567 However these bfloat16 math functions have generic support for all backends, at least via float emulation. So it might be appropriate to move them out of experimental to match the bfloat16 class. @rdeodhar what do you think?

JackAKirk avatar Oct 09 '23 08:10 JackAKirk

I think it would be OK to move the math functions out of experimental. @gmlueck do you have an opinion?

rdeodhar avatar Oct 09 '23 17:10 rdeodhar

I think this could be OK. I'd like to consider merging the math functions into the base extension for bfloat16, though, rather than having two separate extensions.

gmlueck avatar Oct 09 '23 17:10 gmlueck

I think this could be OK. I'd like to consider merging the math functions into the base extension for bfloat16, though, rather than having two separate extensions.

Sounds good to me. I'd be happy to draft a PR merging the two extensions.

JackAKirk avatar Oct 09 '23 18:10 JackAKirk

@gmlueck @JackAKirk So, after the bfloat16 math functions are merged into base extension, we will plan to refine the migration logic in SYCLomatic, pls remind us after your PR is merged.

tomflinda avatar Oct 10 '23 01:10 tomflinda

@gmlueck @JackAKirk So, after the bfloat16 math functions are merged into base extension, we will plan to refine the migration logic in SYCLomatic, pls remind us after your PR is merged.

PR is here: https://github.com/intel/llvm/pull/11506

JackAKirk avatar Oct 13 '23 08:10 JackAKirk

Hi, @JackAKirk. The PR (https://github.com/intel/llvm/pull/11506) is in draft status for about one year, so we need wait. By the way, you can migrate bf16 math function by using --use-experimental-features=bfloat16_math_functions. We have already support migration bf16 math function to sycl::ext::oneapi::experimental math funtion.

tangjj11 avatar Sep 23 '24 07:09 tangjj11