Static Audits & Database Verification¶
MIPPv2 validates its declarative JSON database before emitting any code. Two kinds of checks coexist:
- Validation checks are always active. They stop the generator with an error (non-zero exit code).
- Audits are selected with
--audit. They report warnings and never stop generation.
The header-generator checks live in generator/helpers_headers/input_validation.py, plus a few in the modules that read the files (gen_mipp_headers.py, registry.py, forms.py, codegen/); the test-generator checks live in generator/helpers_tests/tests_builder.py.
1. Validation Checks (Always Active, Blocking)¶
| File | Checks |
|---|---|
| All inputs | Valid against its JSON Schema (generator/helpers_headers/schemas/, generator/helpers_tests/schemas/, documented in Registries): registries, ISA descriptors, templates and implementation files, half-vector (*ldiv_mask.json) and <isa>_sw_lmul.json files, tests_specs.json, tests_templates.json. The <isa>_explorer.json files are only validated by gen_mipp_docs.py. funcs_docs.json, registry_utilities.json and jinja_keywords.json have no schema. |
registry_protos.json |
An argument may only have "lmul": "ratio" (the other lmul values are for ret). |
registry_interfaces.json |
Every proto_ref exists in registry_protos.json.variants contains u.A domain key names a data register of the prototype (vd0 to vd<n-1>).A scalar form ( forms) has one letter v or s per data register, at least one of each, and its name (sub_vs) is not a declared function. |
registry_categories.json |
A function is listed at most once per category; a function listed in several categories gives its main category ("main_category" of registry_interfaces.json), one of them.Every categorized function is declared. |
registry_scalar_implems.json |
Every declared function has a scalar implementation, for exactly its declared datatypes. Every function of the file is declared. Every mask variant of a function is covered by an entry ( check_mipp_funcs_scalar_implems in gen_mipp_headers.py). |
<isa>_native_implems.json<isa>_emu_implems.json |
Every implemented function and emulation dependency is declared. The implemented datatypes are supported by the interface and by the ISA descriptor. |
*_implems.json |
Every template / template_ref resolves to an existing template. |
<isa>_emu_implems.json |
No dependency cycle between emulated functions. |
<isa>_imm_implems.json |
The function has an integer argument. The immediate bodies only use intrinsics and the types of the DSL, no MIPP function. |
*ldiv_mask.json, <isa>_sw_lmul.json |
Every function and datatype exists. A function that changes the LMUL has an entry without if (the fallback of generic_ldiv_mask.json).<isa>_sw_lmul.json requires software LMUL 2 registers (2 in sw_lmul, not in hw_lmul). |
<isa>_isa.json |
sub_isa exists.-2 in sw_lmul requires sw_ldiv_type: sub_isa or mask.sw_ldiv_type: sub_isa requires sub_isa and a size twice the size of sub_isa.sw_ldiv_type: mask only supports -2.At most one default info_names entry, in last position.A {field} placeholder in a datatype entry names a field of that entry, with a value for every LMUL when the field is a per-LMUL mapping. |
simd_ext/<isa>/ |
Contains <isa>_isa.json, <isa>_native_implems.json and <isa>_native_templates.json. |
2. Header Generator Audits (gen_mipp_headers.py --audit)¶
./gen_mipp_headers.py --audit all # default
./gen_mipp_headers.py --audit levels dead-code
./gen_mipp_headers.py --audit none
2.1. levels: Implementation Level Placement¶
For each ISA, the template of every entry of <isa>_native_implems.json and <isa>_emu_implems.json is inspected heuristically to infer its level:
- a single intrinsic call and no call to other MIPP functions: L0;
- the calls that materialize a constant do not count (
strip_negligible_callsinhelpers_headers/input_validation.py): a broadcast whose arguments are literals, macros or generation-time values (%set1<tp>%(0.5),%set0<tp>%(),_mm512_set1_epi32(INT32_MIN),vdupq_n_*,svdup_n_*,__riscv_vmv_v_x_*), and a constant predicate (svptrue_*,svpfalse_*,__riscv_vmset_m_*,__riscv_vmclr_m_*). A broadcast of an argument of the function (%set1<tp>%(s0)) still counts. A body made only of such a constant (theset0of NEON,vdupq_n_*(0)) is L0: the constant is the instruction of the function. The prefix of the ISA may be written in Jinja ({{ isa.prefix }}dup_n_*). The casts and reinterpretations of a register do not count either, since they generate no instruction (_mm_castps_si128,vreinterpretq_*,svreinterpret_*,__riscv_vreinterpret_*, the changes of LMUL of the RVV register groups__riscv_vlmul_trunc_*/__riscv_vlmul_ext_*, thecastcalls). The calls tocast,cast_k,tovdandtovmare not counted as MIPP functions; a call whose name is one Jinja expression ({{ ci }}(x)) is a cast; - intrinsics combined with other intrinsics or MIPP functions: L1;
- MIPP functions only: L2.
A warning is emitted when the inferred level does not match the file the entry lives in (<isa>_native_implems.json is expected to be L0, <isa>_emu_implems.json L1). Intentional exceptions can be marked on the entry with "skip_audit_level": true and a "skip_audit_level_reason".
The same rules give their level to the templates of <isa>_ldiv_mask.json and <isa>_sw_lmul.json without a level key (_auto_level in codegen/ldiv_mask.py, even with --audit none). They are applied to the code rendered by Jinja, for each datatype, LMUL and RVV half-vector representation, so only the branch that applies counts; a template with neither intrinsic nor MIPP function is L0. These files have no expected level and get no warning.
2.2. dead-code: Unreferenced or Unreachable Entries¶
- Native and ISA-specific emulation templates that no implementation entry references, directly or through another template.
- Generic templates (
tpl_generic_emu,tpl_mask_generic_emu,tpl_horiz_lmul_generic_emu) that no generic implementation entry references. - Generic emulation entries that can never be selected because every targeted datatype is already implemented natively on every candidate ISA.
- Functions declared in
registry_interfaces.jsonbut not assigned to any category.
2.3. duplicates: Overlapping Implementations¶
Reports, for a given (function, datatype, mask variant) of an ISA, two entries of its native and emulation files at the same level whose preprocessor conditions (if) are not mutually exclusive, or overlapping entries across levels.
2.4. json-structure: Repository Hygiene¶
- Top-level keys of every JSON file of
generator/(except the JSON Schemas) must be sorted lexicographically. - Implementation files (
*implems*.json) must not contain empty lists.
3. Test Generator Audits (gen_mipp_tests.py --audit)¶
The options are consistency, all and none. consistency warns when tests_specs.json describes a function that is not declared in registry_interfaces.json.
4. Continuous Integration¶
Both CI pipelines run the generators with their default audits (Continuous Integration). Since audits only emit warnings, they do not fail a pipeline. Validation checks (§1) do.