10-31-2020 01:51 AM - edited 10-31-2020 01:55 AM
11-01-2020 01:08 PM
I remove the clustering showed in the figure. It works now. But I still do not understand why cluster the wires before entering into case structure caused problems. I guess it is the problem of data passing between individual wires and cluster. Are the "bundle VI" and "Array index VI" by reference or by value?
11-03-2020 01:29 PM
I might have found the problem. In my parent VI, I used this VI twice in parallel. I heard that LabView is a pseudo OO Language. So perhaps the two simultaneously running VIs interfere with each other and cause the the problem? Any thought?
11-04-2020 02:23 PM
@Jacobier wrote:
I might have found the problem. In my parent VI, I used this VI twice in parallel. I heard that LabView is a pseudo OO Language. So perhaps the two simultaneously running VIs interfere with each other and cause the the problem? Any thought?
By default, VIs are non-reentrant, meaning all instances in your code share a copy and it cannot be used simultaneously in two different places at the very same time. You can easily make them reentrant (vi properties..execution...).
Your VIs don't store local data (e.g. uninitialized shift registers) and I cannot see how non-reentrant uses would be a problem unless you try to run two instances in parallel. Do you?
Can you give us a little insight into the overall code architecture?
11-04-2020 03:06 PM
Yes, I did run two copies of this VI parallel in the upper level VI. This VI is my image processing code. I have data from two cameras that need to be processed. If I need to run two instances of the same VI parallelly (Like two objects of the same class in other OOP languages). Which setting in execution I should use?
11-04-2020 03:13 PM
Do I need to make all the subVIs under this VI reentriable as well?
11-04-2020 03:30 PM - edited 11-04-2020 03:30 PM
If they are not reentrant, one instance must wait until the other instance has completed. If you make them reentrant, they can run in parallel. Look at the help on the execution settings.
I assume that each instance operates on a different folder, right? What is the bottleneck? If the bottleneck is disk IO, that cannot be parallel, if course.
I don't have IMAQ installed at the moment, but please don't modify system VIs.
One of your subVIs is "vector remove...". What does it do? (can you attach the code?). If it completes in an instance, it does not really need to be reentrant, but you are calling it several times in parallel and reentrant might help. You might even inline it. How many CPU cores do you have?
Your code is still somewhat of a mess. Do you understand my earlier comments?
11-04-2020 04:58 PM
Thank you for your quick answer.
1. I do not need to make them parallel. But by default, in LabViews if I put two subVIs in the same block with two different paths, they automatically become parallel. In this case, does it mean that the same subVI needs to be on the same path (or connected in series)?
2. Yes, each instance operates on a different folder.
3. I tried to run my code step by step using debug tools, I found that the two parallel subVI (the one I posted) only run once. It did not look like on instance is waiting for another. I am guessing that this is the root cause of the problem.
4 "Vector remove" is just to remove the first element or the last element of an array. What confused me more is that these subVIs did not cause any problem even they are paralleled.
11-04-2020 05:16 PM - edited 11-04-2020 06:18 PM
@Jacobier wrote:
But by default, in LabViews if I put two subVIs in the same block with two different paths, they automatically become parallel.
No, they don't become parallel. They get both scheduled to run, but whatever instance is first will prevent the other instance from running until it is done. Once it is reentrant, both have their own code and can run at the same time.
Can you tell me in more detail what you are seeing when stepping through the code? Too ambiguous. Can you probe e.g. the path inside the subVI?
@Jacobier wrote:
4 "Vector remove" is just to remove the first element or the last element of an array. What confused me more is that these subVIs did not cause any problem even they are paralleled.
Why would you need a subVI for that? Just take the array subset starting at 1 with a length of N-2.
11-04-2020 05:29 PM
As mentioned, you can make your code 7x smaller by using a single 2D array in a shift register. Why is your cluster size set to 9 for "Array to cluster"? Why does your blue array constant contain an element?