Skip to content

Commit

Permalink
Fix compilation errors.
Browse files Browse the repository at this point in the history
vec_avx.h needs x86cpu.h, and x86cpu.h needs to detect SSE2 (or
 greater) without the Opus macros.
Also, nobody was defining OPUS_CLEAR (but several things were
 including the non-existent os_support.h where it is defined in
 libopus), so replace those calls with RNN_CLEAR and remove the
 erroneous includes.
Take the opportunity to hoist OPUS_GNUC_PREREQ to common.h, too,
 since it is needed in multiple places now.

Fixes GitHub #222
  • Loading branch information
Timothy B. Terriberry committed Apr 16, 2024
1 parent 904a876 commit 372f7b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ static RNN_INLINE void rnnoise_free (void *ptr)
#define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
#endif

# if !defined(OPUS_GNUC_PREREQ)
# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
# define OPUS_GNUC_PREREQ(_maj,_min) \
((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
# else
# define OPUS_GNUC_PREREQ(_maj,_min) 0
# endif
# endif


#endif
9 changes: 4 additions & 5 deletions src/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define VEC_H

#include "opus_types.h"
#include "common.h"
#include <math.h>
#include "arch.h"
#include "x86/x86_arch_macros.h"
Expand All @@ -41,16 +42,14 @@
#include "vec_neon.h"
#else

#include "os_support.h"

#define MAX_INPUTS (2048)

#define NO_OPTIMIZATIONS

static inline void sgemv16x1(float *out, const float *weights, int rows, int cols, int col_stride, const float *x)
{
int i, j;
OPUS_CLEAR(out, rows);
RNN_CLEAR(out, rows);
for (i=0;i<rows;i+=16)
{
for (j=0;j<cols;j++)
Expand Down Expand Up @@ -84,7 +83,7 @@ static inline void sgemv16x1(float *out, const float *weights, int rows, int col
static inline void sgemv8x1(float *out, const float *weights, int rows, int cols, int col_stride, const float *x)
{
int i, j;
OPUS_CLEAR(out, rows);
RNN_CLEAR(out, rows);
for (i=0;i<rows;i+=8)
{
for (j=0;j<cols;j++)
Expand Down Expand Up @@ -124,7 +123,7 @@ static inline void sgemv(float *out, const float *weights, int rows, int cols, i
static inline void sparse_sgemv8x4(float *out, const float *w, const int *idx, int rows, const float *x)
{
int i, j;
OPUS_CLEAR(out, rows);
RNN_CLEAR(out, rows);
for (i=0;i<rows;i+=8)
{
int cols;
Expand Down
2 changes: 1 addition & 1 deletion src/vec_avx.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <immintrin.h>
#include <math.h>
/*#include "celt/x86/x86cpu.h"*/
#include "x86/x86cpu.h"

#define MAX_INPUTS (2048)

Expand Down
5 changes: 3 additions & 2 deletions src/vec_neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#define VEC_NEON_H

#include <arm_neon.h>
#include "os_support.h"
#include "opus_types.h"
#include "common.h"

#if defined(__arm__) && !defined(__aarch64__) && (__ARM_ARCH < 8 || !defined(__clang__))
/* Emulate vcvtnq_s32_f32() for ARMv7 Neon. */
Expand Down Expand Up @@ -302,7 +303,7 @@ static inline void sgemv(float *out, const float *weights, int rows, int cols, i
static inline void sparse_sgemv8x4(float *out, const float *w, const int *idx, int rows, const float *x)
{
int i, j;
OPUS_CLEAR(out, rows);
RNN_CLEAR(out, rows);
for (i=0;i<rows;i+=8)
{
int cols;
Expand Down
4 changes: 2 additions & 2 deletions src/x86/x86cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
int opus_select_arch(void);
# endif

# if defined(OPUS_X86_MAY_HAVE_SSE2)
# include "opus_defines.h"
# if defined(__SSE2__)
# include "common.h"

/*MOVD should not impose any alignment restrictions, but the C standard does,
and UBSan will report errors if we actually make unaligned accesses.
Expand Down

0 comments on commit 372f7b4

Please sign in to comment.