Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
lib_voice change log
====================

UNRELEASED
----------

* CHANGED: `app_pipeline` example is now single-tile

1.0.1
-----

Expand Down
8 changes: 7 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pipeline {
defaultValue: '15.3.1',
description: 'The XTC tools version'
)
string(
name: 'TOOLS_VX4_VERSION',
defaultValue: '-j --repo arch_vx_slipgate -b master -a XTC 112',
description: 'The XTC Slipgate tools version'
)
string(
name: 'XMOSDOC_VERSION',
defaultValue: 'v8.0.1',
Expand Down Expand Up @@ -66,7 +71,8 @@ pipeline {
}
dir("${REPO}/examples") {
withVenv {
xcoreBuild()
xcoreBuild(archiveBins: false, buildDir: "build_xs3a", toolsVersion: params.TOOLS_VERSION)
xcoreBuild(archiveBins: false, buildDir: "build_vx4b", toolsVersion: params.TOOLS_VX4_VERSION, cmakeOpts: "-DXCORE_TARGET=XK-EVK-XU416")
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(lib_voice_examples)

if(DEFINED XCORE_TARGET)
set(XCORE_TARGET ${XCORE_TARGET})
else()
set(XCORE_TARGET XK-EVK-XU316)
endif()

add_subdirectory(app_aec)
add_subdirectory(app_vnr)

Expand Down
6 changes: 5 additions & 1 deletion examples/app_aec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(app_aec)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

if(NOT BUILD_NATIVE)
set(APP_COMPILER_FLAGS_1th -report -DAEC_THREADS=1)
Expand Down
7 changes: 6 additions & 1 deletion examples/app_pipeline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(app_pipeline)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

set(APP_COMPILER_FLAGS_std_arch -report)
set(APP_COMPILER_FLAGS_alt_arch -report -DALT_ARCH_MODE=1)

Expand Down
61 changes: 43 additions & 18 deletions examples/app_pipeline/src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
#include <xcore/channel.h>
#include <xcore/chanend.h>
#include <xcore/channel_transaction.h>
#include <xcore/parallel.h>

extern void pipeline_tile0_init(pipeline_state_tile0_t *state);
extern void pipeline_tile1_init(pipeline_state_tile1_t *state);
DECLARE_JOB(pipeline_wrapper_thread0, (chanend_t));
DECLARE_JOB(pipeline_wrapper_thread1, (chanend_t));

extern void pipeline_process_frame_tile0(pipeline_state_tile0_t *state,
extern void pipeline_thread0_init(pipeline_state_thread0_t *state);
extern void pipeline_thread1_init(pipeline_state_thread1_t *state);

extern void pipeline_process_frame_thread0(pipeline_state_thread0_t *state,
int32_t (*input_y_data)[AP_FRAME_ADVANCE],
int32_t (*input_x_data)[AP_FRAME_ADVANCE],
int32_t (*output_data)[AP_FRAME_ADVANCE],
pipeline_metadata_t *md_output);

extern void pipeline_process_frame_tile1(pipeline_state_tile1_t *state, pipeline_metadata_t *md_input,
extern void pipeline_process_frame_thread1(pipeline_state_thread1_t *state, pipeline_metadata_t *md_input,
int32_t (*input_data)[AP_FRAME_ADVANCE],
int32_t output_data[AP_FRAME_ADVANCE]);

Expand All @@ -39,43 +43,64 @@ static inline void consumer(int32_t frame_y[AP_FRAME_ADVANCE]) {
printf("frame done\n");
}

void pipeline_wrapper_tile0(chanend_t c_pcm_out)
void pipeline_wrapper_thread0(chanend_t c_pcm_out)
{
int32_t DWORD_ALIGNED frame_y[AP_MAX_Y_CHANNELS][AP_FRAME_ADVANCE];
int32_t DWORD_ALIGNED frame_x[AP_MAX_X_CHANNELS][AP_FRAME_ADVANCE];

// Initialise pipeline
pipeline_state_tile0_t DWORD_ALIGNED pipeline_tile0_state;
pipeline_tile0_init(&pipeline_tile0_state);
pipeline_state_thread0_t DWORD_ALIGNED pipeline_thread0_state;
pipeline_thread0_init(&pipeline_thread0_state);

for(unsigned b = 0; b < 5; b++){
producer(frame_y, frame_x);

pipeline_metadata_t md;
int32_t DWORD_ALIGNED tile0_output[AP_MAX_Y_CHANNELS][AP_FRAME_ADVANCE];
pipeline_process_frame_tile0(&pipeline_tile0_state, frame_y, frame_x, tile0_output, &md);
int32_t DWORD_ALIGNED thread0_output[AP_MAX_Y_CHANNELS][AP_FRAME_ADVANCE];
pipeline_process_frame_thread0(&pipeline_thread0_state, frame_y, frame_x, thread0_output, &md);

// Send data to process to the other tile and receive processed output back
//Transfer to other tile
// Send data to process to the other thread and receive processed output back
// Send the "valid" signal first
chan_out_byte(c_pcm_out, 1);
chan_out_buf_byte(c_pcm_out, (uint8_t*)&md, sizeof(pipeline_metadata_t));
chan_out_buf_word(c_pcm_out, (uint32_t*)&tile0_output[0][0], (AP_MAX_Y_CHANNELS * AP_FRAME_ADVANCE));
chan_out_buf_word(c_pcm_out, (uint32_t*)&thread0_output[0][0], (AP_MAX_Y_CHANNELS * AP_FRAME_ADVANCE));
}
// Send the "terminate" signal
chan_out_byte(c_pcm_out, 0);
}

void pipeline_wrapper_tile1(chanend_t c_pcm_in)
void pipeline_wrapper_thread1(chanend_t c_pcm_in)
{
pipeline_state_tile1_t DWORD_ALIGNED pipeline_tile1_state;
pipeline_state_thread1_t DWORD_ALIGNED pipeline_thread1_state;
pipeline_metadata_t md;
int32_t DWORD_ALIGNED tile0_output[AP_MAX_Y_CHANNELS][AP_FRAME_ADVANCE];
int32_t DWORD_ALIGNED thread0_output[AP_MAX_Y_CHANNELS][AP_FRAME_ADVANCE];
int32_t DWORD_ALIGNED pipeline_output[AP_FRAME_ADVANCE];

pipeline_tile1_init(&pipeline_tile1_state);
pipeline_thread1_init(&pipeline_thread1_state);
while(1) {
// Check the "valid" status first
uint8_t status = chan_in_byte(c_pcm_in);
if (!status) break;

chan_in_buf_byte(c_pcm_in, (uint8_t*)&md, sizeof(pipeline_metadata_t));
chan_in_buf_word(c_pcm_in, (uint32_t*)&tile0_output[0][0], (AP_MAX_Y_CHANNELS * AP_FRAME_ADVANCE));
chan_in_buf_word(c_pcm_in, (uint32_t*)&thread0_output[0][0], (AP_MAX_Y_CHANNELS * AP_FRAME_ADVANCE));

pipeline_process_frame_tile1(&pipeline_tile1_state, &md, tile0_output, pipeline_output);
pipeline_process_frame_thread1(&pipeline_thread1_state, &md, thread0_output, pipeline_output);

consumer(pipeline_output);
}
}

// producer -> stage1 -> (thread0_to_thread1) -> stage2 -> stage3 -> stage4 -> consumer
// producer and stage1 run on thread0
// stage2, stage3, stage4 and consumer run on thread1

int main() {
channel_t ch = chan_alloc();
PAR_JOBS(
PJOB(pipeline_wrapper_thread0, (ch.end_a)),
PJOB(pipeline_wrapper_thread1, (ch.end_b))
);
chan_free(ch);
return 0;
}
32 changes: 0 additions & 32 deletions examples/app_pipeline/src/main.xc

This file was deleted.

12 changes: 6 additions & 6 deletions examples/app_pipeline/src/pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "pipeline_state.h"

void pipeline_tile0_init(pipeline_state_tile0_t *state) {
memset(state, 0, sizeof(pipeline_state_tile0_t));
void pipeline_thread0_init(pipeline_state_thread0_t *state) {
memset(state, 0, sizeof(pipeline_state_thread0_t));

// Initialise AEC, DE, ADEC stages
aec_conf_t aec_de_mode_conf, aec_non_de_mode_conf;
Expand Down Expand Up @@ -44,8 +44,8 @@ void pipeline_tile0_init(pipeline_state_tile0_t *state) {
stage1_init(&state->stage_1_state, &aec_de_mode_conf, &aec_non_de_mode_conf, &adec_conf);
}

void pipeline_tile1_init(pipeline_state_tile1_t *state) {
memset(state, 0, sizeof(pipeline_state_tile1_t));
void pipeline_thread1_init(pipeline_state_thread1_t *state) {
memset(state, 0, sizeof(pipeline_state_thread1_t));

// Initialise IC, VNR
ic_init(&state->ic_state);
Expand All @@ -58,7 +58,7 @@ void pipeline_tile1_init(pipeline_state_tile1_t *state) {
agc_init(&state->agc_state, &agc_conf_asr);
}

void pipeline_process_frame_tile0(pipeline_state_tile0_t *state,
void pipeline_process_frame_thread0(pipeline_state_thread0_t *state,
int32_t (*input_y_data)[AP_FRAME_ADVANCE],
int32_t (*input_x_data)[AP_FRAME_ADVANCE],
int32_t (*output_data)[AP_FRAME_ADVANCE],
Expand All @@ -79,7 +79,7 @@ void pipeline_process_frame_tile0(pipeline_state_tile0_t *state,
memcpy(md_output, &md, sizeof(pipeline_metadata_t));
}

void pipeline_process_frame_tile1(pipeline_state_tile1_t *state, pipeline_metadata_t *md_input,
void pipeline_process_frame_thread1(pipeline_state_thread1_t *state, pipeline_metadata_t *md_input,
int32_t (*input_data)[AP_FRAME_ADVANCE],
int32_t output_data[AP_FRAME_ADVANCE])
{
Expand Down
4 changes: 2 additions & 2 deletions examples/app_pipeline/src/pipeline_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef struct {
typedef struct {
// Stage1 - AEC, DE, ADEC
stage1_t DWORD_ALIGNED stage_1_state;
} pipeline_state_tile0_t;
} pipeline_state_thread0_t;

typedef struct {
// IC, VNR
Expand All @@ -26,6 +26,6 @@ typedef struct {
ns_state_t DWORD_ALIGNED ns_state;
// AGC
agc_state_t agc_state;
} pipeline_state_tile1_t;
} pipeline_state_thread1_t;

#endif
6 changes: 5 additions & 1 deletion examples/app_vnr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(app_vnr)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

if(NOT BUILD_NATIVE)
set(APP_COMPILER_FLAGS -report)
Expand Down
2 changes: 1 addition & 1 deletion lib_voice/lib_build_info.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(LIB_NAME lib_voice)
set(LIB_VERSION 1.0.1)
set(LIB_DEPENDENT_MODULES "lib_xcore_math(2.4.1)")
set(LIB_DEPENDENT_MODULES "lib_xcore_math(develop)")

set(LIB_COMPILER_FLAGS
-g
Expand Down
4 changes: 2 additions & 2 deletions lib_voice/src/aec/aec_process_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum e_fft {Y_FFT, X_FFT, ERROR_FFT};

#define REF_ACTIVE_THRESHOLD f64_to_float_s32(pow(10, REF_ACTIVE_THRESHOLD_DB/20.0))

#ifdef __XS3A__
#if defined(__XS3A__) || defined(__VX4B__)
#include <xcore/parallel.h>
DECLARE_JOB(calc_time_domain_ema_energy_task, (const aec_par_tasks_and_channels_t*, aec_filter_state_t *, int32_t*, int, int, enum e_td_ema));
DECLARE_JOB(fft_task, (const aec_par_tasks_and_channels_t*, aec_filter_state_t*, aec_filter_state_t*, int, int, enum e_fft));
Expand Down Expand Up @@ -272,7 +272,7 @@ void filter_adapt_task(const aec_par_tasks_t *s, aec_filter_state_t *main_state,
}
}

#ifdef __XS3A__
#if defined(__XS3A__) || defined(__VX4B__)

#define PAR_THREADS_PJOBS(FUNC, ARR, NUM_THREADS, ...) \
do { \
Expand Down
13 changes: 11 additions & 2 deletions lib_voice/vnr_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ else()
if(NOT TARGET tflite_micro)
set(TFLM_LIB_NAME tflite_micro)
add_library(${TFLM_LIB_NAME} STATIC IMPORTED GLOBAL)
target_compile_options(${TFLM_LIB_NAME} INTERFACE -Os)
target_compile_definitions(${TFLM_LIB_NAME} INTERFACE ${XMOS_AITOOLSLIB_DEFINITIONS})
set_target_properties(${TFLM_LIB_NAME} PROPERTIES
LINKER_LANGUAGE CXX
Expand All @@ -38,12 +39,20 @@ set(MODEL_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/src.autogen/vnr_model/)
set(MODEL_IN_PATH ${CMAKE_CURRENT_LIST_DIR}/src/vnr/model/trained_model.tflite)
set(MODEL_OUT_PATH ${MODEL_OUT_DIR}/trained_model_xcore.tflite)
set(MODEL_N_CORES 1)
set(MODEL_TH 0.50)

if (APP_BUILD_ARCH STREQUAL "vx4b")
set(MODEL_TH 2)
set(ARCH_STR "VX4A")
else()
# xs3a and native
set(MODEL_TH 0.50)
set(ARCH_STR "XS3A")
endif()

file(MAKE_DIRECTORY ${MODEL_OUT_DIR})

add_custom_command(
OUTPUT ${MODEL_OUT_PATH}.cpp ${MODEL_OUT_PATH}.h ${MODEL_OUT_PATH}
COMMAND xcore-opt ${MODEL_IN_PATH} -tc ${MODEL_N_CORES} -o ${MODEL_OUT_PATH} --xcore-conv-err-threshold ${MODEL_TH} --xcore-naming-prefix vnr_model_
COMMAND xcore-opt ${MODEL_IN_PATH} -tc ${MODEL_N_CORES} -o ${MODEL_OUT_PATH} --xcore-conv-err-threshold ${MODEL_TH} --xcore-naming-prefix vnr_model_ --xcore-target-arch=${ARCH_STR}
DEPENDS ${MODEL_IN_PATH}
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# python_version 3.11
# pip_version 25.*

xmos-ai-tools==1.4.2
xmos-ai-tools==1.4.3.dev24
2 changes: 1 addition & 1 deletion tests/profile_mips/lib_voice_mips.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"app_mips_ic": 13.21,
"app_mips_ns": 20.79,
"app_mips_aec_alt_arch_2threads": 30.7,
"app_mips_agc": 21.31
"app_mips_agc": 20.46
}
2 changes: 1 addition & 1 deletion tests/profile_mips/lib_voice_mips_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* - AEC_STD_ARCH_2THREADS
- 40.85
* - AGC
- 21.31
- 20.46
* - IC
- 13.21
* - NS
Expand Down
4 changes: 2 additions & 2 deletions tests/requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pytest~=9.0.2
pytest-xdist~=3.8.0
matplotlib~=3.10.8
soundfile~=0.13.1
xmos-ai-tools==1.4.2
xmos-ai-tools==1.4.3.dev24
xscope-fileio==1.3.1
# Development dependencies
#
Expand All @@ -39,5 +39,5 @@ xscope-fileio==1.3.1
# setup.py file, e.g., '-e .' or '-e ./python' (without the quotes).
-e ./shared/python
git+ssh://git@github.com/xmos/audio_test_tools@v4.6.0#egg=audio_test_tools&subdirectory=python
git+ssh://git@github.com/xmos/py_voice@v1.2.0#egg=py_voice
git+ssh://git@github.com/xmos/py_voice@develop#egg=py_voice
git+ssh://git@github0.xmos.com/xmos-int/xtagctl@v3.0.0#egg=xtagctl