Skip to content

Commit 46b19be

Browse files
authored
[SYCLomatic #712 #788 #836] Add math help function test. (#371)
Signed-off-by: Tang, Jiajun [email protected]
1 parent 6d657fe commit 46b19be

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

help_function/help_function.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<test testName="image_array" configFile="image_array/config/image_array.xml" />
2828
<test testName="test_complex" configFile="config/TEMPLATE_help_function.xml" />
2929
<test testName="math_function" configFile="config/TEMPLATE_help_function.xml" />
30+
<test testName="math" configFile="config/TEMPLATE_help_function.xml" />
3031
<test testName="cpu_device_index_initializaion_test" configFile="config/cpu_device_index_initializaion_test.xml" />
3132
<test testName="image_wrapper_usm" configFile="config/TEMPLATE_syclct_help_function_image_wrapper_usm.xml" />
3233
<test testName="image_wrapper_2_usm" configFile="config/TEMPLATE_syclct_help_function_image_wrapper_usm.xml" />

help_function/src/math.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ===------------------- math.cpp ---------- -*- C++ -* ------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//
8+
// ===---------------------------------------------------------------------===//
9+
10+
#include <dpct/dpct.hpp>
11+
12+
int main() {
13+
double d;
14+
float f;
15+
int i;
16+
sycl::half h;
17+
sycl::half2 h2;
18+
unsigned u;
19+
dpct::fast_length(&f, i);
20+
dpct::length(&d, i);
21+
dpct::compare(h, h, std::equal_to<>());
22+
dpct::compare(h2, h2, std::equal_to<>());
23+
dpct::unordered_compare(h, h, std::equal_to<>());
24+
dpct::unordered_compare(h2, h2, std::equal_to<>());
25+
dpct::compare_both(h2, h2, std::equal_to<>());
26+
dpct::unordered_compare_both(h2, h2, std::equal_to<>());
27+
dpct::isnan(h2);
28+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::abs_diff());
29+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::add_sat());
30+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::rhadd());
31+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::hadd());
32+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::maximum());
33+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::minimum());
34+
dpct::vectorized_binary<sycl::short2>(u, u, dpct::sub_sat());
35+
dpct::vectorized_unary<sycl::short2>(u, dpct::abs());
36+
dpct::vectorized_sum_abs_diff<sycl::short2>(u, u);
37+
printf("test pass!\n");
38+
return 0;
39+
}

0 commit comments

Comments
 (0)