Any method to reduce the calculation time on PS (PYNQ-z2)

As proof of this you can make a very quick check.

import pynq
import numpy as np

#### Download your overlay here ####

# Declare test array, an 8-element array from 0 to 7
test_array = np.arange(0, 8, dtype=np.uint8)

#Assign test array to an 8-element (8-bit) pynq buffer
in_buff1 = pynq.allocate((8,), dtype=np.uint8)
in_buff1[:] = test_array

# Assign test array to a 1-element (64-bit) pynq buffer
in_buff2 = pynq.allocate((1,), dtype=np.uint64)
aux = 0;
for i in range(len(test_array)):
    aux += test_array[i] * 2**(i*8)
in_buff2[:] = aux

# Compare byte representation (this is how the elements are stored in memory)
print("Byte representation equal: {}".format(in_buff2.tobytes() == in_buff1.tobytes()))

Hope this helps
Mario

1 Like