LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW code speed optimization

Any definitive reference that explains in technical terms why shift
registers are faster than globals for variable memory?

/dev/null
0 Kudos
Message 1 of 3
(2,972 Views)
The simple answer is that a shift register is a memory allocation reused, the global however creates copies wherever it is placed. That means more memory used and slower code due to the memory operations involved.

There are other reasons to use shift registers / functional globals as well. It's easier to avoid race conditions, you can include manipulation methods inside the functional global so that you can work directly on the data, you can have error handling etc...
0 Kudos
Message 2 of 3
(2,972 Views)
> Any definitive reference that explains in technical terms why shift
> registers are faster than globals for variable memory?
>

There are articles on devzone, you might look in particular at the Dr.
VI articles.

The short summary is that access requires protection. Shift registers
have very limited access that is well suited to optimizations, and
globals can be accessed at anytime from anywhere with accessors coming
and going from memory via the VI server. This flexibility means that
you never know much about the access patterns of the global, and it is
hard to optimize them without introducing race conditions or deadlocks.

Functional globals restrict that access to one diagram and to one caller
at a time, so they immediately gain an advantage. W
hen implemented with
a shift register, it is clear only one place on that diagram has access,
and the compiler can go further.

Greg McKaskle
0 Kudos
Message 3 of 3
(2,972 Views)