Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit ad174cf

Browse files
authored
[SYCL][ESIMD] Move rounding functions out of experimental namespace (#914)
Also add tests for esimd::floor() and esimd::ceil() fuctions. Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent 6cfcd72 commit ad174cf

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

SYCL/ESIMD/ext_math.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ enum class MathOp {
9595
inv,
9696
log,
9797
rsqrt,
98+
floor,
99+
ceil,
98100
trunc,
99101
exp2,
100102
log2,
@@ -130,6 +132,8 @@ DEFINE_HOST_OP(inv, 1.0f / X);
130132
DEFINE_HOST_OP(sqrt, std::sqrt(X));
131133
DEFINE_HOST_OP(sqrt_ieee, std::sqrt(X));
132134
DEFINE_HOST_OP(rsqrt, 1.0f / std::sqrt(X));
135+
DEFINE_HOST_OP(floor, std::floor(X));
136+
DEFINE_HOST_OP(ceil, std::ceil(X));
133137
DEFINE_HOST_OP(trunc, std::trunc(X));
134138
DEFINE_HOST_OP(exp2, std::exp2(X));
135139
DEFINE_HOST_OP(log2, std::log2(X));
@@ -146,7 +150,7 @@ DEFINE_HOST_BIN_OP(pow, std::pow(X, Y));
146150

147151
#define DEFINE_ESIMD_DEVICE_OP(Op) \
148152
template <class T, int N> struct ESIMDf<T, N, MathOp::Op, AllVec> { \
149-
simd<T, N> operator()(simd<T, N>X) const SYCL_ESIMD_FUNCTION { \
153+
simd<T, N> operator()(simd<T, N> X) const SYCL_ESIMD_FUNCTION { \
150154
return esimd::Op<T, N>(X); \
151155
} \
152156
}; \
@@ -155,17 +159,6 @@ DEFINE_HOST_BIN_OP(pow, std::pow(X, Y));
155159
return esimd::Op<T, N>(X); \
156160
} \
157161
};
158-
#define DEFINE_EXP_ESIMD_DEVICE_OP(Op) \
159-
template <class T, int N> struct ESIMDf<T, N, MathOp::Op, AllVec> { \
160-
simd<T, N> operator()(simd<T, N> X) const SYCL_ESIMD_FUNCTION { \
161-
return experimental::esimd::Op<T, N>(X); \
162-
} \
163-
}; \
164-
template <class T, int N> struct ESIMDf<T, N, MathOp::Op, AllSca> { \
165-
simd<T, N> operator()(T X) const SYCL_ESIMD_FUNCTION { \
166-
return experimental::esimd::Op<T, N>(X); \
167-
} \
168-
};
169162

170163
DEFINE_ESIMD_DEVICE_OP(sin);
171164
DEFINE_ESIMD_DEVICE_OP(cos);
@@ -175,7 +168,9 @@ DEFINE_ESIMD_DEVICE_OP(inv);
175168
DEFINE_ESIMD_DEVICE_OP(sqrt);
176169
DEFINE_ESIMD_DEVICE_OP(sqrt_ieee);
177170
DEFINE_ESIMD_DEVICE_OP(rsqrt);
178-
DEFINE_EXP_ESIMD_DEVICE_OP(trunc);
171+
DEFINE_ESIMD_DEVICE_OP(floor);
172+
DEFINE_ESIMD_DEVICE_OP(ceil);
173+
DEFINE_ESIMD_DEVICE_OP(trunc);
179174
DEFINE_ESIMD_DEVICE_OP(exp2);
180175
DEFINE_ESIMD_DEVICE_OP(log2);
181176

@@ -416,6 +411,8 @@ template <class T, int N> bool testESIMD(queue &Q) {
416411
Pass &= test<T, N, MathOp::log, ESIMDf>(Q, "log", InitWide<T>{});
417412
Pass &= test<T, N, MathOp::exp2, ESIMDf>(Q, "exp2", InitInRange0_5<T>{});
418413
Pass &= test<T, N, MathOp::log2, ESIMDf>(Q, "log2", InitWide<T>{});
414+
Pass &= test<T, N, MathOp::floor, ESIMDf>(Q, "floor", InitWide<T>{});
415+
Pass &= test<T, N, MathOp::ceil, ESIMDf>(Q, "ceil", InitWide<T>{});
419416
Pass &= test<T, N, MathOp::trunc, ESIMDf>(Q, "trunc", InitWide<T>{});
420417
return Pass;
421418
}

0 commit comments

Comments
 (0)