Пример #1
0
    def _load_parameters(self, code):
        #range_md = spuiter.memory_desc('I') # use 'I' for sizeof(float)
        #range_md.from_array(self.range)

        #pattern_md = spuiter.memory_desc('I')
        #pattern_md.from_array(self.pattern)

        # Range is in address 0-63
        #range_md.get(code, 0)
        size = len(self.range) * self.range.itemsize
        dma.mem_get(code, 0, self.range.buffer_info()[0], size, 12)
        #dma.mem_complete(code, 12)

        # Pattern is at address 64
        #pattern_md.get(code, 64)
        size = len(self.pattern) * self.pattern.itemsize
        dma.mem_get(code, 64, self.pattern.buffer_info()[0], size, 12)
        dma.mem_complete(code, 12)

        return
Пример #2
0
  def _load_parameters(self, code):
    #range_md = spuiter.memory_desc('I') # use 'I' for sizeof(float)
    #range_md.from_array(self.range)

    #pattern_md = spuiter.memory_desc('I')
    #pattern_md.from_array(self.pattern)

    # Range is in address 0-63
    #range_md.get(code, 0)
    size = len(self.range) * self.range.itemsize
    dma.mem_get(code, 0, self.range.buffer_info()[0], size, 12)
    #dma.mem_complete(code, 12)

    # Pattern is at address 64
    #pattern_md.get(code, 64)
    size = len(self.pattern) * self.pattern.itemsize
    dma.mem_get(code, 64, self.pattern.buffer_info()[0], size, 12)
    dma.mem_complete(code, 12)
    
    return
Пример #3
0
  SPUS = 6

  proc = env.Processor()
  prgms = [env.Program() for i in xrange(0, SPUS)]

  for rank, prgm in enumerate(prgms):
    code = prgm.get_stream()
    spu.set_active_code(code)

    # First all the SPUs should start up and wait for an mbox message.
    # The PPU will collect all the PS map addresses into an array for the SPUs.
    r_psinfo_mma = dma.spu_read_signal1(code)

    # DMA the PS info into local store
    dma.mem_get(code, 0x0, r_psinfo_mma, SPUS * 4 * 4, 17)
    dma.mem_complete(code, 17)

    # Load the PS info into some registers.. one register per address
    r_psinfo = prgm.acquire_registers(SPUS)
    for i in xrange(0, SPUS):
      spu.lqd(r_psinfo[i], code.r_zero, i)

    # Initialize a data register with this rank and store it at LSA 0
    r_send = prgm.acquire_register()
    load_word(code, r_send, rank)
    spu.stqd(r_send, code.r_zero, 0)
    prgm.release_register(r_send)

    # Send our rank as a mailbox message to the rank after this rank
    dma.mem_write_in_mbox(code, r_psinfo[(rank + 1) % SPUS], 12, 18)
    dma.mem_complete(code, 18)
Пример #4
0
import corepy.arch.spu.lib.dma as dma
from corepy.arch.spu.lib.util import load_word

if __name__ == '__main__':
  a = extarray.extarray('i', range(0, 32))
  b = extarray.extarray('i', [0 for i in range(0, 32)])
  prgm = env.Program()
  code = prgm.get_stream()
  proc = env.Processor()

  spu.set_active_code(code)

  abi = a.buffer_info()
  print "abi", abi, a.itemsize
  dma.mem_get(code, 0x1000, abi[0], abi[1] * a.itemsize, 2)
  dma.mem_complete(code, 2)

  bbi = b.buffer_info()
  print "bbi", bbi, b.itemsize
  dma.mem_put(code, 0x1000, bbi[0], bbi[1] * b.itemsize, 2)
  dma.mem_complete(code, 2)

  prgm.add(code)
  prgm.print_code()
  proc.execute(prgm)
 
  for i in range(0, 32):
    if b[i] != i:
      print "ERROR %d %d %d" % (i, b[i], a[i])

 
Пример #5
0
import corepy.lib.extarray as extarray
import corepy.arch.spu.isa as spu
import corepy.arch.spu.platform as env
import corepy.arch.spu.lib.dma as dma
from corepy.arch.spu.lib.util import load_word

if __name__ == '__main__':
    a = extarray.extarray('i', range(0, 32))
    b = extarray.extarray('i', [0 for i in range(0, 32)])
    code = env.InstructionStream()
    proc = env.Processor()

    spu.set_active_code(code)

    abi = a.buffer_info()
    print "abi", abi, a.itemsize
    dma.mem_get(code, 0x1000, abi[0], abi[1] * a.itemsize, 2)
    dma.mem_complete(code, 2)

    bbi = b.buffer_info()
    print "bbi", bbi, b.itemsize
    dma.mem_put(code, 0x1000, bbi[0], bbi[1] * b.itemsize, 2)
    dma.mem_complete(code, 2)

    code.print_code()
    proc.execute(code)

    for i in range(0, 32):
        if b[i] != i:
            print "ERROR %d %d %d" % (i, b[i], a[i])