Skip to content

Commit 56521ff

Browse files
Fix a test to check the generic setup
1 parent 9451c46 commit 56521ff

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

src/periphery/VPM.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ namespace vc4c
328328
*
329329
* see Broadcom spec, table 33
330330
*/
331-
class VPRGenericSetup : private Bitfield<uint32_t>
331+
// class VPRGenericSetup : private Bitfield<uint32_t>
332+
class VPRGenericSetup : public Bitfield<uint32_t>
332333
{
333334
public:
334335
VPRGenericSetup(uint8_t size, uint8_t stride, uint8_t numVectors = 1, uint8_t address = 0) : Bitfield(0)

test/TestOptimizationSteps.cpp

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,24 +1996,33 @@ void TestOptimizationSteps::testCombineDMALoads()
19961996
uint8_t elementBitCount = vectorType.getElementType().getScalarBitCount();
19971997
uint8_t dmaSetupMode = 0;
19981998
uint8_t vpitch = 1;
1999+
uint8_t vprSize = 0;
2000+
uint8_t vprStride = 0;
19992001
switch(elementBitCount)
20002002
{
2001-
case 8:
2002-
dmaSetupMode = 4;
2003-
vpitch = 4;
2004-
break;
2005-
case 16:
2006-
dmaSetupMode = 2;
2007-
vpitch = 2;
2008-
break;
2009-
case 32:
2010-
dmaSetupMode = 0;
2011-
vpitch = 1;
2012-
break;
2003+
case 8:
2004+
dmaSetupMode = 4;
2005+
vpitch = 4;
2006+
vprSize = 0;
2007+
vprStride = 4;
2008+
break;
2009+
case 16:
2010+
dmaSetupMode = 2;
2011+
vpitch = 2;
2012+
vprSize = 1;
2013+
vprStride = 2;
2014+
break;
2015+
case 32:
2016+
dmaSetupMode = 0;
2017+
vpitch = 1;
2018+
vprSize = 2;
2019+
vprStride = 1;
2020+
break;
20132021
}
20142022

20152023
const int numOfLoads = 3;
20162024
periphery::VPRDMASetup expectedDMASetup(dmaSetupMode, vectorType.getVectorWidth() % 16, numOfLoads, vpitch, 0);
2025+
periphery::VPRGenericSetup expectedVPRSetup(vprSize, vprStride, numOfLoads, 0);
20172026

20182027
inputMethod.dumpInstructions();
20192028

@@ -2025,7 +2034,7 @@ void TestOptimizationSteps::testCombineDMALoads()
20252034
{
20262035
int numOfDMASetup = 0;
20272036
int numOfStrideSetup = 0;
2028-
int numOfVPMSetup = 0;
2037+
int numOfVPRSetup = 0;
20292038
int numOfVPMRead = 0;
20302039

20312040
for(auto& it : bb)
@@ -2066,28 +2075,28 @@ void TestOptimizationSteps::testCombineDMALoads()
20662075
}
20672076
if(vpr.isGenericSetup())
20682077
{
2069-
auto vpmSetup = vpr.genericSetup;
2070-
TEST_ASSERT_EQUALS(numOfLoads, vpmSetup.getNumber());
2071-
numOfVPMSetup++;
2078+
TEST_ASSERT_EQUALS(expectedVPRSetup, vpr.genericSetup);
2079+
numOfVPRSetup++;
20722080
}
20732081
}
20742082
}
20752083
}
20762084

20772085
TEST_ASSERT_EQUALS(1, numOfDMASetup);
20782086
TEST_ASSERT_EQUALS(1, numOfStrideSetup);
2079-
TEST_ASSERT_EQUALS(1, numOfVPMSetup);
2087+
TEST_ASSERT_EQUALS(1, numOfVPRSetup);
20802088
TEST_ASSERT_EQUALS(numOfLoads, numOfVPMRead);
20812089
}
20822090
};
20832091

2084-
auto putMethodCall = [](Method& inputMethod, InstructionWalker& inIt, const DataType& vectorType, std::string funcName, std::vector<Value>&& args) {
2092+
auto putMethodCall = [](Method& inputMethod, InstructionWalker& inIt, const DataType& vectorType,
2093+
std::string funcName, std::vector<Value>&& args) {
20852094
auto res = inputMethod.addNewLocal(vectorType);
20862095
inIt.emplace((new intermediate::MethodCall(std::move(res), std::move(funcName), std::move(args))));
20872096
};
20882097

20892098
const DataType Float16{DataType::WORD, 16, true};
2090-
const DataType Float8 {DataType::WORD, 8, true};
2099+
const DataType Float8{DataType::WORD, 8, true};
20912100
const DataType Uchar16{DataType::BYTE, 16, false};
20922101

20932102
// vload16(size_t, const float*)
@@ -2181,10 +2190,9 @@ void TestOptimizationSteps::testCombineDMALoads()
21812190
Literal l(2);
21822191
Value a(l, TYPE_INT32);
21832192
Value b = 3_val;
2184-
std::shared_ptr<ValueExpr> expr(new ValueBinaryOp(
2185-
makeValueBinaryOpFromLocal(a, ValueBinaryOp::BinaryOp::Add, b),
2186-
ValueBinaryOp::BinaryOp::Sub,
2187-
std::make_shared<ValueTerm>(1_val)));
2193+
std::shared_ptr<ValueExpr> expr(
2194+
new ValueBinaryOp(makeValueBinaryOpFromLocal(a, ValueBinaryOp::BinaryOp::Add, b),
2195+
ValueBinaryOp::BinaryOp::Sub, std::make_shared<ValueTerm>(1_val)));
21882196
ValueExpr::ExpandedExprs expanded;
21892197
expr->expand(expanded);
21902198

0 commit comments

Comments
 (0)