Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contiguous storage of CPoint(s) #966

Merged
merged 33 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
31000a6
re-write CPoint for contiguous storage
pcarruscag May 1, 2020
b9b609c
first auto pass
pcarruscag May 1, 2020
e5419ba
second auto pass
pcarruscag May 1, 2020
fc6e88d
Common compiles (with todos)
pcarruscag May 1, 2020
b413e0d
address the TODO's
pcarruscag May 1, 2020
80551a2
SU2_CFD compiles
pcarruscag May 1, 2020
87c5ba9
cgns fixes
pcarruscag May 1, 2020
0cbc58e
cleanup (still not going to work)
pcarruscag May 1, 2020
fb4224c
fix the segfaults (hopefully)
pcarruscag May 1, 2020
ab64512
Merge branch 'contiguous_cedge' into contiguous_cpoint
pcarruscag May 1, 2020
31e9148
fix for DG problems
pcarruscag May 1, 2020
047d1f2
make some methods of CPoint operate on entire set
pcarruscag May 1, 2020
7bf5e2e
Merge remote-tracking branch 'upstream/develop' into contiguous_cpoint
pcarruscag May 1, 2020
fd6fe1a
contiguous storage of adjacency info in CPoint
pcarruscag May 1, 2020
4a629c5
fix and cleanup
pcarruscag May 1, 2020
9338faf
sort Point adjacency, cleanup GriVelGrad methods
pcarruscag May 2, 2020
6830c09
add some hybrid parallel to easy geometry preprocessing methods, clea…
pcarruscag May 2, 2020
d74f0f8
make code factor happy
pcarruscag May 2, 2020
394dbd2
revert sorting of points
pcarruscag May 2, 2020
eccac75
fine tune what structures of CPoint are allocated for different uses
pcarruscag May 3, 2020
41b36c9
Merge branch 'multigrid_tweaks' into cpoint_and_mg
pcarruscag May 3, 2020
133098d
Merge branch 'multigrid_tweaks' into cpoint_and_mg
pcarruscag May 5, 2020
7b53c2f
Merge branch 'multigrid_tweaks' into cpoint_and_mg
pcarruscag May 5, 2020
6182c97
Merge branch 'multigrid_tweaks' into cpoint_and_mg
pcarruscag May 5, 2020
dc63f1e
Merge branch 'multigrid_tweaks' into cpoint_and_mg
pcarruscag May 7, 2020
2577b07
Merge remote-tracking branch 'upstream/develop' into contiguous_cpoint
pcarruscag May 8, 2020
5e509c8
experiment on adjacency sorting
pcarruscag May 12, 2020
26ffc6f
fix compilation
pcarruscag May 12, 2020
016b482
fix for MSH
pcarruscag May 12, 2020
c1da478
give up on the sorted point idea, cleanup RCM ordering
pcarruscag May 13, 2020
9d5caec
try to put the residuals back... more cleanup...
pcarruscag May 13, 2020
165ffa8
Merge branch 'develop' into contiguous_cpoint
pcarruscag May 13, 2020
5418396
use stable_sort trying to avoid one residual change
pcarruscag May 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CGeometry {
CPrimalGrid** elem; /*!< \brief Element vector (primal grid information). */
CPrimalGrid** face; /*!< \brief Face vector (primal grid information). */
CPrimalGrid*** bound; /*!< \brief Boundary vector (primal grid information). */
CPoint** node; /*!< \brief Node vector (dual grid information). */
CPoint* nodes; /*!< \brief Node vector (dual grid information). */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usual change no 1

CEdge* edges; /*!< \brief Edge vector (dual grid information). */
CVertex*** vertex; /*!< \brief Boundary Vertex vector (dual grid information). */
CTurboVertex**** turbovertex; /*!< \brief Boundary Vertex vector ordered for turbomachinery calculation(dual grid information). */
Expand Down
2 changes: 1 addition & 1 deletion Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ class CPhysicalGeometry final : public CGeometry {
*/
void SetWallDistance(su2double val) override {
for (unsigned long iPoint = 0; iPoint < GetnPoint(); iPoint++){
node[iPoint]->SetWall_Distance(val);
nodes->SetWall_Distance(iPoint, val);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usual change no 2.

}
}

Expand Down
876 changes: 447 additions & 429 deletions Common/include/geometry/dual_grid/CPoint.hpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Common/include/omp_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline size_t computeStaticChunkSize(size_t totalWork,
template<class T, class U>
void parallelCopy(size_t size, const T* src, U* dst)
{
SU2_OMP_FOR_STAT(4196)
SU2_OMP_FOR_STAT(4096)
for(size_t i=0; i<size; ++i) dst[i] = src[i];
}

Expand All @@ -169,7 +169,7 @@ void parallelCopy(size_t size, const T* src, U* dst)
template<class T, class U>
void parallelSet(size_t size, T val, U* dst)
{
SU2_OMP_FOR_STAT(4196)
SU2_OMP_FOR_STAT(4096)
for(size_t i=0; i<size; ++i) dst[i] = val;
}

Expand Down
58 changes: 46 additions & 12 deletions Common/include/toolboxes/C2DContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,52 @@ class C2DContainer :
}
};

/*!
* \brief Useful typedefs with default template parameters
*/
template<class T> using su2vector = C2DContainer<unsigned long, T, StorageType::ColumnMajor, 64, DynamicSize, 1>;
template<class T> using su2matrix = C2DContainer<unsigned long, T, StorageType::RowMajor, 64, DynamicSize, DynamicSize>;

using su2activevector = su2vector<su2double>;
using su2activematrix = su2matrix<su2double>;

using su2passivevector = su2vector<passivedouble>;
using su2passivematrix = su2matrix<passivedouble>;

/*!
* \class CVectorOfMatrix
* \brief This contrived container is used to store small matrices in a contiguous manner
* but still present the "su2double**" interface to the outside world.
* The "interface" part should be replaced by something more efficient, e.g. a "matrix view".
*/
struct CVectorOfMatrix {
su2activevector storage;
su2matrix<su2double*> interface;
unsigned long M, N;

CVectorOfMatrix() = default;

CVectorOfMatrix(unsigned long length, unsigned long rows, unsigned long cols, su2double value = 0.0) {
resize(length, rows, cols, value);
}

void resize(unsigned long length, unsigned long rows, unsigned long cols, su2double value = 0.0) {
M = rows;
N = cols;
storage.resize(length*rows*cols) = value;
interface.resize(length,rows);

for(unsigned long i=0; i<length; ++i)
for(unsigned long j=0; j<rows; ++j)
interface(i,j) = &(*this)(i,j,0);
}

su2double& operator() (unsigned long i, unsigned long j, unsigned long k) { return storage(i*M*N + j*N + k); }
const su2double& operator() (unsigned long i, unsigned long j, unsigned long k) const { return storage(i*M*N + j*N + k); }

su2double** operator[] (unsigned long i) { return interface[i]; }
const su2double* const* operator[] (unsigned long i) const { return interface[i]; }
};

/*!
* \class C2DDummyLastView
Expand Down Expand Up @@ -549,15 +595,3 @@ struct C3DDummyMiddleView
return data(i,k);
}
};

/*!
* \brief Useful typedefs with default template parameters
*/
template<class T> using su2vector = C2DContainer<unsigned long, T, StorageType::ColumnMajor, 64, DynamicSize, 1>;
template<class T> using su2matrix = C2DContainer<unsigned long, T, StorageType::RowMajor, 64, DynamicSize, DynamicSize>;

using su2activevector = su2vector<su2double>;
using su2activematrix = su2matrix<su2double>;

using su2passivevector = su2vector<passivedouble>;
using su2passivematrix = su2matrix<passivedouble>;
58 changes: 52 additions & 6 deletions Common/include/toolboxes/graph_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ class CCompressedSparsePattern {

CCompressedSparsePattern() = default;

/*!
* \brief Construct with default inner indices.
* \param[in] outerPtrBegin - Start of outer pointers.
* \param[in] outerPtrEnd - End of outer pointers.
* \param[in] defaultInnerIdx - Default value for inner indices.
*/
template<class Iterator>
CCompressedSparsePattern(Iterator outerPtrBegin, Iterator outerPtrEnd, Index_t defaultInnerIdx)
{
const auto size = outerPtrEnd - outerPtrBegin;
m_outerPtr.resize(size);
Index_t k = 0;
for(auto it = outerPtrBegin; it != outerPtrEnd; ++it)
m_outerPtr(k++) = *it;

m_innerIdx.resize(m_outerPtr(size-1)) = defaultInnerIdx;
}

/*!
* \brief Construct from rvalue refs.
* \note This is the most efficient constructor as no data copy occurs.
Expand Down Expand Up @@ -102,6 +120,25 @@ class CCompressedSparsePattern {
assert(m_innerIdx.size() == m_outerPtr(m_outerPtr.size()-1));
}

/*!
* \brief Build from a "list of lists" type object
* \param[in] lil - An object with operator [][] and method "size" e.g. vector<vector<?> >.
*/
template<class T>
CCompressedSparsePattern(const T& lil)
{
m_outerPtr.resize(lil.size()+1);
m_outerPtr(0) = 0;
for(Index_t i=1; i < Index_t(m_outerPtr.size()); ++i)
m_outerPtr(i) = m_outerPtr(i-1) + lil[i-1].size();

m_innerIdx.resize(m_outerPtr(lil.size()));
Index_t k = 0;
for(Index_t i=0; i < Index_t(lil.size()); ++i)
for(Index_t j=0; j < Index_t(lil[i].size()); ++j)
m_innerIdx(k++) = lil[i][j];
}

/*!
* \brief Build a list of pointers to the diagonal entries of the pattern.
*/
Expand Down Expand Up @@ -172,6 +209,16 @@ class CCompressedSparsePattern {
return m_innerIdx(m_outerPtr(iOuterIdx) + iNonZero);
}

/*!
* \param[in] iOuterIdx - Outer index.
* \param[in] iNonZero - Relative position of the inner index.
* \return The index of the i'th inner index associated with the outer index.
*/
inline Index_t& getInnerIdx(Index_t iOuterIdx, Index_t iNonZero) {
assert(iNonZero >= 0 && iNonZero < getNumNonZeros(iOuterIdx));
return m_innerIdx(m_outerPtr(iOuterIdx) + iNonZero);
}

/*!
* \param[in] iOuterIdx - Outer index (row/col).
* \param[in] iInnerIdx - Inner index (col/row).
Expand Down Expand Up @@ -285,6 +332,7 @@ using CEdgeToNonZeroMap = C2DContainer<unsigned long, Index_t, StorageType::RowM


using CCompressedSparsePatternUL = CCompressedSparsePattern<unsigned long>;
using CCompressedSparsePatternL = CCompressedSparsePattern<long>;
using CEdgeToNonZeroMapUL = CEdgeToNonZeroMap<unsigned long>;


Expand Down Expand Up @@ -335,14 +383,12 @@ CCompressedSparsePattern<Index_t> buildCSRPattern(Geometry_t& geometry,
* neighbors, not duplicating any existing neighbor. ---*/
for(auto jPoint : addedNeighbors)
{
auto point = geometry.node[jPoint];

if(type == ConnectivityType::FiniteVolume)
{
/*--- For FVM we know the neighbors of point j directly. ---*/
for(unsigned short iNeigh = 0; iNeigh < point->GetnPoint(); ++iNeigh)
for(unsigned short iNeigh = 0; iNeigh < geometry.nodes->GetnPoint(jPoint); ++iNeigh)
{
Index_t kPoint = point->GetPoint(iNeigh);
Index_t kPoint = geometry.nodes->GetPoint(jPoint, iNeigh);

if(neighbors.count(kPoint) == 0) // no duplication
newNeighbors.insert(kPoint);
Expand All @@ -351,9 +397,9 @@ CCompressedSparsePattern<Index_t> buildCSRPattern(Geometry_t& geometry,
else // FiniteElement
{
/*--- For FEM we need the nodes of all elements that contain point j. ---*/
for(unsigned short iNeigh = 0; iNeigh < point->GetnElem(); ++iNeigh)
for(unsigned short iNeigh = 0; iNeigh < geometry.nodes->GetnElem(jPoint); ++iNeigh)
{
auto elem = geometry.elem[point->GetElem(iNeigh)];
auto elem = geometry.elem[geometry.nodes->GetElem(jPoint, iNeigh)];

for(unsigned short iNode = 0; iNode < elem->GetnNodes(); ++iNode)
{
Expand Down
Loading