Skip to content

Commit

Permalink
libclc/r600: Use target specific builtins to implement rsqrt and nati…
Browse files Browse the repository at this point in the history
…ve_rsqrt

Fixes OCL CTS rsqrt and half_rsqrt (1 thread, scalaer) tests on AMD Turks.

Reviewer: awatry
Differential Revision: https://reviews.llvm.org/D74016
  • Loading branch information
jvesely committed Feb 9, 2020
1 parent 4b23a2e commit 85e2fa4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libclc/r600/lib/SOURCES
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
math/fmax.cl
math/fmin.cl
math/native_rsqrt.cl
math/rsqrt.cl
synchronization/barrier.cl
workitem/get_global_offset.cl
workitem/get_group_id.cl
Expand Down
10 changes: 10 additions & 0 deletions libclc/r600/lib/math/native_rsqrt.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <clc/clc.h>

#include "../../../generic/lib/clcmacro.h"

_CLC_OVERLOAD _CLC_DEF float native_rsqrt(float x)
{
return __builtin_r600_recipsqrt_ieeef(x);
}

_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, native_rsqrt, float);
23 changes: 23 additions & 0 deletions libclc/r600/lib/math/rsqrt.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <clc/clc.h>

#include "../../../generic/lib/clcmacro.h"

_CLC_OVERLOAD _CLC_DEF float rsqrt(float x)
{
return __builtin_r600_recipsqrt_ieeef(x);
}

_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, rsqrt, float);

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_OVERLOAD _CLC_DEF double rsqrt(double x)
{
return __builtin_r600_recipsqrt_ieee(x);
}

_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, rsqrt, double);

#endif

0 comments on commit 85e2fa4

Please sign in to comment.