Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/parallelization/mpi_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void CBaseMPIWrapper<ScalarType>::CopyData(const void* sendbuf, void* recvbuf, i
}

template class CBaseMPIWrapper<su2double>;
#if defined CODI_REVERSE_TYPE
#if defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE)
template class CBaseMPIWrapper<passivedouble>;
#endif
#if defined(USE_MIXED_PRECISION) && !defined(USE_SINGLE_PRECISION)
Expand Down
2 changes: 1 addition & 1 deletion Common/include/parallelization/mpi_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ struct SelectMPIWrapper {
};

/*--- In AD we specialize for the passive wrapper. ---*/
#if defined CODI_REVERSE_TYPE
#if defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE)
template <>
struct SelectMPIWrapper<passivedouble> {
#if defined HAVE_MPI
Expand Down
12 changes: 12 additions & 0 deletions SU2_CFD/include/output/filewriter/CFileWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ using namespace std;

class CFileWriter{
protected:
/*!
* \brief Wall-clock time in seconds, also without MPI and OpenMP (where SU2_MPI::Wtime measures CPU time).
*/
static passivedouble WallTime();

passivedouble fileStartTime = 0.0; /*!< \brief Time when the file was opened, to time the whole write. */

/*!
* \brief Set the write time to the largest one over all ranks and compute the bandwidth with the file size.
* \param[in] elapsed - Write time of this rank.
*/
void UpdateBandwidth(passivedouble elapsed);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pre-existing, but this PR now feeds the result into the bandwidth report.

DetermineFilesize (line 86) returns -1 cast to unsigned long when stat fails. That value now reaches UpdateBandwidth. For example, a build without TecIO that asks for TECPLOT_BINARY writes no file, so the file size becomes ~1.8e19 and the reported bandwidth is absurd.

Suggestion: return 0 (or report the error) when stat fails.


/*!
* \brief The MPI rank
Expand Down
6 changes: 6 additions & 0 deletions SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ class CParallelDataSorter{
void PrepareSendBuffers(std::vector<unsigned long>& globalID);

public:
/*!
* \brief Stop with an error if count * entries does not fit in an int (node IDs and MPI counts are int).
* \param[in] count - Number of items.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: \param[in] count - Number of items. only restates the parameter name. Either drop the line or say what is counted (elements, nodes, ...).

* \param[in] entries - Number of int entries per item.
*/
static void CheckIntCount(unsigned long count, unsigned long entries = 1);

/*!
* \brief Constructor
Expand Down
6 changes: 3 additions & 3 deletions SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CCGNSFileWriter::WriteData(string val_filename) {
val_filename.append(fileExt);

/*--- Set a timer for the file writing. ---*/
startTime = SU2_MPI::Wtime();
startTime = WallTime();

/*--- Names of all the nodes, before the file is opened: a duplicate name would stop the run with the file open. ---*/
PrepareNames();
Expand Down Expand Up @@ -75,10 +75,10 @@ void CCGNSFileWriter::WriteData(string val_filename) {
#endif

/*--- Compute and store the write time and the bandwidth. ---*/
stopTime = SU2_MPI::Wtime();
stopTime = WallTime();
usedTime = stopTime - startTime;
fileSize = DetermineFilesize(val_filename);
bandwidth = fileSize / (1.0e6) / usedTime;
UpdateBandwidth(SU2_TYPE::GetValue(usedTime));

#endif
}
Expand Down
2 changes: 2 additions & 0 deletions SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto

/*--- Create a linear partition --- */

CheckIntCount(nGlobalPointBeforeSort);
linearPartitioner.Initialize(nGlobalPointBeforeSort, 0);

/*--- Prepare the send buffers ---*/
Expand Down Expand Up @@ -150,6 +151,7 @@ void CFEMDataSorter::SortVolumetricConnectivity(CConfig *config, CGeometry *geom

/* Allocate the memory to store the connectivity if the size is
larger than zero. */
CheckIntCount(nSubElem_Local, NODES_PER_ELEMENT);
int *Conn_SubElem = nullptr;
if(nSubElem_Local > 0) Conn_SubElem = new int[nSubElem_Local*NODES_PER_ELEMENT];

Expand Down
3 changes: 3 additions & 0 deletions SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void CFVMDataSorter::SetHaloPoints(CGeometry *geometry, CConfig *config){
}

void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) {
CheckIntCount(geometry->GetnElem());

/*--- Sort connectivity for each type of element (excluding halos). Note
In these routines, we sort the connectivity into a linear partitioning
Expand Down Expand Up @@ -242,7 +243,9 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config,
if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++;
if ((ii != rank) && (nElem_Cum[ii+1] > 0)) nRecvs++;

CheckIntCount(static_cast<unsigned long>(nElem_Send[ii]) + nElem_Send[ii+1], NODES_PER_ELEMENT);
nElem_Send[ii+1] += nElem_Send[ii];
CheckIntCount(static_cast<unsigned long>(nElem_Cum[ii]) + nElem_Cum[ii+1], NODES_PER_ELEMENT);
nElem_Cum[ii+1] += nElem_Cum[ii];
}

Expand Down
11 changes: 11 additions & 0 deletions SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
#include "../../../include/output/filewriter/CParallelDataSorter.hpp"
#include <cassert>
#include <numeric>
#include <limits>

void CParallelDataSorter::CheckIntCount(unsigned long count, unsigned long entries) {
if (entries && count > static_cast<unsigned long>(std::numeric_limits<int>::max()) / entries)
SU2_MPI::Error("Output exceeds the supported 32-bit node ID or MPI count range", CURRENT_FUNCTION);
}

CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector<string> &valFieldNames) :
rank(SU2_MPI::GetRank()),
Expand Down Expand Up @@ -240,6 +246,8 @@ void CParallelDataSorter::SortOutputData() {
}

void CParallelDataSorter::PrepareSendBuffers(std::vector<unsigned long>& globalID){
CheckIntCount(nGlobalPointBeforeSort);
CheckIntCount(nLocalPointsBeforeSort);

unsigned long iPoint;
unsigned short iProcessor;
Expand Down Expand Up @@ -281,7 +289,9 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector<unsigned long>& globalI
if ((ii != rank) && (nPoint_Send[ii+1] > 0)) nSends++;
if ((ii != rank) && (nPoint_Recv[ii+1] > 0)) nRecvs++;

CheckIntCount(static_cast<unsigned long>(nPoint_Send[ii]) + nPoint_Send[ii+1], 1);
nPoint_Send[ii+1] += nPoint_Send[ii];
CheckIntCount(static_cast<unsigned long>(nPoint_Recv[ii]) + nPoint_Recv[ii+1], 1);
nPoint_Recv[ii+1] += nPoint_Recv[ii];
}

Expand Down Expand Up @@ -378,6 +388,7 @@ void CParallelDataSorter::SetTotalElements(){

nElemGlobal = std::accumulate(nElemPerTypeGlobal.begin(), nElemPerTypeGlobal.end(), 0ul);
nElem = std::accumulate(nElemPerType.begin(), nElemPerType.end(), 0ul);
CheckIntCount(nElemGlobal);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Large meshes are rejected although the global element count is never stored as an int.

CheckIntCount(nElemGlobal) limits the global element count to INT_MAX, but nElemGlobal is unsigned long, and the Paraview XML writer already switches to int64 connectivity and offsets (connInt64). Only node IDs and per-rank counts are int.

Example: a tet mesh with 2.3e9 elements and ~4e8 nodes fits everywhere it matters, but this check aborts the run at its first output.

Suggestion: drop the global element check, and check only the per-rank element/connectivity counts and the global node count.


nConn = 0;
nConnGlobal = 0;
Expand Down
Loading