Skip to content
Merged
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
9 changes: 9 additions & 0 deletions Common/include/code_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,20 @@ using su2double = double;
using passivedouble = double;

/*--- Define a type for potentially lower precision operations. ---*/
#ifndef CODI_FORWARD_TYPE
#ifdef USE_MIXED_PRECISION
using su2mixedfloat = float;
#else
using su2mixedfloat = passivedouble;
#endif
#else
/*--- There is no lower precision for forward AD so undefine the macro to simplify
* the logic needed to deal with the multiple type configurations. ---*/
#ifdef USE_MIXED_PRECISION
#undef USE_MIXED_PRECISION
#endif
using su2mixedfloat = su2double;
#endif

/*--- Detect if OpDiLib has to be used. ---*/
#if defined(HAVE_OMP) && defined(CODI_REVERSE_TYPE)
Expand Down
111 changes: 106 additions & 5 deletions Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,23 @@ class CGeometry {
in point-to-point comms. */
su2double* bufD_P2PRecv{nullptr}; /*!< \brief Data structure for su2double point-to-point receive. */
su2double* bufD_P2PSend{nullptr}; /*!< \brief Data structure for su2double point-to-point send. */
#ifdef CODI_REVERSE_TYPE
passivedouble* bufPD_P2PRecv{nullptr}; /*!< \brief Data structure for passivedouble point-to-point receive. */
passivedouble* bufPD_P2PSend{nullptr}; /*!< \brief Data structure for passivedouble point-to-point send. */
#endif
#ifdef USE_MIXED_PRECISION
su2mixedfloat* bufF_P2PRecv{nullptr}; /*!< \brief Data structure for su2mixedfloat point-to-point receive. */
su2mixedfloat* bufF_P2PSend{nullptr}; /*!< \brief Data structure for su2mixedfloat point-to-point send. */
#endif
unsigned short* bufS_P2PRecv{nullptr}; /*!< \brief Data structure for unsigned long point-to-point receive. */
unsigned short* bufS_P2PSend{nullptr}; /*!< \brief Data structure for unsigned long point-to-point send. */
SU2_MPI::Request* req_P2PSend{nullptr}; /*!< \brief Data structure for point-to-point send requests. */
SU2_MPI::Request* req_P2PRecv{nullptr}; /*!< \brief Data structure for point-to-point recv requests. */

using PassiveRequest = typename SelectMPIWrapper<passivedouble>::W::Request;
PassiveRequest* reqP_P2PSend{nullptr}; /*!< \brief Data structure for point-to-point send requests. */
PassiveRequest* reqP_P2PRecv{nullptr}; /*!< \brief Data structure for point-to-point recv requests. */

/*--- Data structures for periodic communications. ---*/

int maxCountPerPeriodicPoint{0}; /*!< \brief Maximum number of pieces of data sent per vertex in periodic comms. */
Expand Down Expand Up @@ -370,7 +382,7 @@ class CGeometry {
* \param[in] countPerPoint - Number of variables per point.
* \param[in] val_reverse - Boolean controlling forward or reverse communication between neighbors.
*/
void PostP2PRecvs(CGeometry* geometry, const CConfig* config, unsigned short commType, unsigned short countPerPoint,
void PostP2PRecvs(CGeometry* geometry, const CConfig* config, COMM_TYPE commType, unsigned short countPerPoint,
bool val_reverse) const;

/*!
Expand All @@ -383,9 +395,98 @@ class CGeometry {
* \param[in] val_iMessage - Index of the message in the order they are stored.
* \param[in] val_reverse - Boolean controlling forward or reverse communication between neighbors.
*/
void PostP2PSends(CGeometry* geometry, const CConfig* config, unsigned short commType, unsigned short countPerPoint,
void PostP2PSends(CGeometry* geometry, const CConfig* config, COMM_TYPE commType, unsigned short countPerPoint,
int val_iMessage, bool val_reverse) const;

/*!
* \brief Returns the COMM_TYPE enum for a given data type.
*/
template <class T>
COMM_TYPE GetCommType() const {
if constexpr (std::is_same_v<T, su2double>) {
return COMM_TYPE::DOUBLE;
} else if constexpr (std::is_same_v<T, passivedouble>) {
return COMM_TYPE::PASSIVE_DOUBLE;
} else if constexpr (std::is_same_v<T, su2mixedfloat>) {
return COMM_TYPE::FLOAT;
} else {
static_assert(std::is_same_v<T, unsigned short>);
return COMM_TYPE::UNSIGNED_SHORT;
}
}

/*!
* \brief Returns the send buffer for a given data type.
*/
template <class T>
auto* GetP2PSendBuf() const {
if constexpr (std::is_same_v<T, su2double>) {
return bufD_P2PSend;
#ifdef CODI_REVERSE_TYPE
} else if constexpr (std::is_same_v<T, passivedouble>) {
return bufPD_P2PSend;
#endif
#ifdef USE_MIXED_PRECISION
} else if constexpr (std::is_same_v<T, su2mixedfloat>) {
return bufF_P2PSend;
#endif
} else {
static_assert(std::is_same_v<T, unsigned short>);
return bufS_P2PSend;
}
}

/*!
* \brief Returns the receive buffer for a given data type.
*/
template <class T>
auto* GetP2PRecvBuf() const {
if constexpr (std::is_same_v<T, su2double>) {
return bufD_P2PRecv;
#ifdef CODI_REVERSE_TYPE
} else if constexpr (std::is_same_v<T, passivedouble>) {
return bufPD_P2PRecv;
#endif
#ifdef USE_MIXED_PRECISION
} else if constexpr (std::is_same_v<T, su2mixedfloat>) {
return bufF_P2PRecv;
#endif
} else {
static_assert(std::is_same_v<T, unsigned short>);
return bufS_P2PRecv;
}
}

/*!
* \brief Returns the send requests for a given data type.
*/
template <class T>
auto* GetP2PSendReq() const {
if constexpr (std::is_same_v<T, su2double>) {
return req_P2PSend;
} else if constexpr (std::is_same_v<T, passivedouble> || std::is_same_v<T, su2mixedfloat>) {
return reqP_P2PSend;
} else {
static_assert(std::is_same_v<T, unsigned short>);
return req_P2PSend;
}
}

/*!
* \brief Returns the receive requests for a given data type.
*/
template <class T>
auto* GetP2PRecvReq() const {
if constexpr (std::is_same_v<T, su2double>) {
return req_P2PRecv;
} else if constexpr (std::is_same_v<T, passivedouble> || std::is_same_v<T, su2mixedfloat>) {
return reqP_P2PRecv;
} else {
static_assert(std::is_same_v<T, unsigned short>);
return req_P2PRecv;
}
}

/*!
* \brief Routine to set up persistent data structures for periodic communications.
* \param[in] geometry - Geometrical definition of the problem.
Expand All @@ -408,7 +509,7 @@ class CGeometry {
* \param[in] commType - Enumerated type for the quantity to be communicated.
* \param[in] countPerPeriodicPoint - Number of variables per point.
*/
void PostPeriodicRecvs(CGeometry* geometry, const CConfig* config, unsigned short commType,
void PostPeriodicRecvs(CGeometry* geometry, const CConfig* config, COMM_TYPE commType,
unsigned short countPerPeriodicPoint);

/*!
Expand All @@ -420,7 +521,7 @@ class CGeometry {
* \param[in] countPerPeriodicPoint - Number of variables per point.
* \param[in] val_iMessage - Index of the message in the order they are stored.
*/
void PostPeriodicSends(CGeometry* geometry, const CConfig* config, unsigned short commType,
void PostPeriodicSends(CGeometry* geometry, const CConfig* config, COMM_TYPE commType,
unsigned short countPerPeriodicPoint, int val_iMessage) const;

/*!
Expand All @@ -431,7 +532,7 @@ class CGeometry {
* \param[out] MPI_TYPE - Enumerated type for the datatype of the quantity to be communicated.
*/
void GetCommCountAndType(const CConfig* config, MPI_QUANTITIES commType, unsigned short& COUNT_PER_POINT,
unsigned short& MPI_TYPE) const;
COMM_TYPE& MPI_TYPE) const;

/*!
* \brief Routine to load a geometric quantity into the data structures for MPI point-to-point communication and to
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 @@ -220,7 +220,7 @@ class CPhysicalGeometry final : public CGeometry {
*/
void InitiateCommsAll(void* bufSend, const int* nElemSend, SU2_MPI::Request* sendReq, void* bufRecv,
const int* nElemRecv, SU2_MPI::Request* recvReq, unsigned short countPerElem,
unsigned short commType);
COMM_TYPE commType);

/*!
* \brief Routine to complete the set of non-blocking communications launched with InitiateComms() with MPI_Waitany().
Expand Down
2 changes: 1 addition & 1 deletion Common/include/geometry/meshreader/CCGNSMeshReaderFVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CCGNSMeshReaderFVM final : public CCGNSMeshReaderBase {
*/
void InitiateCommsAll(void* bufSend, const int* nElemSend, SU2_MPI::Request* sendReq, void* bufRecv,
const int* nElemRecv, SU2_MPI::Request* recvReq, unsigned short countPerElem,
unsigned short commType);
COMM_TYPE commType);

/*!
* \brief Routine to complete the set of non-blocking communications launched with InitiateComms() with MPI_Waitany().
Expand Down
5 changes: 0 additions & 5 deletions Common/include/grid_movement/CLinearElasticity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ class CLinearElasticity final : public CVolumetricMovement {

unsigned long nIterMesh; /*!< \brief Number of iterations in the mesh update. +*/

#ifndef CODI_FORWARD_TYPE
CSysMatrix<su2mixedfloat> StiffMatrix; /*!< \brief Stiffness matrix of the elasticity problem. */
CSysSolve<su2mixedfloat> System; /*!< \brief Linear solver/smoother. */
#else
CSysMatrix<su2double> StiffMatrix;
CSysSolve<su2double> System;
#endif
CSysVector<su2double> LinSysSol;
CSysVector<su2double> LinSysRes;

Expand Down
13 changes: 11 additions & 2 deletions Common/include/linear_algebra/CSysSolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,17 @@ class CSysSolve {
* \param[in] config - Definition of the particular problem.
* \param[in] directCall - If this method is called directly, or in AD context.
*/
unsigned long Solve_b(MatrixType& Jacobian, const CSysVector<su2double>& LinSysRes, CSysVector<su2double>& LinSysSol,
CGeometry* geometry, const CConfig* config, bool directCall = true);
unsigned long Solve_b(MatrixType& Jacobian, const VectorType& LinSysRes, VectorType& LinSysSol, CGeometry* geometry,
const CConfig* config, bool directCall = true);

template <class OtherType, su2enable_if<!std::is_same_v<ScalarType, OtherType>> = 0>
unsigned long Solve_b(MatrixType& Jacobian, const CSysVector<OtherType>& LinSysRes, CSysVector<OtherType>& LinSysSol,
CGeometry* geometry, const CConfig* config, bool directCall = true) {
HandleTemporariesIn(LinSysRes, LinSysSol);
auto iter = Solve_b(Jacobian, *LinSysRes_ptr, *LinSysSol_ptr, geometry, config, directCall);
HandleTemporariesOut(LinSysSol);
return iter;
}

/*!
* \brief Get the number of iterations.
Expand Down
18 changes: 11 additions & 7 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ const int MASTER_NODE = 0; /*!< \brief Master node for MPI parallelization.
const int SINGLE_NODE = 1; /*!< \brief There is only a node in the MPI parallelization. */
const int SINGLE_ZONE = 1; /*!< \brief There is only a zone. */

const unsigned short COMM_TYPE_UNSIGNED_LONG = 1; /*!< \brief Communication type for unsigned long. */
const unsigned short COMM_TYPE_LONG = 2; /*!< \brief Communication type for long. */
const unsigned short COMM_TYPE_UNSIGNED_SHORT = 3; /*!< \brief Communication type for unsigned short. */
const unsigned short COMM_TYPE_DOUBLE = 4; /*!< \brief Communication type for double. */
const unsigned short COMM_TYPE_CHAR = 5; /*!< \brief Communication type for char. */
const unsigned short COMM_TYPE_SHORT = 6; /*!< \brief Communication type for short. */
const unsigned short COMM_TYPE_INT = 7; /*!< \brief Communication type for int. */
enum class COMM_TYPE {
UNSIGNED_LONG, /*!< \brief Communication type for unsigned long. */
LONG, /*!< \brief Communication type for long. */
UNSIGNED_SHORT, /*!< \brief Communication type for unsigned short. */
FLOAT, /*!< \brief Communication type for su2mixedfloat. */
DOUBLE, /*!< \brief Communication type for double. */
PASSIVE_DOUBLE, /*!< \brief Communication type for passivedouble. */
CHAR, /*!< \brief Communication type for char. */
SHORT, /*!< \brief Communication type for short. */
INT, /*!< \brief Communication type for int. */
};

/*!
* \brief Types of geometric entities based on VTK nomenclature
Expand Down
4 changes: 2 additions & 2 deletions Common/include/parallelization/mpi_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern MediTypes* mediTypes;

#else
class CBaseMPIWrapper;
typedef CBaseMPIWrapper SU2_MPI;
using SU2_MPI = CBaseMPIWrapper;
#endif // defined CODI_REVERSE_TYPE || defined CODI_FORWARD_TYPE

/*!
Expand Down Expand Up @@ -632,7 +632,7 @@ struct SelectMPIWrapper<passivedouble> {
#endif

/*--- Specialize for the low precision type. ---*/
#if defined USE_MIXED_PRECISION
#if defined(USE_MIXED_PRECISION)
template <>
struct SelectMPIWrapper<su2mixedfloat> {
#if defined HAVE_MPI
Expand Down
Loading
Loading