Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d5128df
Add: fully_distributed_within_core runtime — SPMD on-core orchestration
hengliao1972 Jun 24, 2026
98c0e65
Add: execute-first run-ahead loop + per-core swimlane for fully_distr…
hengliao1972 Jun 25, 2026
3ebf6eb
docs(fully_distributed_within_core): embed FullCore24 execution swimlane
hengliao1972 Jun 25, 2026
9158240
Add: runtime_overhead_test — isolate on-core orchestration/scheduling…
hengliao1972 Jun 26, 2026
ccf77a7
docs(fully_distributed_within_core): add §6.2 measured orchestration …
hengliao1972 Jun 26, 2026
efe9deb
Fix sim pthread-key leak; add CPU-affinity sweep + binding docs
hengliao1972 Jun 26, 2026
30bb973
perf(fully_distributed_within_core): make per-core TensorMap O(N) ins…
hengliao1972 Jun 26, 2026
f896159
perf+feat(fully_distributed_within_core): AICore single-NUMA thread p…
hengliao1972 Jun 26, 2026
5297a0e
fix(sim): guard Linux-only AICore pinning for non-Linux build; platfo…
hengliao1972 Jun 26, 2026
3090183
chore(runtime_overhead_test): macOS default --blocks 1-4
hengliao1972 Jun 26, 2026
75c38a1
perf(fully_distributed_within_core): winner-only fan-in lookup (skip …
hengliao1972 Jun 26, 2026
15c1ae8
perf(fully_distributed_within_core): shard claim cursor by task_index…
hengliao1972 Jun 26, 2026
ca4fdf1
docs(fully_distributed_within_core): add §6.7 measured cursor-shardin…
hengliao1972 Jun 26, 2026
f228b0d
style(fully_distributed_within_core): clang-format dist_engine.cpp
poursoul Jun 30, 2026
13a9f91
Add: sim trace-driven replay via --use-example-exec-time
poursoul Jun 30, 2026
8bd67ca
fix(fully_distributed_within_core): elect a single alloc owner; phase…
poursoul Jun 30, 2026
9035e46
Merge pull request #1 from poursoul/fdwic-alloc-owner-fix
hengliao1972 Jun 30, 2026
4398f45
perf(fully_distributed_within_core): dual-clock swimlane (wall + thre…
poursoul Jun 30, 2026
0e37ff4
perf(fully_distributed_within_core): swimlane dependency + slot-relea…
poursoul Jun 30, 2026
74b6756
perf(fully_distributed_within_core): startup barrier to align worker …
poursoul Jun 30, 2026
b5e39b8
perf(fully_distributed_within_core): full-submit lap swimlane, gated …
poursoul Jul 1, 2026
84e78bd
Merge pull request #2 from poursoul/fdwic-swimlane-deps
hengliao1972 Jul 1, 2026
d14bd89
feat(fully_distributed_within_core): unified ring-per-bucket TensorMa…
hengliao1972 Jul 2, 2026
f3f950a
feat(fully_distributed_within_core): a5sim SPMD bring-up + shared dis…
hengliao1972 Jul 2, 2026
a1b722a
feat(fully_distributed_within_core): run-ahead balance knob (both mod…
hengliao1972 Jul 3, 2026
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
822 changes: 822 additions & 0 deletions docs/fully_distributed_within_core.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) PyPTO Contributors.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
* -----------------------------------------------------------------------------------------------------------
*/

#include <cstdint>

#ifndef __gm__
#define __gm__
#endif
#ifndef __aicore__
#define __aicore__ [aicore]
#endif

#include <pto/pto-inst.hpp>
#include "pto/common/pto_tile.hpp"

#include "tensor.h"

using namespace pto;

extern "C" __aicore__ __attribute__((always_inline)) void kernel_entry(__gm__ int64_t *args) {
__gm__ Tensor *src_tensor = reinterpret_cast<__gm__ Tensor *>(args[1]);
__gm__ Tensor *result_tensor = reinterpret_cast<__gm__ Tensor *>(args[2]);
__gm__ int32_t *notify_counter = reinterpret_cast<__gm__ int32_t *>(args[3]);

__gm__ float *src = reinterpret_cast<__gm__ float *>(src_tensor->buffer.addr) + src_tensor->start_offset;
__gm__ float *result = reinterpret_cast<__gm__ float *>(result_tensor->buffer.addr) + result_tensor->start_offset;

constexpr int kRows = 128;
constexpr int kCols = 128;
using DynShapeDim5 = Shape<1, 1, 1, kRows, kCols>;
using DynStridDim5 = Stride<1, 1, 1, kCols, 1>;
using GlobalData = GlobalTensor<float, DynShapeDim5, DynStridDim5>;
using TileData = Tile<TileType::Vec, float, kRows, kCols, BLayout::RowMajor, -1, -1>;

TileData src_tile(kRows, kCols);
TileData dst_tile(kRows, kCols);
TASSIGN(src_tile, 0x0);
TASSIGN(dst_tile, 0x10000);

GlobalData src_global(src);
GlobalData dst_global(result);
TLOAD(src_tile, src_global);
set_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
wait_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
TADDS(dst_tile, src_tile, static_cast<float>(*notify_counter));
set_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
wait_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
TSTORE(dst_global, dst_tile);
set_flag(PIPE_MTE3, PIPE_S, EVENT_ID7);
wait_flag(PIPE_MTE3, PIPE_S, EVENT_ID7);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) PyPTO Contributors.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
* -----------------------------------------------------------------------------------------------------------
*/

#include <cstdint>

#ifndef __gm__
#define __gm__
#endif
#ifndef __aicore__
#define __aicore__ [aicore]
#endif

#include <pto/pto-inst.hpp>
#include "pto_async_kernel_api.h"

extern "C" __aicore__ __attribute__((always_inline)) void kernel_entry(__gm__ int64_t *args) {
uint64_t notify_counter_addr = static_cast<uint64_t>(args[1]);
uint32_t expected_value = static_cast<uint32_t>(args[2]);
AsyncCtx async_ctx = get_async_ctx(args);
save_expected_notification_counter(
async_ctx, reinterpret_cast<volatile __gm__ void *>(notify_counter_addr), expected_value
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) PyPTO Contributors.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
* -----------------------------------------------------------------------------------------------------------
*/

#include <cstdint>

#ifndef __gm__
#define __gm__
#endif
#ifndef __aicore__
#define __aicore__ [aicore]
#endif

#include <pto/pto-inst.hpp>

#include "platform_comm/comm_context.h"
#include "pto_async_kernel_api.h"
#include "tensor.h"

using namespace pto;

template <typename T>
static inline __aicore__ __gm__ T *comm_remote_ptr(__gm__ CommContext *ctx, __gm__ T *local_ptr, int peer_rank) {
uint64_t local_base = ctx->windowsIn[ctx->rankId];
uint64_t offset = reinterpret_cast<uint64_t>(local_ptr) - local_base;
return reinterpret_cast<__gm__ T *>(ctx->windowsIn[peer_rank] + offset);
}

extern "C" __aicore__ __attribute__((always_inline)) void kernel_entry(__gm__ int64_t *args) {
__gm__ Tensor *in_tensor = reinterpret_cast<__gm__ Tensor *>(args[0]);
__gm__ Tensor *out_tensor = reinterpret_cast<__gm__ Tensor *>(args[1]);
__gm__ int32_t *local_counter = reinterpret_cast<__gm__ int32_t *>(args[2]);
__gm__ CommContext *comm_ctx = reinterpret_cast<__gm__ CommContext *>(args[3]);

__gm__ float *in_data = reinterpret_cast<__gm__ float *>(in_tensor->buffer.addr) + in_tensor->start_offset;
__gm__ float *out_data = reinterpret_cast<__gm__ float *>(out_tensor->buffer.addr) + out_tensor->start_offset;

int my_rank = static_cast<int>(comm_ctx->rankId);
int peer_rank = 1 - my_rank;

constexpr int kRows = 128;
constexpr int kCols = 128;
using DynShapeDim5 = Shape<1, 1, 1, kRows, kCols>;
using DynStridDim5 = Stride<1, 1, 1, kCols, 1>;
using GlobalData = GlobalTensor<float, DynShapeDim5, DynStridDim5>;
using TileData = Tile<TileType::Vec, float, kRows, kCols, BLayout::RowMajor, -1, -1>;

TileData in_tile(kRows, kCols);
TileData out_tile(kRows, kCols);
TASSIGN(in_tile, 0x0);
TASSIGN(out_tile, 0x10000);

GlobalData in_global(in_data);
GlobalData out_global(out_data);
TLOAD(in_tile, in_global);
set_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
wait_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
TADD(out_tile, in_tile, in_tile);
set_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
wait_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
TSTORE(out_global, out_tile);
set_flag(PIPE_MTE3, PIPE_S, EVENT_ID7);
wait_flag(PIPE_MTE3, PIPE_S, EVENT_ID7);

if (my_rank == 1) {
for (volatile int i = 0; i < 2000000; ++i) {}
}

__gm__ int32_t *remote_counter = comm_remote_ptr(comm_ctx, local_counter, peer_rank);
send_notification(remote_counter, 1, pto::comm::NotifyOp::AtomicAdd);
pipe_barrier(PIPE_ALL);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) PyPTO Contributors.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
* -----------------------------------------------------------------------------------------------------------
*/

#include <stdint.h>

#include "platform_comm/comm_context.h"
#include "pto_orchestration_api.h"

extern "C" {

__attribute__((visibility("default"))) PTO2OrchestrationConfig
async_notify_orchestration_config(const L2TaskArgs &orch_args) {
(void)orch_args;
return PTO2OrchestrationConfig{.expected_arg_count = 5};
}

__attribute__((visibility("default"))) PTO2OrchestrationConfig aicpu_orchestration_config(const L2TaskArgs &orch_args) {
return async_notify_orchestration_config(orch_args);
}

__attribute__((visibility("default"))) void async_notify_orchestration(const L2TaskArgs &orch_args) {
if (orch_args.tensor_count() + orch_args.scalar_count() != 5) {
LOG_ERROR("async_notify_demo: expected 5 args");
return;
}

const Tensor &input = orch_args.tensor(0).ref();
const Tensor &output = orch_args.tensor(1).ref();
const Tensor &result = orch_args.tensor(2).ref();
const Tensor &notify_counter = orch_args.tensor(3).ref();
auto *comm_ctx = reinterpret_cast<CommContext *>(static_cast<uintptr_t>(orch_args.scalar(0)));

L0TaskArgs params_producer;
params_producer.add_input(input);
params_producer.add_output(output);
params_producer.add_scalar(notify_counter.buffer.addr);
params_producer.add_scalar(reinterpret_cast<uint64_t>(comm_ctx));
rt_submit_aiv_task(0, params_producer);

uint32_t notify_token_shape[1] = {1};
TensorCreateInfo notify_token_info(notify_token_shape, 1, DataType::INT32);
L0TaskArgs params_notify;
params_notify.add_output(notify_token_info);
params_notify.add_scalar(notify_counter.buffer.addr);
params_notify.add_scalar(static_cast<uint64_t>(1));
TaskOutputTensors notify_outputs = rt_submit_aiv_task(2, params_notify);
Tensor notify_token = notify_outputs.get_ref(0);

L0TaskArgs params_consumer;
params_consumer.add_input(notify_token);
params_consumer.add_input(output);
params_consumer.add_output(result);
params_consumer.add_scalar(notify_counter.buffer.addr);
rt_submit_aiv_task(1, params_consumer);
}

} // extern "C"
Loading
Loading