syntax = "proto3";

package tensorflow.profiler;

message TopologyDimension {
  int32 x = 1;
  int32 y = 2;
  int32 z = 3;
}

message TopologyLocation {
  int32 x = 1;
  int32 y = 2;
  int32 z = 3;

  int32 host_x = 4;
  int32 host_y = 5;
  int32 host_z = 6;

  int32 index_on_host = 7;
  int32 global_id = 8;
}

// Topology of the system.
// Describes the number of chips and hosts and their connectivity.
message Topology {
  // Topology of chips per host.
  TopologyDimension chips_per_host_bounds = 1;
  // Topology of hosts.
  TopologyDimension host_bounds = 2;
  // Chip position within the mesh
  repeated TopologyLocation mesh_location = 3;
}

// The logical topology of the job.
message LogicalTopology {
  // Logical metadata about a specific device.
  message LogicalDevice {
    // The id that uniquely identifies the device globally.
    int32 global_id = 1;

    // The id that uniquely identifies the device within its slice.
    int32 slice_local_id = 2;

    // The id that uniquely identifies the device within its host.
    int32 host_local_id = 3;
  }

  // The network address of a specific host.
  message HostNetworkAddress {
    string address = 1;
    string interface_name = 2;
  }

  // Logical metadata about a specific host.
  message LogicalHost {
    // The id that uniquely identifies the host within its slice.
    int32 slice_local_id = 1;

    // The network addresses of the host.
    repeated HostNetworkAddress network_addresses = 2;

    // The devices that are connected to this host.
    repeated LogicalDevice devices = 3;
  }

  // Logical metadata about a specific slice.
  message LogicalSlice {
    // The id that uniquely identifies the slice globally.
    int32 global_id = 1;

    // The hosts that are part of this slice.
    repeated LogicalHost hosts = 2;
  }

  // The slices that are part of the job.
  repeated LogicalSlice slices = 1;
}
