Skip to content

Commit

Permalink
adding test and fix for pairwise accumulate
Browse files Browse the repository at this point in the history
  • Loading branch information
andyD123 committed Aug 31, 2023
1 parent b1bc300 commit 7d7ed91
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
50 changes: 49 additions & 1 deletion VectorTest/TestAccumulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,52 @@ TEST(TestAccumulator, simpleTransformAccumulate_BinaryFunc_X)
//eval over multiple lengths
evalTransformAccumulateInnerProduct_X(957, 1043);

}
}


////////////////////////////////////////


void evalAccumulateUR_X_pairwise(int startLen, int endLen)
{
Numeric testEpsilon;
setEpsilonAccumulate(testEpsilon);


for (int SZ = startLen; SZ <= endLen; SZ++)
{
std::vector<Numeric> v(SZ, asNumber(0.0));
for (int i = 0; i < SZ; i++)
{
v[i] -= asNumber(500.0 - i);
}

VecXX test(v);
auto Sum = [](auto lhs, auto rhs) { return lhs + rhs; };
Numeric resSTL = std::accumulate(v.begin(), v.end(), asNumber(0.0));
Numeric resAcc1 = ApplyAccumulate2UR_X_pairwise(test, Sum);
EXPECT_NEAR(resSTL, resAcc1, testEpsilon);
}

}

TEST(TestAccumulator, simple_pairwise)
{
EXPECT_EQ(1, 1);
EXPECT_TRUE(true);

evalAccumulateUR_X_pairwise(32, 32);
evalAccumulateUR_X_pairwise(64, 64);
evalAccumulateUR_X_pairwise(128, 128);
evalAccumulateUR_X_pairwise(256, 256);
evalAccumulateUR_X_pairwise(512, 512);
evalAccumulateUR_X_pairwise(1024, 1024);

evalAccumulateUR_X_pairwise(1, 80);

evalAccumulateUR_X_pairwise(957, 1043);


evalAccumulateUR_X_pairwise(159, 159);

}
3 changes: 2 additions & 1 deletion Vectorisation/VecX/accumulate_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,9 @@ typename InstructionTraits<INS_VEC>::FloatType ApplyAccumulate2UR_X_pairwise(con
if (working_Size & current_block_SZ)
{
accumulations_of_all_blocks += accum_recurse(pRhs, current_block_SZ, accum_recurse);
pRhs += current_block_SZ;
}

//pRhs += current_block_SZ;
current_block_SZ *= 2;
}

Expand Down

0 comments on commit 7d7ed91

Please sign in to comment.