fix this funny bug, which was (for some strange reason) not detected within the commits a few weeks ago...

This commit is contained in:
Christian Zimmermann 2017-10-30 17:52:27 +01:00
parent 8620c076be
commit 0570a502c0
4 changed files with 28 additions and 28 deletions

View file

@ -96,7 +96,7 @@ namespace MultiArrayTools
return out; return out;
} }
void minimizeAppearanceOfType(std::map<std::shared_ptr<IndexBase>, std::vector<BTSS> > mp, void minimizeAppearanceOfType(std::map<std::shared_ptr<IndexBase>, std::vector<BTSS> >& mp,
BlockType bt) BlockType bt)
{ {
size_t minNum = getBTNum( mp.begin()->second, bt ); size_t minNum = getBTNum( mp.begin()->second, bt );
@ -121,7 +121,7 @@ namespace MultiArrayTools
template <typename T> template <typename T>
std::shared_ptr<IndexBase> seekBlockIndex(std::shared_ptr<IndexBase> ownIdx, std::shared_ptr<IndexBase> seekBlockIndex(std::shared_ptr<IndexBase> ownIdx,
const OperationBase<T>& second) const OperationBase<T>& second)
{ {
std::vector<std::shared_ptr<IndexBase> > ivec; std::vector<std::shared_ptr<IndexBase> > ivec;
seekIndexInst(ownIdx, ivec); seekIndexInst(ownIdx, ivec);
@ -130,10 +130,8 @@ namespace MultiArrayTools
for(auto& xx: ivec){ for(auto& xx: ivec){
mp[xx] = second.block(xx); mp[xx] = second.block(xx);
} }
// seek minimal number of VALUEs => guarantees absence of conflicting blocks // seek minimal number of VALUEs => guarantees absence of conflicting blocks
minimizeAppearanceOfType(mp, BlockType::VALUE); minimizeAppearanceOfType(mp, BlockType::VALUE);
// seek mininmal number of SPLITs => maximal vectorization possible // seek mininmal number of SPLITs => maximal vectorization possible
minimizeAppearanceOfType(mp, BlockType::SPLIT); minimizeAppearanceOfType(mp, BlockType::SPLIT);
@ -207,7 +205,7 @@ namespace MultiArrayTools
block(blockIndex); block(blockIndex);
second.block(blockIndex); second.block(blockIndex);
for(*mIndex = 0; mIndex->pos() != mIndex->max(); mIndex->pp(blockIndex) ){ for(*mIndex = 0; mIndex->pos() != mIndex->max(); mIndex->pp(blockIndex) ){
get() = mSecond.get(); get() = mSecond.get();
} }

View file

@ -50,7 +50,7 @@ namespace MultiArrayTools
size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt); size_t getBTNum(const std::vector<BTSS>& mp, BlockType bt);
void minimizeAppearanceOfType(std::map<std::shared_ptr<IndexBase>, std::vector<BTSS> > mp, void minimizeAppearanceOfType(std::map<std::shared_ptr<IndexBase>, std::vector<BTSS> >& mp,
BlockType bt); BlockType bt);
template <typename T> template <typename T>

View file

@ -165,12 +165,12 @@ namespace {
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 8.870 - 1.470) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 8.870 - 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 4.790 - 2.210) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 4.790 - 2.210) );
} }
/*
TEST_F(OpTest_MDim, ExecOp3) TEST_F(OpTest_MDim, ExecOp3)
{ {
MultiArray<double,MRange,SRange> res(mr1ptr,sr4ptr); MultiArray<double,MRange,SRange> res(mr1ptr,sr4ptr);
MultiArray<double,MRange> ma1(mr1ptr, v3); MultiArray<double,MRange> ma1(mr1ptr, v3);
MultiArray<double,SRange> ma2(sr2ptr, v1); MultiArray<double,SRange> ma2(sr2ptr, v1);
MultiArray<double,SRange> ma3(sr4ptr, v4); MultiArray<double,SRange> ma3(sr4ptr, v4);
auto si1 = std::dynamic_pointer_cast<SRange::IndexType>( sr2ptr->index() ); auto si1 = std::dynamic_pointer_cast<SRange::IndexType>( sr2ptr->index() );
@ -181,21 +181,21 @@ namespace {
res(mi,si3) = ma1(mi) + ma2(si1) + ma3(si3); res(mi,si3) = ma1(mi) + ma2(si1) + ma3(si3);
EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'A')) ), xround(0.353 + 2.917 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'A')) ), xround(0.353 + 2.917 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'B')) ), xround(0.353 + 2.917 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'B')) ), xround(0.353 + 2.917 + 2.210) );
EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'A')) ), xround(4.005 + 2.917 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'A')) ), xround(4.005 + 2.917 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'B')) ), xround(4.005 + 2.917 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'B')) ), xround(4.005 + 2.917 + 2.210) );
EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'A')) ), xround(1.070 + 9.436 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'A')) ), xround(1.070 + 9.436 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'B')) ), xround(1.070 + 9.436 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'B')) ), xround(1.070 + 9.436 + 2.210) );
EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'A')) ), xround(2.310 + 9.436 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'A')) ), xround(2.310 + 9.436 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'B')) ), xround(2.310 + 9.436 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'B')) ), xround(2.310 + 9.436 + 2.210) );
EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'A')) ), xround(9.243 + 0.373 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'A')) ), xround(9.243 + 0.373 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'B')) ), xround(9.243 + 0.373 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'B')) ), xround(9.243 + 0.373 + 2.210) );
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 0.373 + 1.470) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 0.373 + 1.470) );
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 0.373 + 2.210) ) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 0.373 + 2.210) );
}*/ }
} // anonymous namspace } // anonymous namspace

View file

@ -88,11 +88,12 @@ namespace MultiArrayHelper
std::shared_ptr<IndexBase> idxPtr) std::shared_ptr<IndexBase> idxPtr)
{ {
auto& siPtr = std::get<N>(ip); auto& siPtr = std::get<N>(ip);
//VCHECK(siPtr.id());
if(siPtr.get() == idxPtr.get()){ if(siPtr.get() == idxPtr.get()){
return std::get<N>(bs) + PackNum<N-1>::pp(ip, bs, idxPtr); return PackNum<N-1>::pp(ip, bs, idxPtr);
} }
else { else {
size_t tmp = siPtr->pp(idxPtr); int tmp = siPtr->pp(idxPtr);
if(siPtr->pos() == siPtr->max()){ if(siPtr->pos() == siPtr->max()){
(*siPtr) = 0; (*siPtr) = 0;
return PackNum<N-1>::pp(ip, bs, idxPtr) - siPtr->max() + 1; return PackNum<N-1>::pp(ip, bs, idxPtr) - siPtr->max() + 1;
@ -298,7 +299,8 @@ namespace MultiArrayHelper
return std::get<0>(bs); return std::get<0>(bs);
} }
else { else {
return siPtr->pp(idxPtr) * std::get<1>(bs); int tmp = siPtr->pp(idxPtr);
return tmp * std::get<1>(bs);
} }
} }