Integrate @toofishes improvement: Unroll loop in convert_to_phi.

“This yields a 10% CPU savings vs the original single value per loop
iteration implementation on a Raspberry Pi 2 Model B.”

https://github.com/mutability/dump978/commit/b0958f4305d2c7355d07fa9b938
8f6ad1b31b161
pull/446/head
Christopher Young 2016-06-21 14:54:59 -04:00
rodzic e180f79855
commit fc5641cb69
2 zmienionych plików z 25 dodań i 8 usunięć

Wyświetl plik

@ -143,11 +143,23 @@ void make_atan2_table(void) {
}
}
static void convert_to_phi(uint16_t *dest, uint16_t *src, int n) {
int i;
static void convert_to_phi(uint16_t *buffer, int n)
{
int i;
for (i = 0; i < n; ++i)
dest[i] = iqphase[src[i]];
// unroll the loop. n is always > 2048, usually 36864
for (i = 0; i+8 <= n; i += 8) {
buffer[i] = iqphase[buffer[i]];
buffer[i+1] = iqphase[buffer[i+1]];
buffer[i+2] = iqphase[buffer[i+2]];
buffer[i+3] = iqphase[buffer[i+3]];
buffer[i+4] = iqphase[buffer[i+4]];
buffer[i+5] = iqphase[buffer[i+5]];
buffer[i+6] = iqphase[buffer[i+6]];
buffer[i+7] = iqphase[buffer[i+7]];
}
for (; i < n; ++i)
buffer[i] = iqphase[buffer[i]];
}
static void calc_power(uint16_t *samples, int len) { // sets signal_strength to scaled amplitude. 0 = no signal, 1000 = saturated receiver on all samples in measurement.

Wyświetl plik

@ -599,9 +599,14 @@ func New(buf string) (*UATMsg, error) {
buf = strings.Trim(buf, "\r\n") // Remove newlines.
x := strings.Split(buf, ";") // We want to discard everything before the first ';'.
if len(x) < 2 {
return ret, errors.New(fmt.Sprintf("New UATMsg: Invalid format (%s).", buf))
}
/*
RS_Err int
SignalStrength int
Parse _;rs=?;ss=? - if available.
RS_Err int
SignalStrength int
*/
ret.SignalStrength = -1
ret.RS_Err = -1
@ -628,10 +633,10 @@ func New(buf string) (*UATMsg, error) {
}
if s[0] != '+' { // Only want + ("Uplink") messages currently. - (Downlink) or messages that start with other are discarded.
return ret, errors.New("New UATMsg: expecting uplink frames.")
return ret, errors.New("New UATMsg: expecting uplink frame.")
}
s = s[1:]
s = s[1:] // Remove the preceding '+' or '-' character.
// Convert the hex string into a byte array.
frame := make([]byte, UPLINK_FRAME_DATA_BYTES)