Skip to content

Commit 30c40ff

Browse files
Finalize serialization API for checkpointing. (#1298)
* Finalize element-facing serialization API for checkpointing. - SST_SER and SST_SER_NAME are primary APIs for serializing - operator& and operator| have been deprecated - sst_ser_object() can also safely be called directly - moved all uses of ser& and ser| to SST_SER - Added options that can be passed into the serialization macros or function - Options in class SerOption enum Options: as_ptr, as_ptr_elem, no_map, map_read_only. Accessed with SerOption::as_ptr, etc. - Move serialize<T> template into SST::Core::Serialization::pvt namespace - Added SST_FRIEND_SERIALIZE macro that should be called in all specializaations of serialize_impl Fixed handling of warning suppression not being pushed/popped correctly --------- Co-authored-by: leekillough <15950023+leekillough@users.noreply.github.com>
1 parent 34d6c2f commit 30c40ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1113
-983
lines changed

src/sst/core/activity.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ class Activity : public SST::Core::MemPoolItem
213213
// inherit from it need to be serializable.
214214
void serialize_order(SST::Core::Serialization::serializer& ser) override
215215
{
216-
ser& delivery_time;
217-
ser& priority_order;
218-
ser& queue_order;
216+
SST_SER(delivery_time);
217+
SST_SER(priority_order);
218+
SST_SER(queue_order);
219219
}
220220

221221
ImplementVirtualSerializable(SST::Activity);

src/sst/core/baseComponent.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,8 @@ BaseComponent::initiateInteractive(const std::string& msg)
887887
void
888888
BaseComponent::serialize_order(SST::Core::Serialization::serializer& ser)
889889
{
890-
ser& my_info;
891-
ser& isExtension;
890+
SST_SER(my_info);
891+
SST_SER(isExtension);
892892

893893
switch ( ser.mode() ) {
894894
case SST::Core::Serialization::serializer::SIZER:
@@ -897,12 +897,12 @@ BaseComponent::serialize_order(SST::Core::Serialization::serializer& ser)
897897
// Need to serialize each handler
898898
std::pair<Clock::HandlerBase*, SimTime_t> p;
899899
size_t num_handlers = clock_handlers.size();
900-
ser& num_handlers;
900+
SST_SER(num_handlers);
901901
for ( auto* handler : clock_handlers ) {
902902
p.first = handler;
903903
// See if it's currently registered with a clock
904904
p.second = sim_->getClockForHandler(handler);
905-
ser& p;
905+
SST_SER(p);
906906
}
907907
break;
908908
}
@@ -911,9 +911,9 @@ BaseComponent::serialize_order(SST::Core::Serialization::serializer& ser)
911911
sim_ = Simulation_impl::getSimulation();
912912
std::pair<Clock::HandlerBase*, SimTime_t> p;
913913
size_t num_handlers;
914-
ser& num_handlers;
914+
SST_SER(num_handlers);
915915
for ( size_t i = 0; i < num_handlers; ++i ) {
916-
ser& p;
916+
SST_SER(p);
917917
// Add handler to clock_handlers list
918918
clock_handlers.push_back(p.first);
919919
// If it was previously registered, register it now
@@ -1077,19 +1077,18 @@ SerializeBaseComponentHelper::map_basecomponent(serializable_base*& s, serialize
10771077
// on slotname and slotnum
10781078
name_str += it->second.getSlotName() + "[" + std::to_string(it->second.getSlotNum()) + "]";
10791079
}
1080-
// sst_map_object(ser, it->second.component, it->second.getShortName().c_str());
1081-
sst_map_object(ser, it->second.component, name_str.c_str());
1080+
SST_SER_NAME(it->second.component, name_str.c_str());
10821081
it->second.serialize_comp(ser);
10831082
}
10841083

10851084
// Put in ComponentInfo data
10861085
ObjectMap* my_info_dir = new ObjectMapHierarchyOnly();
10871086
ser.mapper().map_hierarchy_start("my_info", my_info_dir);
1088-
ser.mapper().setNextObjectReadOnly();
1089-
sst_map_object(ser, const_cast<ComponentId_t&>(comp->my_info->id_), "id");
1090-
ser.mapper().setNextObjectReadOnly();
1091-
sst_map_object(ser, const_cast<std::string&>(comp->my_info->type), "type");
1092-
sst_map_object(ser, comp->my_info->defaultTimeBase, "defaultTimeBase");
1087+
1088+
SST_SER_NAME(const_cast<ComponentId_t&>(comp->my_info->id_), "id", SerOption::map_read_only);
1089+
SST_SER_NAME(const_cast<std::string&>(comp->my_info->type), "type", SerOption::map_read_only);
1090+
SST_SER_NAME(comp->my_info->defaultTimeBase, "defaultTimeBase");
1091+
10931092
ser.mapper().map_hierarchy_end(); // for my_info_dir
10941093

10951094
s->serialize_order(ser);

src/sst/core/baseComponent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,7 @@ class SerializeBaseComponentHelper
11561156
template <class T>
11571157
class serialize_impl<T*, std::enable_if_t<std::is_base_of_v<SST::BaseComponent, T>>>
11581158
{
1159-
template <class A>
1160-
friend class serialize;
1161-
void operator()(T*& s, serializer& ser)
1159+
void operator()(T*& s, serializer& ser, ser_opt_t UNUSED(options))
11621160
{
11631161
serializable_base* sp = static_cast<serializable_base*>(s);
11641162
switch ( ser.mode() ) {
@@ -1177,6 +1175,8 @@ class serialize_impl<T*, std::enable_if_t<std::is_base_of_v<SST::BaseComponent,
11771175
}
11781176
s = static_cast<T*>(sp);
11791177
}
1178+
1179+
SST_FRIEND_SERIALZE();
11801180
};
11811181

11821182
} // namespace Core::Serialization

src/sst/core/clock.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ Clock::serialize_order(SST::Core::Serialization::serializer& ser)
157157

158158
// Won't serialize the handlers; they'll be re-registered at
159159
// restart
160-
ser& currentCycle;
161-
ser& period;
162-
ser& next;
163-
ser& scheduled;
160+
SST_SER(currentCycle);
161+
SST_SER(period);
162+
SST_SER(next);
163+
SST_SER(scheduled);
164164
}
165165

166166

src/sst/core/componentInfo.cc

Lines changed: 27 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ ComponentInfo::~ComponentInfo()
199199
void
200200
ComponentInfo::serialize_comp(SST::Core::Serialization::serializer& ser)
201201
{
202-
ser& component;
203-
ser& link_map;
202+
SST_SER(component);
203+
SST_SER(link_map);
204204
for ( auto it = subComponents.begin(); it != subComponents.end(); ++it ) {
205205
it->second.serialize_comp(ser);
206206
}
@@ -219,21 +219,21 @@ ComponentInfo::serialize_order(SST::Core::Serialization::serializer& ser)
219219

220220
// Serialize all my data except the component and link_map
221221

222-
ser& const_cast<ComponentId_t&>(id_);
223-
ser& parent_info;
224-
ser& const_cast<std::string&>(name);
225-
ser& const_cast<std::string&>(type);
222+
SST_SER(const_cast<ComponentId_t&>(id_));
223+
SST_SER(parent_info);
224+
SST_SER(const_cast<std::string&>(name));
225+
SST_SER(const_cast<std::string&>(type));
226226

227227
// Not used after construction, no need to serialize
228-
// ser& params;
228+
// SST_SER(params);
229229

230-
ser& defaultTimeBase;
230+
SST_SER(defaultTimeBase);
231231

232-
// ser& coordinates;
233-
ser& subIDIndex;
234-
ser& const_cast<std::string&>(slot_name);
235-
ser& slot_num;
236-
ser& share_flags;
232+
// SST_SER(coordinates);
233+
SST_SER(subIDIndex);
234+
SST_SER(const_cast<std::string&>(slot_name));
235+
SST_SER(slot_num);
236+
SST_SER(share_flags);
237237

238238
// Serialize statistic data structures - only needed for late stat registration
239239
// No one else has these pointers so serialize the data structure & reallocate on UNPACK
@@ -243,39 +243,39 @@ ComponentInfo::serialize_order(SST::Core::Serialization::serializer& ser)
243243
std::map<std::string, StatisticId_t> enabled_stat_names;
244244
bool is_null = true;
245245

246-
ser& is_null;
246+
SST_SER(is_null);
247247
if ( !is_null ) {
248-
ser& stat_configs;
248+
SST_SER(stat_configs);
249249
stat_configs_ = new std::map<StatisticId_t, ConfigStatistic>(stat_configs);
250250
}
251251

252-
ser& is_null;
252+
SST_SER(is_null);
253253
if ( !is_null ) {
254-
ser& all_stat_config;
254+
SST_SER(all_stat_config);
255255
all_stat_config_ = new ConfigStatistic(all_stat_config);
256256
}
257257

258-
ser& is_null;
258+
SST_SER(is_null);
259259
if ( !is_null ) {
260-
ser& enabled_stat_names;
260+
SST_SER(enabled_stat_names);
261261
enabled_stat_names_ = new std::map<std::string, StatisticId_t>(enabled_stat_names);
262262
}
263263
}
264264
else {
265265
bool is_null = stat_configs_ == nullptr;
266-
ser& is_null;
267-
if ( !is_null ) ser&(*stat_configs_);
266+
SST_SER(is_null);
267+
if ( !is_null ) SST_SER(*stat_configs_);
268268

269269
is_null = all_stat_config_ == nullptr;
270-
ser& is_null;
271-
if ( !is_null ) ser&(*all_stat_config_);
270+
SST_SER(is_null);
271+
if ( !is_null ) SST_SER(*all_stat_config_);
272272

273273
is_null = enabled_stat_names_ == nullptr;
274-
ser& is_null;
275-
if ( !is_null ) ser&(*enabled_stat_names_);
274+
SST_SER(is_null);
275+
if ( !is_null ) SST_SER(*enabled_stat_names_);
276276
}
277277

278-
ser& statLoadLevel; // Potentially needed for late stat registration
278+
SST_SER(statLoadLevel); // Potentially needed for late stat registration
279279

280280
// For SubComponents map, need to serialize map by hand since we
281281
// we will need to use the track non-pointer as pointer feature in
@@ -284,48 +284,7 @@ ComponentInfo::serialize_order(SST::Core::Serialization::serializer& ser)
284284
// own SubCompenents that will need to point to the data location
285285
// in the map.
286286

287-
// ser& subComponents;
288-
switch ( ser.mode() ) {
289-
case SST::Core::Serialization::serializer::SIZER:
290-
{
291-
size_t size = subComponents.size();
292-
ser& size;
293-
for ( auto it = subComponents.begin(); it != subComponents.end(); ++it ) {
294-
// keys are const values - annoyingly
295-
ser& const_cast<ComponentId_t&>(it->first);
296-
ser | it->second;
297-
}
298-
break;
299-
}
300-
case SST::Core::Serialization::serializer::PACK:
301-
{
302-
size_t size = subComponents.size();
303-
ser& size;
304-
for ( auto it = subComponents.begin(); it != subComponents.end(); ++it ) {
305-
// keys are const values - annoyingly
306-
ser& const_cast<ComponentId_t&>(it->first);
307-
ser | it->second;
308-
}
309-
break;
310-
}
311-
case SST::Core::Serialization::serializer::UNPACK:
312-
{
313-
size_t size;
314-
ser& size;
315-
for ( size_t i = 0; i < size; ++i ) {
316-
ComponentId_t key;
317-
ser& key;
318-
319-
auto p = subComponents.emplace(key, ComponentInfo {});
320-
321-
ser | p.first->second;
322-
}
323-
break;
324-
}
325-
case SST::Core::Serialization::serializer::MAP:
326-
// Add your code here
327-
break;
328-
}
287+
SST_SER(subComponents, SerOption::as_ptr_elem);
329288

330289
// Only the parent Component will call serialize_comp directly.
331290
// This function will walk the hierarchy and call it on all of its

src/sst/core/config.h

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -420,61 +420,61 @@ class Config : public ConfigShared, public SST::Core::Serialization::serializabl
420420

421421
void serialize_order(SST::Core::Serialization::serializer& ser) override
422422
{
423-
ser& verbose_;
424-
ser& configFile_;
425-
ser& model_options_;
426-
ser& print_timing_;
427-
ser& stop_at_;
428-
ser& exit_after_;
429-
ser& partitioner_;
430-
ser& heartbeat_wall_period_;
431-
ser& heartbeat_sim_period_;
432-
ser& output_directory_;
433-
ser& output_core_prefix_;
434-
435-
ser& output_config_graph_;
436-
ser& output_json_;
437-
ser& parallel_output_;
438-
439-
ser& output_dot_;
440-
ser& dot_verbosity_;
441-
ser& component_partition_file_;
442-
ser& output_partition_;
443-
444-
ser& timeBase_;
445-
ser& parallel_load_;
446-
ser& parallel_load_mode_multi_;
447-
ser& timeVortex_;
448-
ser& interthread_links_;
423+
SST_SER(verbose_);
424+
SST_SER(configFile_);
425+
SST_SER(model_options_);
426+
SST_SER(print_timing_);
427+
SST_SER(stop_at_);
428+
SST_SER(exit_after_);
429+
SST_SER(partitioner_);
430+
SST_SER(heartbeat_wall_period_);
431+
SST_SER(heartbeat_sim_period_);
432+
SST_SER(output_directory_);
433+
SST_SER(output_core_prefix_);
434+
435+
SST_SER(output_config_graph_);
436+
SST_SER(output_json_);
437+
SST_SER(parallel_output_);
438+
439+
SST_SER(output_dot_);
440+
SST_SER(dot_verbosity_);
441+
SST_SER(component_partition_file_);
442+
SST_SER(output_partition_);
443+
444+
SST_SER(timeBase_);
445+
SST_SER(parallel_load_);
446+
SST_SER(parallel_load_mode_multi_);
447+
SST_SER(timeVortex_);
448+
SST_SER(interthread_links_);
449449
#ifdef USE_MEMPOOL
450-
ser& cache_align_mempools_;
450+
SST_SER(cache_align_mempools_);
451451
#endif
452-
ser& debugFile_;
453-
ser& libpath_;
454-
ser& addlibpath_;
452+
SST_SER(debugFile_);
453+
SST_SER(libpath_);
454+
SST_SER(addlibpath_);
455455
#if PY_MINOR_VERSION >= 9
456-
ser& enable_python_coverage_;
456+
SST_SER(enable_python_coverage_);
457457
#endif
458-
ser& enabled_profiling_;
459-
ser& profiling_output_;
460-
ser& runMode_;
461-
ser& interactive_console_;
462-
ser& interactive_start_time_;
458+
SST_SER(enabled_profiling_);
459+
SST_SER(profiling_output_);
460+
SST_SER(runMode_);
461+
SST_SER(interactive_console_);
462+
SST_SER(interactive_start_time_);
463463
#ifdef USE_MEMPOOL
464-
ser& event_dump_file_;
464+
SST_SER(event_dump_file_);
465465
#endif
466-
ser& load_from_checkpoint_;
467-
ser& checkpoint_wall_period_;
468-
ser& checkpoint_sim_period_;
469-
ser& checkpoint_prefix_;
470-
ser& checkpoint_name_format_;
471-
472-
ser& enable_sig_handling_;
473-
ser& sigusr1_;
474-
ser& sigusr2_;
475-
ser& sigalrm_;
476-
ser& print_env_;
477-
ser& no_env_config_;
466+
SST_SER(load_from_checkpoint_);
467+
SST_SER(checkpoint_wall_period_);
468+
SST_SER(checkpoint_sim_period_);
469+
SST_SER(checkpoint_prefix_);
470+
SST_SER(checkpoint_name_format_);
471+
472+
SST_SER(enable_sig_handling_);
473+
SST_SER(sigusr1_);
474+
SST_SER(sigusr2_);
475+
SST_SER(sigalrm_);
476+
SST_SER(print_env_);
477+
SST_SER(no_env_config_);
478478
}
479479
ImplementSerializable(SST::Config);
480480

0 commit comments

Comments
 (0)