modules: cmsis-dsp: re-add compilation control

Re-add finer grained compilation control that was lost in the CMSIS
split (#56957). CMSIS DSP is several hundred files and has a measurable
effect on compile times.

Only compiling features that are required improves this.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2023-11-24 16:01:53 +10:00 committed by David Leach
parent b64af4008f
commit 5c849f8e2e
2 changed files with 1083 additions and 813 deletions

View file

@ -52,7 +52,7 @@ if(CONFIG_CMSIS_DSP)
zephyr_compile_definitions_ifndef(CONFIG_ARM __GNUC_PYTHON__)
# BasicMathFunctions
if(CONFIG_CMSIS_DSP_BASICMATH)
set(SRCF64 ${CMSIS_DSP_DIR}/Source/BasicMathFunctions/arm_abs_f64.c
${CMSIS_DSP_DIR}/Source/BasicMathFunctions/arm_add_f64.c
${CMSIS_DSP_DIR}/Source/BasicMathFunctions/arm_dot_prod_f64.c
@ -152,13 +152,16 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${SRCU32})
zephyr_library_sources(${SRCU16})
zephyr_library_sources(${SRCU8})
endif()
# BayesFunctions
if (CONFIG_CMSIS_DSP_BAYES)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/BayesFunctions/arm_gaussian_naive_bayes_predict_f32.c)
if ((NOT ARMAC5) AND (NOT DISABLEFLOAT16))
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/BayesFunctions/arm_gaussian_naive_bayes_predict_f16.c)
endif()
endif()
# Common Tables
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/CommonTables/arm_common_tables.c
@ -193,6 +196,7 @@ if(CONFIG_CMSIS_DSP)
# MVE code is using a table for computing the fast sqrt arm_cmplx_mag_q31
# There is the possibility of not compiling this function and not including
# the table.
if (CONFIG_CMSIS_DSP_COMPLEXMATH)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ComplexMathFunctions/arm_cmplx_mag_q31.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ComplexMathFunctions/arm_cmplx_mag_q15.c)
@ -227,8 +231,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ComplexMathFunctions/arm_cmplx_mult_cmplx_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ComplexMathFunctions/arm_cmplx_mult_real_f16.c)
endif()
endif()
# Controller Functions
if (CONFIG_CMSIS_DSP_CONTROLLER)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ControllerFunctions/arm_pid_init_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ControllerFunctions/arm_pid_init_q15.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ControllerFunctions/arm_pid_init_q31.c)
@ -239,8 +245,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ControllerFunctions/arm_sin_cos_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/ControllerFunctions/arm_sin_cos_q31.c)
endif()
# Distance Functions
if (CONFIG_CMSIS_DSP_DISTANCE)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/DistanceFunctions/arm_boolean_distance.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/DistanceFunctions/arm_braycurtis_distance_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/DistanceFunctions/arm_canberra_distance_f32.c)
@ -282,8 +290,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/DistanceFunctions/arm_jensenshannon_distance_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/DistanceFunctions/arm_minkowski_distance_f16.c)
endif()
endif()
# Fast Math Functions
if (CONFIG_CMSIS_DSP_FASTMATH)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FastMathFunctions/arm_cos_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FastMathFunctions/arm_cos_q15.c)
@ -322,8 +332,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FastMathFunctions/arm_atan2_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FastMathFunctions/arm_atan2_q31.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FastMathFunctions/arm_atan2_q15.c)
endif()
# Filtering Functions
if (CONFIG_CMSIS_DSP_FILTERING)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FilteringFunctions/arm_lms_norm_init_q31.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FilteringFunctions/arm_lms_norm_init_q15.c)
@ -443,8 +455,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FilteringFunctions/arm_correlate_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/FilteringFunctions/arm_levinson_durbin_f16.c)
endif()
endif()
# Interpolation Functions
if (CONFIG_CMSIS_DSP_INTERPOLATION)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_bilinear_interp_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_bilinear_interp_q15.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_bilinear_interp_q31.c)
@ -457,13 +471,14 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_spline_interp_init_f32.c)
if ((NOT ARMAC5) AND (NOT DISABLEFLOAT16))
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_bilinear_interp_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/InterpolationFunctions/arm_linear_interp_f16.c)
endif()
endif()
# Matrix Functions
if (CONFIG_CMSIS_DSP_MATRIX)
set(SRCF64 ${CMSIS_DSP_DIR}/Source/MatrixFunctions/arm_mat_cholesky_f64.c
${CMSIS_DSP_DIR}/Source/MatrixFunctions/arm_mat_inverse_f64.c
${CMSIS_DSP_DIR}/Source/MatrixFunctions/arm_mat_ldlt_f64.c
@ -524,7 +539,6 @@ if(CONFIG_CMSIS_DSP)
${CMSIS_DSP_DIR}/Source/MatrixFunctions/arm_mat_trans_q7.c
)
zephyr_library_sources(${SRCF64})
zephyr_library_sources(${SRCF32})
@ -551,8 +565,10 @@ if(CONFIG_CMSIS_DSP)
${CMSIS_DSP_DIR}/Source/MatrixFunctions/arm_householder_f16.c
)
endif()
endif()
# Quaternion Math Functions
if (CONFIG_CMSIS_DSP_QUATERNIONMATH)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_quaternion_norm_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_quaternion_inverse_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_quaternion_conjugate_f32.c)
@ -561,8 +577,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_quaternion_product_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_quaternion2rotation_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/QuaternionMathFunctions/arm_rotation2quaternion_f32.c)
endif()
# Statistics Functions
if (CONFIG_CMSIS_DSP_STATISTICS)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/StatisticsFunctions/arm_entropy_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/StatisticsFunctions/arm_entropy_f64.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/StatisticsFunctions/arm_kullback_leibler_f32.c)
@ -665,8 +683,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/StatisticsFunctions/arm_absmin_no_idx_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/StatisticsFunctions/arm_accumulate_f16.c)
endif()
endif()
# Support Functions
if (CONFIG_CMSIS_DSP_SUPPORT)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SupportFunctions/arm_barycenter_f32.c
${CMSIS_DSP_DIR}/Source/SupportFunctions/arm_bitonic_sort_f32.c
${CMSIS_DSP_DIR}/Source/SupportFunctions/arm_bubble_sort_f32.c
@ -725,8 +745,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SupportFunctions/arm_f16_to_f64.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SupportFunctions/arm_f64_to_f16.c)
endif()
endif()
# SVM Functions
if (CONFIG_CMSIS_DSP_SVM)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SVMFunctions/arm_svm_linear_init_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SVMFunctions/arm_svm_rbf_init_f32.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SVMFunctions/arm_svm_linear_predict_f32.c)
@ -746,8 +768,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SVMFunctions/arm_svm_polynomial_predict_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/SVMFunctions/arm_svm_sigmoid_predict_f16.c)
endif()
endif()
# Transform Functions
if (CONFIG_CMSIS_DSP_TRANSFORM)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/TransformFunctions/arm_bitreversal.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/TransformFunctions/arm_bitreversal2.c)
@ -879,8 +903,10 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/TransformFunctions/arm_mfcc_init_f16.c)
zephyr_library_sources(${CMSIS_DSP_DIR}/Source/TransformFunctions/arm_mfcc_f16.c)
endif()
endif()
# Window Functions
if (CONFIG_CMSIS_DSP_WINDOW)
set(SRCF64 ${CMSIS_DSP_DIR}/Source/WindowFunctions/arm_welch_f64.c
${CMSIS_DSP_DIR}/Source/WindowFunctions/arm_bartlett_f64.c
${CMSIS_DSP_DIR}/Source/WindowFunctions/arm_hamming_f64.c
@ -927,5 +953,5 @@ if(CONFIG_CMSIS_DSP)
zephyr_library_sources(${SRCF64})
zephyr_library_sources(${SRCF32})
endif()
endif()

View file

@ -11,6 +11,250 @@ menuconfig CMSIS_DSP
if CMSIS_DSP
comment "Components"
config CMSIS_DSP_BASICMATH
bool "Basic Math Functions"
help
This option enables the Basic Math Functions, which support the
following operations:
* Elementwise Clipping
* Vector Absolute Value
* Vector Addition
* Vector Subtraction
* Vector Multiplication
* Vector Dot Product
* Vector Absolute Value
* Vector Negate
* Vector Offset
* Vector Scale
* Vector Shift
* Vector Bitwise AND
* Vector Bitwise OR
* Vector Bitwise Exclusive OR
* Vector Bitwise NOT
config CMSIS_DSP_COMPLEXMATH
bool "Complex Math Functions"
imply CMSIS_DSP_FASTMATH
help
This option enables the Complex Math Functions, which support the
following operations:
* Complex-by-Complex Multiplication
* Complex-by-Real Multiplication
* Complex Dot Product
* Complex Magnitude
* Complex Magnitude Squared
* Complex Conjugate
config CMSIS_DSP_CONTROLLER
bool "Controller Functions"
help
This option enables the Controller Functions, which support the
following operations:
* PID Control
* Vector Clarke Transform
* Vector Inverse Clarke Transform
* Vector Park Transform
* Vector Inverse Park Transform
* Sine-Cosine
These functions can be used to implement a generic PID controller, as
well as field oriented motor control using Space Vector Modulation
algorithm.
config CMSIS_DSP_FASTMATH
bool "Fast Math Functions"
imply CMSIS_DSP_BASICMATH
help
This option enables the Fast Math Functions, which support the
following operations:
* Fixed-Point Division
* Sine
* Cosine
* Square Root
config CMSIS_DSP_FILTERING
bool "Filtering Functions"
imply CMSIS_DSP_BASICMATH
imply CMSIS_DSP_FASTMATH
imply CMSIS_DSP_SUPPORT
help
This option enables the Filtering Functions, which support the
following operations:
* Convolution
* Partial Convolution
* Correlation
* Levinson-Durbin Algorithm
The following filter types are supported:
* FIR (finite impulse response) Filter
* FIR Lattice Filter
* FIR Sparse Filter
* FIR Filter with Decimator
* FIR Filter with Interpolator
* IIR (infinite impulse response) Lattice Filter
* Biquad Cascade IIR Filter, Direct Form I Structure
* Biquad Cascade IIR Filter, Direct Form II Transposed Structure
* High Precision Q31 Biquad Cascade Filter
* LMS (least mean square) Filter
* Normalized LMS Filter
config CMSIS_DSP_INTERPOLATION
bool "Interpolation Functions"
help
This option enables the Interpolation Functions, which support the
following operations:
* Bilinear Interpolation
* Linear Interpolation
* Cubic Spline Interpolation
config CMSIS_DSP_MATRIX
bool "Matrix Functions"
help
This option enables the Matrix Functions, which support the following
operations:
* Matrix Initialization
* Matrix Addition
* Matrix Subtraction
* Matrix Multiplication
* Complex Matrix Multiplication
* Matrix Vector Multiplication
* Matrix Inverse
* Matrix Scale
* Matrix Transpose
* Complex Matrix Transpose
* Cholesky and LDLT Decompositions
config CMSIS_DSP_QUATERNIONMATH
bool "Quaternion Math Functions"
help
This option enables the Quaternion Math Functions, which support the
following operations:
* Quaternion Conversions
* Quaternion Conjugate
* Quaternion Inverse
* Quaternion Norm
* Quaternion Normalization
* Quaternion Product
config CMSIS_DSP_STATISTICS
bool "Statistics Functions"
imply CMSIS_DSP_BASICMATH
imply CMSIS_DSP_FASTMATH
help
This option enables the Statistics Functions, which support the
following operations:
* Minimum
* Absolute Minimum
* Maximum
* Absolute Maximum
* Mean
* Root Mean Square (RMS)
* Variance
* Standard Deviation
* Power
* Entropy
* Kullback-Leibler Divergence
* LogSumExp (LSE)
config CMSIS_DSP_SUPPORT
bool "Support Functions"
help
This option enables the Support Functions, which support the
following operations:
* Vector 8-bit Integer Value Conversion
* Vector 16-bit Integer Value Conversion
* Vector 32-bit Integer Value Conversion
* Vector 16-bit Floating-Point Value Conversion
* Vector 32-bit Floating-Point Value Conversion
* Vector Copy
* Vector Fill
* Vector Sorting
* Weighted Sum
* Barycenter
config CMSIS_DSP_TRANSFORM
bool "Transform Functions"
imply CMSIS_DSP_BASICMATH
help
This option enables the Transform Functions, which support the
following transformations:
* Real Fast Fourier Transform (RFFT)
* Complex Fast Fourier Transform (CFFT)
* Type IV Discrete Cosine Transform (DCT4)
config CMSIS_DSP_SVM
bool "Support Vector Machine Functions"
help
This option enables the Support Vector Machine Functions, which
support the following algorithms:
* Linear
* Polynomial
* Sigmoid
* Radial Basis Function (RBF)
config CMSIS_DSP_BAYES
bool "Bayesian Estimators"
imply CMSIS_DSP_STATISTICS
help
This option enables the Bayesian Estimator Functions, which
implements the naive gaussian Bayes estimator.
config CMSIS_DSP_DISTANCE
bool "Distance Functions"
imply CMSIS_DSP_STATISTICS
help
This option enables the Distance Functions, which support the
following distance computation algorithms:
* Boolean Vectors
* Hamming
* Jaccard
* Kulsinski
* Rogers-Tanimoto
* Russell-Rao
* Sokal-Michener
* Sokal-Sneath
* Yule
* Dice
* Floating-Point Vectors
* Canberra
* Chebyshev
* Cityblock
* Correlation
* Cosine
* Euclidean
* Jensen-Shannon
* Minkowski
* Bray-Curtis
config CMSIS_DSP_WINDOW
bool "Windowing Functions"
help
This option enabled the Window Functions, which support the
following windowing functions:
* Bartlett
* Hamming
* Hanning
* Nuttall
* Blackman Harris
* HFT
comment "Instruction Set"
# NOTE: These configurations should eventually be derived from the arch ISA and
# FP support configurations.