[Python] How can I get LLVM loop vectorization debug output in Numba?

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to view LLVM debug messages for loop vectorization using Numba and llvmlite. I want to see the loop vectorization "LV:" debug output (e.g., messages like LV: Checking a loop in ...) so I can analyze the vectorization decisions made by LLVM. https://numba.readthedocs.io/en/stable/user/faq.html#does-numba-vectorize-array-computations-simd

    I'm using a conda environment with the following YAML file. This makes sure I’m using the llvmlite build from the numba channel (which should have LLVM built with assertions enabled):

    name: numbadev

    channels:
    - defaults
    - numba

    dependencies:
    - python>=3.12.9
    - numba::numba
    - numba::llvmlite
    - intel-cmplr-lib-rt


    Running conda list shows:

    # Name Version Build Channel
    python 3.13.2 hf623796_100_cp313
    llvmlite 0.44.0 py313h84b9e52_0 numba
    numba 0.61.2 np2.1py3.13hf94e718_g1e70d8ceb_0 numba
    ...


    This is my script debug_loop_vectorization.py:

    import llvmlite.binding as llvm
    llvm.set_option('', '--debug-only=loop-vectorize')

    import numpy as np
    from numba import jit

    @jit(nopython=True, fastmath=True)
    def test_func(a):
    result = 0.0
    for i in range(a.shape[0]):
    result += a * 2.0
    return result

    # Trigger compilation.
    a = np.arange(1000, dtype=np.float64)
    test_func(a)

    # Print the LLVM IR
    print(test_func.inspect_llvm(test_func.signatures[0]))


    When I run the script from a Linux terminal I see the LLVM-IR but no lines starting with "LV:...".

    How can I get LLVM loop vectorization debug output?

    Continue reading...

Compartilhe esta Página