einpoklum
einpoklum

Reputation: 131666

Is there a CUDA equivalent of native_recip() in OpenCL?

OpenCL has a built-in function named native_recip:

gentype native_recip(gentype x);

native_recip computes reciprocal over an implementation-defined range. The maximum error is implementation-defined.

The vector versions of the math functions operate component-wise. The description is per-component.

The built-in math functions are not affected by the prevailing rounding mode in the calling environment, and always return the same value as they would if called with the round to nearest even rounding mode.

Is there an equivalent to this function in CUDA?

Upvotes: 2

Views: 272

Answers (1)

einpoklum
einpoklum

Reputation: 131666

As noted in comments, it's __frcp_rn() for float's and __drcp_rn() for double's; and an implementation for vector types (e.g. float4) such that frcp/drcp is applied elementwise.

Note: "rcp" is short for "reciprocal" and "rn" is for the rounding mode "round to nearest even".

Upvotes: 2

Related Questions