Skip to content

Half-Vector Templates

Generated page

This page is generated by gen_mipp_docs.py from the JSON Schemas of the generator (generator/helpers_headers/schemas/, generator/helpers_tests/schemas/). To change it, edit the description fields of the schemas, not this page.

Templates of the half-vectors by mask ("sw_ldiv_type": "mask" in the ISA Descriptor) and of the functions that change the LMUL between m1 and d2 (lo, hi, combine, wcvt, ncvt, and the _k mask versions). helpers_headers/generic_ldiv_mask.json gives the generic version, used by every ISA; simd_ext/<isa>/<isa>_ldiv_mask.json overrides it for one ISA, and is also where the ISAs with sub_isa half-vectors (AVX, AVX-512) and with hardware LMUL groups (RVV) write these functions. A function without an entry is written as a lane-wise wrapper of its LMUL 1 version on the same register. The code is Jinja2 and templating DSL, rendered for the LMUL of the arguments (d2, or m1 for lo and hi). Each key is a function name, or several names separated by | that share the entries. See Code Generation and Add an ISA.

Files (in generator/) Schema
simd_ext/<isa>/<isa>_ldiv_mask.json
helpers_headers/generic_ldiv_mask.json
helpers_headers/schemas/ldiv_mask_schema.json

Example

{
    "combine": [
        {
            "variants": [
                "u"
            ],
            "code": [
                "%vd<tr>% res;",
                "{% if isa_dt.reg == '__m128' %}res.vd = _mm_movelh_ps(vd0.vd, vd1.vd);",
                "{% elif isa_dt.reg == '__m128d' %}res.vd = _mm_unpacklo_pd(vd0.vd, vd1.vd);",
                "{% else %}res.vd = _mm_unpacklo_epi64(vd0.vd, vd1.vd);{% endif %}",
                "return res;"
            ],
            "datatypes": [
                "float32"
            ]
        }
    ]
}

Fields

Field Type Description
<function> array of object Candidate entries of the function, tried in order (the entries of <isa>_ldiv_mask.json first, then those of generic_ldiv_mask.json).
<function>[].level any Implementation level shown in the generated // Level comment, in the summary table and in the documentation. Optional. Without it, the level of an entry of <isa>_ldiv_mask.json is detected from its code with the rules of the level audit (0: a single intrinsic, or no instruction at all such as an identity; 1: several intrinsics, or intrinsics and MIPP functions; 2: only MIPP functions), and an entry of generic_ldiv_mask.json is level 2. Sequential code (level 3) must be declared with this key. Values: 0, 1, 2, 3.
<function>[].if string C preprocessor condition (e.g. defined(__SSE4_1__)) under which this entry is used. Otherwise the next matching entry is used (the entries of <isa>_ldiv_mask.json come first, then those of generic_ldiv_mask.json), down to an entry without if, or the lane-wise wrapper of the LMUL 1 function. lo / hi / combine need a fallback entry without if (given by generic_ldiv_mask.json).
<function>[].variants array of any Mask variants the entry applies to (u, m, z, s). Omitted: all the variants of the function.
<function>[].datatypes "all_datatypes" or array of string Datatypes (or dt_par,dt_ret pairs for the conversions) the entry applies to, or all_datatypes (the default).
<function>[].code array of string Required. Body of the function, one line per item: Jinja2 and templating DSL (%vd<tp>%, %N<tp\|m:tp*2>%, %vd<tr>% for the result). Jinja2 variables: isa (the ISA descriptor), isa_dt (its entry for the datatype of the arguments), f (the function name), dt / dt_ret (the datatypes of the arguments and of the result, with category and n_bits), mask_kind (None, maskm, maskz or masks), UI (the unsigned datatype of the same width, e.g. uint32). Helpers: call1(name, args..., mk=None, dt=None) calls the LMUL 1 function name, in the mask variant mk and for the datatype dt (default: the one of the arguments), and records it as a dependency; call_half(name, args..., dt=None, dt_ret=None) and call_m1(name, args..., dt=None, dt_ret=None) call the d2 / LMUL 1 version of a conversion between the datatypes dt and dt_ret (wcvt in wmul, ncvts in ncvtsrshiftround) and record it as a dependency; wrap(names...) declares the LMUL 1 copies w_<name> of the d2 parameters; ret_d2(expr) returns the LMUL 1 result expr as a d2 result; lanemask(name) declares the LMUL 1 mask name (default lm), true on the lower half of the lanes; neutral(f) is the neutral element of the reduction f. ctx also gives ctx.dt_par, ctx.dt_ret, ctx.lmul_in / ctx.lmul_out (LMUL of the arguments and of the result), ctx.N() / ctx.N2() (the macros of the number of lanes of the full and of the half register) and, for the ISAs whose intrinsics carry the LMUL (RVV), ctx.ext(dt, lmul), ctx.uext(dt, lmul) and ctx.bext(dt, lmul) (intrinsic suffixes at an LMUL). The generation-time tables of the implementation templates (compress_lut, iota...) are not available here.