LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compiled Code runs on one Core

Solved!
Go to solution

Hi Everyone,

 

My compiled code seems to be using only one core when it is compiled, the other cores don't seem to have a notice change when running to code. I have read a lot about the possible reasons for this and have already done a few things to ensure that it's not something simple. I have done the following:

 

  1. Gone through and made sure as many VIs as possible are running in non-reentrant mode
  2. My code is completely split into smaller While loops so that no single VI does anything particularly complicated
  3. I have made sure that all VIs can run "asynchronously" from every other VI

So, some possible thoughts as to why this is occuring is the following:

 

  1. I have written a system so that I can fetch Control References from one VI to another, and use that to share info between VIs (I have read that Property and Method nodes are however synchronous and perhaps this is the problem, I tried creating an asynchronous call to a VI that reads and writes property nodes but that seemed to have made my code slower (see attachment)
  2. I have DLL that have to be called on the UI thread, however I have checked these and they don't use any significant amount of CPU so I doubt that they are the problem

If there is something I am missing that is causing this behavior than I would love to hear back from someone!

 

Cheers,

Nik

 

 

Download All
0 Kudos
Message 1 of 5
(2,300 Views)

If your code is using property nodes they must execute in the UI thread, which forces the execution of all your VIs into a single thread. A single thread only needs a single core.

 

Without more information, I'd imagine that's the issue you're seeing.

0 Kudos
Message 2 of 5
(2,298 Views)

Thanks for the reply! That's what I thought the issue was going to be. Would you know any way that I could asynchronously call property nodes so that it would free up CPU time for my SubVIs while not altering the architecture too much?

0 Kudos
Message 3 of 5
(2,274 Views)
Solution
Accepted by NikolaRistovski

You can call a property node any way you like, but the actual code execution OF the property node will ALWAYS be in the UI Thread AFAIK.

 

There are other methods where you can share values between FP controls and indicators by reference which does NOT require the UI Thread.

 

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/set_ctrl_val_by_index/

 

I thik it's called "Set Value by Index" or something. It's similar to how a local variable works. Changing that aspect might be your best bet.

0 Kudos
Message 4 of 5
(2,267 Views)

Hi Nik,

 

As Intaris mentioned - "Get Control Values by Index" and "Set Control Values by Index" are much

more efficient than property nodes.

 

Your ref to ref code using Get/Set by index:

 

conrtol index update.png

Note: You must supply the vi server reference to the source and destination controls/indicators

          (if they are not in the vi where this code resides) in addition to their Control Indexes.

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 5 of 5
(2,200 Views)