Skip to content

Commit e3e5c6f

Browse files
authored
Serialize arrays, making the code much simpler and more general (#1293)
* Serialize arrays, making the code much simpler and more general * simplify handling of map names for better performance
1 parent 5d44262 commit e3e5c6f

File tree

8 files changed

+247
-212
lines changed

8 files changed

+247
-212
lines changed

src/sst/core/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ sst_core_sources = \
224224
serialization/serializer.cc \
225225
serialization/statics.cc \
226226
serialization/impl/mapper.cc \
227+
serialization/impl/serialize_array.cc \
227228
sstinfo.h \
228229
interfaces/TestEvent.cc \
229230
interfaces/stdMem.cc \

src/sst/core/serialization/impl/mapper.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919
#include <iostream>
2020

21-
namespace SST {
22-
namespace Core {
23-
namespace Serialization {
24-
namespace pvt {
21+
namespace SST::Core::Serialization::pvt {
2522

2623
void
2724
ser_mapper::map_primitive(const std::string& name, ObjectMap* map)
@@ -83,8 +80,4 @@ ser_mapper::setNextObjectReadOnly()
8380
next_item_read_only = true;
8481
}
8582

86-
87-
} // namespace pvt
88-
} // namespace Serialization
89-
} // namespace Core
90-
} // namespace SST
83+
} // namespace SST::Core::Serialization::pvt
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2009-2025 NTESS. Under the terms
2+
// of Contract DE-NA0003525 with NTESS, the U.S.
3+
// Government retains certain rights in this software.
4+
//
5+
// Copyright (c) 2009-2025, NTESS
6+
// All rights reserved.
7+
//
8+
// This file is part of the SST software package. For license
9+
// information, see the LICENSE file in the top level directory of the
10+
// distribution.
11+
12+
#include "sst_config.h"
13+
14+
#include "sst/core/serialization/serialize.h"
15+
16+
namespace SST::Core::Serialization::pvt {
17+
18+
void
19+
serialize_array(
20+
serializer& ser, void* data, size_t size, void serialize_array_element(serializer& ser, void* data, size_t index))
21+
{
22+
for ( size_t index = 0; index < size; ++index )
23+
serialize_array_element(ser, data, index);
24+
}
25+
26+
void
27+
serialize_array_map(
28+
serializer& ser, void* data, size_t size, ObjectMap* map,
29+
void serialize_array_map_element(serializer& ser, void* data, size_t index, const std::string& name))
30+
{
31+
ser.mapper().map_hierarchy_start(ser.getMapName(), map);
32+
for ( size_t index = 0; index < size; ++index )
33+
serialize_array_map_element(ser, data, index, std::to_string(index));
34+
ser.mapper().map_hierarchy_end();
35+
}
36+
37+
} // namespace SST::Core::Serialization::pvt

0 commit comments

Comments
 (0)