LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

in range and coerce

dear all,

i am workig on an array of size 600,000 of I32. i need to check if the data values are withing range or not?

the time taken to execute "in range and corece" function is appox 15 ms. But, i need it to be completed in less than 10 ms as i have to perform other processing on the data(which takes arnd 8-9 ms to execute) and the complete processing has to be done in less than 20 ms.

 

what better way i can adopt to check if the data lies within the range and coerce it?

 

 

Thanks,

Ritesh 

0 Kudos
Message 1 of 6
(4,267 Views)

You can try with comparison functions (>,<) , but i doubt it will be faster.

 

Allthough i think the solution is not there. How do you get those 600.000 values?

If you receiveing them one by one, you can do the "in range and coerce" function for each value, the time you receive it.

This way will need no extra time when the array is completed 

0 Kudos
Message 2 of 6
(4,263 Views)

What kind of other processing are you doing on the data? Maybe you could combine the operations so each element needs to be touched only once. Are you sure the other operations are optimized? Is everything done "in place"? No unecessary operations, buffer allocationsetc.

 

For example, do you really need to coerce all data or do you only need to check if all are in range or not for a simple Yes/No answer. In this case, you could just do "array min/max" and only compare the min and max with your boundaries.

 

OTOH, if you only need to coerce, you could do a bitwise AND with a mask. (e.g. coerce to 4 bits, for example).

 

Both operations would be very fast.

 

 

Anyway, you are well within a factor of two so you're close or you might even be able to solve the problem with a faster computer.

 

In range and coerce only uses one CPU core. You might be able to split the problem and use multiple cores of you have such a CPU.

 

Please show us your code so we can see if everything is optimized. How do you actually measure the speed?

Message Edited by altenbach on 06-27-2009 01:08 AM
Message 3 of 6
(4,255 Views)

This is the thing: i recieve 200 points(I16) from my H/W every 20 ms. i keep them adding to the buffer(1D) already allocated for it.

now, i need to display this data on the screen, not as 1D array, but in multiple rows(could be 2,4,8,16) selected by the user. and the no. of points to be displayed in 1 row depends on the sweep speed.the max no of points in a row can be 37,500. they could be less if the sweep speed is low.

when i recieve data from the H/W, i first add the data to the buffer, then take portion from the data which is the be diplayed and then reshape it into rows and colums selected by the user.

after i reshape it, i need to add shift to the data. after adding the shift, i need to check if the data is in range or not? so, i convert the I16 data to I32, add the shift and then apply the functon "in range and corece". yes, i need to corece the data. after coercing, i convert it back to I16.

 

i am attacing 2 Vis. pls have a look at it and let me know of a possible otimized solution.

 

 

 

Thanks,

Ritesh

Download All
0 Kudos
Message 4 of 6
(4,247 Views)

ritesh024 wrote:

yes, i need to corece the data. after coercing, i convert it back to I16.


OK, I played a bit with the coercion. Equivalent code using split number and a few bitwise operations, is identical in speed and result to the coerce function, so is not worth it. (Masking alone would give a wraparound).

 

However, I found a way to speed it up by almost a factor of two:

 

FXP conversions allows for "saturate" overflow operations, so if you convert to FXP (16 bits, delta=1, saturate) and then to I16, you get the desired result. ToFXP currently does not accept arrays, so you need to wrap a few FOR loops around it, depending on the array dimensionality.

 

 

I have not looked at the rest of your code yet.

 

Are you running htis on a LabVIEW RT system? On a multipurpose OS, it might not be possible to reliably keep these speeds up, depending on other OS tasks.

Message Edited by altenbach on 06-27-2009 11:15 AM
Message 5 of 6
(4,209 Views)

Hi Alten,

i dont know but this FXP method also is taking the same amount of time as "in range and coerce".

 

I finally had to look at some other part of the code and did some optimization with that and finally reduced the processing speed to quiet a bit. Though the speed is not reduced by a big factor, but its within range now.

 

 I am running this program on my Win Xp, Core 2 Duo processor.

Message Edited by ritesh024 on 07-01-2009 02:25 AM
0 Kudos
Message 6 of 6
(4,145 Views)