Ahead of Time Compilation (AOT)
Ahead-of-Time (AOT) compilation allows you to optimize Atym containers for better performance and achieve near-native execution speeds. This is accomplished by creating a container image that targets a specific platform configuration to be used by a device. The Atym Hub trans-piles a given WASM binary based on the provided platform target details into these target images.
How it Works
AOT works in two main steps. First, AOT is enabled at the device level, then containers are pushed with an AOT configuration file to the Atym Hub. The AOT configuration file tells the Hub that this container should be compiled using AOT for specific architectures. When a container is deployed to a device, it uses the AOT settings from that device’s configuration to determine the appropriate container type to deploy.
Order of Operations
To successfully deploy an AOT-compiled container, there are three steps that must happen in sequence:
- Create an AOT image — push the container with an AOT configuration file so the Hub can transpile it into a device-specific binary.
- Enable AOT on the device — set the device’s configuration so the Hub knows to use the AOT image.
- Update the container set — after the image is created and AOT is enabled, you must perform a container set update for the image to actually be installed on the device.
Skipping the container set update step will prevent the AOT image from being deployed.
Enabling and Disabling AOT
AOT can be enabled or disabled at the device level with the add device or update device commands. These settings configure how the Hub behaves when deploying containers to your device.
Using add device (with Command Line Arguments)
In addition to the standard required flags for add device, you can enable or disable AOT by using the --aotEnabled flag:
# Enable AOT
atym add device --deviceName "MyDevice" --serialNumber "1234567890" --aotEnabled true --cpu cortex-m4 --target thumbv8m.base --targetAbi eabihf
# Disable AOT
atym add device --deviceName "MyDevice" --serialNumber "1234567890" --aotEnabled false
AOT is disabled by default, so explicitly setting --aotEnabled false is usually not required unless you are overriding a previous configuration.
See the Device Configuration Fields table below for details on required and optional flags used in these examples.
Using update device
Update an existing device to enable/disable AOT with the update device command:
# Enable AOT
atym update device <deviceUUID> --aot true --target thumbv8m.base
# Disable AOT
atym update device <deviceUUID> --aot false
When using update device, you only need to provide the values you want to change. For example, setting --aot false is enough to disable AOT without re-specifying CPU or target information.
Refer to the Device Configuration Fields section below for descriptions of these flags and valid values.
When enabling AOT with update device, the required fields follow this hierarchy:
[target]
[target] [targetAbi]
[target] [targetAbi] [cpu]
[target] [targetAbi] [cpu] [features]
At a minimum, you must provide target. Additional fields such as targetAbi, cpu, and features can be included to guide the compiler, but if omitted the compiler will apply whatever optimizations are possible with the information provided.
Device Configuration Fields
| Parameter | Description | Accepted Values |
|---|---|---|
aotEnabled | Enable or disable AOT at the device level | true, false |
cpu | The CPU variant for this configuration | See available CPU types |
target | The device architecture type | See available Target types |
targetAbi | The Application Binary Interface for the target platform | See available TargetAbi types |
Using add device (with Configuration File)
You can also enable or disable AOT using a device config file:
atym add device -file device.yaml
Note that enabling AOT at the device level tells the Hub which container type to deploy. This lets you switch between standard Atym containers (for debugging/development) and AOT-compiled binaries (for production performance) as needed. While devices can technically run both types, you may not want AOT enabled all the time.
Example
aotConfigs:
- cpu: cortex-m55
target: armv7
targetAbi: eabihf
- cpu: cortex-m4
target: thumbv8m.base
targetAbi: eabihf
xip: false
This example shows an AOT configuration file that applies to two targets.
Config File Fields
| Parameter | Description | Accepted Values |
|---|---|---|
cpu | The CPU variant for this configuration | See available CPU types |
target | The device architecture type | See available Target types |
targetAbi | The Application Binary Interface for the target platform | See available TargetAbi types |
Using AOT
Once enabled, you need to push the YAML config file along with your container:
atym push hello-world:latest -a aot.yaml
Alternative: Single AOT Configuration
You can also run atym add aot to add an AOT binary using command-line arguments instead of a configuration file:
atym add aot hello-world:latest -c cortex-m7 -t armv7em -a eabihf
This enables AOT for boards that use the cortex-m7 CPU and armv7em target architecture.