ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

取消
显示结果 
搜索替代 
您的意思是: 

Efficient unwrap phase code (SGL precision)

已解决!
转到解答

I wanted to implement an "unwrap phase" function that works with SGL data, since the built-in one (using lvanlys.dll) only accepts DBL data as input and would create conversion overhead. I followed the documentation and implemented the unwrap phase function as discrete Labview code (for loop with shift register), but the benchmark shows that my descrete implementation (with SGL data) runs twice as long as the lvanlys function (with DBL data). The issue is not SGL vs. DBL, this makes only ~10% difference in this case, so it must have to do with the implementation.

unwrap_bench.png

 

 

 

 

 

 

 

 

 

 

I also made a parallelized version of the discrete implementation (cutting the array into chunks, processing them in a parallel loop and stitching them back together), which just barely matches the speed of the built-in (lvanlys) function but uses much more CPU load (the built-in function appears to be single-threaded). Does the built-in function use a different implementation than what is stated in the documentation or is a native C implementation just that much faster (despite the DLL overhead)?

0 项奖励
1 条消息(共 6 条)
3,179 次查看

Can you "save for previous (2020 or below)" so more can have a look.

 

 

0 项奖励
2 条消息(共 6 条)
3,140 次查看

Here is a LV2018 version.

0 项奖励
3 条消息(共 6 条)
3,128 次查看
解答
已被主题作者 Novgorod 接受

if you want fast code, you should avoid floating point division and make loop iterations independent

try to implement Matlabs phase unwrap algorithm (https://de.mathworks.com/help/dsp/ref/unwrap.html)

0 项奖励
4 条消息(共 6 条)
3,103 次查看

Weird question 

What happens if you add pi(sgl), take the remainder mod 2pi and subtract pi?

 

No loop needed.


"Should be" isn't "Is" -Jay
0 项奖励
5 条消息(共 6 条)
3,081 次查看

@cordm: Thanks, this is much faster, even than the lvanlys function (the sign check should be done before the abs() function though :)). I didn't expect division to be so "expensive". The lvanlys version can handle jumps of multiples of 2pi, while the matlab version requires the discontinuities to be single steps of 2pi (positive or negative), but I think this can be added efficiently in the matlab version (only do division if there is a jump, not for every element) and it's a fringe use case anyway.

 

@JÞB: That sounds like the opposite, i.e. phase wrapping, not unwrapping...

0 项奖励
6 条消息(共 6 条)
3,056 次查看