Jump to content

Parallel Loop Debugging


X___

Recommended Posts

I am not sure whether this has been discussed before, but I stumbled upon a simple (alternative) trick to debug parallelized loops that may be of interests to others.

Of course there is always the option to edit the parallelism settings and check the "Allow Debugging" box. The "P" terminal is slightly grayed out and parallelism is turned off until the user changes the settings back to not "Allow Debugging".

I find it easy to forget or even fail to notice that a parallelized loop is in "Debug" mode due to the very subtle cue that parallelism is turned off. Generally, it is the degraded performance of the code that will trigger a question and then once is off to a rabbit chase for the culprit...

A potentially useful trick is to do what is illustrated below:

1831000133_ParallelLoopDebugging.png.c99e0f1c79e6d793f310a834597444a6.png

The code inside the loop is encompassed by a disabled structure (set to "Enabled") and the degree of parallelism set to 1. Note that it is not necessary to edit the Loop Parallelism settings! I find the visual cues much easier to notice (and the code easy to revert to full parallelism).

Note that it is possible to use a different P value, but in that case you will miss the majority of loops and the actual loop that will be debugged appears to be somewhat random (I have some idea about which ones are, but this is pure guess). This might fit your needs.

Once debugged, it is pretty obvious that the parallel loop is not truly "parallel" anymore, and therefore it is hard to forget to revert to a fully parallelized state.

HTH.

  • Like 1
Link to comment

First I'll mention that snippets aren't working recently on LAVA.  I messaged the admin but haven't heard anything.  Second I'm wondering why this can't be a native LabVIEW feature.  Has anyone made an idea on the Idea Exchange for probes to work on parallel For loops, where the P terminals can constant fold to a 1?  I'm also not sure why this works only in the enabled structure.  I wouldn't expect the structure to be a non-reentrant type function.  And it doesn't, when I put a wait in there as a test.

Link to comment
31 minutes ago, hooovahh said:

I'm also not sure why this works only in the enabled structure.  I wouldn't expect the structure to be a non-reentrant type function.  And it doesn't, when I put a wait in there as a test.

Probes on the top-level diagram of the parallel For Loop simply show no debug info unless debugging is enabled. Any subdiagram will do the trick.

image.png.74f2471a1f15a0422afe2a37e301a2c6.png

Link to comment
7 hours ago, hooovahh said:

First I'll mention that snippets aren't working recently on LAVA.  I messaged the admin but haven't heard anything.  Second I'm wondering why this can't be a native LabVIEW feature.  Has anyone made an idea on the Idea Exchange for probes to work on parallel For loops, where the P terminals can constant fold to a 1?  I'm also not sure why this works only in the enabled structure.  I wouldn't expect the structure to be a non-reentrant type function.  And it doesn't, when I put a wait in there as a test.

Hopefully the diagram is simple enough to reproduce... The parallelization options have a maximum number of 16 parallel loops, but this doesn't really play a role in this discussion.

As far as "native function", it is native in the sense that you can enable debugging. The only catch is that it is fairly subtle to see that this is enabled (the P terminal is lightly grayed out). It might be a simple matter of enhancing the visual feedback of this option: maybe draw a red cross on the "P"?

Link to comment
6 hours ago, LogMAN said:

Probes on the top-level diagram of the parallel For Loop simply show no debug info unless debugging is enabled. Any subdiagram will do the trick.

image.png.74f2471a1f15a0422afe2a37e301a2c6.png

Nice catch on the type specialization structure (or other structures). Obviously I discovered this playing around with a disable structure and did not bother investigating further.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.