Closed krasznaa closed 2 years ago
runOnHost
and runOnDevice
with functor are quite impressive - I don't have particular comments
You should hold onto your hats... :stuck_out_tongue:
After some back-and-forth about how the tests should be set up exactly, I ended up with this implementation. In which I make use of GoogleTest's templated testing infrastructure in the same way as we do it for the host tests.
Note that this means that CUDA must use at least C++17 for the build. I tried for a long time to set up the code such that using C++14 with CUDA would still be possible. But after being laughed at by the linker for a while (it's a long story...), I decided that requiring C++17 should be fine...
Also note that the CI is not testing the CUDA build at the moment at all. However I'd propose that we set that up in a separate PR. This one is quite bloated already...
P.S. I found that algebra::eigen_eigen
does work in device code, but only under protest.
[100%] Building CUDA object tests/accelerator/cuda/CMakeFiles/algebra_test_eigen_cuda.dir/eigen_eigen.cu.o
/home/krasznaa/ATLAS/projects/algebra-plugins/build/_deps/eigen3-src/Eigen/src/Geometry/Transform.h(292): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "Eigen::Transform<_Scalar, _Dim, _Mode, _Options>::Transform(const Eigen::EigenBase<OtherDerived> &) [with _Scalar=double, _Dim=3, _Mode=2, _Options=0, OtherDerived=Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, 4, 4, 0, 4, 4>>]"
(535): here
instantiation of "const Eigen::Transform<_Scalar, _Dim, _Mode, _Options> Eigen::Transform<_Scalar, _Dim, _Mode, _Options>::Identity() [with _Scalar=double, _Dim=3, _Mode=2, _Options=0]"
/home/krasznaa/ATLAS/projects/algebra-plugins/algebra-plugins/math/eigen/include/algebra/math/impl/eigen_transform3.hpp(85): here
instantiation of "algebra::eigen::math::transform3<scalar_t>::transform3(const algebra::eigen::math::transform3<scalar_t>::vector3 &, const algebra::eigen::math::transform3<scalar_t>::vector3 &, const algebra::eigen::math::transform3<scalar_t>::vector3 &) [with scalar_t=algebra::scalar]"
/home/krasznaa/ATLAS/projects/algebra-plugins/algebra-plugins/tests/common/test_device_basics.hpp(83): here
instantiation of "test_device_basics<T>::scalar test_device_basics<T>::transform3_ops(test_device_basics<T>::vector3, test_device_basics<T>::vector3, test_device_basics<T>::vector3, test_device_basics<T>::vector3, test_device_basics<T>::vector3) const [with T=test_types<algebra::scalar, algebra::eigen::point2, algebra::eigen::point3, algebra::eigen::vector2, algebra::eigen::vector3, algebra::eigen::transform3, algebra::eigen::cartesian2, algebra::eigen::polar2, algebra::eigen::cylindrical2>]"
...
Apparently the Eigen developers are not too thorough with their own tests either... :frowning:
However Vc types can not be used in device code at all. :frowning: Even though I was secretly hoping that that may be possible...
I have already filed some issues on some warnings in Eigen and they fixed them very quickly. I guess most of warnings will be gone in next release
This is a draft proposal for how we could add "device tests" to this repository. So that we could catch incompatibilities with CUDA/HIP/SYCL already in the CI of this repository.
This is very much a work in progress at the moment. I just wanted to get some feedback early on it.
Note that I found a bunch more places where CUDA was not playing along with the current implementation. (Like the ones we had to fix in #34.) I'm pretty sure that I didn't fix all of them still. (Since the one test so far only instantiates a small number of template functions/types.)
One thing that I didn't quite appreciate is that the templating that I wrote for the repository, strictly requires C++17. With C++14 neither GCC nor NVCC can resolve some of the template calls in the code. (I was about to open a bug report to NVidia when I realised that it was the C++ standard that was preventing it from using functions like
algebra::cmath::phi
conveniently.)