Skip to content

Build Instructions - KERNELS_L0

Prerequisites

The KERNELS_L0 library is header-only for maximum portability and ease of integration. However, tests require compilation.

Required Tools

  • C++17 Compiler:
  • Windows: MSVC 2019+ or MinGW-GCC 9+
  • Linux: GCC 9+ or Clang 10+
  • macOS: Clang 10+ (Xcode Command Line Tools)

  • CMake: 3.15 or higher (optional, for building tests)

Optional Tools

  • Python 3.8+ (for Python bindings - coming in future phase)
  • Catch2 (for advanced testing - will be integrated later)

Quick Start (Header-Only Usage)

Since KERNELS_L0 is header-only, you can use it without building:

Option 1: Direct Include

// Your project
#include "path/to/05_04_KERNELS_L0/05_04_00_arithmetic_kernels/include/arithmetic_kernels.h"
#include "path/to/05_04_KERNELS_L0/05_04_08_signal_generators/include/signal_generators.h"

int main() {
    float a[100], b[100], out[100];

    // Fill a, b...

    audiolab::kernels::l0::add_kernel(a, b, out, 100);
    return 0;
}

Compile:

# Windows (MSVC - requires Developer Command Prompt)
cl /EHsc /std:c++17 /O2 /arch:AVX2 your_program.cpp

# Windows (MinGW)
g++ -std=c++17 -O3 -march=native your_program.cpp -o your_program.exe

# Linux/macOS
g++ -std=c++17 -O3 -march=native your_program.cpp -o your_program

Option 2: CMake Integration

Add to your CMakeLists.txt:

add_subdirectory(path/to/05_04_KERNELS_L0)

target_link_libraries(your_target PRIVATE
    arithmetic_kernels
    signal_generators
)

Building Tests (With CMake)

Windows (MSVC)

Prerequisites: - Install Visual Studio 2019 or 2022 with "Desktop development with C++" - Install CMake: https://cmake.org/download/

Steps:

  1. Open "Developer Command Prompt for VS 2022" (or VS 2019)

  2. Navigate to KERNELS_L0 directory:

    cd "C:\AudioDev\audio-lab\3 - COMPONENTS\05_MODULES\05_04_KERNELS_L0"
    

  3. Create build directory and configure:

    mkdir build
    cd build
    cmake .. -G "Visual Studio 17 2022" -A x64
    

  4. Build:

    cmake --build . --config Release
    

  5. Run tests:

    ctest -C Release -V
    

Or run individual test executables:

.\05_04_00_arithmetic_kernels\Release\test_arithmetic_kernels.exe
.\05_04_08_signal_generators\Release\test_signal_generators.exe


Windows (MinGW-GCC)

Prerequisites: - Install MinGW-w64: https://www.mingw-w64.org/ - Install CMake

Steps:

  1. Open Command Prompt

  2. Navigate to KERNELS_L0:

    cd "C:\AudioDev\audio-lab\3 - COMPONENTS\05_MODULES\05_04_KERNELS_L0"
    

  3. Configure and build:

    mkdir build
    cd build
    cmake .. -G "MinGW Makefiles"
    cmake --build .
    

  4. Run tests:

    ctest -V
    


Linux

Prerequisites:

# Ubuntu/Debian
sudo apt install build-essential cmake

# Fedora
sudo dnf install gcc-c++ cmake

# Arch
sudo pacman -S base-devel cmake

Steps:

cd /path/to/05_04_KERNELS_L0
mkdir build && cd build
cmake ..
cmake --build . -j$(nproc)
ctest -V

macOS

Prerequisites:

# Install Xcode Command Line Tools
xcode-select --install

# Install CMake via Homebrew
brew install cmake

Steps:

cd /path/to/05_04_KERNELS_L0
mkdir build && cd build
cmake ..
cmake --build . -j$(sysctl -n hw.ncpu)
ctest -V

Building Without CMake (Manual Compilation)

If CMake is not available, you can compile tests manually:

Arithmetic Kernels Test

# Windows (MSVC - in Developer Command Prompt)
cl /EHsc /std:c++17 /O2 /I"05_04_00_arithmetic_kernels\include" ^
   05_04_00_arithmetic_kernels\tests\test_arithmetic_kernels.cpp ^
   /Fe:test_arithmetic.exe

# Linux/macOS/MinGW
g++ -std=c++17 -O3 -march=native \
    -I05_04_00_arithmetic_kernels/include \
    05_04_00_arithmetic_kernels/tests/test_arithmetic_kernels.cpp \
    -o test_arithmetic

Signal Generators Test

# Windows (MSVC)
cl /EHsc /std:c++17 /O2 /I"05_04_08_signal_generators\include" ^
   05_04_08_signal_generators\tests\test_signal_generators.cpp ^
   /Fe:test_generators.exe

# Linux/macOS/MinGW
g++ -std=c++17 -O3 -march=native \
    -I05_04_08_signal_generators/include \
    05_04_08_signal_generators/tests/test_signal_generators.cpp \
    -o test_generators

Optimization Flags

For maximum performance, use these compiler flags:

MSVC

/O2          - Maximum speed optimization
/arch:AVX2   - Enable AVX2 SIMD instructions
/fp:fast     - Fast floating-point model

GCC/Clang

-O3              - Maximum optimization
-march=native    - Optimize for current CPU (enables AVX2/AVX-512 if available)
-ffast-math      - Fast floating-point (slightly relaxes IEEE compliance)

Verification

After building, tests should output:

==============================================
ARITHMETIC KERNELS TEST SUITE
==============================================

Running test_add_kernel_basic...
✓ test_add_kernel_basic passed

Running test_multiply_scalar_kernel...
✓ test_multiply_scalar_kernel passed

...

==============================================
ALL TESTS PASSED ✓
==============================================

Troubleshooting

Issue: "cmake: command not found"

Solution: Install CMake or use manual compilation method above.

Issue: "No C++ compiler found"

Windows: Install Visual Studio with C++ workload or MinGW-w64 Linux: sudo apt install build-essential macOS: xcode-select --install

Issue: Tests fail with numerical errors

Possible causes: - Compiler optimizations too aggressive (try removing -ffast-math) - Platform-specific floating-point behavior - Check test epsilon values

Issue: Poor performance (no SIMD speedup)

Check: - Are you building in Release mode? (cmake --build . --config Release) - Are SIMD flags enabled? (-march=native or /arch:AVX2) - Is auto-vectorization working? (Check compiler output with -fopt-info-vec on GCC)


Current Status

Implemented and Tested: - 05_04_00_arithmetic_kernels (8 kernels) - 05_04_08_signal_generators (9 generators)

🚧 In Progress: - 05_04_02_delay_and_buffers - 05_04_03_interpolation_kernels

📋 Planned: - 05_04_01_signal_operations - 05_04_04_mathematical_functions - 05_04_05_logical_operations - 05_04_06_format_conversion - 05_04_07_lookup_tables - 05_04_09_measurement_kernels - 05_04_10_boundary_handling


Next Steps

  1. ✅ Verify header-only usage works
  2. ✅ Run tests (when compiler available)
  3. 🚧 Integrate into larger DSP project
  4. 📋 Implement remaining kernel families (TAREA 2-11)

For questions or issues, see: README.md and PLAN_DE_DESARROLLO.md