Neon detection

Use runtime check to detect Neon. Also add some copyright headers.
master
Raph Levien 11 years ago
parent 75902125d5
commit 9497e4407c
  1. 12
      cpp/src/fm_op_kernel.cc
  2. 16
      cpp/src/neon_fm_kernel.s
  3. 16
      cpp/src/neon_ladder.s
  4. 7
      cpp/src/resofilter.cc
  5. 15
      cpp/src/synth.h
  6. 16
      lab/ladder/sawtest.py

@ -16,20 +16,12 @@
#include <math.h> #include <math.h>
#ifdef HAVE_NEON
#include <cpu-features.h>
#endif
#include "synth.h" #include "synth.h"
#include "sin.h" #include "sin.h"
#include "fm_op_kernel.h" #include "fm_op_kernel.h"
#ifdef HAVE_NEON #ifdef HAVE_NEON
static bool hasNeon() {
return true;
return (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}
extern "C" extern "C"
void neon_fm_kernel(const int *in, const int *busin, int *out, int count, void neon_fm_kernel(const int *in, const int *busin, int *out, int count,
@ -37,10 +29,6 @@ void neon_fm_kernel(const int *in, const int *busin, int *out, int count,
const int32_t __attribute__ ((aligned(16))) zeros[N] = {0}; const int32_t __attribute__ ((aligned(16))) zeros[N] = {0};
#else
static bool hasNeon() {
return false;
}
#endif #endif
void FmOpKernel::compute(int32_t *output, const int32_t *input, void FmOpKernel::compute(int32_t *output, const int32_t *input,

@ -1,3 +1,19 @@
@ Copyright 2013 Google Inc.
@
@ Licensed under the Apache License, Version 2.0 (the "License");
@ you may not use this file except in compliance with the License.
@ You may obtain a copy of the License at
@
@ http://www.apache.org/licenses/LICENSE-2.0
@
@ Unless required by applicable law or agreed to in writing, software
@ distributed under the License is distributed on an "AS IS" BASIS,
@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ See the License for the specific language governing permissions and
@ limitations under the License.
@ NEON assembly implementation of FM operator kernel
.text .text
.align 2 .align 2

@ -1,3 +1,19 @@
@ Copyright 2013 Google Inc.
@
@ Licensed under the Apache License, Version 2.0 (the "License");
@ you may not use this file except in compliance with the License.
@ You may obtain a copy of the License at
@
@ http://www.apache.org/licenses/LICENSE-2.0
@
@ Unless required by applicable law or agreed to in writing, software
@ distributed under the License is distributed on an "AS IS" BASIS,
@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ See the License for the specific language governing permissions and
@ limitations under the License.
@ NEON assembly implementation of ladder filter core
.text .text
.align 2 .align 2

@ -197,12 +197,9 @@ void ResoFilter::process(const int32_t **inbufs, const int32_t *control_in,
float overdrive = control_in[2] * (1.0 / (1 << 24)); float overdrive = control_in[2] * (1.0 / (1 << 24));
const int32_t *ibuf = inbufs[0]; const int32_t *ibuf = inbufs[0];
int32_t *obuf = outbufs[0]; int32_t *obuf = outbufs[0];
bool useneon = false; bool useneon = hasNeon();
#ifdef HAVE_NEON
useneon = true; // TODO: detect
#endif
if (overdrive == 0) { if (overdrive < 0.01) {
if (useneon) { if (useneon) {
#ifdef HAVE_NEON #ifdef HAVE_NEON
AlignedBuf<float, 20> a_neon; AlignedBuf<float, 20> a_neon;

@ -21,6 +21,7 @@
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
#include <stdint.h> #include <stdint.h>
// TODO(raph): move from fixed to variable N
#define LG_N 6 #define LG_N 6
#define N (1 << LG_N) #define N (1 << LG_N)
@ -50,4 +51,18 @@ inline static T max(const T& a, const T& b) {
return a > b ? a : b; return a > b ? a : b;
} }
#ifdef HAVE_NEON
#include <cpu-features.h>
static inline bool hasNeon() {
return (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}
#else
static inline bool hasNeon() {
return false;
}
#endif
#endif // __SYNTH_H #endif // __SYNTH_H

@ -1,3 +1,19 @@
# Copyright 2013 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script for generating sound samples for comparing ladder filters
import argparse import argparse
import struct import struct
import numpy as np import numpy as np

Loading…
Cancel
Save