LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to separate execution threads to different CPU core?

I have code that needs to be executed in parallel.  The code is not in a loop.  One part of the code needs to handle GUI selections while the other part of the code does something else.  I want each thread to run in a separate core because the other part of the code is taking over all the processing from both cores and prevents the GUI selection portion to run in parallel.  Unfortunately, I cannot post the code.

 

0 Kudos
Message 1 of 6
(3,515 Views)

Do you need to use separate CPU cores?

 

Are you simply trying to run things in parallel and one thread is hogging down the execution?  Is the code into two separate sub-vis?

If so, you could change their priorities and see if that works...  Set the higher priority to the GUI subvi and a lower priority to the other thread.

 

I only know of using a timed loop (or for loop) to separate the execution over different cores or CPUs.

 

Which version of LabVIEW are you using?

 

I would need to see the code or at least its architecture to suggest anything really useful... 

0 Kudos
Message 2 of 6
(3,513 Views)

@schtrumphette wrote:

Unfortunately, I cannot post the code. 


Unfortunately, I don't think we can help much in this case. There is an infinite number of possibilities that could explain what you are seeing (or think you are seeing ;))

 

Why is the other code using all CPU? What does it do? (heavy processing of large data? Mindlessly spinning nearly empty loops as fast as it can? Is it forced to run in the UI thread?)

 

How many CPU cores do you have? Why do you think forcing CPU assignment will solve your problem? 

 

Are you sure the GUI section cannot run in parallel because of processor hogging? Could it be you have a dataflow problem? Could it be you have event structures that lock the front panel while executing lenghy events? Could it be you have gigantic data structures (e.g. graphs with millions of points) and heavily overlapping objects, etc. that take forever to refresh?

 

In any case, your question should be "How can I keep the UI responsive". Correctly programmed, this is always possible, even on a computer with only a single core processor. CPU assignement is probably NOT the solution, this is better left to LabVIEW and the OS to decide.

0 Kudos
Message 3 of 6
(3,510 Views)

@schtrumphette wrote:

The code is not in a loop.


What does this even mean? The code of a toplevel VI should always be in a loop!

Are you possibly using the "continous run" mode?

0 Kudos
Message 4 of 6
(3,507 Views)

The code has a top level GUI.  It has 2 other parts.  One thread calls an application using ActiveX,  The other thread calls a sub-GUI to select the configuration.  The application being called using ActiveX needs to load lots of data and analyze it.  This takes minutes.  In the meantime, we want to be able to select the configuration.  Although the ActiveX call is slow, it uses very little CPU (~15%).  LabVIEW does not allow the sub-GUI to run until the ActiveX call has completed.  This is annoying.

 

The ActiveX call is not in a loop.  The sub-GUI, which is a sub vi is not in a loop.  The code within the sub vi is in a state machine with an event handler.  Although they are wired in parallel, the sub vi is not executed until the ActiveX application has completed.

0 Kudos
Message 5 of 6
(3,490 Views)

I don't remember if ActiveX has to run in the UI thread.  I would think not, but that could be one issue.

 

Are you subVIs calling another subVI that is the same?  If one VI is using the subVI and it takes a long time, the other VI won't be able to run it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(3,454 Views)