RAJA
RAJA copied to clipboard
Left-hand tensor indexes used for lookups in the right-hand side of Expression templates
On the latest version of the develop
branch (f8c702cb116841ed43229f70f1deb75ca98acd15), when compiling with gcc-8.1.0 for TOSS3, the following program
#include "RAJA/RAJA.hpp"
#include "camp/camp.hpp"
int main (int argc, char* argv[])
{
double A[2] = { 1, 2 };
double B[16] = {
1, 1, 1, 1,
10, 10, 10, 10,
100, 100, 100, 100,
1000, 1000, 1000, 1000
};
double C[16] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
};
using mat_t = RAJA::expt::RectMatrixRegister<double, RAJA::expt::RowMajorLayout, 4, 4, RAJA::avx2_register>;
using row_t = RAJA::expt::RowIndex<int, mat_t>;
using col_t = RAJA::expt::ColIndex<int, mat_t>;
using vec_t = RAJA::expt::VectorRegister<double>;
using idx_t = RAJA::expt::VectorIndex<int, vec_t>;
auto aa = RAJA::View<double, RAJA::Layout<2>> ( A, 1, 2 );
auto bb = RAJA::View<double, RAJA::Layout<2>> ( B, 4, 4 );
auto cc = RAJA::View<double, RAJA::Layout<2>> ( C, 4, 4 );
auto rall = row_t::all();
auto call = col_t::all();
cc(row_t::range(0,1),call) = aa(0,0) * bb(row_t::range(0,1),call);
cc(row_t::range(1,2),call) = aa(0,1) * bb(row_t::range(0,1),call);
cc(row_t::range(2,3),call) = aa(0,0) * bb(row_t::range(1,2),call);
cc(row_t::range(3,4),call) = aa(0,1) * bb(row_t::range(1,2),call);
for(int i=0; i<4; i++){
for(int j=0; j<4; j++){
printf("%f\t",cc(i,j));
}
printf("\n");
}
}
reports the following matrix as a result:
[ 1, 1, 1, 1]
[ 20, 20, 20, 20]
[ 100, 100, 100, 100]
[2000,2000,2000,2000]
However, the correct result would be:
[ 1, 1, 1, 1]
[ 2, 2, 2, 2]
[ 10, 10, 10, 10]
[ 20, 20, 20, 20]
It appears that the row tensor index provided for the left-hand side of the assignment (cc) is being used to look up rows for the second operand in the right-hand side (bb).
@ajkunen