示例#1
0
def TestExtended():
    class Add10(spe.ExtendedInstruction):
        isa_module = ppc

        def __init__(self, d, value):
            self.d = d
            self.value = value

            spe.ExtendedInstruction.__init__(self)

            return

        def block(self):
            for i in range(10):
                ppc.addi(self.d, self.d, self.value)
            return

    code = InstructionStream()
    proc = Processor()

    # Using code.add
    code.add(ppc.addi(code.gp_return, 0, 0))
    code.add(Add10(code.gp_return, 1))

    Add10.ex(1).eval(code, reg=code.gp_return)

    code.print_code()
    r = proc.execute(code)
    print r
    assert r == 20

    # Using active code
    code.reset()
    ppc.set_active_code(code)

    ppc.addi(code.gp_return, 0, 0)
    Add10(code.gp_return, 1)

    Add10.ex(1).eval(ppc.get_active_code(), reg=code.gp_return)

    code.print_code()
    r = proc.execute(code)
    print r
    assert r == 20

    return
示例#2
0
def TestExtended():
    class Add10(spe.ExtendedInstruction):
        isa_module = ppc

        def __init__(self, d, value):
            self.d = d
            self.value = value

            spe.ExtendedInstruction.__init__(self)

            return

        def block(self):
            for i in range(10):
                ppc.addi(self.d, self.d, self.value)
            return

    code = InstructionStream()
    proc = Processor()

    # Using code.add
    code.add(ppc.addi(code.gp_return, 0, 0))
    code.add(Add10(code.gp_return, 1))

    Add10.ex(1).eval(code, reg=code.gp_return)

    code.print_code()
    r = proc.execute(code)
    print r
    assert (r == 20)

    # Using active code
    code.reset()
    ppc.set_active_code(code)

    ppc.addi(code.gp_return, 0, 0)
    Add10(code.gp_return, 1)

    Add10.ex(1).eval(ppc.get_active_code(), reg=code.gp_return)

    code.print_code()
    r = proc.execute(code)
    print r
    assert (r == 20)

    return
示例#3
0
文件: gemm.py 项目: tmaone/efi
  def synthesize(self, code, tB, N):
    """
    Extract a block from B and pack it for fast access.

    tB is transposed.
    """
    old_code = ppc.get_active_code()
    ppc.set_active_code(code)

    code.add_storage(tB)

    self._init_constants(code, tB, N)
    self._init_vars()
    self._load_params()
    self._pack_b(code)

    ppc.set_active_code(old_code)        
    return
示例#4
0
  def synthesize(self, prgm, tB, M, K, N, kc, nc, mr = 1, nr = 1):
    code = prgm.get_stream()

    old_code = ppc.get_active_code()
    ppc.set_active_code(code)

    gepb  = SynGEPB(self.gepb_mode)
    packb = SynPackB()

    gepb._init_constants(M, K, N, kc, nc, mr, nr, True)
    packb._init_constants(prgm, tB, N)

    gepb._init_vars()

    # Reuse the C/C_aux registers for B.  They are set in init pointers.
    packb._init_vars2(gepb.p_C, gepb.c[0][0], gepb.r_tB_addr)
    
    gepb._load_params()
    packb._load_params(pvB = 7)

    # kN = k * N * 8
    # for j in range(0, N * 8, nc * 8):
    for j in syn_iter(code, N, nc):
      # # Pack B into tB -- tB1.transpose(B[k:k+kc, j:j+nc])
      # pack_params.p1 = B_addr + kN + j # (k * N + j) * 8      

      packb.vN.v = N
      packb._pack_b(code)

      # proc.execute(cgepb, params = pm)
      gepb._init_pointers()
      gepb._gepb(code)

      # pm.p3 += nc8      
      gepb.r_C_addr.v = gepb.r_C_addr + nc * 8

      packb.vB.v = packb.vB + nc * 8      

    # /end for j

    ppc.set_active_code(old_code)
    return 
示例#5
0
    def synthesize(self, prgm, tB, M, K, N, kc, nc, mr=1, nr=1):
        code = prgm.get_stream()

        old_code = ppc.get_active_code()
        ppc.set_active_code(code)

        gepb = SynGEPB(self.gepb_mode)
        packb = SynPackB()

        gepb._init_constants(M, K, N, kc, nc, mr, nr, True)
        packb._init_constants(prgm, tB, N)

        gepb._init_vars()

        # Reuse the C/C_aux registers for B.  They are set in init pointers.
        packb._init_vars2(gepb.p_C, gepb.c[0][0], gepb.r_tB_addr)

        gepb._load_params()
        packb._load_params(pvB=7)

        # kN = k * N * 8
        # for j in range(0, N * 8, nc * 8):
        for j in syn_iter(code, N, nc):
            # # Pack B into tB -- tB1.transpose(B[k:k+kc, j:j+nc])
            # pack_params.p1 = B_addr + kN + j # (k * N + j) * 8

            packb.vN.v = N
            packb._pack_b(code)

            # proc.execute(cgepb, params = pm)
            gepb._init_pointers()
            gepb._gepb(code)

            # pm.p3 += nc8
            gepb.r_C_addr.v = gepb.r_C_addr + nc * 8

            packb.vB.v = packb.vB + nc * 8

        # /end for j

        ppc.set_active_code(old_code)
        return
示例#6
0
  def synthesize(self, prgm, tB, N):
    """
    Extract a block from B and pack it for fast access.

    tB is transposed.
    """
    code = prgm.get_stream()

    old_code = ppc.get_active_code()
    ppc.set_active_code(code)

    prgm.add_storage(tB)

    self._init_constants(prgm, tB, N)
    self._init_vars()
    self._load_params()
    self._pack_b(code)

    ppc.set_active_code(old_code)        
    return
示例#7
0
  def synthesize(self, prgm, M, K, N, kc, nc, mr = 1, nr = 1, _transpose = False): 
    """
    tA is M  x nc
    tB is nc x kc
    C  is M  x nc
    I  is the current block column in C
    """
    code = prgm.get_stream()

    old_code = ppc.get_active_code()
    ppc.set_active_code(code)

    self._init_constants(M, K, N, kc, nc, mr, nr, _transpose)

    self._init_vars()
    self._load_params()
    self._init_pointers()

    self._gepb(code)
    
    ppc.set_active_code(old_code)
    return
示例#8
0
文件: gemm.py 项目: tmaone/efi
  def synthesize(self, code, M, K, N, kc, nc, mr = 1, nr = 1, _transpose = False): 
    """
    tA is M  x nc
    tB is nc x kc
    C  is M  x nc
    I  is the current block column in C
    """


    old_code = ppc.get_active_code()
    ppc.set_active_code(code)

    self._init_constants(M, K, N, kc, nc, mr, nr, _transpose)

    self._init_vars()
    self._load_params()
    self._init_pointers()

    self._gepb(code)
    
    ppc.set_active_code(old_code)
    return
示例#9
0
 def _get_active_code(self):
     return ppc.get_active_code()
示例#10
0
 def _get_active_code(self):
   return ppc.get_active_code()