It looks like I have to reload the dma everytime I need to get the computations for new values. How do I overcome this?
This is the code that I am using:
import time
import struct
from pynq import Overlay
import pynq.lib.dma
from pynq import Xlnk
import numpy as np
from pynq import MMIO
ol = Overlay('kernel.bit') # check your path
ol.download() # it downloads your bit to FPGA
dma = ol.axi_dma_0 # creating a dma instance. Note that we packed smul and smul_dma into streamMul
sadd_ip = ol.smul_0
xlnk = Xlnk()
def pl_rbf_kernel(samples):
length = samples.shape[0]
in_buffer = xlnk.cma_array(shape=(length,), dtype=np.float32)
np.copyto(in_buffer, samples)
sadd_ip.write(0x18, length)
dma.sendchannel.transfer(in_buffer)
dma.sendchannel.wait()
in_buffer.close()
return struct.unpack("f", struct.pack("I", sadd_ip.read(0x10)))
pl_rbf_kernel(np.load('array.npy')[0:500])
When I run the last line for differnt values, it gives me results for the previous input. When I run it once again then it gives me results for the current input.