srdatalog.ir.codegen.cuda.plugin¶
Index-type plugin registry + default DSAI (DeviceSortedArrayIndex) hooks.
Port of src/srdatalog/index_plugin.nim. Every C++ expression the JIT backend emits for handle/view operations dispatches through an IndexPlugin so custom index types (e.g., Device2LevelIndex used by polonius_test) can override behavior. The default plugin matches DSAI and is what every existing integration fixture uses.
Module Contents¶
Classes¶
Codegen hooks for one index family. Each field is a callable that
emits a C++ expression string. Plugins register themselves by C++ type
( |
|
How a prefix() / prefix_lower_bound() call is dispatched. |
Functions¶
Collect unique C++ headers declared by the plugins resolving from
|
|
Baseline DSAI plugin — matches every built-in integration fixture. |
|
Emit chained .prefix(key, …) calls. For each |
|
Like |
|
Register a plugin by its |
|
Look up plugin by C++ type; empty string / unknown type returns the default (DSAI). Substring match lets partial type strings resolve, matching Nim’s resolvePlugin behavior. |
API¶
- class srdatalog.ir.codegen.cuda.plugin.IndexPlugin[source]¶
Codegen hooks for one index family. Each field is a callable that emits a C++ expression string. Plugins register themselves by C++ type (
cpp_type) and the resolver falls back to the default (DSAI) when no plugin is registered for a given type.- gen_child: collections.abc.Callable[[str, str], str]¶
None
- gen_degree: collections.abc.Callable[[str], str]¶
None
- gen_iterators: collections.abc.Callable[[str, str], str]¶
None
- gen_prefix: collections.abc.Callable[[str, str, str, srdatalog.ir.codegen.cuda.plugin.PrefixMode], str]¶
None
- gen_prefix_lower_bound: collections.abc.Callable[[str, str, str, srdatalog.ir.codegen.cuda.plugin.PrefixMode], str]¶
None
- gen_root_handle: collections.abc.Callable[[str], str]¶
None
- gen_valid: collections.abc.Callable[[str], str]¶
None
- view_count: collections.abc.Callable[[str], int]¶
None
- class srdatalog.ir.codegen.cuda.plugin.PrefixMode(*args, **kwds)[source]¶
Bases:
enum.EnumHow a prefix() / prefix_lower_bound() call is dispatched.
Initialization
- COOPERATIVE¶
‘cooperative’
- SEQUENTIAL¶
‘sequential’
- srdatalog.ir.codegen.cuda.plugin.get_extra_headers_for_types(index_types: list[str]) list[str][source]¶
Collect unique C++ headers declared by the plugins resolving from
index_types. Empty strings are skipped.
- srdatalog.ir.codegen.cuda.plugin.new_default_plugin() srdatalog.ir.codegen.cuda.plugin.IndexPlugin[source]¶
Baseline DSAI plugin — matches every built-in integration fixture.
- srdatalog.ir.codegen.cuda.plugin.plugin_chained_prefix_calls(parent_handle: str, prefix_vars: list[str], view_var: str, cartesian_bound_vars: list[str] | None = None, scalar_mode: bool = False, index_type: str = '') str[source]¶
Emit chained .prefix(key, …) calls. For each
vinprefix_vars:Sequential mode (per-thread), or cartesian_bound_vars containing v: use
.prefix_seq(v, view)Else cooperative:
.prefix(v, tile, view)
Matches Nim’s pluginChainedPrefixCalls exactly.
- srdatalog.ir.codegen.cuda.plugin.plugin_chained_prefix_with_last_lower_bound(parent_handle: str, prefix_vars: list[str], view_var: str, cartesian_bound_vars: list[str] | None = None, scalar_mode: bool = False, index_type: str = '') str[source]¶
Like
plugin_chained_prefix_callsbut the LAST key usesprefix_lower_boundinstead ofprefix. Used for range intersection.
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_child(handle: str, idx: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_child_range(handle: str, pos: str, key: str, tile: str, view_var: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_get_value(view_var: str, col: int, pos: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_get_value_at(handle: str, view_var: str, idx: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_host_view_setup(idx_expr: str, version: str, index_type: str = '') list[str][source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_iterators(handle: str, view_var: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_prefix(handle: str, key: str, view_var: str, mode: srdatalog.ir.codegen.cuda.plugin.PrefixMode, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_prefix_lower_bound(handle: str, key: str, view_var: str, mode: srdatalog.ir.codegen.cuda.plugin.PrefixMode, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.plugin_gen_root_handle(view_var: str, index_type: str = '') str[source]¶
- srdatalog.ir.codegen.cuda.plugin.register_index_plugin(plugin: srdatalog.ir.codegen.cuda.plugin.IndexPlugin) None[source]¶
Register a plugin by its
cpp_typestring. Called from each index module at import time (mirroring Nim’s compile-time registration).
- srdatalog.ir.codegen.cuda.plugin.resolve_plugin(index_type: str) srdatalog.ir.codegen.cuda.plugin.IndexPlugin[source]¶
Look up plugin by C++ type; empty string / unknown type returns the default (DSAI). Substring match lets partial type strings resolve, matching Nim’s resolvePlugin behavior.