-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][Test] Devicelib test #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: haonanya <[email protected]>
…math.o depends on device_math.h, modify here Signed-off-by: haonanya <[email protected]>
Hi, @bader , @asavonic , @andykaylor |
Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
…t.cpp, as math_utils.hpp changes Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
…math_utils.hpp Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
sycl/test/devicelib/math_utils.hpp
Outdated
else { | ||
T max_v = std::fmax(std::abs(x), std::abs(y)); | ||
return (std::abs(x - y) / max_v) < | ||
std::numeric_limits<T>::epsilon() * 100; |
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.
std::numeric_limits<T>::epsilon() * 100; | |
std::numeric_limits<T>::epsilon() * 100; |
Why 100?
Different math functions have different accuracy requirements and this seems to be too relax.
The bigger problem is that single threshold is applied to all functions. I think it should the threshold should be function dependent. Not sure if we want to checks the requirements set by the specification, but current value seems to be too relaxed.
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.
Hi, Alexey.
In fact, we added those cases only to test basic functionality of math functions provided by device library. The accuracy is not meant to be covered by these tests, all those input values of cmath functions are very simple ones. In fact, we are doing some accuracy tests on device library's and , all input will be much more complicated and different threshold are used and compared.
Thank you very much.
Signed-off-by: haonanya <[email protected]>
sycl/test/devicelib/math_utils.hpp
Outdated
// At least one input is nan | ||
if (std::isnan(x) || std::isnan(y)) | ||
ret = std::isnan(x) && std::isnan(y); | ||
|
||
// At least one input is inf | ||
else if (std::isinf(x) || std::isinf(y)) |
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.
I find the code with early exit more readable than this version.
// At least one input is nan | |
if (std::isnan(x) || std::isnan(y)) | |
ret = std::isnan(x) && std::isnan(y); | |
// At least one input is inf | |
else if (std::isinf(x) || std::isinf(y)) | |
// At least one input is nan | |
if (std::isnan(x) || std::isnan(y)) | |
return std::isnan(x) && std::isnan(y); | |
// At least one input is inf | |
if (std::isinf(x) || std::isinf(y)) |
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.
Fix for fixing this, but could you apply this comment to the file, please?
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.
Hi, Alexey.
I am sorry to make things complicated. I am new user.
Thanks for your patience.
Please, fix code formatting issues. |
Signed-off-by: haonanya <[email protected]>
sycl/test/devicelib/math_utils.hpp
Outdated
@@ -1,25 +1,33 @@ | |||
#ifndef MATH_UTILS | |||
#include <complex> | |||
#include <limits> | |||
using namespace std; | |||
// T must be float-point type | |||
template <typename T> | |||
bool is_about_FP(T x, T y) { |
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.
While you are here, could you add a comment explaining what this function... is_about? :-)
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.
Hi, Ronan.
Since it is not proper to compare float point using operator ==, this function measure whether the result of cmath function from kernel is close to the reference and machine epsilon is used as threshold in this function.
Thanks very much.
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.
Ah quite clearer with a comment! :-)
Then perhaps a clearer name for the function would help...
fuzzy_equal_fp
? approx_equal_fp
? I am not an native English speaker so I am not very helpful here...
Modify code to follow coding standards Co-Authored-By: Ronan Keryell <[email protected]> Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
sycl/test/devicelib/math_utils.hpp
Outdated
@@ -1,25 +1,33 @@ | |||
#ifndef MATH_UTILS | |||
#include <complex> | |||
#include <limits> | |||
using namespace std; | |||
// T must be float-point type | |||
template <typename T> | |||
bool is_about_FP(T x, T y) { |
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.
Ah quite clearer with a comment! :-)
Then perhaps a clearer name for the function would help...
fuzzy_equal_fp
? approx_equal_fp
? I am not an native English speaker so I am not very helpful here...
sycl/test/devicelib/math_utils.hpp
Outdated
} | ||
} | ||
return ret; |
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.
In this kind of code it is probably clearer to remove ret
and just have as many early return as required.
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.
Thank for your comment, early return is applied to new commit and approx_equal_fp is used as the name of float point comparison.
… return. Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
….hpp, Modify corresponding call in these files. Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
@haonanya, please, resolve conflicts. |
Signed-off-by: haonanya <[email protected]>
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.
One minor comment.
Other than that - looks good to me.
sycl/test/devicelib/math_utils.hpp
Outdated
if (std::isinf(x) || std::isinf(y)) | ||
return (x == y); | ||
|
||
// two finite | ||
else { |
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.
Please, don't use else after return.
Apply here and all the cases below.
Signed-off-by: haonanya <[email protected]>
LGTM, but I'd like to have reviews from @asavonic and @romanovvlad. |
@@ -0,0 +1,113 @@ | |||
// UNSUPPORTED: windows | |||
// RUN: %clangxx -fsycl -c %s -o %t.o | |||
// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath-fp64.o -o %t.out |
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.
Please add a RUN line for execution here and in all other tests.
Otherwise this just tests for compilation and no runtime validation is performed.
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.
If these are going to run the compiled program, they should be moved to end-to-end testing.
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.
Hi, @andykaylor and @asavonic
Could we enable the run command for cmath tests on CPU device currently?
For GPU, only OCL RT can work. For CPU, all cmath and complex tests should work in theory but OCL CPU RT has an issue which will lead to crash on some platforms, the fix has not been merged into latest OCL CPU RT, so we may encounter some unexpected crash if enable complex tests.
Thank you very much.
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.
If these are going to run the compiled program, they should be moved to end-to-end testing.
Most of the tests in sycl/test
directory have RUN lines to test on available devices.
This test in particular has a lot of runtime asserts.
Could we enable the run command for cmath tests on CPU device currently?
I think they should be enabled for all devices you expect this code to work. I assume it should work for CPU and GPU, right? FPGA is probably not going work, because AOT compilation is not support for device libraries yet.
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.
If a test doesn't work on some platform due to a bug, it should be disabled temporarily.
Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
Signed-off-by: haonanya <[email protected]>
@asavonic, ping. |
…c_abi_checks * origin/sycl: [SYCL][Driver] Enforce unique filenames when -save-temps is used (intel#1545) [SYCL] [xmethods] Allow replacing xmethod script (intel#1532) [SYCL] Add tests for inline asm feature (intel#1444) [SYCL][Doc] Add device_specific_kernel_queries extension. (intel#1540) [SYCL][USM] Remove unused header and unnecessary includes (intel#1537) Fix check-llvm dependencies (intel#1547) [SYCL] Add __SYCL_EXPORT to declaration of contextSetExtendedDeleter (intel#1531) [SYCL][Doc] Add static local memory query extension. (intel#1539) [SYCL][Doc] Add sycl_bitcast extension (intel#1541) [SYCL][NFC] Temporarily disable sporadically failing test (intel#1533) [SYCL][NFC] Adjust codeowners for sycl directory (intel#1529) [SYCL] Fix processing of spec consts referenced twice (intel#1524) [SYCL] Use correct macro name in export.hpp (intel#1527) [Driver][NFC] Fix -help information for -Xs options (intel#1530) [SYCL][Doc] Add Graph Scheduler design documentation (intel#1457) [SYCL] Add diagnostics for long double in device code (intel#1512) [SYCL] Add a mutex to state-modifying program functions (intel#1204) [SYCL][Test] Add Devicelib tests (intel#1256) [SYCL] Refactor semantic checks for variable types (intel#1513)
The types of lower bound, upper bound, and step are converted into the type of the loop variable if necessary. OpenMP runtime requires 32-bit or 64-bit loop variables. OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed. This patch is part of upstreaming code from the fir-dev branch of https://github.com/flang-compiler/f18-llvm-project. (#1256) Co-authored-by: kiranchandramohan <[email protected]> Reviewed By: kiranchandramohan, shraiysh Differential Revision: https://reviews.llvm.org/D125740
modify here.