This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
Tests for sycl_ext_intel_math_inv #1571
Open
jinge90
wants to merge
9
commits into
intel:intel
Choose a base branch
from
jinge90:test_imf_inv
base: intel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
efa0c49
Add test for sycl::ext::intel::math::inv
jinge90 ac0a1f5
Merge remote-tracking branch 'origin/intel' into test_imf_inv
jinge90 79ba9ac
Add tests for sycl_ext_intel_math_inv for fp32, fp64, fp16
jinge90 c1de399
Update SYCL/DeviceLib/sycl_ext_intel_math_fp16.cpp
jinge90 ae00ea8
Update SYCL/DeviceLib/sycl_ext_intel_math_fp16.cpp
jinge90 ca30bbe
avoid overriding test binaries
jinge90 68b712d
Merge remote-tracking branch 'origin/test_imf_inv' into test_imf_inv
jinge90 d26122b
fix clang format issue
jinge90 9c6c8cf
simplify code and implement is_close2 using is_close
jinge90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fno-builtin -fsycl-device-lib-jit-link %s -o %t.noblt.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.noblt.out | ||
// | ||
// UNSUPPORTED: cuda || hip | ||
|
||
#include "imf_utils.hpp" | ||
#include <sycl/ext/intel/math.hpp> | ||
|
||
class is_close { | ||
public: | ||
bool operator()(sycl::half x, sycl::half y) { | ||
return sycl::fabs((x - y) / (x + y)) < | ||
std::numeric_limits<sycl::half>::epsilon() * 2; | ||
} | ||
}; | ||
|
||
class is_close2 { | ||
public: | ||
bool operator()(sycl::half2 x, sycl::half2 y) { | ||
is_close cls1; | ||
return cls1(x.s0(), y.s0()) && cls1(x.s1(), y.s1()); | ||
} | ||
}; | ||
|
||
int main(int, char **) { | ||
sycl::queue device_queue(sycl::default_selector_v); | ||
std::cout << "Running on " | ||
<< device_queue.get_device().get_info<sycl::info::device::name>() | ||
<< "\n"; | ||
|
||
if (!device_queue.get_device().has(sycl::aspect::fp16)) { | ||
std::cout << "Test skipped on platform without fp16 support." << std::endl; | ||
return 0; | ||
} | ||
|
||
// sycl::ext::intel::math::inv | ||
{ | ||
std::initializer_list<sycl::half> input_vals = {1.f, 2.0f, 0.5f, 100.f, | ||
3.f, 0.25f, 0.002f}; | ||
std::initializer_list<sycl::half> ref_vals = { | ||
1.f, 0.5f, 2.0f, 0.01f, 0.333333333f, 4.f, 500.f}; | ||
constexpr auto inv_op = [](sycl::half x) { | ||
return sycl::ext::intel::math::inv(x); | ||
}; | ||
test<sycl::half, sycl::half, decltype(inv_op), is_close>( | ||
device_queue, input_vals, ref_vals, inv_op); | ||
|
||
constexpr auto inv_op2 = [](sycl::half2 x) { | ||
return sycl::ext::intel::math::inv(x); | ||
}; | ||
std::initializer_list<sycl::half2> input_vals2 = { | ||
{1.f, 2.0f}, {0.5f, 100.f}, {3.f, 0.25f}, {0.002f, 0.005f}}; | ||
std::initializer_list<sycl::half2> ref_vals2 = { | ||
{1.f, 0.5f}, {2.0f, 0.01f}, {0.333333333f, 4.f}, {500.f, 200.f}}; | ||
test<sycl::half2, sycl::half2, decltype(inv_op2), is_close2>( | ||
device_queue, input_vals2, ref_vals2, inv_op2); | ||
std::cout << "sycl::ext::intel::math::inv passes" << std::endl; | ||
} | ||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fno-builtin -fsycl-device-lib-jit-link %s -o %t.noblt.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.noblt.out | ||
// | ||
// UNSUPPORTED: cuda || hip | ||
|
||
#include "imf_utils.hpp" | ||
#include <sycl/ext/intel/math.hpp> | ||
|
||
class is_close { | ||
public: | ||
bool operator()(float x, float y) { | ||
return std::fabs((x - y) / (x + y)) < | ||
std::numeric_limits<float>::epsilon() * 2; | ||
} | ||
}; | ||
|
||
int main(int, char **) { | ||
sycl::queue device_queue(sycl::default_selector_v); | ||
std::cout << "Running on " | ||
<< device_queue.get_device().get_info<sycl::info::device::name>() | ||
<< "\n"; | ||
|
||
// sycl::ext::intel::math::inv | ||
{ | ||
std::initializer_list<float> input_vals = {1.f, 2.0f, 0.5f, 100.f, | ||
3.f, 0.25f, 0.002f}; | ||
std::initializer_list<float> ref_vals = {1.f, 0.5f, 2.0f, 0.01f, | ||
0.333333333f, 4.f, 500.f}; | ||
constexpr auto inv_op = [](float x) { | ||
return sycl::ext::intel::math::inv(x); | ||
}; | ||
test<float, float, decltype(inv_op), is_close>(device_queue, input_vals, | ||
ref_vals, inv_op); | ||
std::cout << "sycl::ext::intel::math::inv passes" << std::endl; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fno-builtin -fsycl-device-lib-jit-link %s -o %t.noblt.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.noblt.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.noblt.out | ||
// | ||
// UNSUPPORTED: cuda || hip | ||
|
||
#include "imf_utils.hpp" | ||
#include <sycl/ext/intel/math.hpp> | ||
|
||
class is_close { | ||
public: | ||
bool operator()(double x, double y) { | ||
return std::fabs((x - y) / (x + y)) < | ||
std::numeric_limits<double>::epsilon() * 2; | ||
} | ||
}; | ||
|
||
int main(int, char **) { | ||
sycl::queue device_queue(sycl::default_selector_v); | ||
std::cout << "Running on " | ||
<< device_queue.get_device().get_info<sycl::info::device::name>() | ||
<< "\n"; | ||
|
||
if (!device_queue.get_device().has(sycl::aspect::fp64)) { | ||
std::cout << "Test skipped on platform without fp64 support." << std::endl; | ||
return 0; | ||
} | ||
|
||
// sycl::ext::intel::math::inv | ||
{ | ||
std::initializer_list<double> input_vals = {1., 2.0, 0.5, 100., | ||
3., 0.25, 0.002}; | ||
std::initializer_list<double> ref_vals = { | ||
1., 0.5, 2.0, 0.01, 0.3333333333333333, 4., 500.}; | ||
constexpr auto inv_op = [](double x) { | ||
return sycl::ext::intel::math::inv(x); | ||
}; | ||
test<double, double, decltype(inv_op), is_close>(device_queue, input_vals, | ||
ref_vals, inv_op); | ||
std::cout << "sycl::ext::intel::math::inv passes" << std::endl; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was only applied to this test, but other tests are missing it too.