Skip to content

OpenCL behavior when re-defining builtin math functions #152

Open
@preda

Description

@preda

Consider the following example, which implements a complex multiply-add function named "mad" with a signature that clashes with the
builtin OpenCL math function mad(gentype, gentype, gentype)
(where gentype includes double2).

__attribute__((overloadable)) double2 mad(double2 a, double2 b, double2 c) {
  return (double2) (fma(a.x, b.x, fma(a.y, -b.y, c.x)), fma(a.x, b.y, fma(a.y, b.x, c.y)));
}

kernel void testKernel(global double2* out, global double2* in) {
  uint me = get_local_id(0);

  double2 a = in[3*me];
  double2 b = in[3*me + 1];
  double2 c = in[3*me + 2];
  out[me] = mad(a, b, c);
}

This example is compiled very differently by ROCm 6.1.3 and ROCm 6.2.0.
In both case it is accepted without errors or warnings.
The resulting compilation is:
With ROCm 6.1.3, the user-defined mad() is used,
with ROCm 6.2.0, the built-in mad() is used.

In particular the 6.2.0 behavior, where the user defined function is accepted without errors and silently ignored afterwards, is not acceptable IMO and represents a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Under Investigationdevice-libsRelated to Device LibrariesgenericBuild error, or some other issue not caused by an LLVM bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions