Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/a2a3/platform/onboard/host/device_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,24 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) {
l2_swimlane_collector_.set_core_types(core_types.data(), num_aicore);
}

rc = launch_run(runtime, num_aicore, launch_aicpu_num);
if (rc != 0) return rc;

rc = reap_run();
if (rc != 0) return rc;

// Print handshake results (reads from device memory, must be before free)
print_handshake_results();

return 0;
}

int DeviceRunner::launch_run(Runtime &runtime, int num_aicore, int launch_aicpu_num) {
// KernelLaunch is the pipeline boundary: this method clears the handshake
// consumed by the launch and submits exactly the AICore and AICPU kernels.
// It intentionally performs no stream synchronization or per-run cleanup.
int rc = 0;

// Launch the AICore worker BEFORE the AICPU Run task — mirrors the a5 path
// so the two arches stay symmetric. First-launch latency optimization +
// op-timeout-family defense-in-depth: with the AICPU Run task launched first
Expand Down Expand Up @@ -478,7 +496,11 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) {
return rc;
}

rc = sync_run_streams();
return 0;
}

int DeviceRunner::reap_run() {
int rc = sync_run_streams();
if (rc != 0) {
// sync_run_streams surfaces the AICore op-timeout (STARS-reaped op ->
// 507000/507018/507046 at AICPU/AICore stream sync). The op-timeout
Expand Down Expand Up @@ -517,9 +539,6 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) {
}
}

// Print handshake results (reads from device memory, must be before free)
print_handshake_results();

return 0;
}

Expand Down
9 changes: 7 additions & 2 deletions src/a2a3/platform/onboard/host/device_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class DeviceRunner : public DeviceRunnerBase {
* 1. Initializes device if not already done (lazy initialization)
* 2. Initializes worker handshake buffers in the runtime based on block_dim
* 3. Transfers runtime to device memory
* 4. Launches AICPU main kernel
* 5. Launches AICore kernel
* 4. Launches AICore kernel
* 5. Launches AICPU main kernel
* 6. Synchronizes streams
* 7. Cleans up runtime memory
*
Expand Down Expand Up @@ -219,6 +219,11 @@ class DeviceRunner : public DeviceRunnerBase {
// recovery. See run() and recover_device_or_mark_unusable().
bool device_unusable_{false};

// Keep the kernel submission boundary separate from stream synchronization
// and teardown. run() still invokes these back-to-back in this change.
int launch_run(Runtime &runtime, int num_aicore, int launch_aicpu_num);
int reap_run();
Comment thread
ChaoWao marked this conversation as resolved.

// On an AICore launch/sync error, best-effort drain the device so a later
// run() on the same DeviceRunner can recover in place; if the drain itself
// errors the context is unrecoverable without a full reset, so flip
Expand Down
Loading