Skip to content

PIM API

Deyuan Guo edited this page Oct 6, 2024 · 2 revisions

Overview

PIMeval provides a single public header for PIM benchmark application development, locating at libpimeval/src/libpimeval.h. Details of data types and APIs of this header are described in this wiki page.

(more details to be added)

Data Structure

  • PimObjId
    • An integer value represents an allocated PIM object.
  • PimDeviceEnum
    • PIM architecture.
  • PimAllocEnum
    • PIM allocation strategy.
    • PIM_ALLOC_AUTO: Recommended way which can automatically determine V or H data layouts based on functional simulation target.
  • PimDataType
    • PIM object element data type required for allocating a PIM object.
  • PimCopyEnum
    • Data copy strategy.
  • PimDeviceProperties
    • PIM device properties.

APIs

PIM Device Management

  • pimCreateDevice
    • Create a PIM device of a specific PIM device type to start simulation.
    • Use PIM_FUNCTIONAL for functional simulation, so that a PIM benchmark can work for multiple PIM simulation targets.
    • Use specific PIM device type for micro-ops level simulation.
  • pimCreateDeviceFromConfig
    • Read PIMeval and device parameters from a config file.
    • Alternatively, config file can be specified through environment variables.
      • PIMEVAL_TARGET
      • PIMEVAL_CONFIG_PATH
      • PIMEVAL_CONFIG_SIM
  • pimGetDeviceProperties
    • Get PIM device properties.
  • pimDeleteDevice
    • Delete PIM device and end simulation.

PIM Data Object Management

  • pimAlloc
    • Allocate a new PIM data object.
  • pimAllocAssociated
    • Allocate a new PIM data object associated with an existing PIM object.
    • Associated PIM objects have same number of elements, and element indices are aligned during allocation.
  • pimFree
    • Delete a PIM object and free the memory space.

Data Transfer

  • pimCopyHostToDevice
    • Copy data from CPU memory space to PIM memory space.
  • pimCopyDeviceToHost
    • Copy data from PIM memory space to CPU memory space.
  • pimCopyDeviceToDevice
    • COpy data between two associated PIM objects.

PIM Computation

Arithmetic

  • pimAdd - C[i] = A[i] + B[i]
  • pimSub - C[i] = A[i] - B[i]
  • pimMul - C[i] = A[i] * B[i]
  • pimDiv - C[i] = A[i] / B[i]
  • pimAbs - C[i] = abs(A[i])
  • pimMin - C[i] = min(A[i], B[i])
  • pimMax - C[i] = max(A[i], B[i])
  • pimAddScalar - C[i] = A[i] + scalar
  • pimSubScalar - C[i] = A[i] - scalar
  • pimMulScalar - C[i] = A[i] * scalar
  • pimDivScalar - C[i] = A[i] / scalar
  • pimMinScalar - C[i] = min(A[i], scalar)
  • pimMaxScalar - C[i] = max(A[i], scalar)

Bitwise

  • pimAnd - C[i] = A[i] & B[i]
  • pimOr - C[i] = A[i] | B[i]
  • pimXor - C[i] = A[i] ^ B[i]
  • pimXnor - C[i] = ~(A[i] ^ B[i])
  • pimAndScalar - C[i] = A[i] & scalar
  • pimOrScalar - C[i] = A[i] | scalar
  • pimXorScalar - C[i] = A[i] ^ scalar
  • pimXnorScalar - C[i] = ~(A[i] ^ scalar)
  • pimShiftBitsRight - C[i] = A[i] >> shiftAmount
  • pimShiftBitsLeft - C[i] = A[i] << shiftAmount
  • pimPopCount - C[i] = popcount(A[i])

Relational

  • pimGT - C[i] = A[i] > B[i]
  • pimLT - C[i] = A[i] < B[i]
  • pimEQ - C[i] = A[i] == B[i]
  • pimGTScalar - C[i] = A[i] > scalar
  • pimLTScalar - C[i] = A[i] < scalar
  • pimEQScalar - C[i] = A[i] == scalar

Reduction sum

  • pimRedSumInt - result = sum of all elements in A
  • pimRedSumUInt - result = sum of all elements in A
  • pimRedSumRangedInt - result = sum of elements of a range in A
  • pimRedSumRangedUInt - result = sum of elements of a range in A

Broadcast

  • pimBroadcastInt - C[i] = scalar
  • pimBroadcastUInt - C[i] = scalar

Element-wise shift/rotate

  • pimRotateElementsRight - In place, A[i] = A[i - 1], A.first = A.last
  • pimRotateElementsLeft - In place, A[i] = A[i + 1], A.last = A.first
  • pimShiftElementsRight - In place, A[i] = A[i - 1]
  • pimShiftElementsLeft - In place, A[i] = A[i + 1]

Micro-ops Simulation APIs

To be added.