ispc-builtins
Best practices for creating and modifying ISPC builtin files. Use when adding target-specific optimizations, implementing new builtin functions, or working with the hierarchical target system.
Install
mkdir -p .claude/skills/ispc-builtins && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3326" && unzip -o skill.zip -d .claude/skills/ispc-builtins && rm skill.zipInstalls to .claude/skills/ispc-builtins
About this skill
ISPC Builtins Guide
Understanding the hierarchical target system is critical for correctly implementing and maintaining builtins.
Architecture Overview
ISPC's standard library consist of two layers:
- Standard Library (
stdlib/stdlib.ispc) — User-visible functions written in ISPC language - Builtins (
builtins/) — Target-specific implementations in LLVM IR that support the stdlib
Hierarchical Target System
Key Concept: Targets are organized hierarchically. A child target inherits all functions from its parent that it doesn't explicitly override.
Target Parent Map (src/builtins.cpp)
The hierarchy is defined in targetParentMap:
std::unordered_map<ISPCTarget, ISPCTarget> targetParentMap = {
// ARM NEON -> generic
{ISPCTarget::neon_i8x16, ISPCTarget::generic_i8x16},
// AVX512 hierarchy: dmr -> gnr -> spr -> icl -> skx -> generic
{ISPCTarget::avx10_2dmr_x16, ISPCTarget::avx512gnr_x16},
{ISPCTarget::avx512gnr_x16, ISPCTarget::avx512spr_x16},
{ISPCTarget::avx512spr_x16, ISPCTarget::avx512icl_x16},
{ISPCTarget::avx512icl_x16, ISPCTarget::avx512skx_x16},
{ISPCTarget::avx512skx_x16, ISPCTarget::generic_i1x16},
// AVX/SSE hierarchy: avx2vnni -> avx2 -> avx1 -> sse4 -> sse2 -> generic
{ISPCTarget::avx2vnni_i32x8, ISPCTarget::avx2_i32x8},
{ISPCTarget::avx2_i32x8, ISPCTarget::avx1_i32x8},
// ...
};
How Linking Works
When compiling user code:
- Link the target-specific builtins (e.g.,
avx512skx-x16) - Check for unresolved symbols
- If unresolved, link parent target's builtins (e.g.,
generic-i1x16) - Repeat until all symbols are resolved or error
Implication: You only need to implement functions that differ from the parent.
File Structure (builtins/)
| File Pattern | Description |
|---|---|
target-<isa>-<variant>.ll | Target-specific LLVM IR (e.g., target-avx512skx-x16.ll) |
target-<isa>-common.ll | Shared code for ISA family (e.g., target-sse4-common.ll) |
target-<isa>-utils.ll | Utility macros/functions for ISA (e.g., target-avx512-utils.ll) |
generic.ispc | Target-independent implementations in ISPC |
util.m4 | M4 macros for generating LLVM IR |
Function signatures are declared in stdlib/include/builtins.isph.
Creating/Modifying Builtins
Step 1: Define the Function Signature
Add declaration to stdlib/include/builtins.isph:
EXT inline READNONE varying float __my_builtin_float(varying float);
Step 2: Implement Generic Fallback and Optimized Versions
New builtins must always have a generic implementation in generic.ispc. This ensures all targets work correctly via hierarchy fallback.
Then add optimized LLVM IR versions at the appropriate level — they will be inherited by all children:
avx512skx— inherited byicl,spr,gnr,dmravx512icl— inherited byspr,gnr,dmr(overridesskx)
Example optimized implementation in target-avx512skx-x16.ll:
define <16 x float> @__my_builtin_float(<16 x float> %input) nounwind readnone alwaysinline {
%result = call <16 x float> @llvm.x86.avx512.something(<16 x float> %input)
ret <16 x float> %result
}
Best Practices
- Leverage hierarchy — Only implement what differs from parent; don't copy-paste
- Use generic as fallback — Implement in
generic.ispcfirst, optimize later - Use
include()— Share code viatarget-*-utils.llfiles - Mark functions correctly — Use
nounwind readnone alwaysinlineattributes
Testing Builtins
See CLAUDE.md for build, lit test, and IR/assembly inspection commands.
Verify Correct Builtin Was Linked
Dump IR before optimizations to see builtins as they were linked:
build/bin/ispc test.ispc --target=avx512skx-x16 --debug-phase=pre:first --dump-file=dbg -o /dev/null
# Check dbg/ir_*.ll files for the builtin implementation
More by ispc
View all skills by ispc →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversBoost productivity with Task Master: an AI-powered tool for project management and agile development workflows, integrat
Edit PDF and DOC files online with Office Word. Access advanced text formatting, table editing, and image scaling in you
pg-aiguide — Version-aware PostgreSQL docs and best practices tailored for AI coding assistants. Improve queries, migrat
Empower your Unity projects with Unity-MCP: AI-driven control, seamless integration, and advanced workflows within the U
Supercharge AI platforms with Azure MCP Server for seamless Azure API Management and resource automation. Public Preview
Discover AntV Visualization Libraries for smart documentation, code examples, and best practices in g2, g6, l7, x6, f2,
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.