-
Notifications
You must be signed in to change notification settings - Fork 6
Update testing to use Catch2 and CMake #16
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
|
Back in vacation, will have a look :) Thanks! |
|
Should we use |
tests/CMakeLists.txt
Outdated
| @@ -0,0 +1,45 @@ | |||
| file(GLOB test_cases CONFIGURE_DEPENDS "*.cpp") | |||
|
|
|||
| # set(test_cases | |||
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 guess we can remove the comments now :)
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.
Haha thanks for catching this. I have removed the comments
| return Q.get_device().has(sycl::aspect::fp64); | ||
| } | ||
|
|
||
| template <> inline bool is_type_supported<float>(sycl::queue &Q) { |
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 never realized that indeed fp32 is required by the SYCL spec :D
|
|
||
| // Check functions return correct types | ||
| void check_math_function_types() { | ||
| TEST_MATH_FUNC_TYPE("Test complex acos types", "[acos]", acos) |
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.
Maybe a stupid question, but it seems strange to me that if we list all the TEST_MATH_FUNC_TYPE we need to add them manually in the CMAKELIST.
Sorry, I'm sure I'm missing something obvious...
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.
So I don't quite understand. TEST_MATH_FUNC_TYPE is a macro that just allows the test to be repeated for all the different functions without me re-writing them. CMake needs a list of all the source files which then Catch2 parses for the tests Catch2 looks for a different macro something along the line of TEST_CASE("Test is_gencomplex", "[gencomplex]").
CMake needs a list of the test source files so it knows which files to compile otherwise it is will compile none of the tests files.
Does this answer your question, could you clarify if it does not?
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.
Oh I see. Yes it clarifies; thanks! TEST_MATH_FUNC_TYPE(acos) is not calling or registering the tests inside acos_complex.cpp.
TEST_MATH_FUNC_TYPE are just another type of tests.
Thanks!
| inline constexpr T inf_val = std::numeric_limits<T>::infinity(); | ||
|
|
||
| template <typename T> | ||
| inline constexpr T nan_val = std::numeric_limits<T>::quiet_NaN(); |
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.
Oh nice, I did knew about ::quiet_Nan(). I was using std::nan("") like a caveman :)
| sycl::ext::cplx::complex<T> cplx_input{input.re, input.im}; | ||
|
|
||
| std::complex<T> std_out{init_re, init_im}; | ||
| auto *cplx_out = sycl::malloc_shared<sycl::ext::cplx::complex<T>>(1, Q); | ||
| std::complex<T> std_out{input.re, input.im}; |
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 guess we can just do std_out{input} (or maybe init_std_complex for taking care of half)
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.
So unfortunately I cant do std_out{input} as input is of type cmplx which is just a helper struct of real and imaginary components. std::complex does not have a constructor for my helper struct cmplx.
Also in this case we don't want the half's to be be translated into floats as this is the output value which should have the half type. As no operation is being performed on the output type this is valid, the reason we are initializing it to the input values is for the case were we are checking if acosh can undo cosh. However when error codes are tested this value is overwritten.
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.
Oh yes ofc! I'm stupid, it's a std::complex not our complex! Sorry, after coming back from vacation, my brain is slower than usual :)
Thanks for the explanation
| if (is_error_checking) | ||
| std_out = std::acosh(std_in); | ||
| // Get std::complex output | ||
| if (is_error_checking) |
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.
Not important but I think the is_type_supported should protect this guy too, as we can this lead to the variable is not used type of warning.
But thinking more can we use CTEST to only run those tests if is_type_supported is True? May avoid the duplication of is_type_supported call.
The tests assume that the type is supported, and it's ctests / catch2 responsibility to run then if possible. I don't know if it's possible, I know nothing about ctests / catch2...
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 don't think is_type_supported should protect this, as lower down we test if the behaviour is valid on the host. While SYCL does say that a device does not need to support double and half types the host does so it makes sense not to calculate the reference value and have it for the later host check. It simply saves having two places where the reference value is calculated.
|
Thanks for all ctest / catch integration. Look far better now :) |
tests/CMakeLists.txt
Outdated
| file(GLOB test_cases CONFIGURE_DEPENDS "*.cpp") | ||
|
|
||
| foreach(test_file IN LISTS test_cases) | ||
| # if(EXISTS "${test_file}") |
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(EXISTS "${test_file}") |
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 have uncommented these checks to make sure each file is available and emit a warning if it is not.
tests/CMakeLists.txt
Outdated
| # else() | ||
| # message(FATAL_ERROR "No file named ${test_file}") | ||
| # endif() |
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.
| # else() | |
| # message(FATAL_ERROR "No file named ${test_file}") | |
| # endif() |
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 have uncommented this check. Same as above.
|
We saw |
|
Filled intel/llvm#6720 |
Co-authored-by: Thomas Applencourt <[email protected]>
|
Thanks for filing the ticket. I do not have these issues locally. I am building |
Did you use the L0 backend? It's maybe backend specific. But We have a work-around ( just run the test one by one), so I will write a little script to do so, so I can continue testing with Sorry for the late merge! And thanks again |
Yes, I have been testing with the L0 backend on a local machine |
This PR moves the testing away from using
makeand utility functions. It introduces Catch2 as a git submodule so the user does not have to separately build it. CMake is then used to build and run the tests. Using Catch2 reduces the amount of code needed to testSyclCPLXand will speed up adding new tests.The readme has been updated to reflect this change.