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

[ESIMD] Add tests for esimd::exp2 and esimd::log2 functions #673

Merged
merged 3 commits into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions SYCL/ESIMD/ext_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
//===----------------------------------------------------------------------===//
// REQUIRES: gpu
// UNSUPPORTED: cuda || hip
// TODO the test started failing on Linux apprently due to host-side changes in
// code generation for log/exp, as device code remained the same as earlier,
// when the test passed.
// XFAIL: linux
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

Expand Down Expand Up @@ -58,7 +54,7 @@ struct InitDataInRange0_5 {

// --- Math operation identification

enum class MathOp { sin, cos, exp, sqrt, inv, log, rsqrt, trunc };
enum class MathOp { sin, cos, exp, sqrt, inv, log, rsqrt, trunc, exp2, log2 };

// --- Template functions calculating given math operation on host and device

Expand Down Expand Up @@ -95,14 +91,16 @@ template <MathOp Op> float HostMathFunc(float X);
} \
}

DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(sin, sin);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(cos, cos);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(exp, exp);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(log, log);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(sin, std::sin);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(cos, std::cos);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(exp, std::exp);
DEFINE_SIMD_OVERLOADED_STD_SYCL_OP(log, std::log);
DEFINE_ESIMD_OP(inv, 1.0f /);
DEFINE_ESIMD_OP(sqrt, sqrt);
DEFINE_ESIMD_OP(rsqrt, 1.0f / sqrt);
DEFINE_ESIMD_RT_OP(trunc, trunc);
DEFINE_ESIMD_OP(sqrt, std::sqrt);
DEFINE_ESIMD_OP(rsqrt, 1.0f / std::sqrt);
DEFINE_ESIMD_OP(exp2, std::exp2);
DEFINE_ESIMD_OP(log2, std::log2);
DEFINE_ESIMD_RT_OP(trunc, std::trunc);

// --- Generic kernel calculating an extended math operation on array elements

Expand Down Expand Up @@ -199,6 +197,8 @@ template <int VL> bool test(queue &Q) {
Pass &= test<MathOp::exp, VL>(Q, "exp", InitDataInRange0_5{});
Pass &= test<MathOp::log, VL>(Q, "log", InitDataFuncWide{});
Pass &= test<MathOp::trunc, VL>(Q, "trunc", InitDataFuncWide{});
Pass &= test<MathOp::exp2, VL>(Q, "exp2", InitDataFuncWide{});
Pass &= test<MathOp::log2, VL>(Q, "log2", InitDataFuncWide{});
return Pass;
}

Expand Down