Class DummyBackend

Nested Relationships

Inheritance Relationships

Base Type

Class Documentation

class switchml::DummyBackend : public switchml::Backend

A backend for debugging which simulates communication by sleeping.

It allows us to test the correctness of all components without having to deal with the complexities of a real backend and without performing any actual communication. The backend launches worker threads and sleeps when a send or receive is called. The sleeping duration is determined by the dummy bandwidth and the size of the tensor. The bandwidth is configurable through the configuration file.

Public Functions

DummyBackend(Context &context, Config &config)

Initialize members and allocate worker_threads and pending_messages arrays.

Parameters
  • context[in] a reference to the switchml context.

  • config[in] a reference to the switchml configuration.

~DummyBackend()

Free worker_threads and pending_messages arrays.

DummyBackend(DummyBackend const&) = delete
void operator=(DummyBackend const&) = delete
DummyBackend(DummyBackend&&) = default
DummyBackend &operator=(DummyBackend&&) = default
virtual void SetupWorker() override

Creates and starts worker threads.

See

CleanupWorker()

virtual void CleanupWorker() override

Stops worker threads.

See

SetupWorker()

void SetupWorkerThread(WorkerTid worker_thread_id)

Does nothing.

void CleanupWorkerThread(WorkerTid worker_thread_id)

Does nothing.

void SendBurst(WorkerTid worker_thread_id, const std::vector<DummyPacket> &packets_to_send)

Sends a burst of packets specific to a worker thread.

This is a generic function that could be used to send a single message or multiple packets at once. The function sleeps for a period equal to all packets sizes divided by the dummy backend bandwidth to simulate network sending.

The sent packets are stored internally so that they can later be retrieved by ReceiveBurst()

See

ReceiveBurst()

Parameters
  • worker_thread_id[in] The id of the calling worker thread.

  • packets_to_send[in] A vector of dummy packets to send.

void ReceiveBurst(WorkerTid worker_thread_id, std::vector<DummyPacket> &packets_received)

Receives a burst of packets specific to a worker thread.

This function returns a random number of packets from the packets that the worker has sent using SendBurst() The packets can be received out of order to simulate a real network. Before the packets are returned, the elements are multiplied by the number of workers to simulate that an AllReduce Sum opearation took place.

See

SendBurst()

Parameters
  • worker_thread_id[in] The id of the calling worker thread.

  • packets_received[out] The vector to fill with packets received.

struct DummyPacket

A struct that describes the unit of transmission in the dummy backend (The DummyPacket).

A JobSlice is divided by the worker thread to multiple **DummyPacket* structs which then get sent then received using the backend.

Public Members

uint64_t pkt_id

A packet identifier unique only within a job slice. Accessed only by the worker thread that created the message. Can be calculated as packet offset from the job slice divided by the packet size

JobId job_id

The identifier of the job from which this message came from

Numel numel

The number of elements in the packet

DataType data_type

The data type of the elements

void *entries_ptr

Pointer to data that is supposed to be outstanding (in the network)

void *extra_info_ptr

Pointer to extra info that is supposed to be outstanding (in the network)