Skip to content

Commit 5f3d1d8

Browse files
authored
Merge pull request #7521 from nilsvu/upgrade_container
Fix compiling with gcc 15, nvcc 13
2 parents 9488965 + 6ea2c00 commit 5f3d1d8

7 files changed

Lines changed: 69 additions & 49 deletions

File tree

cmake/EnableWarnings.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ include(AddCxxFlag)
66
# On systems where we can't use -isystem (Cray), we don't want
77
# all the warnings enabled because we get flooded with system warnings.
88
option(ENABLE_WARNINGS "Enable the default warning level" ON)
9+
# `-Wdisabled-optimization` is deliberately not enabled. It reports that the
10+
# compiler gave up on an optimization because a function exceeded an internal
11+
# size limit, which our template-heavy code hits routinely and cannot act on.
912
if(${ENABLE_WARNINGS})
1013
create_cxx_flags_target(
1114
"-W;\
1215
-Wall;\
1316
-Wcast-align;\
1417
-Wcast-qual;\
15-
-Wdisabled-optimization;\
1618
-Wdocumentation;\
1719
-Wextra;\
1820
-Wformat-nonliteral;\

cmake/FindCharm.cmake

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,32 @@ execute_process(
358358
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tmp/
359359
ERROR_VARIABLE CHARM_MODULEINIT_ERROR
360360
)
361+
# Append a weak `CkRegisterMainModule`. `libck` expects it from the executable,
362+
# but only a generated main module defines it, so executables without one (e.g.
363+
# `ConvertComposeTable`) fail to link. They never call it, hence the abort,
364+
# which also catches an executable linked without its main module instead of
365+
# letting Charm++ hang with no main chare. It goes into the generated file
366+
# because `tools/WrapExecutableLinker.sh` stubs out every `*.cpp.o` on the link
367+
# line, which would break a source file of its own. Copy it with
368+
# `configure_file` so its timestamp only changes with its contents: this object
369+
# file is a link dependency of every executable.
370+
file(READ ${CMAKE_BINARY_DIR}/tmp/CharmModuleInit.C CHARM_MODULEINIT_CONTENTS)
371+
file(WRITE ${CMAKE_BINARY_DIR}/tmp/CharmModuleInitWithMainModule.C
372+
"${CHARM_MODULEINIT_CONTENTS}"
373+
"#include <cstdio>\n"
374+
"#include <cstdlib>\n"
375+
"extern \"C\" __attribute__((weak)) void CkRegisterMainModule() {\n"
376+
" fprintf(stderr,\n"
377+
" \"No Charm++ main module was registered. This executable was \"\n"
378+
" \"linked without the object file that defines its main \"\n"
379+
" \"module.\\n\");\n"
380+
" abort();\n"
381+
"}\n"
382+
)
361383
configure_file(
362-
${CMAKE_BINARY_DIR}/tmp/CharmModuleInit.C
363-
${CMAKE_BINARY_DIR}
384+
${CMAKE_BINARY_DIR}/tmp/CharmModuleInitWithMainModule.C
385+
${CMAKE_BINARY_DIR}/CharmModuleInit.C
386+
COPYONLY
364387
)
365388
add_library(CharmModuleInit OBJECT ${CMAKE_BINARY_DIR}/CharmModuleInit.C)
366389
# -w -- suppress all warnings because this is charm-generated source

src/DataStructures/DataBox/DataBox.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,8 @@ struct tag_and_bases<Tag, Others...>
797797

798798
template <typename... Tags>
799799
auto DataBox<tmpl::list<Tags...>>::compute_tag_graphs() -> TagGraphs {
800+
// The member function pointers below are `static_cast` explicitly because
801+
// deducing them makes nvcc name the host-only members in device code.
800802
TagGraphs result{};
801803
// Compute graphs for retrieving tags
802804
const auto process_tag = [&result]<typename ConcreteTag>(
@@ -807,7 +809,8 @@ auto DataBox<tmpl::list<Tags...>>::compute_tag_graphs() -> TagGraphs {
807809
const std::string tag_name = pretty_type::get_name<Tag>();
808810
detail::set_or_null_if_ambiguous(
809811
make_not_null(&result.tag_retrieval_functions), tag_name,
810-
&DataBox::template get_item_as_void_pointer<ConcreteTag>);
812+
static_cast<const void* (DataBox::*)() const>(
813+
&DataBox::template get_item_as_void_pointer<ConcreteTag>));
811814
result.tag_aliases[concrete_tag_name].push_back(tag_name);
812815
});
813816
};
@@ -852,7 +855,8 @@ auto DataBox<tmpl::list<Tags...>>::compute_tag_graphs() -> TagGraphs {
852855
result.tags_and_dependents[argument_tag].push_back(tag_name);
853856
}
854857
result.tags_and_reset_functions[tag_name] =
855-
&DataBox::template reset_compute_item<compute_tag>;
858+
static_cast<bool (DataBox::*)()>(
859+
&DataBox::template reset_compute_item<compute_tag>);
856860
});
857861

858862
// Set mutation function
@@ -863,8 +867,9 @@ auto DataBox<tmpl::list<Tags...>>::compute_tag_graphs() -> TagGraphs {
863867
const std::string tag_name = pretty_type::get_name<Tag>();
864868
detail::set_or_null_if_ambiguous(
865869
make_not_null(&result.tag_mutate_functions), tag_name,
866-
&DataBox::template get_item_as_void_pointer_for_mutate<
867-
MutableTag>);
870+
static_cast<void* (DataBox::*)()>(
871+
&DataBox::template get_item_as_void_pointer_for_mutate<
872+
MutableTag>));
868873
detail::set_or_null_if_ambiguous(
869874
make_not_null(&result.mutate_mutable_subitems_functions),
870875
tag_name,
@@ -873,7 +878,9 @@ auto DataBox<tmpl::list<Tags...>>::compute_tag_graphs() -> TagGraphs {
873878
detail::set_or_null_if_ambiguous(
874879
make_not_null(&result.reset_compute_items_after_mutate_functions),
875880
tag_name,
876-
&DataBox::template reset_compute_items_after_mutate<MutableTag>);
881+
static_cast<void (DataBox::*)()>(
882+
&DataBox::template reset_compute_items_after_mutate<
883+
MutableTag>));
877884
});
878885
});
879886
return result;

src/DataStructures/TaggedTuple.hpp

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ class er;
3131
*/
3232
namespace tuples {
3333

34-
#if __cplusplus >= 201402L
35-
#define TUPLES_LIB_CONSTEXPR_CXX_14 constexpr
36-
#else
37-
#define TUPLES_LIB_CONSTEXPR_CXX_14
38-
#endif
39-
4034
namespace tuples_detail {
4135

4236
template <class T>
@@ -167,11 +161,7 @@ class TaggedTupleLeaf<Tag, false> {
167161
~TaggedTupleLeaf() = default;
168162

169163
// Note: name get_data instead of get to enable structured binding support.
170-
#if __cplusplus < 201402L
171-
value_type& get_data() { return value_; }
172-
#else
173164
constexpr value_type& get_data() { return value_; }
174-
#endif
175165
constexpr const value_type& get_data() const { return value_; }
176166

177167
bool swap(TaggedTupleLeaf& t) {
@@ -208,11 +198,7 @@ class TaggedTupleLeaf<Tag, true> : private Tag::type {
208198
~TaggedTupleLeaf() = default;
209199

210200
// Note: name get_data instead of get to enable structured binding support.
211-
#if __cplusplus < 201402L
212-
value_type& get_data() { return static_cast<value_type&>(*this); }
213-
#else
214201
constexpr value_type& get_data() { return static_cast<value_type&>(*this); }
215-
#endif
216202

217203
constexpr const value_type& get_data() const {
218204
return static_cast<const value_type&>(*this);
@@ -549,15 +535,14 @@ inline constexpr typename tmpl::at_c<tmpl::list<Tags...>, I>::type& get(
549535
namespace tuples_detail {
550536
struct equal {
551537
template <class T, class U>
552-
static TUPLES_LIB_CONSTEXPR_CXX_14 void apply(T const& lhs, U const& rhs,
553-
bool* result) {
538+
static constexpr void apply(T const& lhs, U const& rhs, bool* result) {
554539
*result = *result and lhs == rhs;
555540
}
556541
};
557542

558543
template <class... LTags, class... RTags>
559-
TUPLES_LIB_CONSTEXPR_CXX_14 bool tuple_equal_impl(
560-
TaggedTuple<LTags...> const& lhs, TaggedTuple<RTags...> const& rhs) {
544+
constexpr bool tuple_equal_impl(TaggedTuple<LTags...> const& lhs,
545+
TaggedTuple<RTags...> const& rhs) {
561546
bool equal = true;
562547
// This short circuits in the sense that the operator== is only evaluated if
563548
// the result thus far is true
@@ -570,25 +555,24 @@ TUPLES_LIB_CONSTEXPR_CXX_14 bool tuple_equal_impl(
570555
template <class... LTags, class... RTags,
571556
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
572557
nullptr>
573-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator==(TaggedTuple<LTags...> const& lhs,
574-
TaggedTuple<RTags...> const& rhs) {
558+
constexpr bool operator==(TaggedTuple<LTags...> const& lhs,
559+
TaggedTuple<RTags...> const& rhs) {
575560
return tuples_detail::tuple_equal_impl(lhs, rhs);
576561
}
577562

578563
template <class... LTags, class... RTags,
579564
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
580565
nullptr>
581-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator!=(TaggedTuple<LTags...> const& lhs,
582-
TaggedTuple<RTags...> const& rhs) {
566+
constexpr bool operator!=(TaggedTuple<LTags...> const& lhs,
567+
TaggedTuple<RTags...> const& rhs) {
583568
return not(lhs == rhs);
584569
}
585570

586571
namespace tuples_detail {
587572
struct less {
588573
template <class T, class U>
589-
static TUPLES_LIB_CONSTEXPR_CXX_14 void apply(T const& lhs, U const& rhs,
590-
bool* last_rhs_less_lhs,
591-
bool* result) {
574+
static constexpr void apply(T const& lhs, U const& rhs,
575+
bool* last_rhs_less_lhs, bool* result) {
592576
if (*result or *last_rhs_less_lhs) {
593577
return;
594578
}
@@ -601,8 +585,8 @@ struct less {
601585
};
602586

603587
template <class... LTags, class... RTags>
604-
TUPLES_LIB_CONSTEXPR_CXX_14 bool tuple_less_impl(
605-
TaggedTuple<LTags...> const& lhs, TaggedTuple<RTags...> const& rhs) {
588+
constexpr bool tuple_less_impl(TaggedTuple<LTags...> const& lhs,
589+
TaggedTuple<RTags...> const& rhs) {
606590
bool result = false;
607591
bool last_rhs_less_lhs = false;
608592
static_cast<void>(
@@ -616,32 +600,32 @@ TUPLES_LIB_CONSTEXPR_CXX_14 bool tuple_less_impl(
616600
template <class... LTags, class... RTags,
617601
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
618602
nullptr>
619-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator<(TaggedTuple<LTags...> const& lhs,
620-
TaggedTuple<RTags...> const& rhs) {
603+
constexpr bool operator<(TaggedTuple<LTags...> const& lhs,
604+
TaggedTuple<RTags...> const& rhs) {
621605
return tuples_detail::tuple_less_impl(lhs, rhs);
622606
}
623607

624608
template <class... LTags, class... RTags,
625609
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
626610
nullptr>
627-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator>(TaggedTuple<LTags...> const& lhs,
628-
TaggedTuple<RTags...> const& rhs) {
611+
constexpr bool operator>(TaggedTuple<LTags...> const& lhs,
612+
TaggedTuple<RTags...> const& rhs) {
629613
return rhs < lhs;
630614
}
631615

632616
template <class... LTags, class... RTags,
633617
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
634618
nullptr>
635-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator<=(TaggedTuple<LTags...> const& lhs,
636-
TaggedTuple<RTags...> const& rhs) {
619+
constexpr bool operator<=(TaggedTuple<LTags...> const& lhs,
620+
TaggedTuple<RTags...> const& rhs) {
637621
return not(rhs < lhs);
638622
}
639623

640624
template <class... LTags, class... RTags,
641625
typename std::enable_if<sizeof...(LTags) == sizeof...(RTags)>::type* =
642626
nullptr>
643-
TUPLES_LIB_CONSTEXPR_CXX_14 bool operator>=(TaggedTuple<LTags...> const& lhs,
644-
TaggedTuple<RTags...> const& rhs) {
627+
constexpr bool operator>=(TaggedTuple<LTags...> const& lhs,
628+
TaggedTuple<RTags...> const& rhs) {
645629
return not(lhs < rhs);
646630
}
647631

src/Parallel/StaticSpscQueue.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class StaticSpscQueue {
106106
while (next_write_index == read_index_cache_) {
107107
read_index_cache_ = read_index_.load(std::memory_order_acquire);
108108
}
109+
// Destroy the object this slot already holds (see `data_`).
110+
data_[write_index + padding_].~T();
109111
new (&data_[write_index + padding_]) T(std::forward<Args>(args)...);
110112
write_index_.store(next_write_index, std::memory_order_release);
111113
}
@@ -132,6 +134,8 @@ class StaticSpscQueue {
132134
return false;
133135
}
134136
}
137+
// Destroy the object this slot already holds (see `data_`).
138+
data_[write_index + padding_].~T();
135139
new (&data_[write_index + padding_]) T(std::forward<Args>(args)...);
136140
write_index_.store(next_write_index, std::memory_order_release);
137141
return true;
@@ -206,7 +210,9 @@ class StaticSpscQueue {
206210
"Can't pop an element from an empty queue. read_index: "
207211
<< read_index << " write_index " << write_index);
208212
#endif // SPECTRE_DEBUG
213+
// Leave a live object behind (see `data_`).
209214
data_[read_index + padding_].~T();
215+
new (&data_[read_index + padding_]) T{};
210216
auto next_read_index = read_index + 1;
211217
if (next_read_index == capacity_) {
212218
next_read_index = 0;
@@ -248,6 +254,8 @@ class StaticSpscQueue {
248254

249255
private:
250256
static constexpr size_t capacity_ = Capacity + 1;
257+
// Every slot holds a live object, so the array's destructor destroys each
258+
// element exactly once. `emplace` and `pop` maintain this.
251259
std::array<T, capacity_ + 2 * padding_> data_{};
252260

253261
// Align to cache line size in order to avoid false sharing

tests/Unit/DataStructures/Test_TaggedTuple.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ void test_equivalence() {
604604
CHECK(NotNoExceptCompare{1} != NotNoExceptCompare{0});
605605
CHECK_FALSE(NotNoExceptCompare{1} != NotNoExceptCompare{1});
606606

607-
#if __cplusplus >= 201402L
608607
{
609608
constexpr tuples::TaggedTuple<relational_tags::Int0, relational_tags::Int1,
610609
relational_tags::Int2>
@@ -636,7 +635,6 @@ void test_equivalence() {
636635
static_assert(t0 != t4,
637636
"Failed testing Unit.Utilities.TaggedTuple.relational");
638637
}
639-
#endif
640638
}
641639

642640
struct lex_time_compared {
@@ -770,7 +768,6 @@ void test_relational() {
770768
CHECK(t0 <= t2);
771769
CHECK(global_time_mock == 28);
772770
}
773-
#if __cplusplus >= 201402L
774771
{
775772
// Check constexpr lexicographical comparison
776773
constexpr tuples::TaggedTuple<
@@ -793,7 +790,6 @@ void test_relational() {
793790
static_assert(t0 >= t2, "Failed testing relational operators");
794791
static_assert(t0 >= t3, "Failed testing relational operators");
795792
}
796-
#endif
797793
}
798794

799795
static_assert(

tests/Unit/PointwiseFunctions/GeneralRelativity/Test_GeodesicAcceleration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void test_conserved_quantities_kerr_schild() {
145145
std::vector<std::array<double, 6>> states{};
146146
std::vector<double> times{};
147147
BoostObserver observer{states, times};
148-
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13
148+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 13
149149
#pragma GCC diagnostic push
150150
#pragma GCC diagnostic ignored "-Wuninitialized"
151151
#endif
@@ -156,7 +156,7 @@ void test_conserved_quantities_kerr_schild() {
156156
std::array<double, 6>>()),
157157
BoostGeodesicIntegrator{kerr_schild}, initial_state, 0.0, t_max, 1e-5,
158158
observer);
159-
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13
159+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 13
160160
#pragma GCC diagnostic pop
161161
#endif
162162

0 commit comments

Comments
 (0)