All examples
Scientific computing

Compiled typed CPU repetitions

Build a checked native task with private local state, scalar parameters and exclusive typed output; compare ordered results across admitted local workers.

native_repeat.aner
// Development compiler: native CPU tasks with complete, exclusive output rows.
import aner.parallel
import aner.random

fn trajectory(parameters: List, iteration: Int64, seed: Int64, output: OutputRegion<Float64>) {
    let steps = cast<Int64>(parameters.get(0))
    let buffer = Array<Float64>(2, 0.25)
    let input = random.uniform(seed, 0) * 0.0001
    for step in Range(steps) {
        buffer[0] = buffer[0] * 0.9999 + input
    }
    output[0] = buffer[0]
    output[1] = Float64(iteration)
}

let serial = parallel.repeat(8, trajectory, List(1000), output_shape: List(2), execution: parallel.local(1), seed: 2026)
let concurrent = parallel.repeat(8, trajectory, List(1000), output_shape: List(2), execution: parallel.local(), seed: 2026)
var equivalent = true
for iteration in Range(serial.rows()) {
    if serial[iteration, 0] != concurrent[iteration, 0] { equivalent = false }
    if concurrent[iteration, 1] != Float64(iteration) { equivalent = false }
    if serial.seed(iteration) != concurrent.seed(iteration) { equivalent = false }
}
print(equivalent)
print(concurrent.rows())
print(concurrent.cols())
print(dtype(concurrent))

Make it your experiment.

Use the matching development source-build compiler SDK and C++20 toolchain. Save this program as examples/parallel/native_repeat.aner inside a folder for your experiment. Open a terminal in that folder, then check, build and execute the compiled program.

Choose fresh output paths and retain the generated C++ and JSON build manifest. On Windows, choose an .exe output and use the shell’s executable syntax. Building and the information command start no tasks.

Terminal
aner check examples/parallel/native_repeat.aner
aner build examples/parallel/native_repeat.aner -o native-repeat
./native-repeat --aner-native-info
./native-repeat

Windows PowerShell:

PowerShell
aner check examples/parallel/native_repeat.aner
aner build examples/parallel/native_repeat.aner -o native-repeat.exe
.\native-repeat.exe --aner-native-info
.\native-repeat.exe

Select the matching aner compiler and SDK described in the native build guide; downloaded runtime packages do not provide a usable native SDK.

Requires the matching development source build compiler SDK and C++20 toolchain for compiled typed CPU tasks. Downloaded runtime packages do not include a usable native compiler SDK. Worker requests must fit the runtime’s discovered CPU admission budget.

This numerical example uses the development source-build compiler SDK. Retain its source, generated C++, build manifest and execution observations together when comparing results.

Read the native compiler contract
Install Aner