Пример #1
0
 def __init__(self):
     self.uio          = Uio('uio_argsort')
     self.argsort_axi  = ArgSort_AXI(self.uio.regs())
     self.udmabuf_in   = Udmabuf('udmabuf-argsort-in' )
     self.udmabuf_out  = Udmabuf('udmabuf-argsort-out')
     self.udmabuf_tmp  = Udmabuf('udmabuf-argsort-tmp')
     self.in_dtype     = np.uint32
     self.out_dtype    = np.uint32
     self.tmp_dtype    = np.uint64
     self.in_max_size  = min((self.udmabuf_in .buf_size   ) // (np.dtype(self.in_dtype ).itemsize), self.argsort_axi.max_size)
     self.out_max_size = min((self.udmabuf_out.buf_size   ) // (np.dtype(self.out_dtype).itemsize), self.argsort_axi.max_size)
     self.tmp_max_size = min((self.udmabuf_tmp.buf_size//2) // (np.dtype(self.tmp_dtype).itemsize), self.argsort_axi.max_size)
     self.debug_mode   = 0
Пример #2
0
class ArgSort_Test:
    
    def __init__(self):
        self.uio          = Uio('uio_argsort')
        self.argsort_axi  = ArgSort_AXI(self.uio.regs())
        self.udmabuf_in   = Udmabuf('udmabuf-argsort-in' )
        self.udmabuf_out  = Udmabuf('udmabuf-argsort-out')
        self.udmabuf_tmp  = Udmabuf('udmabuf-argsort-tmp')
        self.in_dtype     = np.uint32
        self.out_dtype    = np.uint32
        self.tmp_dtype    = np.uint64
        self.in_max_size  = min((self.udmabuf_in .buf_size   ) // (np.dtype(self.in_dtype ).itemsize), self.argsort_axi.max_size)
        self.out_max_size = min((self.udmabuf_out.buf_size   ) // (np.dtype(self.out_dtype).itemsize), self.argsort_axi.max_size)
        self.tmp_max_size = min((self.udmabuf_tmp.buf_size//2) // (np.dtype(self.tmp_dtype).itemsize), self.argsort_axi.max_size)
        self.debug_mode   = 0

    def memmap_in(self, size):
        if (size > self.in_max_size):
            raise ValueError('size({0}) is over size of in-buffer({1})' .format(size,self.in_max_size ))
        return self.udmabuf_in .memmap(dtype=self.in_dtype , shape=(size))

    def memmap_out(self, size):
        if (size > self.out_max_size):
            raise ValueError('size({0}) is over size of out-buffer({1})'.format(size,self.out_max_size))
        return self.udmabuf_out.memmap(dtype=self.out_dtype, shape=(size))

    def allocate_array(self, size):
        if (size > self.tmp_max_size):
            raise ValueError('size({0}) is over size of tmp-buffer({1})'.format(size,self.tmp_max_size))
        self.in_array   = self.memmap_in(size)
        self.out_array  = self.memmap_out(size)
        
    def run(self):
        start = time.time()
        self.argsort_axi.setup(self.udmabuf_in .phys_addr ,
                               self.udmabuf_out.phys_addr,
                               self.udmabuf_tmp.phys_addr + 0x00000000,
                               self.udmabuf_tmp.phys_addr + self.udmabuf_tmp.buf_size//2,
                               self.in_array.size,
                               self.debug_mode
        )
        self.uio.irq_on()
        self.argsort_axi.start()
        self.uio.wait_irq()
        self.argsort_axi.clear_status()
        self.run_time = time.time() - start
Пример #3
0
from udmabuf import Udmabuf
from uio     import Uio
import numpy as np
import time

if __name__ == '__main__':
    uio1       = Uio('uio1')
    regs       = uio1.regs()
    udmabuf4   = Udmabuf('udmabuf4')
    udmabuf5   = Udmabuf('udmabuf5')
    test_dtype = np.uint32
    test_size  = min(int(udmabuf4.buf_size/(np.dtype(test_dtype).itemsize)),
                     int(udmabuf5.buf_size/(np.dtype(test_dtype).itemsize)))
  
    udmabuf4_array    = udmabuf4.memmap(dtype=test_dtype, shape=(test_size))
    udmabuf4_array[:] = np.random.randint(-21474836478,2147483647,(test_size))
    udmabuf4.set_sync_to_device(0, test_size*(np.dtype(test_dtype).itemsize))

    udmabuf5_array    = udmabuf5.memmap(dtype=test_dtype, shape=(test_size))
    udmabuf5_array[:] = np.random.randint(-21474836478,2147483647,(test_size))
    udmabuf5.set_sync_to_cpu(   0, test_size*(np.dtype(test_dtype).itemsize))

    total_setup_time   = 0
    total_cleanup_time = 0
    total_xfer_time    = 0
    total_xfer_size    = 0
    count              = 0

    for i in range (0,9):

        start_time  = time.time()
Пример #4
0
from udmabuf import Udmabuf
from uio     import Uio
from pump    import Pump
import numpy as np
import time

if __name__ == '__main__':
    uio0       = Uio('uio0')
    pump       = Pump(uio0.regs())
    udmabuf4   = Udmabuf('udmabuf4')
    udmabuf5   = Udmabuf('udmabuf5')
    test_dtype = np.uint8
    test_size  = min(int(udmabuf4.buf_size/(np.dtype(test_dtype).itemsize)),
                     int(udmabuf5.buf_size/(np.dtype(test_dtype).itemsize)))

    udmabuf4_array = udmabuf4.memmap(dtype=test_dtype, shape=(test_size))
    udmabuf5_array = udmabuf5.memmap(dtype=test_dtype, shape=(test_size))

    udmabuf4_array[:] = np.random.randint(0,255,(test_size))
    udmabuf5_array[:] = np.random.randint(0,255,(test_size))

    total_time = 0
    total_size = 0
    count      = 0
    for i in range (0,9):
        start = time.time()
        pump.setup(udmabuf4.phys_addr, udmabuf5.phys_addr, test_size)
        uio0.irq_on()
        pump.start()
        uio0.wait_irq()
        pump.clear_status
from udmabuf import Udmabuf
from uio import Uio
import numpy as np
import time

if __name__ == '__main__':
    uio1 = Uio('negative-uio')
    regs = uio1.regs()
    udmabuf4 = Udmabuf('negative-udmabuf4')
    udmabuf5 = Udmabuf('negative-udmabuf5')

    test_dtype = np.uint32
    test_size = min(int(udmabuf4.buf_size / (np.dtype(test_dtype).itemsize)),
                    int(udmabuf5.buf_size / (np.dtype(test_dtype).itemsize)))

    udmabuf4_array = udmabuf4.memmap(dtype=test_dtype, shape=(10))
    udmabuf4_array[:] = [
        64591051, 3172697395, 0, 0, 76157580, 46281898, 1342177280, 48498273,
        3373798755, 4290117632
    ]
    udmabuf4.set_sync_to_device(0, 10 * (np.dtype(test_dtype).itemsize))

    udmabuf5_array = udmabuf5.memmap(dtype=test_dtype, shape=(4))
    udmabuf5_array[:] = [0, 0, 0, 0]
    udmabuf5.set_sync_to_cpu(0, 4 * (np.dtype(test_dtype).itemsize))

    print(udmabuf4_array)
    print(udmabuf5_array)
    total_setup_time = 0
    total_cleanup_time = 0
    total_xfer_time = 0