Skip to content

main.aug ​

GPU workers · Source and specification

Files in this project

Code ​

aug
// aug-spec: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import calculate from compute
import GpuError from "https://github.com/GreenPandaStudios/aug-gpu#ebc288b8d88b30213715bdbcd3d4647ff81a5462"
try:
    scope:
        first = start worker calculate(left=[1.0, 2.0, 3.0], right=[4.0, 5.0, 6.0])
        second = start worker calculate(left=[10.0, 20.0], right=[1.0, 2.0])
        (firstResult, secondResult) = wait for first and second
        for value in firstResult:
            print(value)
        for value in secondResult:
            print(value)
catch GpuError error:
    print(value=error.explain())
    exit(status=1)
catch ConcurrencyError error:
    print(value="Worker capacity is exhausted")
aug
// aug-spec: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import calculate from compute
import GpuError from "https://github.com/GreenPandaStudios/aug-gpu#ebc288b8d88b30213715bdbcd3d4647ff81a5462"
try {
    scope {
        first = start worker calculate(left=[1.0, 2.0, 3.0], right=[4.0, 5.0, 6.0])
        second = start worker calculate(left=[10.0, 20.0], right=[1.0, 2.0])
        (firstResult, secondResult) = wait for first and second
        for value in firstResult {
            print(value)
        }
        for value in secondResult {
            print(value)
        }
    }
}
catch GpuError error {
    print(value=error.explain())
    exit(status=1)
}
catch ConcurrencyError error {
    print(value="Worker capacity is exhausted")
}

Compiled specification ​

Interactions and sequences

Startup ​

Within a task and ownership scope, it sets first to a worker task running calculate with left from a list containing 1.0, 2.0, 3.0 and right from a list containing 4.0, 5.0, 6.0 with copies of its inputs on a separate heap. It sets second to a worker task running calculate with left from a list containing 10.0, 20.0 and right from a list containing 1.0, 2.0 with copies of its inputs on a separate heap. It reads the result of waiting for first and second in input order; propagate failures once and binds [0] as firstResult and [1] as secondResult. source

For each value in a snapshot of firstResult, it prints value. After the loop, for each value in a snapshot of secondResult, it prints value. On leaving this scope, join its child tasks and release its local values. If this work raises GpuError as error, it prints error.explain; then it calls exit with status 1. source

If this work raises ConcurrencyError, it prints "Worker capacity is exhausted". source

Dependencies ​

It uses GpuError (explain) from https://github.com/GreenPandaStudios/aug-gpu#ebc288b8d88b30213715bdbcd3d4647ff81a5462. It uses calculate from compute.

Built-in operations follow the language reference.

Last updated:

The world runs on language