<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Parallelism in LabVIEW in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680193#M1034591</link>
    <description>&lt;P data-unlink="true"&gt;THE MOST IMPORTANT THING TO REMEMBER about dataflow is: &lt;EM&gt;Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution.&amp;nbsp; &lt;/EM&gt;(This can be found here.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's probably the ONLY thing you need to know.&amp;nbsp; If you interpret that one sentence as literally as you can, you can figure out how your code will (or won't) run.&amp;nbsp; I haven't found a case yet where it doesn't apply.&amp;nbsp; Sometimes on the surface it doesn't look like it applies, but if you repeat that one sentence over and over in your head, eventually you figure it out.&lt;/P&gt;</description>
    <pubDate>Mon, 05 May 2025 22:05:14 GMT</pubDate>
    <dc:creator>billko</dc:creator>
    <dc:date>2025-05-05T22:05:14Z</dc:date>
    <item>
      <title>Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680029#M1034537</link>
      <description>&lt;P&gt;Hello !&lt;/P&gt;
&lt;P&gt;One of the important features in LabVIEW is parallelism, that may be abvious for a lot of you, but not for me. therefore, i&amp;nbsp;created two VIs to test parallelism in LabVIEW, but after the test, i didn't understand what parallelism really mean in LabVIEW&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://ni.lithium.com/i/smilies/16x16_smiley-sad.gif" alt="Smiley Sad" title="Smiley Sad" /&gt; !!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached a PNG file that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;show&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;the code of the two VIs that i've used for the Test.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;figure 1&lt;/STRONG&gt;, there are 3 add functions. I highlighted the execution with single steping, then i noticed that LabVIEW&amp;nbsp;execute the code&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;the following order :&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;&lt;STRONG&gt;add 3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;function&amp;nbsp;add&amp;nbsp;&lt;STRONG&gt;C&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;2&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;and display the result in&amp;nbsp;&lt;STRONG&gt;R3&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;&lt;STRONG&gt;add 2&lt;/STRONG&gt;&amp;nbsp;function&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;add&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and display the result in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;R2&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;3)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;add 1&lt;/STRONG&gt;&amp;nbsp;function&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;add&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and dsiplay the result in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;R1&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a sequencial execution, it is not parallel !!!&lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://ni.lithium.com/i/smilies/16x16_smiley-indifferent.gif" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt; .I've expected that LabVIEW will&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;execute the add functions&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and display the result in the three indicators (R1,R2 and R3) all at the same time !!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly in the figure 2, LabVIEW start to execute one operation in the first loop, when he is done, he move to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;execute in the same way, one operation in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;second loop and so on until he&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;do the same thing for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;all the loops, then he start again from the first loop he has executed. It seem&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;like the processor is alocated in an equal manner for all the loops, therefore when the execution runs fastly,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;we see it parallel !!.&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;Is that the meaning of paralellism in LabVIEW ??&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more question. If i execute my&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Test&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;VIs&amp;nbsp;in a target that can execute parallel tasks like an&amp;nbsp;&lt;STRONG&gt;FPGA,&amp;nbsp;&lt;/STRONG&gt;and i highlight the execution, will&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;i&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;see something different comparing with what i've seen on my computer ???&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you will help me to answer my questions !&lt;/P&gt;
&lt;P&gt;Thanks for reading my post ! &amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://ni.lithium.com/i/smilies/16x16_smiley-happy.gif" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 08:49:47 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680029#M1034537</guid>
      <dc:creator>ZRD93</dc:creator>
      <dc:date>2017-08-24T08:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680033#M1034539</link>
      <description>&lt;P&gt;Highlight execution will force LabVIEW to run your code in&amp;nbsp;&lt;SPAN&gt;sequencial execution and in slow speed, so that you can follow the dataflow. This it not the same as when you run your code in normal mode.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Highlight execution is only for debugging.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And this goes for all target type in LabVIEW.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 08:59:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680033#M1034539</guid>
      <dc:creator>dkfire</dc:creator>
      <dc:date>2017-08-24T08:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680039#M1034541</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;apart from "highlight execution":&lt;/P&gt;
&lt;P&gt;- The main point here is THINK DATAFLOW: code is executed when the data needed to run the code is available. As long as certain parts of your code will have no data dependency (and no other way of running them sequentially like sequence frames) those parts will run in parallel.&lt;/P&gt;
&lt;P&gt;- Another point is the number of CPU cores you have available: even when LabVIEW tries to run 100 threads in parallel it can only use as many cores as are available. On a quad core only 4 different code parts/threads can truly run in parallel…&lt;/P&gt;
&lt;P&gt;- On a FPGA things looks different: after THINK DATAFLOW is handled then all parts of the code will run in parallel as different structures in the FPGA will handle the code. Think of the FPGA as a big bunch of different logic circuits, each one processing it's share of the code… (On a FPGA it's not the "number of cores", but the "available fabric to execute the code".)&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 09:09:05 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680039#M1034541</guid>
      <dc:creator>GerdW</dc:creator>
      <dc:date>2017-08-24T09:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680101#M1034562</link>
      <description>&lt;P&gt;Thankyou&amp;nbsp;&lt;STRONG&gt;dkfire&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;GerdW&lt;/STRONG&gt;. Because of your answers, i have now a clearer understanding than before. I had like to ask one more question to make things completly clear in my mind.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached a PNG file to show you a new code to test parallelism. It's a code that cause a race condition&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From your answer &lt;STRONG&gt;Mr. GerdW&lt;/STRONG&gt;, i understand that if i have one CPU core in my pc, LabVIEW will choose a random order to execute those 4 add operations sequentially one by one, but if i run this code on a pc that have 4 CPU cores, or on an FPGA, the 4 operations should execute simultaneously, however, it is impossible to write data at the same time in&amp;nbsp;&lt;STRONG&gt;R1&amp;nbsp;indicator&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;R1 local variable&amp;nbsp;&lt;/STRONG&gt;because data will be stored in the same memory location. Similarly, we can't write in the&amp;nbsp;&lt;STRONG&gt;Numeric global variable&amp;nbsp;&lt;/STRONG&gt;from two locations on the block diagram at the same time.&lt;/P&gt;
&lt;P&gt;Can someone you help me to know how LabVIEW will deal with this situation ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thankyou again for your help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 11:21:53 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680101#M1034562</guid>
      <dc:creator>ZRD93</dc:creator>
      <dc:date>2017-08-24T11:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680116#M1034566</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/572572"&gt;@ZRD93&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Can someone you help me to know how LabVIEW will deal with this situation ??&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There are mutexes blocking the resource while it is in use.&amp;nbsp; But writing to the local and global are so fast, it is practically parallel (as parallel as any two independent tasks trying to use the same CPU).&amp;nbsp; And you have a classic race condition such that whoever writes to value last will win.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to have a look at a document I put together: &lt;A href="https://forums.ni.com/t5/Community-Documents/A-Look-at-Race-Conditions/ta-p/3504049" target="_blank" rel="noopener"&gt;A Look At Race Conditions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 22:04:52 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680116#M1034566</guid>
      <dc:creator>crossrulz</dc:creator>
      <dc:date>2025-05-05T22:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680193#M1034591</link>
      <description>&lt;P data-unlink="true"&gt;THE MOST IMPORTANT THING TO REMEMBER about dataflow is: &lt;EM&gt;Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution.&amp;nbsp; &lt;/EM&gt;(This can be found here.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's probably the ONLY thing you need to know.&amp;nbsp; If you interpret that one sentence as literally as you can, you can figure out how your code will (or won't) run.&amp;nbsp; I haven't found a case yet where it doesn't apply.&amp;nbsp; Sometimes on the surface it doesn't look like it applies, but if you repeat that one sentence over and over in your head, eventually you figure it out.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 22:05:14 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680193#M1034591</guid>
      <dc:creator>billko</dc:creator>
      <dc:date>2025-05-05T22:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680203#M1034592</link>
      <description>&lt;P&gt;I will keep that in mind&amp;nbsp;&lt;STRONG&gt;Bill&lt;/STRONG&gt;, Thankyou !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 14:24:31 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680203#M1034592</guid>
      <dc:creator>ZRD93</dc:creator>
      <dc:date>2017-08-24T14:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parallelism in LabVIEW</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680311#M1034629</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/572572"&gt;@ZRD93&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thankyou&amp;nbsp;&lt;STRONG&gt;dkfire&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;GerdW&lt;/STRONG&gt;. Because of your answers, i have now a clearer understanding than before. I had like to ask one more question to make things completly clear in my mind.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached a PNG file to show you a new code to test parallelism. It's a code that cause a race condition&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From your answer &lt;STRONG&gt;Mr. GerdW&lt;/STRONG&gt;, i understand that if i have one CPU core in my pc, LabVIEW will choose a random order to execute those 4 add operations sequentially one by one, but if i run this code on a pc that have 4 CPU cores, or on an FPGA, the 4 operations should execute simultaneously, however, it is impossible to write data at the same time in&amp;nbsp;&lt;STRONG&gt;R1&amp;nbsp;indicator&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;R1 local variable&amp;nbsp;&lt;/STRONG&gt;because data will be stored in the same memory location. Similarly, we can't write in the&amp;nbsp;&lt;STRONG&gt;Numeric global variable&amp;nbsp;&lt;/STRONG&gt;from two locations on the block diagram at the same time.&lt;/P&gt;
&lt;P&gt;Can someone you help me to know how LabVIEW will deal with this situation ??&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Parallelism%202" style="width: 403px;"&gt;&lt;img src="https://ip1.i.lithium.com/74034a9fcd7fc469544858cc7f59c04bbb0abeaf/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f32313136303269413543314130344243363437303034442f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="Parallelism%202" alt="Parallelism%202" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is a bad example, because all your additions are computed at compile time and replaced by the result (the result is known and can never change). There is no addition happening at run time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each control or indicator, there are at least three copies of the data in memory: The instantaneous (1) wire value that gets copied to the (2) transfer buffer of the (3) indicator, and the data in the indicator and vice versa for controls. Indicators are &amp;nbsp;updated asynchronously by the UI thread so the data needs to be held somewhere to allow the code to proceed. While the current code might seemingly always give you the same result, that order is not guaranteed to persist after any recompile or other tiny changes elsewhere, or just running on a different CPU.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The parallelism of LabVIEW is extremely powerful, but that does not mean that everything you see on the diagram runs in parallel. If you have these tiny bits of trivial breadcrumb codes, the compiler might decide to clump it together instead of trying to run it all at once because it would not make a difference and there might be other, more important things to do in parallel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a good introduction, read this article.&amp;nbsp;&lt;A href="https://www.ni.com/en/support/documentation/supplemental/10/ni-labview-compiler--under-the-hood.html" target="_blank" rel="noopener"&gt;NI LabVIEW Compiler: Under the Hood&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 22:05:32 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Parallelism-in-LabVIEW/m-p/3680311#M1034629</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2025-05-05T22:05:32Z</dc:date>
    </item>
  </channel>
</rss>

