Eigen matrix multiplication error on JETSON AGX ORIN

Hi,
I find that eigen matrix multiplication will give wrong result in cuda kernel on my jetson orin, here is the code.

``````__global__ void eigen_test (void)
{
printf("Eigen test from GPU!\n");
Eigen::Matrix3f rot;
rot << 2.0f, 0.f, 0.f,
0.f, 2.0f, 0.f,
0.f, 0.f, 2.0f;
Eigen::Vector3f vec;
vec << 1.0f, 2.0f, 3.0f;
Eigen::Vector3f vec2 = rot * vec;
printf("eigen test2 %lf, %lf, %lf \n", vec2(0), vec2(1), vec2(2));
Eigen::Vector3f vec3;
vec3(0) = rot(0, 0) * vec(0) + rot(0, 1) * vec(1) + rot(0, 2) * vec(2);
vec3(1) = rot(1, 0) * vec(0) + rot(1, 1) * vec(1) + rot(1, 2) * vec(2);
vec3(2) = rot(2, 0) * vec(0) + rot(2, 1) * vec(1) + rot(2, 2) * vec(2);
printf("eigen test3 %lf, %lf, %lf \n", vec3(0), vec3(1), vec3(2));
}
output:
eigen test2 0.000000, 0.000000, 0.000000
eigen test3 2.000000, 4.000000, 6.000000
``````

but on my computer with 1050 gpu, it gives right result
output:
eigen test2 2.000000, 4.000000, 6.000000
eigen test3 2.000000, 4.000000, 6.000000

My eigen version is 3.3.7
cuda 11.4

Hi,

Could you add the synchronize right before the print to see if it helps?
Thanks.

Hi,
I have add __syncthreads() before printf, it still give same result.
here is my minimal code.

eigen_test.cu (919 Bytes)

Hi,

Confirmed that we can reproduce this internally and now are checking internally.
Will let you know once we found something.

Thanks.

Hi,

We got several warnings when linking the source code with the Eigen library.

``````/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(836): warning: calling a __host__ function from a __host__ __device__ function is not allowed
detected during:
instantiation of "void Eigen::internal::call_assignment_no_alias(Dst &, const Src &, const Func &) [with Dst=Eigen::Matrix<float, 3, 1, 0, 3, 1>, Src=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>, Func=Eigen::internal::assign_op<float, float>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(732): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 3, 1, 0, 3, 1>, OtherDerived=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(816): here
instantiation of "void Eigen::PlainObjectBase<Derived>::_init1<T,OtherDerived>(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 3, 1, 0, 3, 1>, T=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>, OtherDerived=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(294): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const T &) [with _Scalar=float, _Rows=3, _Cols=1, _Options=0, _MaxRows=3, _MaxCols=1, T=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
(796): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &, const Func &, Eigen::internal::enable_if<Eigen::internal::evaluator_assume_aliasing<Src, Eigen::internal::evaluator_traits<Src>::Shape>::value, void *>::type) [with Dst=Eigen::Matrix<float, 3, 1, 0, 3, 1>, Src=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>, Func=Eigen::internal::assign_op<float, float>]"
(782): here
instantiation of "void Eigen::internal::call_assignment(Dst &, const Src &) [with Dst=Eigen::Matrix<float, 3, 1, 0, 3, 1>, Src=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h(714): here
instantiation of "Derived &Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived> &) [with Derived=Eigen::Matrix<float, 3, 1, 0, 3, 1>, OtherDerived=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
/usr/include/eigen3/Eigen/src/Core/Matrix.h(225): here
instantiation of "Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> &Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::DenseBase<OtherDerived> &) [with _Scalar=float, _Rows=3, _Cols=1, _Options=0, _MaxRows=3, _MaxCols=1, OtherDerived=Eigen::Product<Eigen::Matrix<float, 3, 3, 0, 3, 3>, Eigen::Matrix<float, 3, 1, 0, 3, 1>, 0>]"
eigen_test.cu(15): here

/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h(836): warning: calling a __host__ function("Eigen::internal::Assignment< ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1> ,  ::Eigen::Product< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> ,  ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1> , (int)0> ,  ::Eigen::internal::assign_op<float, float> ,  ::Eigen::internal::Dense2Dense, void> ::run( ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1>  &, const  ::Eigen::Product< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> ,  ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1> , (int)0>  &, const  ::Eigen::internal::assign_op<float, float>  &)") from a __host__ __device__ function("Eigen::internal::call_assignment_no_alias< ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1> ,  ::Eigen::Product< ::Eigen::Matrix<float, (int)3, (int)3, (int)0, (int)3, (int)3> ,  ::Eigen::Matrix<float, (int)3, (int)1, (int)0, (int)3, (int)1> , (int)0> ,  ::Eigen::internal::assign_op<float, float> > ") is not allowed

In file included from /usr/include/eigen3/Eigen/Core:257,
from /usr/include/eigen3/Eigen/Dense:1,
from eigen_test.cu:1:
/usr/local/cuda-11.4/bin/../targets/aarch64-linux/include/host_defines.h:54:2: warning: #warning "host_defines.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
54 | #warning "host_defines.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
|  ^~~~~~~
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h(94): warning: __host__ annotation is ignored on a function("no_assignment_operator") that is explicitly defaulted on its first declaration
``````

Do you also see a similar?
If yes, could you check with the Eigen team to see if they support the Jetson platform first?

Thanks.

Hi,
This warning occurs on both platforms, but my notebook’s multiplication result are correct.
I will report this to the Eigen team, and let you know if there is any progress.

The latest version of Eigen fixes this problem

Good to know this.
Thanks for the update.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.