Adding CUDA GPU Power for Simulation Physics

The final section of the C tutorial is explicitly work in progress. It sketches an AWACS scenario where Cimba processes model aircraft and targets while CUDA handles heavy physics calculations.

The Python tutorial keeps the same simulation shape but not the CUDA machinery: targets are active processes, a sensor process samples their state, and a summary object collects detections.

The AWACS Scenario on a Single CPU

The C tutorial visualizes the full scenario in ParaView:

AWACS aircraft, terrain, and detected ground targets.

A snapshot of the AWACS scenario used to motivate GPU-backed simulation physics.

import cimba


class Target:
    def __init__(self, name: str):
        self.name = name
        self.x = 0.0
        self.y = 0.0
        self.visible = False


def run_awacs_demo(seed: int = 51, duration: float = 5.0, num_targets: int = 3) -> dict[str, float | int]:
    targets = [Target(f"Target_{idx:03d}") for idx in range(num_targets)]
    detections = cimba.DataSummary()

    def target_proc(target):
        target.x = cimba.uniform(-10.0, 10.0)
        target.y = cimba.uniform(-10.0, 10.0)
        while True:
            target.visible = cimba.bernoulli(0.5)
            cimba.hold(cimba.exponential(1.0))

    def sensor_proc(ctx):
        while True:
            for target in ctx["targets"]:
                detected = target.visible and cimba.bernoulli(0.8)
                ctx["detections"].add(1.0 if detected else 0.0)
            cimba.hold(1.0)

    with cimba.Simulation(seed=seed) as sim:
        for target in targets:
            cimba.Process(target.name, target_proc, target).start()
        cimba.Process("Radar", sensor_proc, {"targets": targets, "detections": detections}).start()
        sim.stop_at(duration)
        sim.execute()

    return {"count": detections.count, "mean": detections.mean}


def main() -> None:
    print(run_awacs_demo())


if __name__ == "__main__":
    main()

The important Cimba idea is still visible: many active targets have their own process loops, and another process observes them at regular simulated times. The heavy physics function could be ordinary Python, NumPy, a C extension, CUDA through a third-party library, or any other thread-safe callable.

CUDA Integration Status

There is no high-level Python tutorial API today for assigning Cimba worker threads to CUDA devices or streams. The low-level native thread hook capsule API exists for advanced integrations, but the tutorial-level CUDA stream assignment described in the C docs is not yet exposed as a friendly Python feature.