并行架构与编程(十四)implementation of message passing abstraction, one level above socket

1. message passing abstraction

  • threads operate within their own private address spaces
  • communicated by sending/receiving messages
    • send:
      • recipient
      • buffer to transmitted
      • optional message identifier(tag)
    • receive:
      • sender
      • buffer to store data
      • optional message identifier(tag)
  • only source knows the destination address
  • only destination knows the source address
  • application
    • network transaction: one-way transfer of information from a source output buffer to a destination input buffer
    • shared address space abstraction: two-way request/response protocol with ack
      • remote operations can be performed on remote memory
  • synchronous
    • send completed after matching receive and source data sent
    • receive completes after data transfer complete from matching send
  • asynchronous:
    • send completes after send buffer may be reused

2. synchronous message passing

  • matching phase
    • initiate send
    • address translation
    • local/remote check
    • send-ready request
    • remote check for posted receive
    • reply transaction
  • data transfer phase
    • source VA -> Dest VA

  • no need to consider contention and buffering at destination
  • performance is terrible

3. asynchronous message passing

3.1. optimistic async

  • initiate send
  • address translation
  • local/remote check
  • send data
  • remote check for posted receive; on fail, allocate data buffer

  • pros
    • good for short messages
  • cons
    • buffer overflow
    • storage is required within the message layer

3.2. conservative async

  • matching phase
    • initiate send
    • address translation
    • local/remote check
    • send ready request, then local can resume computing
    • remote check for posted receive; record send-ready
  • data transfer phase
    • when remote call receive then allocate buffer and send ready request
    • local receive ready request
    • transfer data
      • source VA -> Dest VA

  • pros
    • safer, no contention for buffering
  • cons
    • short messages have high latency

3.3. features of message passing abstraction

  • source knows send address, destination knows receive address
    • no need for service discovery
  • arbitrary storage “outside of the local address spaces”
  • fundamentally a 3-phase transaction

3.4. credit-based async

  • hybrid method
    • pre-allocate limited amount of space(credit) per sender
    • optimistic async: if the sender knows it has sufficient credit at a receiver
    • conservative async: no sufficient credit
  • implementation: tracking credit limit
    • decreased upon send
    • increased piggybacked with msgs

3.5. avoidling fetch deadlock

  • prob: must continue accepting messages, even when cannot source msgs
    • what if incoming transaction is a request
  • solution: must continue accepting messages, even if result cannot sending out
    • approach 1: logically independent request/reply networks
      • physical networks
      • virtual channels
    • approach 2: bound requests and reserve input buffer space
    • approach 3: NACK on input buffer call

4. summary