Commit 6a6500f7 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic '15399_performance_improvements_for_exodus_reader'

70dd85a0

 BUG #15399: Improve performance for exodus modeshapes.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !622
parents 50c8e824 70dd85a0
......@@ -1434,8 +1434,14 @@ void vtkExodusIIReaderPrivate::AddPointArray(
dest->SetName( src->GetName() );
dest->SetNumberOfComponents( src->GetNumberOfComponents() );
dest->SetNumberOfTuples( bsinfop->NextSqueezePoint );
std::map<vtkIdType,vtkIdType>::iterator it;
for ( it = bsinfop->PointMap.begin(); it != bsinfop->PointMap.end(); ++ it )
std::map<vtkIdType,vtkIdType>::iterator it, itEnd;
//
// I moved the end condition of the loop out of the for(;;) loop.
// Assuming it doesn't change within the loop itself!
// The reason is that the code was making the call every loop.
//
itEnd = bsinfop->PointMap.end();
for ( it = bsinfop->PointMap.begin(); it != itEnd; ++ it )
{
pd->CopyTuple( src, dest, it->first, it->second );
}
......@@ -1719,13 +1725,31 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
std::vector<double> tmpTuple;
tmpTuple.resize( ncomps );
tmpTuple[ncomps - 1] = 0.; // In case we're embedding a 2-D vector in 3-D
for ( t = 0; t < arr->GetNumberOfTuples(); ++t )
//
// Lets unroll the most common case - components == 3.
//
if ( ainfop->Components == 3)
{
for ( c = 0; c < ainfop->Components; ++c )
int maxTuples = arr->GetNumberOfTuples();
for ( t = 0; t < maxTuples; ++t )
{
tmpTuple[c] = tmpVal[c][t];
tmpTuple[0] = tmpVal[0][t];
tmpTuple[1] = tmpVal[1][t];
tmpTuple[2] = tmpVal[2][t];
arr->SetTuple( t, &tmpTuple[0] );
}
}
else
{
for ( t = 0; t < arr->GetNumberOfTuples(); ++t )
{
for ( c = 0; c < ainfop->Components; ++c )
{
tmpTuple[c] = tmpVal[c][t];
}
arr->SetTuple( t, &tmpTuple[0] );
}
arr->SetTuple( t, &tmpTuple[0] );
}
}
}
......@@ -2002,7 +2026,11 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
arr = 0;
return 0;
}
for ( vtkIdType i = 0; i < arr->GetNumberOfTuples(); ++i )
//
// Move the check of maxTuples out of the for(;;) loop.
//
vtkIdType maxTuples = arr->GetNumberOfTuples();
for ( vtkIdType i = 0; i < maxTuples; ++i )
{
iarr->SetValue( i, tmpMap[i] );
}
......@@ -2279,7 +2307,11 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
}
else
{
for ( vtkIdType i = 0; i < iarr->GetNumberOfTuples(); ++i )
//
// Move getting the maxTuples from the for(;;) loop.
//
vtkIdType maxTuples = iarr->GetNumberOfTuples();
for ( vtkIdType i = 0; i < maxTuples ; ++i )
{
iarr->SetValue( i, tmpMap[i] );
}
......@@ -2647,7 +2679,24 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
break;
}
double* cptr = darr->GetPointer( c );
for ( t = 0; t < this->ModelParameters.num_nodes; ++t )
//
// num_nodes can get big. Lets unroll the loop
//
for ( t = 0; t+8 < this->ModelParameters.num_nodes; t+=8 )
{
*(cptr+3*0) = coordTmp[t+0];
*(cptr+3*1) = coordTmp[t+1];
*(cptr+3*2) = coordTmp[t+2];
*(cptr+3*3) = coordTmp[t+3];
*(cptr+3*4) = coordTmp[t+4];
*(cptr+3*5) = coordTmp[t+5];
*(cptr+3*6) = coordTmp[t+6];
*(cptr+3*7) = coordTmp[t+7];
cptr += 3*8;
}
for ( ; t < this->ModelParameters.num_nodes; ++t )
{
*cptr = coordTmp[t];
cptr += 3;
......@@ -2661,29 +2710,66 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
*cptr = 0.;
}
}
//
// Unrolling some of the inner loops for the most common case - dim 3.
// Also moving the maxTuples from inside of the for(;;) loops
// Also moving cos() calculations out of the bottom of loops.
//
if ( displ )
{
double* coords = darr->GetPointer( 0 );
if ( this->HasModeShapes && this->AnimateModeShapes )
{
for ( vtkIdType idx = 0; idx < displ->GetNumberOfTuples(); ++idx )
double tempDouble = this->DisplacementMagnitude * cos(2.0 * vtkMath::Pi() * this->ModeShapeTime);
if ( dim == 3)
{
vtkIdType maxTuples = arr->GetNumberOfTuples();
for ( vtkIdType idx = 0; idx < maxTuples; ++idx )
{
double* dispVal = displ->GetTuple( idx );
coords[0] += dispVal[0] * tempDouble;
coords[1] += dispVal[1] * tempDouble;
coords[2] += dispVal[2] * tempDouble;
coords += 3;
}
}
else
{
double* dispVal = displ->GetTuple( idx );
for ( c = 0; c < dim; ++c )
coords[c] += dispVal[c] * this->DisplacementMagnitude * cos( 2. * vtkMath::Pi() * this->ModeShapeTime );
for ( vtkIdType idx = 0; idx < displ->GetNumberOfTuples(); ++idx )
{
double* dispVal = displ->GetTuple( idx );
for ( c = 0; c < dim; ++c )
coords[c] += dispVal[c] * tempDouble;
coords += 3;
coords += 3;
}
}
}
else
{
for ( vtkIdType idx = 0; idx < displ->GetNumberOfTuples(); ++idx )
if ( dim == 3)
{
double* dispVal = displ->GetTuple( idx );
for ( c = 0; c < dim; ++c )
coords[c] += dispVal[c] * this->DisplacementMagnitude;
vtkIdType maxTuples = arr->GetNumberOfTuples();
for ( vtkIdType idx = 0; idx < maxTuples; ++idx )
{
double* dispVal = displ->GetTuple( idx );
coords[0] += dispVal[0] * this->DisplacementMagnitude;
coords[1] += dispVal[1] * this->DisplacementMagnitude;
coords[2] += dispVal[2] * this->DisplacementMagnitude;
coords += 3;
coords += 3;
}
}
else
{
for ( vtkIdType idx = 0; idx < displ->GetNumberOfTuples(); ++idx )
{
double* dispVal = displ->GetTuple( idx );
for ( c = 0; c < dim; ++c )
coords[c] += dispVal[c] * this->DisplacementMagnitude;
coords += 3;
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment