Class: Ignis::Collective::Topology::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/nvruby/collective/topology.rb

Overview

Represents a connection path between two GPUs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src_device:, dst_device:, interconnect_type:, performance_rank:, p2p_supported:, native_atomics: false) ⇒ Path

Returns a new instance of Path.

Parameters:

  • src_device (Integer)

    Source GPU device ID

  • dst_device (Integer)

    Destination GPU device ID

  • interconnect_type (Symbol)

    Detected interconnect type

  • performance_rank (Integer)

    Performance rank from CUDA

  • p2p_supported (Boolean)

    P2P support status

  • native_atomics (Boolean) (defaults to: false)

    Native atomic support



44
45
46
47
48
49
50
51
52
# File 'lib/nvruby/collective/topology.rb', line 44

def initialize(src_device:, dst_device:, interconnect_type:,
               performance_rank:, p2p_supported:, native_atomics: false)
  @src_device = src_device
  @dst_device = dst_device
  @interconnect_type = interconnect_type
  @performance_rank = performance_rank
  @p2p_supported = p2p_supported
  @native_atomics = native_atomics
end

Instance Attribute Details

#dst_deviceInteger (readonly)

Returns Destination GPU device ID.

Returns:

  • (Integer)

    Destination GPU device ID



24
25
26
# File 'lib/nvruby/collective/topology.rb', line 24

def dst_device
  @dst_device
end

#interconnect_typeSymbol (readonly)

Returns Interconnect type (:nvlink, :pcie_p2p, :host_staged, :none).

Returns:

  • (Symbol)

    Interconnect type (:nvlink, :pcie_p2p, :host_staged, :none)



27
28
29
# File 'lib/nvruby/collective/topology.rb', line 27

def interconnect_type
  @interconnect_type
end

#native_atomicsBoolean (readonly)

Returns Whether native atomics are supported.

Returns:

  • (Boolean)

    Whether native atomics are supported



36
37
38
# File 'lib/nvruby/collective/topology.rb', line 36

def native_atomics
  @native_atomics
end

#p2p_supportedBoolean (readonly)

Returns Whether P2P access is supported.

Returns:

  • (Boolean)

    Whether P2P access is supported



33
34
35
# File 'lib/nvruby/collective/topology.rb', line 33

def p2p_supported
  @p2p_supported
end

#performance_rankInteger (readonly)

Returns Performance rank (0 = best).

Returns:

  • (Integer)

    Performance rank (0 = best)



30
31
32
# File 'lib/nvruby/collective/topology.rb', line 30

def performance_rank
  @performance_rank
end

#src_deviceInteger (readonly)

Returns Source GPU device ID.

Returns:

  • (Integer)

    Source GPU device ID



21
22
23
# File 'lib/nvruby/collective/topology.rb', line 21

def src_device
  @src_device
end

Instance Method Details

#bandwidth_gbpsFloat

Alias for estimated_bandwidth for test compatibility

Returns:

  • (Float)

    Bandwidth in GB/s



83
84
85
# File 'lib/nvruby/collective/topology.rb', line 83

def bandwidth_gbps
  estimated_bandwidth
end

#direct_access?Boolean

Returns Whether direct P2P is possible.

Returns:

  • (Boolean)

    Whether direct P2P is possible



67
68
69
# File 'lib/nvruby/collective/topology.rb', line 67

def direct_access?
  @p2p_supported && [:nvlink, :pcie_p2p].include?(@interconnect_type)
end

#estimated_bandwidthFloat

Estimated bandwidth in GB/s

Returns:

  • (Float)

    Bandwidth estimate



56
57
58
# File 'lib/nvruby/collective/topology.rb', line 56

def estimated_bandwidth
  INTERCONNECT_TYPES.dig(@interconnect_type, :bandwidth_gbps) || 0
end

#estimated_latencyFloat

Estimated latency in microseconds

Returns:

  • (Float)

    Latency estimate



62
63
64
# File 'lib/nvruby/collective/topology.rb', line 62

def estimated_latency
  INTERCONNECT_TYPES.dig(@interconnect_type, :latency_us) || Float::INFINITY
end

#nvlink?Boolean

Returns Whether this path uses NVLink.

Returns:

  • (Boolean)

    Whether this path uses NVLink



72
73
74
# File 'lib/nvruby/collective/topology.rb', line 72

def nvlink?
  @interconnect_type == :nvlink
end

#pcie_p2p?Boolean

Returns Whether this path uses PCIe P2P.

Returns:

  • (Boolean)

    Whether this path uses PCIe P2P



77
78
79
# File 'lib/nvruby/collective/topology.rb', line 77

def pcie_p2p?
  @interconnect_type == :pcie_p2p && @p2p_supported
end

#to_sString

Returns Human-readable description.

Returns:

  • (String)

    Human-readable description



88
89
90
91
# File 'lib/nvruby/collective/topology.rb', line 88

def to_s
  "Path[#{@src_device}#{@dst_device}]: #{@interconnect_type} " \
    "(rank=#{@performance_rank}, p2p=#{@p2p_supported})"
end