BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

(On the bus, cannot test)

Parallelization probably won't help much here, I think.

 

I would try to use a U16 LUT  and autoindex at the left boundary followed by type cast to string.

0 Kudos
Message 1361 of 2,635
(10,875 Views)

@altenbach wrote:

I would try to use a U16 LUT  and autoindex at the left boundary followed by type cast to string.


Yup, it is about 2x faster than Darin's code. It is also significantly less code (see my signature :D)

 

(1M string with debugging disabled: mine 5.5ms vs. Darin 11ms)

 

 

 

(not tried parallelization yet)

0 Kudos
Message 1362 of 2,635
(10,868 Views)

@altenbach wrote:
(not tried parallelization yet)

As suspected, parallelization does not do much here, even on my 16 core monster. The times are much more variable. While it sometimes is faster, the average is slower with parallelization enabled. I think this is such a fast loop that the split and reassembly overhead cancels out any potential parallelization advantage.

0 Kudos
Message 1363 of 2,635
(10,855 Views)

@Darin.K wrote:
That coercion dot is a bit more than annoying.  If I remember correctly it blows up the [U8] into a [U64] or [I64].  This is one of those rare moments when a G implementation can outperform a primitive, albeit a botched primitive.

 I was under the impression that it is a false coercion dot that only appears if we connect an array of any numeric datatype. You can connect any type numeric scalar and there is no dot. (This has been around since LabVIEW 8.5. See also my post from 2008)

 

Obviously, things are screwed up. If we hover over the terminal, It says that it expects an array of strings (see picture).

 

 

However, if we actually connect an array of strings, it say it expects an array of I32.

 

 

Go figure. Still, I think it is a cosmetic problem.

 

 

All that said, the code with this primitive followed by "concatenate strings" is about 10x slower than my version with the 16bit LUT. So yes, there are improvements possible 😄

Download All
0 Kudos
Message 1364 of 2,635
(10,841 Views)

@altenbach wrote:
Yup, it is about 2x faster than Darin's code. It is also significantly less code (see my signature :D)

For completeness, here's a quick benchmark (LV 2012) comparing a few implementations. Modify as needed.

 

(A similar LV 2010 version can be found here. I don't know how it performs under 2010).

 

Download All
0 Kudos
Message 1365 of 2,635
(10,814 Views)

@altenbach wrote:

@altenbach wrote:
Yup, it is about 2x faster than Darin's code. It is also significantly less code (see my signature :D)
As a unitasker this is indeed simpler, but I tend to code in generalities.  My code comes from a general VI which will handle arbritrary bases just by changing the LUT and the constant for the stride, not just the special hex case.  Hence the 2D LUT.  Adapt your code to handle octal, binary, and hexavigesimal see how it goes.
0 Kudos
Message 1366 of 2,635
(10,813 Views)

@Darin.K wrote:
As a unitasker this is indeed simpler, but I tend to code in generalities.  My code comes from a general VI which will handle arbritrary bases just by changing the LUT and the constant for the stride, not just the special hex case.  Hence the 2D LUT.  Adapt your code to handle octal, binary, and hexavigesimal see how it goes.

That's a valid point.

 

Yes, I was surprised how fast it is. I usually don't worry about factors of two unless it is something that takes a long time.

 

For a more general reuseable (and readable!) code, I would have thought that the string LUT (blue trace) is similarly good, but it loses another factor of two or so... ;). I wonder how it compares with longer strings, such as binary formatted outputs.

0 Kudos
Message 1367 of 2,635
(10,808 Views)

Hex is such a domninant use case here that I may just adopt it.  On my older, sorrier laptop the win is not quite so much. 

 

I am sure that CAR is super high priority and will be fixed before we know it.  Can't even type that without smirking....

0 Kudos
Message 1368 of 2,635
(10,794 Views)

Not sure about hexavigesimal and octal (they are not aligned at byte boundaries), but hexadecimal and binary can easily be done the same way and seem to be pretty fast.

 

Here's a general purpose subVI (LabVIEW 2012) that does it all. 😄

 

 

Download All
Message 1369 of 2,635
(10,778 Views)

Hey Darin,

 

I know that it might not have been clear by my post, but the "annoying" was a eufemism.

 

I also have had some "problems", because of this coercion dot.

In the end they could be avoided by using a different approach, but there were a few frustrations while encountering it the first time:

http://4.bp.blogspot.com/-CLRPDtmUYH4/T7j3npgnewI/AAAAAAAAASc/Jxj7-WN_-NE/s400/annoyed.jpg

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 1370 of 2,635
(10,745 Views)