Exemple #1
0
    def __init__(self, vm: VM, src: Symbol, dest: Symbol):
        super(GetElementPtr, self).__init__(vm)

        if src.stype != SymbolType.Batch:
            raise InternalError('ptr: operand `src` is not in a batch')

        if not isinstance(src.obj, Matrix):
            raise InternalError(f'ptr: operand `src` is not a matrix')

        if dest.stype != SymbolType.Global:
            raise InternalError('ptr: operand `dest` is not in global mem.')

        if not isinstance(dest.obj, Matrix):
            raise InternalError('ptr: operand `dest` is not a matrix')

        dest.data_view = DataView(rows=src.obj.get_actual_num_rows(),
                                  columns=src.obj.get_actual_num_cols(),
                                  lead_dim=src.obj.num_rows,
                                  is_transposed=False)

        self._dest = dest
        self._src = src
        self._is_ready = True

        src.add_user(self)
        dest.add_user(self)
Exemple #2
0
  def __init__(self,
               vm: VM,
               src: Symbol,
               dest: Symbol,
               alpha: float,
               beta: float,
               num_threads: int):
    super(StoreRegToGlb, self).__init__(vm)

    if src.stype != SymbolType.Register:
      raise InternalError('store: operand `src` is not in reg mem')

    if not isinstance(src.obj, RegMemObject):
      raise InternalError(f'store: operand `src` is registers, instead: {type(src.obj)}')

    if dest.stype != SymbolType.Global:
      raise InternalError('store: operand `dest` is not in global memory.')

    if not isinstance(dest.obj, Matrix):
      raise InternalError('store: operand `dest` is not a matrix')

    src.add_user(self)
    dest.add_user(self)

    dest.data_view = DataView(rows=dest.obj.get_actual_num_rows(),
                              columns=dest.obj.get_actual_num_cols(),
                              lead_dim=dest.obj.num_rows,
                              is_transposed=False)

    self._dest: Symbol = dest
    self._src: Symbol = src
    self._alpha = alpha
    self._beta = beta
    self._num_threads: int = num_threads
    self._is_ready: bool = True
    def __init__(self, vm: VM, src: Symbol):
        super(ClearRegisters, self).__init__(vm)

        if src.stype != SymbolType.Register:
            raise InternalError('ptr: operand `src` is not in registers')

        self._is_ready = True
        self._src = src
        src.add_user(self)
    def build(self, size: Union[int, None] = None):
        self._reset()
        name = self._name_new_symbol()
        self._obj = ShrMemObject(name, size)
        dest = Symbol(name=name, stype=SymbolType.SharedMem, obj=self._obj)

        self._scopes.add_symbol(dest)
        self._instructions.append(ShrMemAlloc(self._vm, dest, size))
    def build(self, size: int, init_value: Union[float, None] = None):
        self._reset()
        name = self._name_new_symbol()
        self._obj = RegMemObject(name, size)
        dest = Symbol(name, SymbolType.Register, self._obj)

        self._scopes.add_symbol(dest)
        self._instructions.append(
            RegisterAlloc(self._vm, dest, size, init_value))
Exemple #6
0
    def __init__(self, vm: VM, trans_a: bool, trans_b: bool, op1: Symbol,
                 op2: Symbol, dest: Symbol):
        super(Gemm, self).__init__(vm)
        self._trans_a = trans_a
        self._trans_b = trans_b
        self._op1 = op1
        self._op2 = op2
        self._is_ready = True

        self.registers = None
        if dest.stype != SymbolType.Register:
            raise InternalError(
                f'gemm: accumulator-register array is not provided. Instead: {dest.stype}'
            )
        else:
            self._dest = dest

        if not isinstance(self._op1.obj, Matrix):
            raise InternalError('gemm: op1 is not a matrix')

        if not isinstance(self._op2.obj, Matrix):
            raise InternalError('gemm: op2 is not a matrix')

        op1.add_user(self)
        op2.add_user(self)
        dest.add_user(self)
Exemple #7
0
  def __init__(self,
               vm: VM,
               src: Symbol,
               dest: Symbol,
               shr_mem: Symbol,
               num_threads: int):
    super(StoreRegToShr, self).__init__(vm)

    if src.stype != SymbolType.Register:
      raise InternalError('store: operand `src` is not in registers')

    if not isinstance(src.obj, RegMemObject):
      raise InternalError(f'store: operand `src` is not registers, instead: {type(src.obj)}')

    if dest.stype != SymbolType.SharedMem:
      raise InternalError('store: operand `dest` is not in shared mem.')

    if not isinstance(dest.obj, Matrix):
      raise InternalError(f'store: operand `dest` is not a matrix, instead: {type(src.obj)}')

    src.add_user(self)
    dest.add_user(self)
    shr_mem.add_user(self)

    dest.data_view = DataView(rows=dest.obj.get_actual_num_rows(),
                              columns=dest.obj.get_actual_num_cols(),
                              lead_dim=dest.obj.num_rows,
                              is_transposed=False)

    self._dest: Symbol = dest
    self._src: Symbol = src
    self._shr_mem: Symbol = shr_mem
    self._num_threads: int = num_threads
    self._shr_mem_offset: Union[int, None] = None
    view: DataView = self._dest.data_view
    self._shm_volume: int = view.rows * view.columns