KhronosGroup / KhronosGroup/OpenCL-Docs

Clarification around returning -0.0 from certain builtins

Open
#1,304 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

I was wondering if the specification could clarify whenever it says `returns 0.0` whether this means strictly `+0.0` or whether `-0.0` is possible?

This appears to apply to the `sign`, `step` and `smoothstep` builtins but admittedly I only really have `sign` in mind. A more efficient implementation of `sign` may be possible in some cases if the sign was able to be copied directly from `x`, in which case negative NaNs would produce `-0.0`.

My interpretation of `sign` would be that it returns `+0.0` but since the documentation goes out of its way to specify a return value of `+0.0` and `-0.0` when `x` is either of those values, leaving in `0.0` without an explicit sign as an option could be misinterpreted.

The OpenCL-CTS currently passes for an implementation of `sign` that returns `-0.0` for `-NaN`. I don't know if those specific input values are being tested, but either way, if `-0.0` is not intended then it is currently being allowed by omission.

Contributor guide

Open the contributing guide

Research direction

Review the OpenCL specification wording for the sign, step, and smoothstep builtins, then compare it with the OpenCL-CTS behavior described in the issue. The clarification is complete when the specification explicitly states whether an unspecified `0.0` may be `-0.0`, consistently covering the cited inputs and builtins.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.