Device Management

ScalingPolicy

class ScalingPolicy : public Object

Abstract base class for DVFS scaling policies.

ScalingPolicy decides target frequency/voltage for a backend accelerator based on reported DeviceMetrics. The DeviceManager calls Decide() for each backend when evaluating scaling.

Subclassed by ns3::ConservativeScalingPolicy, ns3::UtilizationScalingPolicy

Public Functions

virtual Ptr<ScalingDecision> Decide(const ClusterState::BackendState &backend, const std::vector<OperatingPoint> &opps) = 0

Decide on a scaling action based on backend state and available OPPs.

Parameters:
  • backend – Per-backend state including device metrics and load counters.

  • opps – The accelerator’s operating point table, sorted by frequency ascending.

Returns:

A scaling decision, or nullptr if no change needed.

virtual std::string GetName() const = 0

Get the name of this scaling policy.

Returns:

A string identifying the policy.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.

UtilizationScalingPolicy

class UtilizationScalingPolicy : public ns3::ScalingPolicy

Utilization-based DVFS scaling policy inspired by Linux ondemand governor.

Simple binary policy using the accelerator’s OPP table:

  • Busy or queued tasks -> highest OPP (aggressive scale-up for latency)

  • Idle -> lowest OPP (energy savings)

Public Functions

virtual Ptr<ScalingDecision> Decide(const ClusterState::BackendState &backend, const std::vector<OperatingPoint> &opps) override

Decide on a scaling action based on backend state and available OPPs.

Parameters:
  • backend – Per-backend state including device metrics and load counters.

  • opps – The accelerator’s operating point table, sorted by frequency ascending.

Returns:

A scaling decision, or nullptr if no change needed.

virtual std::string GetName() const override

Get the name of this scaling policy.

Returns:

A string identifying the policy.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.

ConservativeScalingPolicy

class ConservativeScalingPolicy : public ns3::ScalingPolicy

Conservative DVFS scaling policy inspired by Linux conservative governor.

This policy steps frequency up or down by one operating point per decision. Frequency and voltage values come from the accelerator’s OPP table.

Public Functions

virtual Ptr<ScalingDecision> Decide(const ClusterState::BackendState &backend, const std::vector<OperatingPoint> &opps) override

Decide on a scaling action based on backend state and available OPPs.

Parameters:
  • backend – Per-backend state including device metrics and load counters.

  • opps – The accelerator’s operating point table, sorted by frequency ascending.

Returns:

A scaling decision, or nullptr if no change needed.

virtual std::string GetName() const override

Get the name of this scaling policy.

Returns:

A string identifying the policy.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.

DeviceProtocol

class DeviceProtocol : public Object

Abstract base class for device management wire protocols.

DeviceProtocol encapsulates how accelerator metrics are serialized into packets and how scaling commands are deserialized and applied. Each accelerator type provides its own concrete protocol implementation.

Subclassed by ns3::GpuDeviceProtocol

Public Functions

virtual Ptr<Packet> CreateMetricsPacket(Ptr<const Accelerator> accel) = 0

Serialize accelerator state into a metrics packet.

Called by the server application on task lifecycle events.

Parameters:

accel – The accelerator whose state is read.

Returns:

A packet containing the serialized metrics header.

virtual Ptr<DeviceMetrics> ParseMetrics(Ptr<Packet> packet) = 0

Parse a metrics packet into a DeviceMetrics object.

Called by the DeviceManager when a type-4 packet arrives.

Parameters:

packet – The packet containing the metrics header.

Returns:

The parsed DeviceMetrics.

virtual Ptr<Packet> CreateCommandPacket(Ptr<ScalingDecision> decision) = 0

Serialize a scaling decision into a command packet.

Called by the DeviceManager when a scaling decision is made.

Parameters:

decision – The scaling decision to serialize.

Returns:

A packet containing the serialized command header.

virtual void ApplyCommand(Ptr<Packet> packet, Ptr<Accelerator> accel) = 0

Parse and apply a command packet to an accelerator.

Called by the server application when a type-5 packet arrives.

Parameters:
  • packet – The packet containing the command header.

  • accel – The accelerator to which the command is applied.

virtual std::string GetName() const = 0

Get the name of this device protocol.

Returns:

A string identifying the protocol.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.

GpuDeviceProtocol

class GpuDeviceProtocol : public ns3::DeviceProtocol

Concrete DeviceProtocol for GPU accelerators.

Serializes metrics using DeviceMetricsHeader (type 4) and applies commands from ScalingCommandHeader (type 5) by calling SetFrequency() and SetVoltage() on the accelerator.

Public Functions

virtual Ptr<Packet> CreateMetricsPacket(Ptr<const Accelerator> accel) override

Serialize accelerator state into a metrics packet.

Called by the server application on task lifecycle events.

Parameters:

accel – The accelerator whose state is read.

Returns:

A packet containing the serialized metrics header.

virtual Ptr<DeviceMetrics> ParseMetrics(Ptr<Packet> packet) override

Parse a metrics packet into a DeviceMetrics object.

Called by the DeviceManager when a type-4 packet arrives.

Parameters:

packet – The packet containing the metrics header.

Returns:

The parsed DeviceMetrics.

virtual Ptr<Packet> CreateCommandPacket(Ptr<ScalingDecision> decision) override

Serialize a scaling decision into a command packet.

Called by the DeviceManager when a scaling decision is made.

Parameters:

decision – The scaling decision to serialize.

Returns:

A packet containing the serialized command header.

virtual void ApplyCommand(Ptr<Packet> packet, Ptr<Accelerator> accel) override

Parse and apply a command packet to an accelerator.

Called by the server application when a type-5 packet arrives.

Parameters:
  • packet – The packet containing the command header.

  • accel – The accelerator to which the command is applied.

virtual std::string GetName() const override

Get the name of this device protocol.

Returns:

A string identifying the protocol.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.

DeviceManager

class DeviceManager : public Object

Manages DVFS scaling for backend accelerators in the orchestrator.

DeviceManager is a concrete component of EdgeOrchestrator. It evaluates a pluggable ScalingPolicy using per-backend state from ClusterState, and sends ScalingCommandHeader packets to backends via the orchestrator’s worker ConnectionManager.

Metrics arrive via HandleMetrics() (called by EdgeOrchestrator when a type-4 packet arrives). Scaling is evaluated via EvaluateScaling() (called by EdgeOrchestrator on task events).

Public Types

typedef void (*FrequencyChangedTracedCallback)(uint32_t backendIdx, double oldFreq, double newFreq)

TracedCallback signature for frequency change events.

Param backendIdx:

The backend index.

Param oldFreq:

The previous frequency in Hz.

Param newFreq:

The new frequency in Hz.

Public Functions

void Start(const Cluster &cluster, Ptr<ConnectionManager> backendCm, ClusterState &state)

Initialize the device manager with a cluster and connection manager.

Must be called before HandleMetrics() or EvaluateScaling().

Parameters:
  • cluster – The backend cluster.

  • backendCm – The backend connection manager for sending commands.

  • state – The cluster state to initialize commanded frequencies.

void HandleMetrics(Ptr<Packet> packet, uint32_t backendIdx, ClusterState &state)

Store metrics received from a backend.

Called by EdgeOrchestrator when a type-4 packet arrives.

Parameters:
  • packet – The metrics packet (DeviceMetricsHeader).

  • backendIdx – The backend index in the cluster.

  • state – The cluster state to update with parsed metrics.

bool TryConsumeMetrics(Ptr<Packet> buffer, const Address &from, ClusterState &state)

Try to consume a device metrics message from a receive buffer.

Peeks at the first byte of the buffer. If it is a metrics message and enough data is available, the message is consumed (removed from the buffer), parsed, and stored in ClusterState.

Parameters:
  • buffer – The receive buffer (modified in-place if consumed).

  • from – The backend address (used to resolve backend index).

  • state – The cluster state to update.

Returns:

true if a metrics message was consumed, false otherwise.

void EvaluateScaling(ClusterState &state)

Evaluate scaling decisions for all backends.

Called by EdgeOrchestrator on task events. For each backend, runs ScalingPolicy::Decide() and sends command packets if frequency or voltage changed.

Parameters:

state – The cluster state with per-backend load and metrics.

Public Static Functions

static TypeId GetTypeId()

Get the type ID.

Returns:

The object TypeId.