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

Updated GCC/Python Support #10340

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 9 additions & 3 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O

# COMPILER FLAGS
target_compile_options(project_options INTERFACE -pipe) # Faster compiler processing
target_compile_options(project_warnings INTERFACE -Wpedantic
)# Turn on warnings about constructs/situations that may be non-portable or outside of the standard
target_compile_options(project_warnings INTERFACE -Wall -Wextra) # Turn on warnings
target_compile_options(project_warnings INTERFACE -Wpedantic)
# Turn on warnings about constructs/situations that may be non-portable or outside of the standard
target_compile_options(project_warnings INTERFACE -Wall) # Turn on warnings
target_compile_options(project_warnings INTERFACE -Wextra) # Turn on warnings
Copy link
Member Author

Choose a reason for hiding this comment

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

No functional change, just cleaning up these lines

target_compile_options(project_warnings INTERFACE -Wno-unknown-pragmas)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
target_compile_options(project_warnings INTERFACE -Wno-deprecated-copy)
Expand All @@ -101,6 +102,11 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O
target_compile_options(project_warnings INTERFACE -Wno-unused-but-set-parameter -Wno-unused-but-set-variable)
target_compile_options(project_warnings INTERFACE -Wno-maybe-uninitialized)
target_compile_options(project_warnings INTERFACE -Wno-aggressive-loop-optimizations)
# Sadly, GCC 13.2 is throwing many false positives on dangling references and compile time array-bounds
# https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=6b927b1297e66e26e62e722bf15c921dcbbd25b9
target_compile_options(project_warnings INTERFACE -Wno-dangling-reference)
target_compile_options(project_warnings INTERFACE -Wno-array-bounds)
target_compile_options(project_warnings INTERFACE -Wno-stringop-overflow)
Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, so with GCC 13.2, I am getting lots of what appear to be false-positives. I'm not the only one seeing the warnings unexpectedly based on internet searches. Before this merges, I would like this to be investigated further, and:

  • understand why the errors are being emitted, are they actually false positives?
  • be more surgical with the warning mutes, if they will stay at any level

Copy link
Contributor

Choose a reason for hiding this comment

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

Define many/lots please? Obviously we're not fans of plain silencing a whole section of warnings, so just trying to gauge if feasible to pragma ignore some of them.

And yes, totally agreed that we should investigate if they are false positive.

(At minimum, I'd say this should be a conditional ignore)

elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
# Suppress unused-but-set warnings until more serious ones are addressed
Expand Down
2 changes: 1 addition & 1 deletion src/ConvertInputFormat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static constexpr std::array<std::string_view, static_cast<int>(OutputTypes::Num)

static constexpr auto outputTypeExperimentalStart = OutputTypes::CBOR;

template <typename... Args> void displayMessage(std::string_view str_format, Args &&... args)
template <typename... Args> void displayMessage(std::string_view str_format, Args &&...args)
Copy link
Member Author

Choose a reason for hiding this comment

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

Format only

{
fmt::print(std::cout, str_format, args...);
std::cout.write("\n", 1);
Expand Down
16 changes: 8 additions & 8 deletions src/EnergyPlus/EPVector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ private:
bool m_allocated{false};
};

template <typename T>[[nodiscard]] bool allocated(EPVector<T> const &v) noexcept
template <typename T> [[nodiscard]] bool allocated(EPVector<T> const &v) noexcept
Copy link
Member Author

Choose a reason for hiding this comment

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

Format only in this file.

{
return v.allocated();
}

template <typename T>[[nodiscard]] auto isize(const EPVector<T> &v) noexcept
template <typename T> [[nodiscard]] auto isize(const EPVector<T> &v) noexcept
{
return v.isize();
}
Expand All @@ -294,7 +294,7 @@ template <typename T>[[nodiscard]] auto isize(const EPVector<T> &v) noexcept
return std::count_if(values.cbegin(), values.cend(), [](bool v) { return v; });
}

template <typename T>[[nodiscard]] EPVector<T> pack(EPVector<T> const &v, EPVector<bool> const &mask)
template <typename T> [[nodiscard]] EPVector<T> pack(EPVector<T> const &v, EPVector<bool> const &mask)
{
EPVector<T> r;
r.reserve(mask.size());
Expand All @@ -306,7 +306,7 @@ template <typename T>[[nodiscard]] EPVector<T> pack(EPVector<T> const &v, EPVect
return r;
}

template <typename T>[[nodiscard]] Array1D<T> pack(Array1<T> const &a, EPVector<bool> const &mask)
template <typename T> [[nodiscard]] Array1D<T> pack(Array1<T> const &a, EPVector<bool> const &mask)
{
Array1D<T> r;
r.reserve(mask.size());
Expand All @@ -318,17 +318,17 @@ template <typename T>[[nodiscard]] Array1D<T> pack(Array1<T> const &a, EPVector<
return r;
}

template <typename T>[[nodiscard]] T magnitude_squared(const EPVector<T> &v)
template <typename T> [[nodiscard]] T magnitude_squared(const EPVector<T> &v)
{
return std::inner_product(v.begin(), v.end(), v.begin(), T{});
}

template <typename T, typename V>[[nodiscard]] T dot(const EPVector<T> &u, const V &v)
template <typename T, typename V> [[nodiscard]] T dot(const EPVector<T> &u, const V &v)
{
return std::inner_product(u.begin(), u.end(), v.begin(), T{});
}

template <typename Element, typename Member>[[nodiscard]] Member maxval(EPVector<Element> const &a, Member Element::*pmem)
template <typename Element, typename Member> [[nodiscard]] Member maxval(EPVector<Element> const &a, Member Element::*pmem)
{
Member v(a.empty() ? std::numeric_limits<Member>::lowest() : a(1).*pmem);
for (int i = 2, e = a.isize(); i <= e; ++i) {
Expand All @@ -343,7 +343,7 @@ template <typename Element, typename Member> inline Member sum(EPVector<Element>
return std::accumulate(c.cbegin(), c.cend(), 0.0, [&pmem](const Member &sum, const Element &e) { return sum + e.*pmem; });
}

template <typename T>[[nodiscard]] T maxval(EPVector<T> const &a)
template <typename T> [[nodiscard]] T maxval(EPVector<T> const &a)
{
auto max = std::max_element(a.begin(), a.end());
if (max == a.end()) {
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/FileSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ namespace FileSystem {
is_any<T, std::unique_ptr<fs::path>, std::unique_ptr<fmt::ostream>, std::unique_ptr<std::ostream>, std::unique_ptr<FILE *>>::value;

template <class T, FileTypes fileType>
inline constexpr bool enable_json_v = is_all_json_type(fileType) && is_any<T, nlohmann::json>::value &&
!is_any<T, std::string_view, std::string, char *>::value;
inline constexpr bool enable_json_v =
is_all_json_type(fileType) && is_any<T, nlohmann::json>::value && !is_any<T, std::string_view, std::string, char *>::value;
Copy link
Member Author

Choose a reason for hiding this comment

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

Format only.


template <FileTypes fileType> void writeFile(fs::path const &filePath, const std::string_view data)
{
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HeatBalanceKivaManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ bool KivaManager::setupKivaInstances(EnergyPlusData &state)

Real64 surfHeight = Surfaces(wl).get_average_height(state);
// round to avoid numerical precision differences
surfHeight = std::round((surfHeight)*1000.0) / 1000.0;
surfHeight = std::round((surfHeight) * 1000.0) / 1000.0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Format only -- surprised that Clang Format ever allowed this before.


if (combinationMap.count({Surfaces(wl).Construction, surfHeight}) == 0) {
// create new combination
Expand Down
9 changes: 4 additions & 5 deletions src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ namespace HeatPumpWaterToWaterCOOLING {
MaxPartLoadRat(0.0), OptPartLoadRat(0.0), LoadSideVolFlowRate(0.0), LoadSideDesignMassFlow(0.0), SourceSideVolFlowRate(0.0),
SourceSideDesignMassFlow(0.0), SourceSideInletNodeNum(0), SourceSideOutletNodeNum(0), LoadSideInletNodeNum(0), LoadSideOutletNodeNum(0),
SourceSideUACoeff(0.0), LoadSideUACoeff(0.0), CompPistonDisp(0.0), CompClearanceFactor(0.0), CompSucPressDrop(0.0), SuperheatTemp(0.0),
PowerLosses(0.0), LossFactor(0.0), HighPressCutoff(0.0), LowPressCutoff(0.0), IsOn(false),
MustRun(false), SourcePlantLoc{}, LoadPlantLoc{}, CondMassFlowIndex(0), Power(0.0), Energy(0.0), QLoad(0.0), QLoadEnergy(0.0),
QSource(0.0), QSourceEnergy(0.0), LoadSideWaterInletTemp(0.0), SourceSideWaterInletTemp(0.0), LoadSideWaterOutletTemp(0.0),
SourceSideWaterOutletTemp(0.0), Running(0), LoadSideWaterMassFlowRate(0.0), SourceSideWaterMassFlowRate(0.0), plantScanFlag(true),
beginEnvironFlag(true)
PowerLosses(0.0), LossFactor(0.0), HighPressCutoff(0.0), LowPressCutoff(0.0), IsOn(false), MustRun(false), SourcePlantLoc{},
LoadPlantLoc{}, CondMassFlowIndex(0), Power(0.0), Energy(0.0), QLoad(0.0), QLoadEnergy(0.0), QSource(0.0), QSourceEnergy(0.0),
LoadSideWaterInletTemp(0.0), SourceSideWaterInletTemp(0.0), LoadSideWaterOutletTemp(0.0), SourceSideWaterOutletTemp(0.0), Running(0),
LoadSideWaterMassFlowRate(0.0), SourceSideWaterMassFlowRate(0.0), plantScanFlag(true), beginEnvironFlag(true)
Copy link
Member Author

Choose a reason for hiding this comment

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

Format only, just changing the line cut off.

{
}

Expand Down
21 changes: 12 additions & 9 deletions src/EnergyPlus/IOFiles.hh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ private:
std::string_view spec_builder()
{
buffer.clear();
// This line seems to be the culprit with some array-bounds warnings
// during compilation on GCC 13.2. I don't see how at the moment.
// I tried pragma-ing it away but it didn't help
Copy link
Member Author

Choose a reason for hiding this comment

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

Some GCC warnings are emitted and mention this line. Not really sure. The other changes in this file are only format related.

buffer.push_back('{');
buffer.push_back(':');
// [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type]
Expand Down Expand Up @@ -492,7 +495,7 @@ inline constexpr bool is_fortran_syntax(const std::string_view format_str)

class InputOutputFile;
template <FormatSyntax formatSyntax = FormatSyntax::Fortran, typename... Args>
void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args);
void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args);

inline constexpr FormatSyntax check_syntax(const std::string_view format_str)
{
Expand Down Expand Up @@ -610,7 +613,7 @@ public:
private:
std::unique_ptr<std::iostream> os;
bool print_to_dev_null = false;
template <FormatSyntax, typename... Args> friend void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args);
template <FormatSyntax, typename... Args> friend void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args);
friend class IOFiles;
};

Expand Down Expand Up @@ -802,7 +805,7 @@ public:
}
};

template <typename... Args> void vprint(std::ostream &os, std::string_view format_str, const Args &... args)
template <typename... Args> void vprint(std::ostream &os, std::string_view format_str, const Args &...args)
{
// assert(os.good());
auto buffer = fmt::memory_buffer();
Expand All @@ -814,7 +817,7 @@ template <typename... Args> void vprint(std::ostream &os, std::string_view forma
os.write(buffer.data(), buffer.size());
}

template <typename... Args> std::string vprint(std::string_view format_str, const Args &... args)
template <typename... Args> std::string vprint(std::string_view format_str, const Args &...args)
{
auto buffer = fmt::memory_buffer();
try {
Expand Down Expand Up @@ -848,19 +851,19 @@ template <typename... Args> std::string vprint(std::string_view format_str, cons
//

namespace {
template <typename... Args> void print_fortran_syntax(std::ostream &os, std::string_view format_str, const Args &... args)
template <typename... Args> void print_fortran_syntax(std::ostream &os, std::string_view format_str, const Args &...args)
{
EnergyPlus::vprint<std::conditional_t<std::is_same_v<double, Args>, DoubleWrapper, Args>...>(os, format_str, args...);
}

template <typename... Args> std::string format_fortran_syntax(std::string_view format_str, const Args &... args)
template <typename... Args> std::string format_fortran_syntax(std::string_view format_str, const Args &...args)
{
return EnergyPlus::vprint<std::conditional_t<std::is_same_v<double, Args>, DoubleWrapper, Args>...>(format_str, args...);
}
} // namespace

template <FormatSyntax formatSyntax = FormatSyntax::Fortran, typename... Args>
void print(std::ostream &os, std::string_view format_str, Args &&... args)
void print(std::ostream &os, std::string_view format_str, Args &&...args)
{
if constexpr (formatSyntax == FormatSyntax::Fortran) {
print_fortran_syntax(os, format_str, args...);
Expand All @@ -871,7 +874,7 @@ void print(std::ostream &os, std::string_view format_str, Args &&... args)
}
}

template <FormatSyntax formatSyntax, typename... Args> void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args)
template <FormatSyntax formatSyntax, typename... Args> void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args)
{
auto *outputStream = [&]() -> std::ostream * {
if (outputFile.os) {
Expand All @@ -894,7 +897,7 @@ template <FormatSyntax formatSyntax, typename... Args> void print(InputOutputFil
}
}

template <FormatSyntax formatSyntax = FormatSyntax::Fortran, typename... Args> std::string format(std::string_view format_str, Args &&... args)
template <FormatSyntax formatSyntax = FormatSyntax::Fortran, typename... Args> std::string format(std::string_view format_str, Args &&...args)
{
if constexpr (formatSyntax == FormatSyntax::Fortran) {
return format_fortran_syntax(format_str, args...);
Expand Down
10 changes: 5 additions & 5 deletions src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace HysteresisPhaseChange {
phaseChangeState = PhaseChangeStates::FREEZING;
this->enthNew =
this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh);
} else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM) {
} else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Reordered some of the IF blocks so that Clang Format will stop trying to format them as template type argument specifiers. Even Clang Format 17 is getting confused about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

There should just be parenthesis around each condition, that'd improve readability too. And I think clang format will stop messing up.

Suggested change
} else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF) {
} else if ((this->enthNew < this->enthalpyF) && (this->enthNew > this->enthalpyM)) {

phaseChangeState = PhaseChangeStates::TRANSITION;
this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD));
} else if (this->enthNew < this->enthalpyF && updatedTempTDT > phaseChangeTempReverse) {
Expand All @@ -191,11 +191,11 @@ namespace HysteresisPhaseChange {
this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD));
this->enthalpyM = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh);
this->enthalpyF = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh);
if (updatedTempTDT < phaseChangeTempReverse && this->enthNew > this->enthalpyF) {
if (this->enthNew > this->enthalpyF && updatedTempTDT < phaseChangeTempReverse) {
phaseChangeState = PhaseChangeStates::FREEZING;
this->enthNew =
this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh);
} else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM &&
} else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF &&
(updatedTempTDT < prevTempTD || updatedTempTDT > prevTempTD)) {
phaseChangeState = PhaseChangeStates::TRANSITION;
this->enthNew =
Expand All @@ -211,7 +211,7 @@ namespace HysteresisPhaseChange {
this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse));
this->enthalpyM = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh);
this->enthalpyF = this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh);
if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM) {
if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF) {
phaseChangeState = PhaseChangeStates::TRANSITION;
this->enthNew =
(this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse));
Expand All @@ -226,7 +226,7 @@ namespace HysteresisPhaseChange {
if (this->enthNew < this->enthOld && updatedTempTDT < prevTempTD) {
phaseChangeState = PhaseChangeStates::TRANSITION;
this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD));
} else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM && updatedTempTDT < prevTempTD) {
} else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF && updatedTempTDT < prevTempTD) {
phaseChangeState = PhaseChangeStates::TRANSITION;
this->enthNew =
(this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse));
Expand Down
Loading
Loading