Skip to content

Commit 62133e6

Browse files
committed
fix bug in signature of Allgatherv in base mpi wrapper
1 parent a46aff3 commit 62133e6

6 files changed

Lines changed: 36 additions & 58 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5089,7 +5089,7 @@ class CConfig {
50895089
* Gradients are w.r.t density, velocity[3], and pressure. when 2D gradient w.r.t. 3rd component of velocity set to 0.
50905090
*/
50915091
su2double GetCoeff_ObjChainRule(unsigned short iVar) const { return Obj_ChainRuleCoeff[iVar]; }
5092-
5092+
50935093
/*!
50945094
* \author H. Kline
50955095
* \brief Get the flag indicating whether to comput a combined objective.
@@ -6781,7 +6781,7 @@ class CConfig {
67816781
* \brief Get the type of wall and roughness height on a wall boundary (Heatflux or Isothermal).
67826782
* \param[in] val_index - Index corresponding to the boundary.
67836783
* \return The wall type and roughness height.
6784-
*/
6784+
*/
67856785
pair<unsigned short, su2double> GetWallRoughnessProperties(string val_marker) const;
67866786

67876787
/*!

Common/include/geometry/CPhysicalGeometry.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ class CPhysicalGeometry final : public CGeometry {
105105
unsigned long *Elem_ID_Line_Linear{nullptr};
106106
unsigned long *Elem_ID_BoundTria_Linear{nullptr};
107107
unsigned long *Elem_ID_BoundQuad_Linear{nullptr};
108-
int *GlobalMarkerStorageDispl{nullptr};
109-
su2double *GlobalRoughness_Height{nullptr};
108+
109+
vector<int> GlobalMarkerStorageDispl;
110+
vector<su2double> GlobalRoughness_Height;
110111

111112
public:
112113
/*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/

Common/include/mpi_structure.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class CBaseMPIWrapper {
417417
void *recvbuf, int recvcnt, Datatype recvtype, Comm comm);
418418

419419
static void Allgatherv(void *sendbuf, int sendcnt, Datatype sendtype,
420-
void *recvbuf, int recvcnt, int *displs, Datatype recvtype, Comm comm);
420+
void *recvbuf, int *recvcnt, int *displs, Datatype recvtype, Comm comm);
421421

422422
static void Sendrecv(void *sendbuf, int sendcnt, Datatype sendtype,
423423
int dest, int sendtag, void *recvbuf, int recvcnt,

Common/include/mpi_structure.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ inline void CBaseMPIWrapper::Scatter(void *sendbuf, int sendcnt, Datatype sendty
612612
}
613613

614614
inline void CBaseMPIWrapper::Allgatherv(void *sendbuf, int sendcnt, Datatype sendtype,
615-
void *recvbuf, int recvcnt, int *displs, Datatype recvtype, Comm comm){
615+
void *recvbuf, int *recvcnt, int *displs, Datatype recvtype, Comm comm){
616616
CopyData(sendbuf, recvbuf, sendcnt, sendtype);
617617
}
618618

Common/src/CConfig.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void CConfig::SetPointersNull(void) {
865865
Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr;
866866
Inlet_Velocity = nullptr; Inflow_Mach = nullptr; Inflow_Pressure = nullptr;
867867
Exhaust_Pressure = nullptr; Outlet_Pressure = nullptr; Isothermal_Temperature= nullptr;
868-
868+
869869
ElasticityMod = nullptr; PoissonRatio = nullptr; MaterialDensity = nullptr;
870870

871871
Load_Dir = nullptr; Load_Dir_Value = nullptr; Load_Dir_Multiplier = nullptr;
@@ -4677,8 +4677,8 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
46774677
}
46784678

46794679
/*--- Update kind_wall when a non zero roughness value is specified. ---*/
4680-
for (iMarker = 0; iMarker < nWall; iMarker++)
4681-
if (Roughness_Height[iMarker] != 0.0)
4680+
for (iMarker = 0; iMarker < nWall; iMarker++)
4681+
if (Roughness_Height[iMarker] != 0.0)
46824682
Kind_Wall[iMarker] = ROUGH;
46834683

46844684
/*--- Check if a non solid wall marker was specified as rough. ---*/
@@ -5334,7 +5334,7 @@ void CConfig::SetMarkers(unsigned short val_software) {
53345334
Marker_CfgFile_KindBC[iMarker_CfgFile] = FLOWLOAD_BOUNDARY;
53355335
iMarker_CfgFile++;
53365336
}
5337-
5337+
53385338
for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) {
53395339
Marker_CfgFile_Monitoring[iMarker_CfgFile] = NO;
53405340
for (iMarker_Monitoring = 0; iMarker_Monitoring < nMarker_Monitoring; iMarker_Monitoring++)
@@ -5460,7 +5460,7 @@ void CConfig::SetMarkers(unsigned short val_software) {
54605460
if (Marker_CfgFile_TagBound[iMarker_CfgFile] == Marker_PyCustom[iMarker_PyCustom])
54615461
Marker_CfgFile_PyCustom[iMarker_CfgFile] = YES;
54625462
}
5463-
5463+
54645464
}
54655465

54665466
void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) {

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ CPhysicalGeometry::CPhysicalGeometry(CGeometry *geometry,
312312
delete [] Elem_ID_BoundTria_Linear;
313313
delete [] Elem_ID_BoundQuad_Linear;
314314

315-
delete[] GlobalMarkerStorageDispl;
316-
delete[] GlobalRoughness_Height;
317-
318315
}
319316

320317
CPhysicalGeometry::~CPhysicalGeometry(void) {
@@ -11242,8 +11239,6 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa
1124211239
/*--- Step 3: Loop over all interior mesh nodes and compute minimum ---*/
1124311240
/*--- distance to a solid wall element ---*/
1124411241
/*--------------------------------------------------------------------------*/
11245-
int rank;
11246-
SU2_MPI::Comm_rank(MPI_COMM_WORLD, &rank);
1124711242

1124811243
/*--- Store marker list and roughness in a global array. ---*/
1124911244
if (config->GetnRoughWall() > 0) SetGlobalMarkerRoughness(config);
@@ -11263,65 +11258,47 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa
1126311258
WallADT->DetermineNearestElement(nodes->GetCoord(iPoint), dist, markerID, elemID, rankID);
1126411259

1126511260
nodes->SetWall_Distance(iPoint, min(dist,nodes->GetWall_Distance(iPoint)));
11261+
1126611262
if (config->GetnRoughWall() > 0) {
11267-
auto index = GlobalMarkerStorageDispl[rankID]+ markerID;
11263+
auto index = GlobalMarkerStorageDispl[rankID] + markerID;
1126811264
auto localRoughness = GlobalRoughness_Height[index];
1126911265
nodes->SetRoughnessHeight(iPoint, localRoughness);
11270-
}
11266+
}
1127111267
}
11272-
11268+
1127311269
}
1127411270
// end SU2_OMP_PARALLEL
1127511271
}
1127611272

1127711273
void CPhysicalGeometry::SetGlobalMarkerRoughness(const CConfig* config) {
1127811274

11279-
unsigned short iMarker;
11280-
unsigned short nMarker_All = config->GetnMarker_All();
11281-
11282-
int *displs = new int [size];
11283-
int* recvCounts = new int [size];
11284-
int sizeLocal = (int) nMarker_All; // number of local markers
11285-
11286-
//Communicate size of local marker array and make an array large enough to hold all data
11287-
SU2_MPI::Allgather(&sizeLocal, 1, MPI_INT, recvCounts, 1,
11288-
MPI_INT, MPI_COMM_WORLD);
11289-
11290-
// displacements based on size on each rank
11291-
displs[0] = 0;
11292-
for(int i=1; i<size; ++i) displs[i] = displs[i-1] + recvCounts[i-1];
11275+
const auto nMarker_All = config->GetnMarker_All();
11276+
11277+
vector<int> recvCounts(size);
11278+
auto sizeLocal = static_cast<int>(nMarker_All); // number of local markers
11279+
11280+
/*--- Communicate size of local marker array and make an array large enough to hold all data. ---*/
11281+
SU2_MPI::Allgather(&sizeLocal, 1, MPI_INT, recvCounts.data(), 1, MPI_INT, MPI_COMM_WORLD);
1129311282

1129411283
/*--- Set the global array of displacements, needed to access the correct roughness element. ---*/
11295-
if (GlobalMarkerStorageDispl == nullptr) GlobalMarkerStorageDispl = new int [size];
11284+
GlobalMarkerStorageDispl.resize(size);
1129611285
GlobalMarkerStorageDispl[0] = 0;
11297-
for (int iRank = 1; iRank < size; iRank++)
11298-
GlobalMarkerStorageDispl[iRank] = displs[iRank];
11299-
11300-
//total size
11301-
int sizeGlobal = displs[size-1] + recvCounts[size-1];
11286+
for (int iRank = 1; iRank < size; iRank++)
11287+
GlobalMarkerStorageDispl[iRank] = GlobalMarkerStorageDispl[iRank-1] + recvCounts[iRank-1];
11288+
11289+
/*--- Total size ---*/
11290+
const auto sizeGlobal = GlobalMarkerStorageDispl[size-1] + recvCounts[size-1];
1130211291

1130311292
/*--- Allocate local and global arrays to hold roughness. ---*/
11304-
su2double *localRough = new su2double [nMarker_All]; // local number of markers
11305-
su2double *globalRough = new su2double[sizeGlobal]; // all markers including send recieve
11306-
pair<unsigned short, su2double> wallprop;
11293+
vector<su2double> localRough(nMarker_All); // local number of markers
11294+
GlobalRoughness_Height.resize(sizeGlobal); // all markers including send recieve
1130711295

11308-
for (iMarker = 0; iMarker < nMarker_All; iMarker++) {
11309-
wallprop = config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker));
11296+
for (auto iMarker = 0u; iMarker < nMarker_All; iMarker++) {
11297+
auto wallprop = config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker));
1131011298
localRough[iMarker] = wallprop.second;
1131111299
}
1131211300

11313-
SU2_MPI::Allgatherv( localRough, sizeLocal, MPI_DOUBLE, globalRough ,
11314-
recvCounts, displs, MPI_DOUBLE,
11315-
MPI_COMM_WORLD);
11316-
11317-
/*--- Set the global array of roughness per marker. ---*/
11318-
if (GlobalRoughness_Height == nullptr) GlobalRoughness_Height = new su2double [sizeGlobal];
11319-
for (int iMarker = 0; iMarker < sizeGlobal; iMarker++)
11320-
GlobalRoughness_Height[iMarker] = globalRough[iMarker];
11321-
11322-
/*--- Deallocate local variables. ---*/
11323-
delete [] displs;
11324-
delete [] recvCounts;
11325-
delete [] localRough;
11326-
delete [] globalRough;
11301+
/*--- Finally, gather the roughness of all markers. ---*/
11302+
SU2_MPI::Allgatherv(localRough.data(), sizeLocal, MPI_DOUBLE, GlobalRoughness_Height.data(),
11303+
recvCounts.data(), GlobalMarkerStorageDispl.data(), MPI_DOUBLE, MPI_COMM_WORLD);
1132711304
}

0 commit comments

Comments
 (0)