stwo fibonacci

it is about this example in stwo

two parameters:

FIB_SEQUENCE_LENGTH specifies the rounds of fibo sequence

LOG_N_INSTANCES as stwo use SIMD, data parallel data struct, this number specify how many instances of fibo sequences are proved at the same time. The data are packed in LOG_N_LANES chunks, which is 16 each chunk, so LOG_N_INSTANCES is at least 5 which is at least 32 instances (I don’t know why it is not 16)

with FIB_SEQUENCE_LENGTH=4 LOG_N_INSTANCES =5

run this test function

print the input here I can get

[FibInput { a: PackedM31([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), b: PackedM31([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) }, FibInput { a: PackedM31([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), b: PackedM31([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) }]

generate trace after this would be

[BaseColumn { data: [PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])], length: 32 }, 
BaseColumn { data: [PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])], length: 32 }, 
BaseColumn { data: [PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])], length: 32 }, 
BaseColumn { data: [PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), PackedM31([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])], length: 32 }]

after fibonacci operation, it looks like

[BaseColumn { data: [PackedM31([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), PackedM31([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])], length: 32 }, 
BaseColumn { data: [PackedM31([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), PackedM31([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])], length: 32 }, 
BaseColumn { data: [PackedM31([1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145, 170, 197, 226]), PackedM31([257, 290, 325, 362, 401, 442, 485, 530, 577, 626, 677, 730, 785, 842, 901, 962])], length: 32 }, 
BaseColumn { data: [PackedM31([1, 5, 29, 109, 305, 701, 1405, 2549, 4289, 6805, 10301, 15005, 21169, 29069, 39005, 51301]), PackedM31([66305, 84389, 105949, 131405, 161201, 195805, 235709, 281429, 333505, 392501, 459005, 533629, 617009, 709805, 812701, 926405])], length: 32 }]

for every baseColumn, at the same row (the same location in the vector) form a fibonacci sequence.

Leave a Reply

Your email address will not be published. Required fields are marked *