atomiq.point_schema¶
Point schema entries, tiers and the mapping of argument values to kernel types.
The point schema lists every attribute of a scan point together with its tier and kernel type. It is frozen once per run and drives the generated point class, the chunk-fetch RPC and the generated kernel code.
Classes¶
Classification of a point attribute by when its value can change. |
|
One attribute of the frozen point schema. |
Functions¶
|
Return the kernel type for a host value. |
|
Cast a host value to the scalar that is sent to the kernel for a schema entry. |
Module Contents¶
- class atomiq.point_schema.Tier(*args, **kwds)[source]¶
Bases:
enum.EnumClassification of a point attribute by when its value can change.
CONSTANTattributes are fixed for the whole run. They are declared as kernel invariants, so the compiler can hoist their loads out of loops. They hold arguments that are neither scanned nor mutable, and the run id.SCANNEDattributes vary per point. They hold scan axes with more than one value and the step counter. The kernel writes them for every point from the columns of the fetched chunk.CHUNKattributes belong to mutable arguments that are not an active scan axis. The value is read once per chunk. It is constant within a chunk and may differ between chunks.COMPUTEDattributes are set inside the kernel and never sent by the host. The point identifier is one.- CONSTANT = 'constant'¶
- SCANNED = 'scanned'¶
- CHUNK = 'chunk'¶
- COMPUTED = 'computed'¶
- class atomiq.point_schema.PointSchemaEntry[source]¶
One attribute of the frozen point schema.
- Parameters:
name -- Attribute name, read as
point.<name>in user code.tier -- Tier of the attribute.
type -- Kernel type of the attribute, for example
floatorstr.options -- Allowed values of an enumeration. The wire value is the index into this tuple.
Nonefor all other entries.
- name: str¶
- options: tuple[str, ...] | None = None¶
- atomiq.point_schema.kernel_type_of(value)[source]¶
Return the kernel type for a host value.
The mapping is
booltobool, integers tonumpy.int64, floats tofloatand strings tostr. The bool check comes first becauseboolis a subclass ofint.- Parameters:
value (object) -- Host value of an argument.
- Returns:
The kernel type of the value.
- Raises:
TypeError -- If the value has no kernel type.
- Return type:
- atomiq.point_schema.to_wire(value, entry)[source]¶
Cast a host value to the scalar that is sent to the kernel for a schema entry.
This only casts. Callers validate the value first, because the casts truncate silently:
numpy.int64(2.7)is 2 andbool("False")isTrue. ARTIQ checks RPC return values strictly. Anumpy.bool_is rejected for a bool and an int is rejected for a float, so every value is cast to the exact type of its entry. Enumeration values are sent as anumpy.int32index into the options of the entry.- Parameters:
value (object) -- Host value of the argument.
entry (PointSchemaEntry) -- Schema entry of the argument.
- Returns:
The value as the kernel type of the entry, or the option index for an enumeration.
- Raises:
ValueError -- If the entry has options and the value is not one of them.
OverflowError -- If an integer value does not fit into
numpy.int64.
- Return type:
object