user3085931
user3085931

Reputation: 1803

Is it faster iterating columnwise than linewise over an n-m-Array?

I'll have this LABVIEW-program, where I have to iterate over large arrays (not queues) and thus I'm interested to speed them up the best as possible.

I think I've heard for OpenCV, when reading an element, the page where this element is extracted from, contains the following column elements. That means if I'd iterate by the lines for every element I'd have to load again a new page, which obviously slows down the whole process.

Does this apply to LABVIEW programs too?

Thanks for the support and kind regards

Upvotes: 3

Views: 925

Answers (3)

Joe Friedrichsen
Joe Friedrichsen

Reputation: 1986

In addition to row-then-column iteration, there are two techniques you can apply to maximize your array processing:

  1. Pipelining - which helps maximize core utilization for sequential tasks
  2. Parallel For loops - which provide data-parallelism

After that, there are other more complex designs like structured grids. There is an NI white paper that describes multi-core programming in LabVIEW, including these and other approaches, in more detail.

Upvotes: 1

Khachik Sahakyan
Khachik Sahakyan

Reputation: 1982

I benchmarked this. I have 100000x5 2D array. By iterating rows first it takes some 9ms from my i7 processor to complete. Iterating by columns first takes some 35ms to complete.

enter image description here

Upvotes: 2

srm
srm

Reputation: 3166

LabVIEW is row-major. If you take a 2D array and wire it to the border of a For Loop for auto indexing, the 1D arrays that you get out are the rows. Wire that into a nested For Loop to process the individual elements.

Upvotes: 2

Related Questions