Skip to content

Commit 64bb80f

Browse files
committed
Change event delivery ordering to be based on the order registerLink() is called in a component, rather than on the alphabetization of link names.
1 parent 6f3e590 commit 64bb80f

File tree

10 files changed

+55
-18
lines changed

10 files changed

+55
-18
lines changed

src/sst/core/baseComponent.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ BaseComponent::configureLink_impl(const std::string& name, SimTime_t timebase, E
686686
}
687687
}
688688
tmp->setDefaultTimeBase(timebase);
689+
tmp->setTag(getNextLinkOrder());
689690
#ifdef __SST_DEBUG_EVENT_TRACKING__
690691
tmp->setSendingComponentInfo(my_info_->getName(), my_info_->getType(), name);
691692
#endif
@@ -843,6 +844,12 @@ BaseComponent::pushValidParams(Params& params, const std::string& type)
843844
params.pushAllowedKeys(Factory::getFactory()->getParamNames(type));
844845
}
845846

847+
uint32_t
848+
BaseComponent::getNextLinkOrder()
849+
{
850+
return getParentComponent()->getNextLinkOrder();
851+
}
852+
846853

847854
void
848855
BaseComponent::vfatal(

src/sst/core/baseComponent.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ class BaseComponent : public SST::Core::Serialization::serializable_base
596596
void serialize_order(SST::Core::Serialization::serializer& ser) override;
597597

598598

599+
/**
600+
Gets the next value or the order field of the link. The ordering of events based on links will be based on
601+
the order that configureLink() is called.
602+
*/
603+
virtual uint32_t getNextLinkOrder();
604+
599605
/**
600606
Handles the profile points, default timebase, handler tracking and checkpointing.
601607

src/sst/core/component.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "sst/core/eli/elementinfo.h"
1717
#include "sst/core/sst_types.h"
1818

19+
#include <cstdint>
1920
#include <map>
2021

2122
using namespace SST::Statistics;
@@ -58,6 +59,12 @@ class Component : public BaseComponent
5859
protected:
5960
friend class SubComponent;
6061
Component() = default; // For Serialization only
62+
63+
private:
64+
65+
uint32_t getNextLinkOrder() override { return next_event_order_++; }
66+
67+
uint32_t next_event_order_ = 1;
6168
};
6269

6370
} // namespace SST

src/sst/core/componentExtension.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ComponentExtension : public BaseComponent
3737
ComponentExtension() = default; // For serialization only
3838

3939
void serialize_order(SST::Core::Serialization::serializer& ser) override;
40-
ImplementSerializable(SST::ComponentExtension)
40+
ImplementSerializable(SST::ComponentExtension);
4141
};
4242

4343
} // namespace SST

src/sst/core/event.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ class Event : public Activity
210210
local links, delivery_info contains the delivery functor.
211211
@return void
212212
*/
213-
inline void setDeliveryInfo(LinkId_t tag, uintptr_t delivery_info)
213+
inline void setDeliveryInfo(uint32_t order_tag, uintptr_t delivery_info)
214214
{
215-
setOrderTag(tag);
215+
setOrderTag(order_tag);
216216
this->delivery_info = delivery_info;
217217
}
218218

@@ -228,9 +228,6 @@ class Event : public Activity
228228
/** Gets the link id used for delivery. For use by SST Core only */
229229
inline Link* getDeliveryLink() { return reinterpret_cast<Link*>(delivery_info); }
230230

231-
/** Gets the link id associated with this event. For use by SST Core only */
232-
inline LinkId_t getTag() const { return getOrderTag(); }
233-
234231

235232
/** Holds the delivery information. This is stored as a
236233
uintptr_t, but is actually a pointer converted using

src/sst/core/link.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ Link::Link() :
501501
current_time(Simulation_impl::getSimulation()->currentSimCycle),
502502
type(UNINITIALIZED),
503503
mode(INIT),
504-
tag(-1),
504+
tag(type_max<uint32_t>),
505505
attached_tools(nullptr)
506506
{}
507507

src/sst/core/link.h

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class alignas(64) Link
127127
friend class Simulation_impl;
128128
friend class SyncManager;
129129
friend class ComponentInfo;
130+
friend class BaseComponent;
130131

131132
~Link();
132133

@@ -245,16 +246,16 @@ class alignas(64) Link
245246
*/
246247
TimeConverter* getDefaultTimeBase();
247248

248-
/** Return the default Time Base for this link
249-
* @return the default Time Base for this link
250-
*/
251-
const TimeConverter* getDefaultTimeBase() const;
252-
253249
/** Return the ID of this link
254250
* @return the unique ID for this link
255251
*/
256252
LinkId_t getId() { return tag; }
257253

254+
/** Return the default Time Base for this link
255+
* @return the default Time Base for this link
256+
*/
257+
const TimeConverter* getDefaultTimeBase() const;
258+
258259
/** Send data during the init() or complete() phase.
259260
* @param data event to send
260261
*/
@@ -295,6 +296,21 @@ class alignas(64) Link
295296
*/
296297
void setDeliveryInfo(uintptr_t info) { delivery_info = info; }
297298

299+
/**
300+
Set the tag field for event link ordering
301+
*/
302+
void setTag(uint32_t new_tag)
303+
{
304+
if ( tag != type_max<uint32_t> ) tag = new_tag;
305+
306+
// Interleaved links
307+
// tag = new_tag;
308+
309+
// Ordered SelfLinks
310+
// if ( tag != type_max<uint32_t> ) tag = new_tag;
311+
// else tag = 0x80000000 | new_tag;
312+
}
313+
298314
/** Send an event over the link with additional delay. Sends an event
299315
* over a link with an additional delay specified with a
300316
* TimeConverter. I.e. the total delay is the link's delay + the
@@ -362,7 +378,7 @@ class alignas(64) Link
362378
SimTime_t& current_time;
363379
Type_t type;
364380
Mode_t mode;
365-
LinkId_t tag;
381+
uint32_t tag;
366382

367383
/** Create a new link with a given tag
368384
@@ -376,7 +392,7 @@ class alignas(64) Link
376392
value used for enforce_link_order (if that feature is
377393
enabled).
378394
*/
379-
explicit Link(LinkId_t tag);
395+
explicit Link(uint32_t tag);
380396

381397
Link(const Link& l);
382398

src/sst/core/model/configGraph.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ ConfigGraph::postCreationCleanup()
204204
// Need to assign the link delivery order. This is done
205205
// alphabetically by link name. To save memory, we'll sort links_
206206
// by name, then sort it back by link_id
207-
std::sort(links_.begin(), links_.end(),
208-
[](const ConfigLink* lhs, const ConfigLink* rhs) -> bool { return lhs->name < rhs->name; });
207+
// std::sort(links_.begin(), links_.end(),
208+
// [](const ConfigLink* lhs, const ConfigLink* rhs) -> bool { return lhs->name < rhs->name; });
209209

210210
LinkId_t count = 1;
211211
for ( auto* link : links_ ) {
212212
link->order = count;
213213
count++;
214214
}
215215

216-
links_.sort();
216+
// links_.sort();
217217

218218
/* Force component / statistic registration for Group stats */
219219
for ( auto& cfg : getStatGroups() ) {

src/sst/core/sst_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ using volts = double;
6161
#define UNLIKELY(x) __builtin_expect((int)(x), 0)
6262
#endif
6363

64+
/* Template to get the maximum value of a type */
65+
template <typename T>
66+
inline constexpr T type_max = std::numeric_limits<T>::max();
67+
6468
enum class SimulationRunMode {
6569
UNKNOWN, /*!< Unknown mode - Invalid for running */
6670
INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */

src/sst/core/subcomponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SubComponent : public BaseComponent
6363
void serialize_order(SST::Core::Serialization::serializer& ser) override;
6464

6565
friend class Component;
66-
ImplementSerializable(SST::SubComponent)
66+
ImplementSerializable(SST::SubComponent);
6767
};
6868

6969
} // namespace SST

0 commit comments

Comments
 (0)