diff --git a/.claude/skills/multi-repo-qwen-setup/SKILL.md b/.claude/skills/multi-repo-qwen-setup/SKILL.md index 1a9e203165..05e942f170 100644 --- a/.claude/skills/multi-repo-qwen-setup/SKILL.md +++ b/.claude/skills/multi-repo-qwen-setup/SKILL.md @@ -214,7 +214,7 @@ makespan** = the "kernel run time" layer. For layers ②③④ — the host↔device and bind/validate spans — parse the `[STRACE]` host-trace markers with `strace_timing.py` (landed in [simpler #1177](https://github.com/hw-native-sys/simpler/pull/1177)). The -markers are emitted at `LOG_INFO_V9` under `SIMPLER_DFX` (no new flag), +markers are emitted at `LOG_TIMING` under `SIMPLER_DFX` (no new flag), so the same log captured above carries them: ```bash @@ -368,9 +368,9 @@ strings "$BD/$SO" | grep -m1 '' # confirm it baked in (`.venv/lib64` is a symlink to `lib`, so the `find` covers both.) AICPU device logs land in `ASCEND_PROCESS_LOG_PATH/.../device-*/device-*.log` — set that var -per run (see `running-onboard`) and note AICPU `LOG_INFO_V*` uses **inverted** -verbosity: `v=9` is must-see (default threshold 5), `v=0` is filtered — use -`LOG_INFO_V9` for a diagnostic you need to read back. +per run (see `running-onboard`). Use `--log-level info` to capture `LOG_INFO` +diagnostics, or `--log-level debug` when the more detailed `LOG_DEBUG` stream is +also needed. ## Anti-patterns diff --git a/conftest.py b/conftest.py index f33f79cf35..bd1e03371d 100644 --- a/conftest.py +++ b/conftest.py @@ -28,15 +28,14 @@ import time import typing -# Make simpler's V0..V9 and NUL acceptable to pytest's `--log-level` validator. +# Make simpler's TIMING and NUL levels acceptable to pytest's `--log-level` validator. # pytest does `int(getattr(logging, level.upper(), level))`, so the value must # exist as a module attribute on `logging` (not just registered via # `addLevelName`). Set both — the addLevelName side gives nice formatter output -# (`%(levelname)s` shows `V3` instead of `Level 18`); the setattr side is what +# (`%(levelname)s` shows `TIMING` instead of `Level 25`); the setattr side is what # pytest's CLI parser actually consumes. -for _v in range(10): - logging.addLevelName(15 + _v, f"V{_v}") - setattr(logging, f"V{_v}", 15 + _v) +logging.addLevelName(25, "TIMING") +setattr(logging, "TIMING", 25) logging.addLevelName(60, "NUL") setattr(logging, "NUL", 60) # `pytest --log-level null` upcases to "NULL" before the getattr lookup, so diff --git a/docs/chip-level-arch.md b/docs/chip-level-arch.md index 252b11fac4..7175e332e8 100644 --- a/docs/chip-level-arch.md +++ b/docs/chip-level-arch.md @@ -114,7 +114,7 @@ runner.finalize(); ```c // libsimpler_log.so (RTLD_GLOBAL, loaded first by the Python wrapper): -simpler_log_init(log_level, log_info_v); // seed HostLogger once +simpler_log_init(log_level); // seed HostLogger once // host_runtime.so (RTLD_LOCAL, loaded after): DeviceContextHandle ctx = create_device_context(); @@ -180,13 +180,13 @@ Python test_*.py (SceneTestCase) └─→ ChipWorker() └─→ init(device_id, bins) # Python wrapper ├─→ ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL) # once per process - ├─→ simpler_log_init(log_level, log_info_v) → HostLogger seeded + ├─→ simpler_log_init(log_level) → HostLogger seeded ├─→ ctypes.CDLL(libcpu_sim_context.so, RTLD_GLOBAL) # sim only, once └─→ _ChipWorker.init(host_path, aicpu_path, aicore_path, device_id) # C++ ├─→ dlopen(host.so, RTLD_LOCAL) → resolve C API symbols via dlsym ├─→ create_device_context() → DeviceContextHandle └─→ simpler_init(ctx, device_id, aicpu*, aicpu_size, aicore*, aicore_size) - ├─→ (onboard) dlog_setlevel(HostLogger.level()) # before context open + ├─→ (onboard) dlog_setlevel(HostLogger.cann_level()) # before context open ├─→ DeviceRunner::attach_current_thread(device_id) │ ├─→ rtSetDevice(device_id) on onboard │ └─→ pto_cpu_sim_bind+acquire on sim diff --git a/docs/dfx/device-phases.md b/docs/dfx/device-phases.md index 987115ee5e..243dede828 100644 --- a/docs/dfx/device-phases.md +++ b/docs/dfx/device-phases.md @@ -80,7 +80,7 @@ deployment can profile the two domains separately: stores) — only whether the host re-emits the readback as markers. * **Host** (`simpler_run` / `bind` / `runner_run` / `validate` spans): no new knob — they ride the compile-time `SIMPLER_HOST_STRACE` macro and the log level - (`LOG_INFO_V9`), so raising the log threshold drops them. + (`LOG_TIMING`), so raising the log threshold drops them. `RunWall` is the whole on-NPU wall (the former `RunTiming.device_wall`); it is emitted as the `simpler_run.runner_run.device_wall` marker, not returned. diff --git a/docs/dfx/host-trace.md b/docs/dfx/host-trace.md index 07be1d0744..cc01b6b095 100644 --- a/docs/dfx/host-trace.md +++ b/docs/dfx/host-trace.md @@ -16,7 +16,7 @@ children share. `[STRACE]` rides on the compile-time `SIMPLER_HOST_STRACE` macro (default on, in `src/common/task_interface/profiling_config.h` — separate from the `SIMPLER_DFX` gate on the device Orch/Sched markers) and is emitted at -`LOG_INFO_V9` (the must-see INFO tier) — **no new env var or flag**. In a +`LOG_TIMING` (the default threshold) — **no new env var or flag**. In a `SIMPLER_HOST_STRACE`-off build the RAII macros compile to nothing. ## Marker grammar diff --git a/docs/dfx/l2-swimlane-profiling.md b/docs/dfx/l2-swimlane-profiling.md index fc3f8be6c1..150045d548 100644 --- a/docs/dfx/l2-swimlane-profiling.md +++ b/docs/dfx/l2-swimlane-profiling.md @@ -678,7 +678,7 @@ in #942, a5 still uses the legacy unified shape: output JSON for both. On a2a3 the orch stream replaces the per-sub-step records folded into ORCH_SUBMIT; there is no separate shared-memory aggregate. The run-window envelope is emitted to device log via -`LOG_INFO_V9 "orch_start=… orch_end=… orch_cost=…"`. +`LOG_INFO "orch_start=… orch_end=… orch_cost=…"`. **Producer/consumer protocol on AICore (AICore-as-producer with rotation).** AICore writes a slim `L2SwimlaneAicoreTaskRecord` into its currently-active per-core diff --git a/docs/dynamic-linking.md b/docs/dynamic-linking.md index fb2b629060..9b143e2970 100644 --- a/docs/dynamic-linking.md +++ b/docs/dynamic-linking.md @@ -97,6 +97,12 @@ because not all symbols may be referenced. Communicates with the runtime through a function pointer table (`PTO2RuntimeOps`), not direct symbol linkage. +`PTO2RuntimeOps` is a binary ABI without size or version negotiation. +Orchestration SOs and their runtime must therefore be built from the same +simpler revision. Changing the table's field count, order, or signatures +invalidates previously built orchestration SOs; cached or prebuilt artifacts +must be rebuilt before they are loaded by the updated runtime. + **File path collision**: all runtimes write the orch SO to `/var/tmp/libdevice_orch_.so`. Safe in serial execution (each task dlcloses before the next writes), but would conflict in parallel in-process @@ -281,7 +287,7 @@ AICore receives only a device copy of that same `KernelArgs` payload. ```text ChipWorker.init(device_id, bins) # Python wrapper ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL) # once per process - simpler_log_init(log_level, log_info_v) seeds HostLogger before host_runtime + simpler_log_init(log_level) seeds HostLogger before host_runtime ctypes.CDLL(libcpu_sim_context.so, RTLD_GLOBAL) # sim only, once per process _ChipWorker.init(host_path, aicpu_path, aicore_path, device_id) # C++ dlopen(host_runtime.so, RTLD_LOCAL) @@ -321,7 +327,7 @@ device_worker_main(device_id) for each runtime_group: ChipWorker.init(device_id, bins) # Python wrapper ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL) # once per process - simpler_log_init(log_level, log_info_v) + simpler_log_init(log_level) _ChipWorker.init(host_path, aicpu_path, aicore_path, dispatcher_path, device_id) # C++ dlopen(host_runtime.so, RTLD_LOCAL) @@ -329,7 +335,7 @@ device_worker_main(device_id) simpler_init(ctx, device_id, aicpu*, aicpu_size, aicore*, aicore_size, dispatcher*, dispatcher_size) - dlog_setlevel(HostLogger.level()) sync CANN dlog before context open + dlog_setlevel(HostLogger.cann_level()) sync CANN dlog before context open DeviceRunner::attach_current_thread(device_id) rtSetDevice() DeviceRunner::set_executors(aicpu, aicore) DeviceRunner::set_dispatcher_binary(dispatcher) diff --git a/docs/getting-started.md b/docs/getting-started.md index 7cca58da63..27b6efdc2c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -239,11 +239,11 @@ Device logs written to `~/ascend/log/debug/device-/` Both host and AICPU kernel code use the unified `LOG_*` macros from `common/unified_log.h`: -- `LOG_INFO_V0` .. `LOG_INFO_V9`: INFO with verbosity tier (V0 most verbose, - V9 most must-see, V5 default) - `LOG_DEBUG`: Debug messages +- `LOG_INFO`: Lifecycle and summary messages +- `LOG_TIMING`: Stable timing markers such as `[STRACE]` - `LOG_WARN`: Warnings - `LOG_ERROR`: Error messages Threshold is configured from Python via the `simpler` logger: -`logging.getLogger("simpler").setLevel(simpler.V3)`. +`logging.getLogger("simpler").setLevel(simpler.TIMING)`. diff --git a/docs/logging.md b/docs/logging.md index 5978f69a78..0b21903562 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -2,7 +2,7 @@ Architecture and contracts for the host + device logging subsystem. -For the **user-facing model** — one Python knob, V0..V9 layout, CLI flags +For the **user-facing model** — one Python knob and the CLI flags — see [testing.md § Log levels](testing.md#log-levels). This file documents the implementation: layering, multi-`.so` singleton sharing, ABIs, build wiring, and output formats. @@ -12,12 +12,12 @@ build wiring, and output formats. ```text Python: logging.getLogger("simpler").setLevel(N) │ - ▼ Worker.init() snapshots level once, splits into (severity, info_v) + ▼ Worker.init() snapshots + normalizes the threshold once │ - ChipWorker.init(device_id, bins, sev, v) ◀── Python wrapper + ChipWorker.init(device_id, bins, level) ◀── Python wrapper │ 1. ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL) ◀── one HostLogger per process - 2. simpler_log_init(sev, v) ──→ HostLogger.set_level/set_info_v + 2. simpler_log_init(level) ──→ HostLogger.set_level (seeds HostLogger BEFORE any host_runtime / sim_context / aicore SO is dlopen'd, so any LOG_* macro firing during dlopen-time @@ -28,17 +28,21 @@ Python: logging.getLogger("simpler").setLevel(N) │ unified_log_* symbols │ resolve via (1) └─ simpler_init(ctx, device_id, aicpu*, aicore*) - ──→ (onboard) dlog_setlevel(HostLogger.level()) + ──→ (onboard) dlog_setlevel(HostLogger.cann_level()) ──→ attach thread + transfer executor binaries -Per kernel launch: - runner reads HostLogger.level() / .info_v() ──→ KernelArgs.log_level/info_v - AICPU receives sev/v in KernelArgs → sets g_is_log_enable_* + g_log_info_v +Per device init: + runner reads HostLogger.level() ──→ InitArgs.log_level + AICPU receives the threshold + ├─ sim: sets g_is_log_enable_* directly + └─ onboard: snapshots CANN CheckLogLevel() into g_is_log_enable_* ``` -Two axes throughout: **severity** (DEBUG/INFO/WARN/ERROR/NUL, CANN-aligned) -and **INFO sub-verbosity** (V0..V9). Python collapses both into a single -integer level; C++ stores them as separate fields. +One threshold controls `DEBUG / INFO / TIMING / WARN / ERROR`; `NUL` suppresses +all output. The values match Python logging (`10 / 20 / 25 / 30 / 40 / 60`). +CANN has no TIMING level, so onboard setup maps both TIMING and WARN to CANN +WARN. The default TIMING threshold therefore keeps host `[STRACE]` markers +without opening CANN's INFO stream. ## File layout @@ -47,21 +51,21 @@ src/common/log/ ← libsimpler_log.so + public ABI ├── CMakeLists.txt libsimpler_log SHARED target ├── include/ │ ├── common/ +│ │ ├── log_level.h shared level values + CANN mapping │ │ └── unified_log.h public ABI (host AND device #include) │ └── host_log.h HostLogger class (public — pto_runtime_c_api uses it) ├── host_log.cpp HostLogger impl └── unified_log_host.cpp C ABI → HostLogger adapter -src/{a5,a2a3}/platform/ ← per-arch device-side log +src/common/platform/ ← shared device-side log ├── include/aicpu/device_log.h low-level dev_vlog_* declarations -├── src/aicpu/unified_log_device.cpp C ABI → dev_vlog_* adapter +├── shared/aicpu/unified_log_device.cpp C ABI → dev_vlog_* adapter ├── onboard/aicpu/device_log.cpp onboard backend (CANN dlog) └── sim/aicpu/device_log.cpp sim backend (fprintf to stderr) ``` -The `aicpu/device_log.h` and `aicpu/unified_log_device.cpp` files are -byte-identical between a5 and a2a3 today but kept per-arch on purpose: -device-side log code is owned by each platform, not by `src/common/`. +Both architectures link these shared implementations into their platform +binaries; the per-architecture init kernels only forward `InitArgs.log_level`. ## Three-layer ABI @@ -70,13 +74,11 @@ device-side log code is owned by each platform, not by `src/common/`. `common/unified_log.h` defines the only macros consumers should use: ```cpp -LOG_DEBUG(fmt, ...) // severity DEBUG -LOG_WARN(fmt, ...) // severity WARN -LOG_ERROR(fmt, ...) // severity ERROR -LOG_INFO_V0(fmt, ...) // INFO sub-tier 0 (most verbose) -LOG_INFO_V1(fmt, ...) -... -LOG_INFO_V9(fmt, ...) // INFO sub-tier 9 (most must-see) +LOG_DEBUG(fmt, ...) +LOG_INFO(fmt, ...) +LOG_TIMING(fmt, ...) // stable performance markers such as STRACE +LOG_WARN(fmt, ...) +LOG_ERROR(fmt, ...) ``` Each macro auto-injects `[__FILENAME__:__LINE__]` in front of the format @@ -84,14 +86,15 @@ string and threads `__FUNCTION__` as a separate argument. ### Layer 2 — C ABI -The macros expand to four `extern "C"` functions declared in +The macros expand to five `extern "C"` functions declared in `common/unified_log.h`: ```cpp void unified_log_error(const char *func, const char *fmt, ...); void unified_log_warn (const char *func, const char *fmt, ...); +void unified_log_timing(const char *func, const char *fmt, ...); +void unified_log_info (const char *func, const char *fmt, ...); void unified_log_debug(const char *func, const char *fmt, ...); -void unified_log_info_v(const char *func, int v, const char *fmt, ...); ``` Two implementations link the same ABI symbols: @@ -115,23 +118,23 @@ locally. class HostLogger { public: static HostLogger &get_instance(); // process-wide singleton - void set_level(LogLevel); // Python pushes via simpler_init - void set_info_v(int); - void vlog (LogLevel, func, fmt, va_list); // adapter entry point - void vlog_info_v(int v, func, fmt, va_list); + void set_level(LogLevel); // Python pushes via simpler_log_init + void vlog(LogLevel, func, fmt, va_list); // adapter entry point + int cann_level() const; // coarser CANN threshold }; ``` -`vlog{,_info_v}` is the single authority for level gating — the C ABI -adapter does not pre-check. +`vlog` is the single authority for level gating — the C ABI adapter does not +pre-check. **Device** (`dev_vlog_*` in `aicpu/device_log.h`): ```cpp void dev_vlog_debug (const char *func, const char *fmt, va_list); +void dev_vlog_info (const char *func, const char *fmt, va_list); +void dev_vlog_timing(const char *func, const char *fmt, va_list); void dev_vlog_warn (const char *func, const char *fmt, va_list); void dev_vlog_error (const char *func, const char *fmt, va_list); -void dev_vlog_info_v(int v, const char *func, const char *fmt, va_list); ``` `unified_log_device.cpp` forwards the caller's `va_list` directly into @@ -151,9 +154,9 @@ symbols against this single instance via `RTLD_GLOBAL` load order. ### Load order — `ChipWorker.init` (Python wrapper) → `_ChipWorker.init` (C++) ```python -# python/simpler/task_interface.py — ChipWorker.init(device_id, bins, sev, v) +# python/simpler/task_interface.py — ChipWorker.init(device_id, bins, level) _preload_global(bins.simpler_log_path) # 1: ctypes.CDLL(RTLD_GLOBAL) -log_handle.simpler_log_init(sev, v) # 2: seed HostLogger BEFORE +log_handle.simpler_log_init(level) # 2: seed HostLogger BEFORE # any consumer SO is opened if bins.sim_context_path: _preload_global(bins.sim_context_path) # 3: ctypes.CDLL(RTLD_GLOBAL), sim only @@ -190,19 +193,19 @@ are allowed by default. CMake blocks live in: ### Verifying singleton sharing -`cpu_sim_context.cpp::pto_cpu_sim_acquire_device` emits a `LOG_INFO_V0` -diagnostic on first call. With `--log-level v0`: +`cpu_sim_context.cpp::pto_cpu_sim_acquire_device` emits a `LOG_DEBUG` +diagnostic on first call. With `--log-level debug`: ```text -[2026-05-06 ...][T0x...][INFO_V0] pto_cpu_sim_acquire_device: cpu_sim_context.cpp:167] cpu_sim_context: acquired device 0 -[2026-05-06 ...][T0x...][INFO_V0] init_runtime_impl: runtime_maker.cpp:119] Registering 3 kernel(s) ... +[2026-05-06 ...][T0x...][DEBUG] pto_cpu_sim_acquire_device: cpu_sim_context.cpp:167] cpu_sim_context: acquired device 0 +[2026-05-06 ...][T0x...][DEBUG] init_runtime_impl: runtime_maker.cpp:119] Registering 3 kernel(s) ... ``` Both lines carry the same `HostLogger`-formatted prefix (timestamp, thread id, level tag), proving that `cpu_sim_context.so` and `host_runtime.so` resolve to the same `HostLogger` instance. If singleton sharing were broken, `cpu_sim_context.so` would have its own `HostLogger` defaulting to -V5 and the V0 diagnostic would be silenced entirely. +TIMING and the DEBUG diagnostic would be silenced entirely. ## Output formats @@ -220,28 +223,28 @@ parallel-test stderr from `pytest-xdist` is recoverable via `sort -k1` ### AICPU sim ```text -[INFO_V] func: [file.cpp:line] message -[DEBUG] func: [file.cpp:line] message -[WARN] func: [file.cpp:line] message -[ERROR] func: [file.cpp:line] message +[DEBUG] func: [file.cpp:line] message +[INFO] func: [file.cpp:line] message +[TIMING] func: [file.cpp:line] message +[WARN] func: [file.cpp:line] message +[ERROR] func: [file.cpp:line] message ``` No timestamp/tid — the AICPU sim path is its own `dev_vlog_*` writing straight to stderr. Onboard AICPU goes through CANN `dlog` and inherits -its format; the V tier is encoded into the message text as `[V]` since -CANN's level enum has no INFO sub-tiers. +its format. Device TIMING uses CANN WARN and carries a `[TIMING]` message tag. ## Configuration flow | Stage | Action | Source | | ----- | ------ | ------ | -| Python import | `_log.py` registers `V0..V9` / `NUL` with `logging.addLevelName`; sets `simpler` logger to V5 if untouched | `python/simpler/_log.py` | -| `Worker.init()` | reads `simpler` logger's effective level, splits via `_split_threshold(t) → (sev, info_v)` | `python/simpler/_log.py:get_current_config()` | -| `ChipWorker.init()` (Python) | `ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL)` → `simpler_log_init(sev,v)` (seeds HostLogger) → `ctypes.CDLL(libcpu_sim_context.so, RTLD_GLOBAL)` (sim) → `_ChipWorker.init` | `python/simpler/task_interface.py` | -| `simpler_log_init` | `HostLogger.set_level/set_info_v` — only writer of log filter | `src/common/log/host_log.cpp` | +| Python import | `_log.py` registers `TIMING` / `NUL`; sets `simpler` logger to TIMING if untouched | `python/simpler/_log.py` | +| `Worker.init()` | reads and normalizes the `simpler` logger's effective threshold | `python/simpler/_log.py:get_current_config()` | +| `ChipWorker.init()` (Python) | `ctypes.CDLL(libsimpler_log.so, RTLD_GLOBAL)` → `simpler_log_init(level)` (seeds HostLogger) → `ctypes.CDLL(libcpu_sim_context.so, RTLD_GLOBAL)` (sim) → `_ChipWorker.init` | `python/simpler/task_interface.py` | +| `simpler_log_init` | `HostLogger.set_level` — only writer of the host filter | `src/common/log/host_log.cpp` | | `_ChipWorker.init()` (C++) | `dlopen(host_runtime.so, RTLD_LOCAL)` → dlsym → `simpler_init` | `src/common/worker/chip_worker.cpp` | -| `simpler_init` (per platform) | (onboard) `dlog_setlevel(HostLogger.level())` — must precede device-context open so CANN snapshots the requested level for the device-side log session; then attach thread, transfer executor binaries to runner | `src/{arch}/platform/{onboard,sim}/host/pto_runtime_c_api.cpp` | -| Per kernel launch | runner reads `HostLogger.level() / info_v()` directly, writes into `KernelArgs`; AICPU `kernel.cpp` calls `set_log_level/set_log_info_v` on entry | `src/{arch}/platform/onboard/aicpu/kernel.cpp` | +| `simpler_init` (per platform) | (onboard) `dlog_setlevel(HostLogger.cann_level())` before device-context open; then attach thread and transfer executor binaries | `src/common/platform/{onboard,sim}/host/c_api_shared.cpp` | +| AICPU init | runner writes `HostLogger.level()` into `InitArgs`; AICPU calls `set_log_level` once | `src/{arch}/platform/onboard/aicpu/kernel.cpp` | The Python-side level snapshot is **one-shot** at `Worker.init()`. Calling `logger.setLevel(...)` afterwards has no effect on a live `ChipWorker` — @@ -272,8 +275,8 @@ RTLD_GLOBAL)`s them before handing off to the C++ `_ChipWorker.init`. | ------------- | ------- | | Change the user-facing single-knob model | `python/simpler/_log.py` + `docs/testing.md § Log levels` | | Change the host output format / pattern | `src/common/log/host_log.cpp::HostLogger::emit` | -| Change the sim AICPU output format | `src/{arch}/platform/sim/aicpu/device_log.cpp::dev_vlog_*` | -| Change the onboard AICPU CANN dlog tagging | `src/{arch}/platform/onboard/aicpu/device_log.cpp::dev_vlog_*` | +| Change the sim AICPU output format | `src/common/platform/sim/aicpu/device_log.cpp::dev_vlog_*` | +| Change the onboard AICPU CANN dlog tagging | `src/common/platform/onboard/aicpu/device_log.cpp::dev_vlog_*` | | Add a new C ABI entry point (e.g. dynamic config push) | `src/common/log/include/common/unified_log.h` + `unified_log_host.cpp` + `src/common/platform/shared/aicpu/unified_log_device.cpp` | | Hook a new consumer `.so` | declare `target_include_directories(target PRIVATE src/common/log/include)`; for host code also link `simpler_log` (or use undefined symbol resolution at runtime via `RTLD_GLOBAL` load) | -| Add a new severity / verbosity tier | `python/simpler/_log.py` (Python integer + `addLevelName`) + `host_log.h::LogLevel` (if a new severity) + `_split_threshold` (band mapping) + AICPU `set_log_*` setters | +| Add a new level | `common/log_level.h` + `python/simpler/_log.py` + `simpler_setup/log_config.py` + AICPU `set_log_level` | diff --git a/docs/testing.md b/docs/testing.md index 0372249a9b..a92c876e13 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -123,14 +123,14 @@ python test_xxx.py -p a2a3sim --log-level debug # verbose C++ l | `--dump-args` | | `0` | Dump tensors plus scalar args into unified runtime artifacts (bare flag = `1`; supports `0/1/2/3`) | | `--enable-pmu [EVENT_TYPE]` | | `0` | Enable a2a3 PMU CSV collection. Bare flag selects `PIPE_UTILIZATION` (`2`); pass an event type such as `4` for `MEMORY`. | | `--exitfirst` | `-x` | false | Stop on first failing test (fail-fast, primarily for CI) | -| `--log-level LEVEL` | | `v5` | Simpler logger threshold. Accepts `debug` / `V0..V9` / `info` / `warn` / `error` / `null` (case-insensitive). pytest's own CLI validator does `int(getattr(logging, level.upper(), level))`, so the V tiers and `NUL`/`NULL` are exposed as attributes on the `logging` module via `setattr` (registration in `conftest.py` runs before pytest's option machinery). `logging.addLevelName` is also called so `%(levelname)s` formatters print `V3` instead of `Level 18`, but it is not what makes the CLI parser accept the value. The "simpler" Python logger is the single source of truth; the value is snapshotted into the platform SO at `Worker.init()` time (not per `Worker.run()`) and pushed to host `HostLogger`, runner state, and (onboard) CANN `dlog_setlevel`. AICPU receives it via `KernelArgs.log_info_v`. Changing the Python logger level after `Worker.init()` does not retroactively affect that worker. See [Log levels](#log-levels). | +| `--log-level LEVEL` | | `timing` | Simpler logger threshold. Accepts `debug` / `info` / `timing` / `warn` / `error` / `null` (case-insensitive). TIMING and NUL/NULL are registered with Python logging before pytest validates the option. The "simpler" Python logger is the single source of truth; `Worker.init()` snapshots it once and pushes the threshold to HostLogger, AICPU, and the onboard CANN mapping. Changing the Python logger afterwards does not affect an existing worker. See [Log levels](#log-levels). | Profiling is enabled only on the first round to avoid overhead on subsequent iterations. Output tensors are reset to their initial values between rounds. ## Log levels -Simpler ties two axes (severity + INFO sub-verbosity) into a single integer -threshold so users only ever set one knob. For implementation details +Simpler uses one integer threshold for host, simulation, and onboard device +logging. For implementation details (`libsimpler_log.so`, multi-`.so` singleton, host vs device backends, output formats), see [logging.md](logging.md). @@ -138,57 +138,53 @@ formats), see [logging.md](logging.md). ```text DEBUG = 10 (Python logging.DEBUG) -V0..V4 = 15..19 sub-INFO, more verbose -V5 = 20 = Python INFO ← default threshold -V6..V9 = 21..24 above-INFO, more must-see +INFO = 20 (Python logging.INFO) +TIMING = 25 ← default threshold WARN = 30 (Python logging.WARNING) ERROR = 40 (Python logging.ERROR) NUL = 60 suppress all ``` The Python `simpler` logger filters by Python's standard `level >= threshold` -rule; the C++ side splits the threshold back into a (severity, info_v) pair -and gates host `LOG_*` plus AICPU device logs accordingly. +rule; C++ and AICPU use the same single-axis rule. ### Where each tier ends up -| Macro | Where it goes today (post-migration) | -| ----- | ------------------------------------ | -| `LOG_DEBUG` | DEBUG severity (`level=10`) — debug-style trace | -| `LOG_INFO_V0` | INFO sub-tier 0 (`level=15`) — old `LOG_INFO` lands here | -| `LOG_INFO_V5` | INFO sub-tier 5 (`level=20`) — default threshold (= Python INFO) | -| `LOG_INFO_V9` | INFO sub-tier 9 (`level=24`) — old `LOG_ALWAYS` lands here | -| `LOG_WARN` | WARN severity (`level=30`) | -| `LOG_ERROR` | ERROR severity (`level=40`) | +| Macro | Level | +| ----- | ----- | +| `LOG_DEBUG` | DEBUG (`10`) — detailed diagnostics | +| `LOG_INFO` | INFO (`20`) — lifecycle and summaries | +| `LOG_TIMING` | TIMING (`25`) — stable performance markers such as `[STRACE]` | +| `LOG_WARN` | WARN (`30`) | +| `LOG_ERROR` | ERROR (`40`) | -V0..V4 are silent by default; raise `--log-level v0` to see them. V5..V9 are -visible by default; lower the threshold (e.g. `--log-level warn`) to hide them. +At the default TIMING threshold, `[STRACE]`, warnings, and errors are visible; +ordinary INFO and DEBUG messages are silent. ### Configuration sources - **Single source of truth**: the Python `simpler` logger (`logging.getLogger("simpler")`). -- The simpler module sets this logger to V5 at import unless the user has +- The simpler module sets this logger to TIMING at import unless the user has already called `setLevel`. Inheritance from the root logger is intentionally - not used so `import simpler` doesn't kill INFO output by inheriting Python's + not used so `import simpler` keeps timing markers visible despite Python's default `WARNING`. -- `V0..V9` and `NUL` are registered with `logging.addLevelName` at import, - so name-based callers (`pytest --log-level v3`, `logger.setLevel("V3")`, - formatters writing `%(levelname)s`) accept and emit them. +- `TIMING` and `NUL` are registered with `logging.addLevelName` at import, so + name-based callers and `%(levelname)s` formatters accept and emit them. - **Snapshot at `Worker.init()`, not per-run**: when a `Worker` is initialised it reads the current `simpler` logger level once and forwards it through - `ChipWorker.init(..., log_level, log_info_v)`. ChipWorker then calls - libsimpler_log's `simpler_log_init` (which writes the values into the + `ChipWorker.init(..., log_level)`. ChipWorker then calls + libsimpler_log's `simpler_log_init` (which writes the value into the process-wide `HostLogger` singleton) BEFORE `host_runtime.so` is dlopen'd; - the platform SO's `simpler_init` reads `HostLogger.level()` to sync CANN - `dlog` onboard, and per-launch the runner reads `HostLogger.level() / .info_v()` - directly when populating `KernelArgs`. **Subsequent `logger.setLevel(...)` + the platform SO's `simpler_init` maps `HostLogger.cann_level()` to CANN `dlog` + onboard, and AICPU receives the threshold through `InitArgs`. + **Subsequent `logger.setLevel(...)` calls are not re-pushed to that worker** — recreate the worker if you need to change levels mid-run. - L3 / L4 hierarchical workers fork chip subprocesses; the parent snapshots - the same `(severity, info_v)` pair before `fork()` and passes it explicitly + the same threshold before `fork()` and passes it explicitly to `_chip_process_loop` so each subprocess starts its own `ChipWorker.init` - with the correct values. + with the correct value. ### Onboard AICPU severity is CANN-owned @@ -196,16 +192,13 @@ The onboard AICPU library reads severity from CANN's `dlog` (CheckLogLevel), not from `KernelArgs.log_level`. Configure it via `ASCEND_GLOBAL_LOG_LEVEL=0..4` or `dlog_setlevel(-1, level, 0)`. `simpler_init` (called from `ChipWorker::init` in the platform SO) issues -`dlog_setlevel(-1, HostLogger.level(), 0)` automatically — unless -`ASCEND_GLOBAL_LOG_LEVEL` is already set in the environment. The INFO **verbosity** sub-tier (V0..V9) is still -controlled through the simpler logger and travels via `KernelArgs.log_info_v`. +`dlog_setlevel(-1, HostLogger.cann_level(), 0)` automatically — unless +`ASCEND_GLOBAL_LOG_LEVEL` is already set in the environment. The mapping is +`debug→DEBUG`, `info→INFO`, `timing/warn→WARN`, `error→ERROR`, and +`null→NUL`. Therefore the default TIMING threshold does not open CANN INFO. -### Behaviour change since the V0..V9 migration +### Output destinations -- 30+ historical `LOG_ALWAYS` sites were rewritten to `LOG_INFO_V9` — - visible at default V5. -- 200+ historical `LOG_INFO` sites were rewritten to `LOG_INFO_V0` — - hidden by default. Run with `--log-level v0` to bring them back. - All log output goes to **stderr** (host + sim AICPU). Onboard AICPU still routes through CANN dlog and lands wherever CANN is configured to write. diff --git a/docs/troubleshooting/device-error-codes/stall.md b/docs/troubleshooting/device-error-codes/stall.md index 3aacab5469..410b9e8b16 100644 --- a/docs/troubleshooting/device-error-codes/stall.md +++ b/docs/troubleshooting/device-error-codes/stall.md @@ -33,7 +33,7 @@ The `sub_class=` line gives you `stuck_task_id` and `stuck_core`. Map the task i back to your orchestration and look at that kernel for an infinite loop, a wait on a signal that never arrives, or simply too much work. -When the task id is not enough, raise the log level to **V0** and the device log +When the task id is not enough, lower the log threshold to **DEBUG** and the device log prints a task snapshot at the moment of the stall: ```text @@ -48,12 +48,13 @@ kernel, on which core". Setting the level: -- **Worker directly**: `logging.getLogger("simpler").setLevel("V0")` **before** +- **Worker directly**: `logging.getLogger("simpler").setLevel("DEBUG")` **before** `worker.init()` — the level is snapshotted at init and pushed to the device, so setting it between `run()` calls has no effect. -- **pytest / scene test**: `--log-level v0`. +- **pytest / scene test**: `--log-level debug`. -V0 is the most verbose level (V0 verbose … V9 terse, default V5). Device logs land +`DEBUG` is the most verbose level (`DEBUG`, `INFO`, `TIMING`, `WARN`, `ERROR`; +default `TIMING`). Device logs land in the shared `~/ascend/log/debug/device-/` by default, where several processes interleave; redirect them per-run with `ASCEND_PROCESS_LOG_PATH` (the directory must exist) before reading. See the "Device logs" section of diff --git a/examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp index dcfc113405..a00167094f 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp @@ -62,7 +62,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta int grid_m = 1; int grid_n = 1; - LOG_INFO_V0( + LOG_DEBUG( "[bgemm_orch] tile_size: %d, grid_m: %d, grid_n: %d, grid_k: %d, num_groups: %d, incore_loop: %d", tile_size, grid_m, grid_n, grid_k, num_groups, incore_loop ); @@ -111,7 +111,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V0( + LOG_DEBUG( "[bgemm_orch] Submitted %d gemm tasks and %d add tasks (%d total)", total_gemm, total_add, total_gemm + total_add ); diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index 2ed86cdf2f..e87df0bf14 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -105,7 +105,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint64_t q_loop = (q_head_num + q_tile - 1) / q_tile; CYCLE_COUNT_LAP(prof_param_extract); - LOG_INFO_V9(">>>>>> batch = %" PRIu64, batch); + LOG_INFO(">>>>>> batch = %" PRIu64, batch); // Reshape tensors for kernel consumption (2D flattened) void *query_ptr = orch_args.tensor(0).ref().data_as(); @@ -254,33 +254,33 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); - LOG_INFO_V9( + LOG_INFO(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp index 4ddab0a70c..37d545dd17 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp @@ -101,7 +101,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint64_t q_loop = (q_head_num + q_tile - 1) / q_tile; CYCLE_COUNT_LAP(prof_param_extract); - LOG_INFO_V9(">>>>>> batch = %" PRIu64, batch); + LOG_INFO(">>>>>> batch = %" PRIu64, batch); // Reshape tensors for kernel consumption (2D flattened) void *query_ptr = orch_args.tensor(0).ref().data_as(); @@ -273,33 +273,33 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); - LOG_INFO_V9( + LOG_INFO(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 diff --git a/examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp index 82bc89f374..23f18801f1 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp @@ -308,37 +308,37 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope_and_loop; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " scope_and_loop : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope_and_loop), prof_scope_and_loop * 100.0 / total ); diff --git a/examples/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp b/examples/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp index a0a8ed7d88..552bb08acd 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/scalar_data_test/kernels/orchestration/scalar_data_orch.cpp @@ -55,7 +55,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_check = orch_args.tensor(3).ref(); uint32_t SIZE = orch_args.tensor(0).ref().shapes[0]; - LOG_INFO_V0("scalar_data_test: SIZE=%u, check_size=%u", SIZE, orch_args.tensor(3).ref().shapes[0]); + LOG_DEBUG("scalar_data_test: SIZE=%u, check_size=%u", SIZE, orch_args.tensor(3).ref().shapes[0]); uint32_t inter_shapes[1] = {SIZE}; TensorCreateInfo inter_ci(inter_shapes, 1, DataType::FLOAT32); @@ -76,7 +76,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // ========================================================= uint32_t idx[1] = {0}; float c0_val = get_tensor_data(c, 1, idx); - LOG_INFO_V0("get_tensor_data(c, {0}) = %f (expected 2.0)", static_cast(c0_val)); + LOG_DEBUG("get_tensor_data(c, {0}) = %f (expected 2.0)", static_cast(c0_val)); uint32_t check_idx[1] = {0}; set_tensor_data(ext_check, 1, check_idx, c0_val); @@ -87,7 +87,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // ========================================================= idx[0] = 100; float c100_val = get_tensor_data(c, 1, idx); - LOG_INFO_V0("get_tensor_data(c, {100}) = %f (expected 102.0)", static_cast(c100_val)); + LOG_DEBUG("get_tensor_data(c, {100}) = %f (expected 102.0)", static_cast(c100_val)); check_idx[0] = 1; set_tensor_data(ext_check, 1, check_idx, c100_val); @@ -108,7 +108,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // ========================================================= idx[0] = 0; float s0_val = get_tensor_data(scalar_tensor, 1, idx); - LOG_INFO_V0("get_tensor_data(scalar_tensor, {0}) after init = %f (expected 77.0)", static_cast(s0_val)); + LOG_DEBUG("get_tensor_data(scalar_tensor, {0}) after init = %f (expected 77.0)", static_cast(s0_val)); check_idx[0] = 2; set_tensor_data(ext_check, 1, check_idx, s0_val); @@ -128,7 +128,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // Value should be preserved (noop kernel didn't modify it) // ========================================================= float s1_val = get_tensor_data(scalar_tensor, 1, idx); - LOG_INFO_V0("get_tensor_data(scalar_tensor, {0}) after 2nd noop = %f (expected 77.0)", static_cast(s1_val)); + LOG_DEBUG("get_tensor_data(scalar_tensor, {0}) after 2nd noop = %f (expected 77.0)", static_cast(s1_val)); check_idx[0] = 3; set_tensor_data(ext_check, 1, check_idx, s1_val); @@ -138,7 +138,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // Tests set_tensor_data write + orchestration arithmetic // ========================================================= float combined = c0_val + s0_val; // 2.0 + 77.0 = 79.0 - LOG_INFO_V0( + LOG_DEBUG( "Orchestration arithmetic: %f + %f = %f", static_cast(c0_val), static_cast(s0_val), static_cast(combined) ); // NOLINT(whitespace/line_length) @@ -153,7 +153,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // ========================================================= set_tensor_data(scalar_tensor, 1, idx, 42.0f); float rw_val = get_tensor_data(scalar_tensor, 1, idx); - LOG_INFO_V0("set_tensor_data→get_tensor_data round-trip = %f (expected 42.0)", static_cast(rw_val)); + LOG_DEBUG("set_tensor_data→get_tensor_data round-trip = %f (expected 42.0)", static_cast(rw_val)); check_idx[0] = 5; set_tensor_data(ext_check, 1, check_idx, rw_val); @@ -177,7 +177,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &e = e_outs.get_ref(0); float e0_val = get_tensor_data(e, 1, idx); - LOG_INFO_V0("Orch→AICore RAW: e[0] = %f (expected 12.0)", static_cast(e0_val)); + LOG_DEBUG("Orch→AICore RAW: e[0] = %f (expected 12.0)", static_cast(e0_val)); check_idx[0] = 6; set_tensor_data(ext_check, 1, check_idx, e0_val); @@ -209,7 +209,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta idx[0] = 0; set_tensor_data(c, 1, idx, 88.0f); float waw_val = get_tensor_data(c, 1, idx); - LOG_INFO_V0("WAW+WAR: set_tensor_data(c, 88.0) after consumer = %f (expected 88.0)", static_cast(waw_val)); + LOG_DEBUG("WAW+WAR: set_tensor_data(c, 88.0) after consumer = %f (expected 88.0)", static_cast(waw_val)); check_idx[0] = 7; set_tensor_data(ext_check, 1, check_idx, waw_val); @@ -238,7 +238,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta idx[0] = 0; set_tensor_data(ext_b, 1, idx, 55.0f); float ext_war_val = get_tensor_data(ext_b, 1, idx); - LOG_INFO_V0( + LOG_DEBUG( "External WAR (INOUT): set_tensor_data(ext_b, 55.0) = %f (expected 55.0)", static_cast(ext_war_val) ); @@ -259,7 +259,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta rt_submit_aiv_task(FUNC_ADD, args); } - LOG_INFO_V0("scalar_data_test: orchestration complete"); + LOG_DEBUG("scalar_data_test: orchestration complete"); } } // extern "C" diff --git a/examples/a2a3/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp b/examples/a2a3/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp index a4b8653268..eea788c807 100644 --- a/examples/a2a3/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp +++ b/examples/a2a3/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_f = orch_args.tensor(2).ref(); uint32_t SIZE = orch_args.tensor(0).ref().shapes[0]; - LOG_INFO_V0("===============SIZE=%u", SIZE); + LOG_DEBUG("===============SIZE=%u", SIZE); uint32_t inter_shapes[1] = {SIZE}; TensorCreateInfo inter_ci(inter_shapes, 1, DataType::FLOAT32); diff --git a/examples/a5/tensormap_and_ringbuffer/bgemm/kernels/orchestration/bgemm_orch.cpp b/examples/a5/tensormap_and_ringbuffer/bgemm/kernels/orchestration/bgemm_orch.cpp index 46881fc6a6..e1661349f8 100644 --- a/examples/a5/tensormap_and_ringbuffer/bgemm/kernels/orchestration/bgemm_orch.cpp +++ b/examples/a5/tensormap_and_ringbuffer/bgemm/kernels/orchestration/bgemm_orch.cpp @@ -66,7 +66,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_B = orch_args.tensor(1).ref(); const Tensor &ext_C = orch_args.tensor(2).ref(); - LOG_INFO_V0("[bgemm_orch] Grid: %dx%dx%d, Batch: %d, Tile: %d", GRID_M, GRID_K, GRID_N, BATCH, TILE); + LOG_DEBUG("[bgemm_orch] Grid: %dx%dx%d, Batch: %d, Tile: %d", GRID_M, GRID_K, GRID_N, BATCH, TILE); uint32_t tile_shapes[1] = {TILE_ELEMS}; @@ -112,7 +112,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V0( + LOG_DEBUG( "[bgemm_orch] Submitted tasks for %d batches, %dx%d output tiles, %d K steps each", BATCH, GRID_M, GRID_N, GRID_K ); diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp index ef2e910520..58795a2925 100644 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -98,7 +98,7 @@ __attribute__((visibility("default"))) void build_paged_attention_graph(const L2 uint64_t q_loop = (q_head_num + q_tile - 1) / q_tile; CYCLE_COUNT_LAP(prof_param_extract); - LOG_INFO_V9(">>>>>> batch = %" PRIu64, batch); + LOG_INFO(">>>>>> batch = %" PRIu64, batch); // Reshape tensors for kernel consumption (2D flattened) void *query_ptr = orch_args.tensor(0).ref().data_as(); @@ -248,33 +248,33 @@ __attribute__((visibility("default"))) void build_paged_attention_graph(const L2 uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); - LOG_INFO_V9( + LOG_INFO(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp index 9307d3441b..0e14060a02 100644 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a5/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp @@ -98,7 +98,7 @@ __attribute__((visibility("default"))) void build_paged_attention_graph(const L2 uint64_t q_loop = (q_head_num + q_tile - 1) / q_tile; CYCLE_COUNT_LAP(prof_param_extract); - LOG_INFO_V9(">>>>>> batch = %" PRIu64, batch); + LOG_INFO(">>>>>> batch = %" PRIu64, batch); // Reshape tensors for kernel consumption (2D flattened) void *query_ptr = orch_args.tensor(0).ref().data_as(); @@ -270,31 +270,31 @@ __attribute__((visibility("default"))) void build_paged_attention_graph(const L2 uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " external_tensor : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " make_tensor : %7.3fus (%5.1f%%)", cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " tensor_view : %7.3fus (%5.1f%%)", cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " submit_task : %7.3fus (%5.1f%%)", cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total ); - LOG_INFO_V9(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); + LOG_INFO(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); } (void)total_tasks; } diff --git a/examples/a5/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp b/examples/a5/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp index 0db4b6c0d9..6ca777f267 100644 --- a/examples/a5/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp +++ b/examples/a5/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp @@ -298,37 +298,37 @@ __attribute__((visibility("default"))) void build_paged_attention_graph(const L2 #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope_and_loop; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " scope_and_loop : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope_and_loop), prof_scope_and_loop * 100.0 / total ); diff --git a/examples/a5/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp b/examples/a5/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp index a4b8653268..eea788c807 100644 --- a/examples/a5/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp +++ b/examples/a5/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_f = orch_args.tensor(2).ref(); uint32_t SIZE = orch_args.tensor(0).ref().shapes[0]; - LOG_INFO_V0("===============SIZE=%u", SIZE); + LOG_DEBUG("===============SIZE=%u", SIZE); uint32_t inter_shapes[1] = {SIZE}; TensorCreateInfo inter_ci(inter_shapes, 1, DataType::FLOAT32); diff --git a/examples/workers/l2/vector_add/test_run_timing.py b/examples/workers/l2/vector_add/test_run_timing.py index 5c3e3c0691..45f0c870bf 100644 --- a/examples/workers/l2/vector_add/test_run_timing.py +++ b/examples/workers/l2/vector_add/test_run_timing.py @@ -26,9 +26,12 @@ import re import pytest +from simpler._log import get_current_config from simpler.task_interface import CallConfig, ChipStorageTaskArgs, DataType, Tensor from simpler.worker import Worker +from simpler_setup.log_config import configure_logging + from .main import N_COLS, N_ELEMS, N_ROWS, NBYTES, build_chip_callable _STRACE_RE = re.compile(r"\[STRACE\] .*\bname=(?P\S+)\b.*\bdur=(?P\d+)") @@ -107,7 +110,7 @@ def test_simpler_run_emits_strace_markers(st_platform, st_device_ids, capfd): assert host_durs, ( "no `[STRACE] ... name=simpler_run` marker found on stderr; " "simpler_run stopped emitting host-trace markers (SIMPLER_HOST_STRACE off, " - "or the host logger V9 tier was suppressed)." + "or the host logger TIMING level was suppressed)." ) assert max(host_durs) > 0, f"simpler_run marker dur must be > 0 ns, got {host_durs}" @@ -118,3 +121,18 @@ def test_simpler_run_emits_strace_markers(st_platform, st_device_ids, capfd): "or marker emission regressed on the default SIMPLER_HOST_STRACE build." ) assert max(dev_durs) > 0, f"device_wall marker dur must be > 0 ns, got {dev_durs}" + + +@pytest.mark.platforms(["a2a3sim", "a5sim"]) +@pytest.mark.runtime("tensormap_and_ringbuffer") +@pytest.mark.device_count(1) +def test_sim_forwards_debug_level_to_aicpu(st_platform, st_device_ids, capfd): + previous_level = get_current_config() + configure_logging("debug") + try: + _drive_one_run(st_platform, int(st_device_ids[0])) + finally: + configure_logging(previous_level) + + err = capfd.readouterr().err + assert "AicpuExecutor: Initializing" in err, "AICPU sim SO did not receive the host DEBUG threshold" diff --git a/python/bindings/task_interface.cpp b/python/bindings/task_interface.cpp index 16c109d92d..16784d14ca 100644 --- a/python/bindings/task_interface.cpp +++ b/python/bindings/task_interface.cpp @@ -1348,9 +1348,9 @@ NB_MODULE(_task_interface, m) { }); // Log default constant — single source. Mirrored in - // src/common/log/host_log.h::simpler::log::kDefaultThreshold; if you change + // src/common/log/include/common/log_level.h::simpler::log::kDefaultThreshold; if you change // one, change the other. - m.attr("DEFAULT_LOG_THRESHOLD") = 20; // V5 = Python INFO + m.attr("DEFAULT_LOG_THRESHOLD") = 25; // TIMING // Per-stage run timing (host wall, on-NPU device wall + AICPU phase // breakdown) is no longer returned from run(); the platform emits it as diff --git a/python/simpler/__init__.py b/python/simpler/__init__.py index a860877a71..19f23a214e 100644 --- a/python/simpler/__init__.py +++ b/python/simpler/__init__.py @@ -17,20 +17,11 @@ Nothing log-related needs to happen at import time here. """ -# Importing _log auto-configures the simpler logger to V5 if unset. +# Importing _log auto-configures the simpler logger to TIMING if unset. from ._log import ( DEFAULT_THRESHOLD, NUL, - V0, - V1, - V2, - V3, - V4, - V5, - V6, - V7, - V8, - V9, + TIMING, get_current_config, get_logger, ) @@ -38,16 +29,7 @@ __all__ = [ "DEFAULT_THRESHOLD", "NUL", - "V0", - "V1", - "V2", - "V3", - "V4", - "V5", - "V6", - "V7", - "V8", - "V9", + "TIMING", "get_current_config", "get_logger", ] diff --git a/python/simpler/_log.py b/python/simpler/_log.py index f7c003ca03..5bc4b3ab6d 100644 --- a/python/simpler/_log.py +++ b/python/simpler/_log.py @@ -6,31 +6,16 @@ # 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. # ----------------------------------------------------------------------------------------------------------- -"""Simpler unified logging — single Python-side knob, propagated to C++. +"""Simpler unified logging — one Python threshold propagated to C++. -User-facing API: just `logging.getLogger("simpler").setLevel(int)`. Optional -constants (V0..V9, NUL) for readability. The integer threshold encodes both -severity and INFO sub-verbosity: +The public ladder is DEBUG / INFO / TIMING / WARN / ERROR. TIMING sits between +INFO and WARN and is the default so stable performance markers remain visible +without enabling ordinary INFO traffic. NUL is a suppression sentinel. - DEBUG = 10 - V0..V4 = 15..19 (sub-INFO, more verbose) - V5 = 20 (= INFO; default threshold) - V6..V9 = 21..24 (above-INFO, more must-see) - WARN = 30 - ERROR = 40 - NUL = 60 (suppress all) - -C++ side uses two axes (severity enum, info_v int) — `_split_threshold()` -converts the Python integer into that pair, which `Worker.init()` forwards -to `ChipWorker.init(device_id, bins, log_level, log_info_v)` once. The Python -`ChipWorker.init` wrapper `ctypes.CDLL`s libsimpler_log.so RTLD_GLOBAL and -calls its `simpler_log_init()` to seed the process-wide HostLogger before the -C++ side dlopens host_runtime.so; from then on the platform SO reads back -through `HostLogger::get_instance()` (populating `KernelArgs.log_level` / -`log_info_v` and, onboard only, syncing CANN dlog inside `simpler_init`). - -This module configures the "simpler" logger at import so that an unconfigured -user gets the V5 default rather than Python's WARNING root inheritance. +`Worker.init()` snapshots the effective ``simpler`` logger threshold and +forwards it to `ChipWorker.init()` once. The Python wrapper seeds the +process-wide HostLogger before the C++ side loads host_runtime.so; onboard +setup maps the same threshold onto CANN's coarser severity ladder. """ import logging @@ -38,39 +23,22 @@ # DEFAULT_LOG_THRESHOLD is exposed by the _task_interface nanobind module so # Python and C++ share one constant. During a fresh `pip install -e .` the # pre-existing .so may be stale or absent, so fall back to the hardcoded -# value (kept in sync manually with src/common/log/host_log.h). +# value (kept in sync manually with src/common/log/include/common/log_level.h). try: from _task_interface import DEFAULT_LOG_THRESHOLD as _NATIVE_DEFAULT # pyright: ignore[reportMissingImports] except (ImportError, AttributeError): - _NATIVE_DEFAULT = 20 + _NATIVE_DEFAULT = 25 # Public verbosity constants (Python integer levels). -V0 = 15 -V1 = 16 -V2 = 17 -V3 = 18 -V4 = 19 -V5 = 20 # alias of logging.INFO -V6 = 21 -V7 = 22 -V8 = 23 -V9 = 24 +TIMING = 25 NUL = 60 -DEFAULT_THRESHOLD = _NATIVE_DEFAULT # 20 (V5) +DEFAULT_THRESHOLD = _NATIVE_DEFAULT -# Register V0..V9 / NUL as Python logging level names so that: -# - `logging.LogRecord.levelname` for these tiers prints as "V0".."V9" -# instead of the default "Level 18" placeholder. -# - `logger.setLevel("V3")` (string form) resolves to 18. -# - pytest's own `--log-level` validator (which does -# `int(getattr(logging, name.upper(), name))`) accepts `pytest --log-level -# v3` — but only if the names exist as module attributes on `logging`. -# pytest validates the CLI value before conftest's first `import simpler`, -# so the same registration is also mirrored at conftest top-level. -for _v in range(10): - logging.addLevelName(15 + _v, f"V{_v}") - setattr(logging, f"V{_v}", 15 + _v) +# pytest validates --log-level before importing simpler, so conftest mirrors +# these registrations at module load. +logging.addLevelName(TIMING, "TIMING") +setattr(logging, "TIMING", TIMING) logging.addLevelName(NUL, "NUL") setattr(logging, "NUL", NUL) setattr(logging, "NULL", NUL) # pytest upcases user's `--log-level null` → NULL @@ -80,49 +48,32 @@ if _logger.level == logging.NOTSET: _logger.setLevel(DEFAULT_THRESHOLD) -# Severity enum integers — must mirror C++ simpler::log::LogLevel. -_SEV_DEBUG = 0 -_SEV_INFO = 1 -_SEV_WARN = 2 -_SEV_ERROR = 3 -_SEV_NUL = 4 - def get_logger() -> logging.Logger: """Return the simpler-namespaced Python logger.""" return _logger -def _split_threshold(t: int) -> tuple[int, int]: - """Convert a Python integer threshold into the C++ (severity, info_v) pair. - - Severity is the floor (CANN-aligned: 0=DEBUG..4=NUL); info_v is the INFO - verbosity threshold (only meaningful when severity == INFO, otherwise 0). - - Banding: - t <= 10 → (DEBUG, 0) # everything visible - 11 <= t <= 14 → (DEBUG, 0) # below V0; treat as DEBUG band - 15 <= t <= 24 → (INFO, t - 15) # V0..V9 → info_v 0..9 - 25 <= t <= 39 → (WARN, 0) # below WARN; round up - 40 <= t <= 59 → (ERROR, 0) - t >= 60 → (NUL, 0) - """ - if t <= 14: - return (_SEV_DEBUG, 0) - if t <= 24: - return (_SEV_INFO, t - 15) - if t <= 39: - return (_SEV_WARN, 0) - if t <= 59: - return (_SEV_ERROR, 0) - return (_SEV_NUL, 0) +def _normalize_threshold(threshold: int) -> int: + """Round an arbitrary Python logging threshold up to the public ladder.""" + if threshold <= logging.DEBUG: + return logging.DEBUG + if threshold <= logging.INFO: + return logging.INFO + if threshold <= TIMING: + return TIMING + if threshold <= logging.WARNING: + return logging.WARNING + if threshold <= logging.ERROR: + return logging.ERROR + return NUL -def get_current_config() -> tuple[int, int]: - """Return current (severity, info_v) for forwarding to ChipWorker.init(). +def get_current_config() -> int: + """Return the current threshold for forwarding to ChipWorker.init(). Reads the simpler logger's effective level — which respects user setLevel() calls and falls back to DEFAULT_THRESHOLD when unconfigured (we set that at module import). """ - return _split_threshold(_logger.getEffectiveLevel()) + return _normalize_threshold(_logger.getEffectiveLevel()) diff --git a/python/simpler/task_interface.py b/python/simpler/task_interface.py index b18142329c..18e70557bd 100644 --- a/python/simpler/task_interface.py +++ b/python/simpler/task_interface.py @@ -1011,7 +1011,7 @@ def __init__(self): self._live_handles: dict[int, bytes] = {} self._next_handle_id = 0 - def init(self, device_id, bins, log_level=None, log_info_v=None, prewarm_config=None, enable_sdma=False): + def init(self, device_id, bins, log_level=None, prewarm_config=None, enable_sdma=False): """Attach the calling thread to ``device_id``, load the host runtime library, and cache platform binaries. @@ -1033,31 +1033,27 @@ def init(self, device_id, bins, log_level=None, log_info_v=None, prewarm_config= simpler_log_path / sim_context_path / dispatcher_path). ``dispatcher_path`` is required for onboard platforms and ignored on sim (set to None). - log_level: Severity floor (0=DEBUG..4=NUL). Defaults to a snapshot - of the simpler logger via `_log.get_current_config()`. - log_info_v: INFO verbosity threshold (0..9). Same default. + log_level: Threshold (10=DEBUG, 20=INFO, 25=TIMING, 30=WARN, + 40=ERROR, 60=NUL). Defaults to a snapshot of the simpler + logger via `_log.get_current_config()`. For tests that need to drive the binding directly with arbitrary path strings (e.g. to assert dlopen failure on `/nonexistent/foo.so`), call `_ChipWorker.init(...)` from `_task_interface` instead of going through this wrapper. """ - if log_level is None or log_info_v is None: + if log_level is None: from . import _log # noqa: PLC0415 - sev, info_v = _log.get_current_config() - if log_level is None: - log_level = sev - if log_info_v is None: - log_info_v = info_v + log_level = _log.get_current_config() # 1. libsimpler_log.so — RTLD_GLOBAL singleton, before host_runtime.so. if not bins.simpler_log_path: raise ValueError("ChipWorker.init: bins.simpler_log_path is required") log_handle = _preload_global(str(bins.simpler_log_path)) - log_handle.simpler_log_init.argtypes = [ctypes.c_int, ctypes.c_int] + log_handle.simpler_log_init.argtypes = [ctypes.c_int] log_handle.simpler_log_init.restype = ctypes.c_int - rc = log_handle.simpler_log_init(int(log_level), int(log_info_v)) + rc = log_handle.simpler_log_init(int(log_level)) if rc != 0: raise RuntimeError(f"simpler_log_init failed with code {rc}") diff --git a/python/simpler/worker.py b/python/simpler/worker.py index 2c3fa7bb6c..9c59528edd 100644 --- a/python/simpler/worker.py +++ b/python/simpler/worker.py @@ -173,7 +173,7 @@ def my_l4_orch(orch, args, config): # enable_pmu, enable_dep_gen, enable_scope_stats) + uint64 ring sizing # overrides (3 per-ring arrays of RUNTIME_ENV_RING_COUNT: ring_task_window, # ring_heap, ring_dep_pool) + 1024-byte NUL-terminated output_prefix. Log config -# travels separately via ChipWorker.init(log_level, log_info_v) — not on per-task wire. +# travels separately via ChipWorker.init(log_level) — not on per-task wire. _RUNTIME_ENV_UINT64_FIELD_COUNT = 3 * RUNTIME_ENV_RING_COUNT _CFG_FMT = struct.Struct("=iiiiii" + ("Q" * _RUNTIME_ENV_UINT64_FIELD_COUNT) + "1024s") # Args region starts after CONFIG, rounded up to 8 bytes so the first @@ -1672,8 +1672,7 @@ def _chip_process_loop( # noqa: PLR0913 -- fork-child entry: all context (bins, registry: dict[int, Any], identity_table: dict[bytes, int], identity_refs: dict[bytes, int], - log_level: int = 1, - log_info_v: int = 5, + log_level: int = 25, platform: str = "", runtime: str = "", prewarm_config=None, @@ -1681,9 +1680,9 @@ def _chip_process_loop( # noqa: PLR0913 -- fork-child entry: all context (bins, ) -> None: """Runs in forked child process. Loads host_runtime.so in own address space. - `log_level` / `log_info_v` are the parent's snapshot of the simpler logger - (computed via `_log.get_current_config()`); the child cannot read the - parent's logger after fork, so the values are passed explicitly. + `log_level` is the parent's snapshot of the simpler logger (computed via + `_log.get_current_config()`); the child cannot read the parent's logger + after fork, so the value is passed explicitly. The main loop is delegated to ``_run_chip_main_loop`` — see its docstring for the TASK_READY / CONTROL_REQUEST / SHUTDOWN state machine. @@ -1696,7 +1695,6 @@ def _chip_process_loop( # noqa: PLR0913 -- fork-child entry: all context (bins, device_id, bins, log_level=log_level, - log_info_v=log_info_v, prewarm_config=prewarm_config, enable_sdma=enable_sdma, ) @@ -4408,7 +4406,7 @@ def _setup(): # Fork ChipWorker processes (L3 with device_ids). Always use the plain # task-loop variant; the base communicator is established lazily on first # ``orch.allocate_domain`` via CTRL_COMM_INIT. - chip_log_level, chip_log_info_v = _simpler_log.get_current_config() + chip_log_level = _simpler_log.get_current_config() if device_ids: for idx, dev_id in enumerate(device_ids): pid = os.fork() @@ -4436,7 +4434,6 @@ def _setup(): target_namespace="LOCAL_CHIP", ), log_level=chip_log_level, - log_info_v=chip_log_info_v, platform=str(self._config["platform"]), runtime=str(self._config["runtime"]), prewarm_config=self._prewarm_config, diff --git a/simpler_setup/log_config.py b/simpler_setup/log_config.py index 0928371cbd..79a1389777 100644 --- a/simpler_setup/log_config.py +++ b/simpler_setup/log_config.py @@ -8,7 +8,7 @@ # ----------------------------------------------------------------------------------------------------------- """Shared CLI log-level helper. -The CLI accepts a string from {debug, V0..V9, info, warn, error, null} or a +The CLI accepts a string from {debug, info, timing, warn, error, null} or a raw integer; we map it to a Python `logging` level and call `logging.getLogger("simpler").setLevel(...)`. The C++ side picks up the same level via `simpler_init` at `Worker.init()` time (one-shot snapshot) — there @@ -22,53 +22,28 @@ import logging +TIMING = 25 + # Recognised level names → Python integer level. -# V0..V9 are simpler's INFO sub-tiers (15..24); INFO == V5 == 20. _NAME_TO_LEVEL = { "debug": logging.DEBUG, "info": logging.INFO, + "timing": TIMING, "warn": logging.WARNING, "warning": logging.WARNING, "error": logging.ERROR, "null": 60, - "v0": 15, - "v1": 16, - "v2": 17, - "v3": 18, - "v4": 19, - "v5": 20, - "v6": 21, - "v7": 22, - "v8": 23, - "v9": 24, } -LOG_LEVEL_CHOICES = [ - "debug", - "v0", - "v1", - "v2", - "v3", - "v4", - "v5", - "v6", - "v7", - "v8", - "v9", - "info", - "warn", - "error", - "null", -] -DEFAULT_LOG_LEVEL = "v5" # = INFO = simpler default threshold +LOG_LEVEL_CHOICES = ["debug", "info", "timing", "warn", "error", "null"] +DEFAULT_LOG_LEVEL = "timing" def parse_level(level: str | int) -> int: """Translate a CLI-style level into a Python logger level integer. Accepts either a name from `LOG_LEVEL_CHOICES` (case-insensitive) or a - raw integer. Unknown names fall back to V5 (INFO) — silently — to match - the previous behaviour that mapped unknown strings to INFO. + raw integer. Unknown names fall back to TIMING. """ if isinstance(level, int): return level diff --git a/simpler_setup/scene_test.py b/simpler_setup/scene_test.py index a51c0b7f0d..c87df2c0af 100644 --- a/simpler_setup/scene_test.py +++ b/simpler_setup/scene_test.py @@ -1599,7 +1599,7 @@ def run_module(module_name): # noqa: PLR0912, PLR0915 -- CLI parsing + dispatch "--log-level", choices=LOG_LEVEL_CHOICES, default=DEFAULT_LOG_LEVEL, - help=f"Simpler logger level (debug/V0..V9/info/warn/error/null; default {DEFAULT_LOG_LEVEL})", + help=f"Simpler logger level (debug/info/timing/warn/error/null; default {DEFAULT_LOG_LEVEL})", ) args = parser.parse_args() configure_logging(args.log_level) diff --git a/simpler_setup/tools/README.md b/simpler_setup/tools/README.md index 356614d5ec..59f2e6c96d 100644 --- a/simpler_setup/tools/README.md +++ b/simpler_setup/tools/README.md @@ -287,7 +287,7 @@ The perf JSON must be captured at l2_swimlane_level >= 3 so that `aicpu_schedule Per-stage breakdown of every `simpler_run()` from `[STRACE]` host-trace markers in a log (host stderr or CANN device log). The runtime emits one `[STRACE]` line per span on scope exit (RAII, gated on `SIMPLER_HOST_STRACE`, -`LOG_INFO_V9`), including the AICPU device-phase subdivision (`clk=dev`). See +`LOG_TIMING`), including the AICPU device-phase subdivision (`clk=dev`). See [docs/dfx/host-trace.md](../../docs/dfx/host-trace.md) for the marker grammar. ```bash diff --git a/simpler_setup/tools/strace_timing.py b/simpler_setup/tools/strace_timing.py index 70d24a6b07..3e8971fa34 100644 --- a/simpler_setup/tools/strace_timing.py +++ b/simpler_setup/tools/strace_timing.py @@ -12,7 +12,7 @@ The host runtime emits one ``[STRACE]`` line per span on scope exit (RAII markers in ``src/common/log/include/common/strace.h``), gated by the compile-time ``SIMPLER_HOST_STRACE`` macro (on by default) and emitted at -``LOG_INFO_V9``. Device-domain phases (AICPU subdivision of the on-NPU wall) +``LOG_TIMING``. Device-domain phases (AICPU subdivision of the on-NPU wall) are emitted by the host after readback as ``clk=dev`` spans nested under ``simpler_run.runner_run.device_wall``. diff --git a/simpler_setup/tools/swimlane_converter.py b/simpler_setup/tools/swimlane_converter.py index 08832c7d6b..540252db66 100644 --- a/simpler_setup/tools/swimlane_converter.py +++ b/simpler_setup/tools/swimlane_converter.py @@ -1711,7 +1711,7 @@ def _find_containing_complete(thread_idx: int, finish_us: float): # # Per-event AicpuPhaseRecord[] is the single source of truth for # orchestrator timing. There is no separate aggregate summary — the - # device-side LOG_INFO_V9 "orch_start=… orch_end=… orch_cost=…" log + # device-side LOG_INFO "orch_start=… orch_end=… orch_cost=…" log # line covers the run-window envelope for debugging without swimlane. if orchestrator_phases: # Process metadata diff --git a/src/a2a3/platform/include/common/kernel_args.h b/src/a2a3/platform/include/common/kernel_args.h index 2383603509..526825932d 100644 --- a/src/a2a3/platform/include/common/kernel_args.h +++ b/src/a2a3/platform/include/common/kernel_args.h @@ -144,8 +144,7 @@ static_assert(offsetof(KernelArgs, regs) == 8, "KernelArgs::regs offset drift"); */ struct InitArgs { uint32_t device_id{0}; // ACL device ordinal -> set_orch_device_id - uint32_t log_level{1}; // Severity floor: 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR, 4=NUL - uint32_t log_info_v{5}; // INFO verbosity threshold (0..9); default V5 + uint32_t log_level{25}; // Threshold: DEBUG=10, INFO=20, TIMING=25, WARN=30, ERROR=40, NUL=60 int32_t scheduler_timeout_ms{0}; // AICPU no-progress watchdog (ms); 0 -> compile default // Per-engine async-DMA workspace dev addrs -> set_dma_workspace_addr(kind, .); // indexed by DmaWorkspaceKind; 0 = that engine unavailable. diff --git a/src/a2a3/platform/include/host/pmu_collector.h b/src/a2a3/platform/include/host/pmu_collector.h index 4d023794d9..78fa1feb0e 100644 --- a/src/a2a3/platform/include/host/pmu_collector.h +++ b/src/a2a3/platform/include/host/pmu_collector.h @@ -333,7 +333,7 @@ inline PmuEventType resolve_pmu_event_type(int requested_event_type) { int val = std::atoi(pmu_env); if (val > 0 && pmu_resolve_event_config_a2a3(static_cast(val)) != nullptr) { resolved = static_cast(val); - LOG_INFO_V0("PMU event type set to %u from SIMPLER_PMU_EVENT_TYPE", static_cast(resolved)); + LOG_DEBUG("PMU event type set to %u from SIMPLER_PMU_EVENT_TYPE", static_cast(resolved)); return resolved; } LOG_WARN("Invalid SIMPLER_PMU_EVENT_TYPE=%s, using default (PIPE_UTILIZATION=%u)", pmu_env, PMU_EVENT_TYPE_DEFAULT); diff --git a/src/a2a3/platform/onboard/aicpu/kernel.cpp b/src/a2a3/platform/onboard/aicpu/kernel.cpp index 28d13f415d..2f9f2e1cfb 100644 --- a/src/a2a3/platform/onboard/aicpu/kernel.cpp +++ b/src/a2a3/platform/onboard/aicpu/kernel.cpp @@ -144,7 +144,6 @@ extern "C" __attribute__((visibility("default"))) int simpler_aicpu_init(void *a InitArgs *init_args = reinterpret_cast(arg); set_log_level(static_cast(init_args->log_level)); - set_log_info_v(static_cast(init_args->log_info_v)); set_orch_device_id(static_cast(init_args->device_id)); set_scheduler_timeout_ms(static_cast(init_args->scheduler_timeout_ms)); for (int k = 0; k < DMA_WORKSPACE_KIND_COUNT; ++k) { diff --git a/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp b/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp index 317d43fca3..e7cbe0fc63 100644 --- a/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp +++ b/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp @@ -112,7 +112,7 @@ bool probe_aicpu_topology(uint32_t device_id, std::vector &out_ return false; } - LOG_INFO_V0("A2A3 AICPU topology probed for device %u: %zu user-schedulable cpu_ids", device_id, probed.size()); + LOG_DEBUG("A2A3 AICPU topology probed for device %u: %zu user-schedulable cpu_ids", device_id, probed.size()); { std::lock_guard lk(s_topo_cache_mu); diff --git a/src/a2a3/platform/onboard/host/comm_hccl.cpp b/src/a2a3/platform/onboard/host/comm_hccl.cpp index 5f9f5ac4bd..7fdaaad6e0 100644 --- a/src/a2a3/platform/onboard/host/comm_hccl.cpp +++ b/src/a2a3/platform/onboard/host/comm_hccl.cpp @@ -200,7 +200,7 @@ wait_for_rootinfo(const std::string &path, HcclRootInfo *root_info, uint64_t *ru return true; } if (i > 0 && i % (kLogEverySec * 10) == 0) { - LOG_INFO_V0("[comm] wait_for_rootinfo: still waiting (%ds elapsed) path=%s", i / 10, path.c_str()); + LOG_DEBUG("[comm] wait_for_rootinfo: still waiting (%ds elapsed) path=%s", i / 10, path.c_str()); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } @@ -1298,7 +1298,7 @@ extern "C" int comm_alloc_windows(CommHandle h, size_t win_size, uint64_t *devic const FabricAttempt fabric_result = alloc_windows_via_fabric(h, effective_win_size); if (fabric_result == FabricAttempt::kError) return -1; if (fabric_result == FabricAttempt::kUnsupported) { - LOG_INFO_V0("[comm rank %d] Fabric V2 unsupported; using VMM IPC windows", h->rank); + LOG_DEBUG("[comm rank %d] Fabric V2 unsupported; using VMM IPC windows", h->rank); if (alloc_windows_via_ipc(h, effective_win_size) != 0) return -1; } @@ -1462,7 +1462,7 @@ extern "C" int comm_alloc_domain_windows( domain_alloc_via_fabric(h, allocation_id, rank_ids, rank_count, domain_rank, window_size, alloc.get()); if (fabric_result == FabricAttempt::kError) return -1; if (fabric_result == FabricAttempt::kUnsupported) { - LOG_INFO_V0("[comm rank %d] Fabric V2 unsupported; using VMM IPC domain windows", h->rank); + LOG_DEBUG("[comm rank %d] Fabric V2 unsupported; using VMM IPC domain windows", h->rank); const int rc = domain_alloc_via_ipc(h, allocation_id, rank_ids, rank_count, domain_rank, window_size, alloc.get()); if (rc != 0) return rc; diff --git a/src/a2a3/platform/onboard/host/device_runner.cpp b/src/a2a3/platform/onboard/host/device_runner.cpp index 0ab734f798..1cda5383d9 100644 --- a/src/a2a3/platform/onboard/host/device_runner.cpp +++ b/src/a2a3/platform/onboard/host/device_runner.cpp @@ -355,7 +355,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { dump += std::to_string(allowed[i]); if (i + 1 == allowed.size()) dump += "(last)"; } - LOG_INFO_V0( + LOG_DEBUG( "A2A3 AICPU ALLOWED_CPUS = [%s] (active=%d, launch=%d, user_cpus=%zu)", dump.c_str(), runtime.get_aicpu_thread_num(), runtime.get_aicpu_launch_count(), user_cpus.size() ); @@ -510,7 +510,7 @@ int DeviceRunner::ensure_run_stream_set(unsigned slot) { } } ++run_stream_sets_created_; - LOG_INFO_V0("DeviceRunner: run stream set %u created", slot); + LOG_DEBUG("DeviceRunner: run stream set %u created", slot); return 0; } @@ -579,7 +579,7 @@ int DeviceRunner::launch_run(Runtime &runtime, int num_aicore, int launch_aicpu_ } } - LOG_INFO_V0("=== launch_aicore_kernel ==="); + LOG_DEBUG("=== launch_aicore_kernel ==="); // Launch AICore kernel (pass device copy of KernelArgs) rc = launch_aicore_kernel(streams.aicore, kernel_args_.device_k_args_); if (rc != 0) { @@ -588,7 +588,7 @@ int DeviceRunner::launch_run(Runtime &runtime, int num_aicore, int launch_aicpu_ return rc; } - LOG_INFO_V0("=== launch_aicpu_kernel %s ===", host::KernelNames::RunName); + LOG_DEBUG("=== launch_aicpu_kernel %s ===", host::KernelNames::RunName); int aicpu_launch_n = (runtime.get_aicpu_launch_count() > 0) ? runtime.get_aicpu_launch_count() : launch_aicpu_num; rc = launch_aicpu_kernel(streams.aicpu, &kernel_args_.args, host::KernelNames::RunName, aicpu_launch_n); if (rc != 0) { diff --git a/src/a2a3/platform/shared/host/pmu_collector.cpp b/src/a2a3/platform/shared/host/pmu_collector.cpp index 9f23adf79f..cc058748ce 100644 --- a/src/a2a3/platform/shared/host/pmu_collector.cpp +++ b/src/a2a3/platform/shared/host/pmu_collector.cpp @@ -208,7 +208,7 @@ int PmuCollector::init( device_id ); - LOG_INFO_V0( + LOG_DEBUG( "PMU collector initialized: %d cores, %d threads, SHM=0x%lx, CSV=%s (opened on first record)", num_cores, num_threads, reinterpret_cast(shm_dev_), csv_path_.c_str() ); @@ -495,7 +495,7 @@ void PmuCollector::reconcile_counters() { static_cast(total_device) - static_cast(total_collected_ + dropped_device) ); } else { - LOG_INFO_V0( + LOG_DEBUG( "PMU reconcile: record counts match (collected=%lu, dropped=%lu, device_total=%lu)", static_cast(total_collected_), static_cast(dropped_device), static_cast(total_device) diff --git a/src/a2a3/platform/sim/host/device_runner.cpp b/src/a2a3/platform/sim/host/device_runner.cpp index 6a4333cdcf..658797addd 100644 --- a/src/a2a3/platform/sim/host/device_runner.cpp +++ b/src/a2a3/platform/sim/host/device_runner.cpp @@ -37,6 +37,7 @@ #include "common/platform_config.h" #include "common/unified_log.h" #include "cpu_sim_context.h" +#include "host_log.h" #include "host/raii_scope_guard.h" #include "host/runtime_timeout_config.h" #include "runtime.h" @@ -145,12 +146,15 @@ int DeviceRunner::ensure_binaries_loaded() { if (!load_sym("set_platform_scope_stats_base", reinterpret_cast(&set_platform_scope_stats_base_func_))) return -1; - // Log config travels via the RTLD_GLOBAL HostLogger singleton in - // libsimpler_log.so — already seeded by simpler_log_init() before the - // AICPU sim SO was dlopen'd, so no per-SO setter forwarding is needed. + // The AICPU sim SO owns its level flags because it is RTLD_LOCAL. + // Forward the process-wide HostLogger threshold explicitly. + using SetLogLevelFunc = void (*)(int); + SetLogLevelFunc set_log_level_func = nullptr; + if (!load_sym("set_log_level", reinterpret_cast(&set_log_level_func))) return -1; + set_log_level_func(HostLogger::get_instance().level()); aicpu_so_loaded_ = true; - LOG_INFO_V0("DeviceRunner(sim): Loaded aicpu_execute from %s", aicpu_so_path_.c_str()); + LOG_DEBUG("DeviceRunner(sim): Loaded aicpu_execute from %s", aicpu_so_path_.c_str()); } // AICore kernel .so: reload every run — kernel binary varies per case and @@ -187,7 +191,7 @@ int DeviceRunner::ensure_binaries_loaded() { LOG_ERROR("dlsym failed for aicore_execute_wrapper: %s", dlerror()); return -1; } - LOG_INFO_V0("DeviceRunner(sim): Loaded aicore_execute_wrapper from %s", aicore_so_path_.c_str()); + LOG_DEBUG("DeviceRunner(sim): Loaded aicore_execute_wrapper from %s", aicore_so_path_.c_str()); // Pass core identity setter function pointers to the AICore SO so it can // set per-thread subblock_id and cluster_id for pto-isa's TPUSH/TPOP hooks. @@ -465,7 +469,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { } constexpr int over_launch = PLATFORM_MAX_AICPU_THREADS_JUST_FOR_LAUNCH; - LOG_INFO_V0("Launching %d AICPU threads (logical=%d)", over_launch, launch_aicpu_num); + LOG_DEBUG("Launching %d AICPU threads (logical=%d)", over_launch, launch_aicpu_num); std::vector aicpu_threads; aicpu_threads.reserve(over_launch); std::atomic aicpu_rc{0}; @@ -512,7 +516,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { })); } - LOG_INFO_V0("Launching %d AICore thread(s)", num_aicore); + LOG_DEBUG("Launching %d AICore thread(s)", num_aicore); std::vector aicore_threads; for (int i = 0; i < num_aicore; i++) { CoreType core_type = runtime.get_workers()[i].core_type; @@ -531,7 +535,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { for (auto &t : aicore_threads) { t.join(); } - LOG_INFO_V0("All threads completed"); + LOG_DEBUG("All threads completed"); // Snapshot the device_wall buffer into device_wall_ns_. device_wall_ns_ = 0; diff --git a/src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cpp b/src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cpp index 3e66debe14..e939ed4570 100644 --- a/src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cpp +++ b/src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cpp @@ -161,7 +161,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { const bool is_leader = (tidx == 0); if (is_leader) { - LOG_INFO_V0("AicpuExecutor: Initializing"); + LOG_DEBUG("AicpuExecutor: Initializing"); // The 0 → 1 fixup already applied above. aicpu_thread_num_ = nthreads; @@ -193,7 +193,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { return -1; } init_done_.store(true, std::memory_order_release); - LOG_INFO_V0("AicpuExecutor: Init complete"); + LOG_DEBUG("AicpuExecutor: Init complete"); } else { while (!init_done_.load(std::memory_order_acquire)) { if (init_failed_.load(std::memory_order_acquire)) return -1; @@ -288,7 +288,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { // only needs total_tasks and the scalar // orchestrator.inline_completed_tasks, both already valid. sched_ctx_.on_orchestration_done(runtime, rt, thread_idx, runtime->host_total_tasks); - LOG_INFO_V0("Thread %d: host-orch boot complete (%d tasks)", thread_idx, runtime->host_total_tasks); + LOG_DEBUG("Thread %d: host-orch boot complete (%d tasks)", thread_idx, runtime->host_total_tasks); } runtime_init_ready_.store(true, std::memory_order_release); @@ -310,7 +310,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { LOG_ERROR("Thread %d: Scheduler failed with rc=%d", thread_idx, completed); run_rc = completed; } else { - LOG_INFO_V0("Thread %d: Executed %d tasks from runtime", thread_idx, completed); + LOG_DEBUG("Thread %d: Executed %d tasks from runtime", thread_idx, completed); } } } @@ -322,7 +322,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { run_rc = shutdown_rc; } - LOG_INFO_V0("Thread %d: Completed", thread_idx); + LOG_DEBUG("Thread %d: Completed", thread_idx); // Check if this is the last thread to finish int32_t prev_finished = finished_count_.fetch_add(1, std::memory_order_acq_rel); @@ -358,7 +358,7 @@ void AicpuExecutor::deinit(Runtime *runtime) { // Clear file-scope PTO2Runtime pointer (freed by orchestrator thread before deinit) rt = nullptr; - LOG_INFO_V0("DeInit: Runtime execution state reset"); + LOG_DEBUG("DeInit: Runtime execution state reset"); init_done_.store(false, std::memory_order_release); init_failed_.store(false, std::memory_order_release); @@ -368,7 +368,7 @@ void AicpuExecutor::deinit(Runtime *runtime) { thread_idx_.store(0, std::memory_order_release); finished_.store(false, std::memory_order_release); - LOG_INFO_V0("DeInit: AicpuExecutor reset complete"); + LOG_DEBUG("DeInit: AicpuExecutor reset complete"); } // ===== Public Entry Point ===== @@ -404,7 +404,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return -1; } - LOG_INFO_V0("%s", "aicpu_execute: Starting AICPU kernel execution"); + LOG_DEBUG("%s", "aicpu_execute: Starting AICPU kernel execution"); // init() barriers every thread internally until init is complete on the // leader (or a thread failed), then returns the status — so a non-zero @@ -423,7 +423,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { // Last thread cleans up if (g_aicpu_executor.finished_.load(std::memory_order_acquire)) { - LOG_INFO_V0("aicpu_execute: Last thread finished, cleaning up"); + LOG_DEBUG("aicpu_execute: Last thread finished, cleaning up"); g_aicpu_executor.deinit(runtime); } @@ -436,6 +436,6 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return rc; } - LOG_INFO_V0("%s", "aicpu_execute: Kernel execution completed successfully"); + LOG_DEBUG("%s", "aicpu_execute: Kernel execution completed successfully"); return 0; } diff --git a/src/a2a3/runtime/host_build_graph/docs/device_log_profiling.md b/src/a2a3/runtime/host_build_graph/docs/device_log_profiling.md index ac070c2e19..45d1d67142 100644 --- a/src/a2a3/runtime/host_build_graph/docs/device_log_profiling.md +++ b/src/a2a3/runtime/host_build_graph/docs/device_log_profiling.md @@ -2,7 +2,7 @@ ## How to Find Device Logs -AICPU logs (via `LOG_INFO_V9`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: +AICPU logs (via `LOG_INFO`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: ```text $HOME/ascend/log/debug/device-/device-_.log diff --git a/src/a2a3/runtime/host_build_graph/docs/profiling_levels.md b/src/a2a3/runtime/host_build_graph/docs/profiling_levels.md index 5ef151d492..5971346052 100644 --- a/src/a2a3/runtime/host_build_graph/docs/profiling_levels.md +++ b/src/a2a3/runtime/host_build_graph/docs/profiling_levels.md @@ -103,7 +103,7 @@ AICPU thread schedules its own core slice, so `N_sched == aicpu_thread_num`. - `Thread %d: Scheduler summary: total_time=%.3fus, loops=%llu, tasks_scheduled=%d` — each scheduler thread - `Thread %d: sched_start=%llu sched_end(timeout)=%llu sched_cost=%.3fus` — timeout path only (replaces normal `sched_end`) -**LOG_INFO_V9 count (normal run):** +**LOG_INFO count (normal run):** - `N_sched*2` (sched_timing + Scheduler_summary per scheduler thread) @@ -140,7 +140,7 @@ Thread 3: Scheduler summary: total_time=147.940us, loops=3402, tasks_scheduled=3 - Phase-specific statistics (complete, scan, dispatch, idle) - Hit rate tracking (complete poll, ready queue pop) -**Log output:** 18 LOG_INFO_V9 logs (11 debug + 2 basic + 7 scheduler detailed - 2 replaced) +**Log output:** 18 LOG_INFO logs (11 debug + 2 basic + 7 scheduler detailed - 2 replaced) - Replaces scheduler summary with detailed breakdown @@ -184,7 +184,7 @@ captured at l2_swimlane_level >= 3) and `deps.json`; consume them via - Atomic operation counters - Wait time tracking -**Log output:** 30 LOG_INFO_V9 logs (11 debug + 2 basic + 1 scheduler summary + 17 orchestrator detailed - 1 replaced) +**Log output:** 30 LOG_INFO logs (11 debug + 2 basic + 1 scheduler summary + 17 orchestrator detailed - 1 replaced) - Replaces basic orchestration completion with detailed breakdown @@ -219,7 +219,7 @@ Thread X: avg/task : XXXus - Hash chain walk tracking - Overlap check counters -**Log output:** 34 LOG_INFO_V9 logs (30 from Level 3 + 4 tensormap) +**Log output:** 34 LOG_INFO logs (30 from Level 3 + 4 tensormap) **TensorMap output:** @@ -417,8 +417,8 @@ definitions to runtime headers. > run (no stall/timeout). host_build_graph boots scheduler-only, so the Level-1 > count is `N_sched*2` with no orchestrator lines (`N_sched == aicpu_thread_num`). -| Level | Macro Settings | LOG_INFO_V9 Count | Description | -| ----- | -------------- | ----------------- | ----------- | +| Level | Macro Settings | LOG_INFO Count | Description | +| ----- | -------------- | -------------- | ----------- | | 0 | `SIMPLER_DFX=0` | 0 | No timing output | | 1 | `SIMPLER_DFX=1` | 8 | Scheduler timing + summary (4 threads × 2) | | 2 | `+SIMPLER_SCHED_PROFILING=1` | — | Scheduler detailed phase breakdown | diff --git a/src/a2a3/runtime/host_build_graph/host/dep_gen_host_graph.cpp b/src/a2a3/runtime/host_build_graph/host/dep_gen_host_graph.cpp index 5f2a0bca13..e0dac3fcc1 100644 --- a/src/a2a3/runtime/host_build_graph/host/dep_gen_host_graph.cpp +++ b/src/a2a3/runtime/host_build_graph/host/dep_gen_host_graph.cpp @@ -517,7 +517,7 @@ extern "C" int dep_gen_host_graph_emit(const char *deps_json_path) { if (!write_deps_json(deps_json_path, s.tasks, s.tensors, s.edges)) { return -2; } - LOG_INFO_V0( + LOG_DEBUG( "dep_gen host graph: wrote deps.json to %s (tasks=%zu, tensors=%zu, edges=%zu)", deps_json_path, s.tasks.size(), s.tensors.size(), s.edges.size() ); diff --git a/src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp b/src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp index f8de55082c..d689441a7d 100644 --- a/src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp +++ b/src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp @@ -556,7 +556,7 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const *out = CallableArtifacts{}; out->signature.assign(callable->signature_, callable->signature_ + callable->sig_count()); - LOG_INFO_V0("Registering %d kernel(s) in register_callable_impl", callable->child_count()); + LOG_DEBUG("Registering %d kernel(s) in register_callable_impl", callable->child_count()); if (upload_and_collect_child_addrs( callable, upload_fn, &out->kernel_addrs, &out->chip_buffer_dev, &out->chip_buffer_hash ) != 0) { @@ -627,9 +627,9 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const eps->bind = reinterpret_cast(bind_sym); out->host_dlopen_handle = handle; out->host_orch_func_ptr = eps; - LOG_INFO_V0("host-orch: loaded orchestration entry '%s' on host", orch_func_name); + LOG_DEBUG("host-orch: loaded orchestration entry '%s' on host", orch_func_name); } - LOG_INFO_V0("Orchestration SO: %zu bytes staged", orch_so_size); + LOG_DEBUG("Orchestration SO: %zu bytes staged", orch_so_size); return 0; } @@ -669,7 +669,7 @@ extern "C" int bind_callable_to_runtime_impl( // it is run below (after the arena is built) against a host SM mirror. int tensor_count = orch_args->tensor_count(); int scalar_count = orch_args->scalar_count(); - LOG_INFO_V0("RT2 bind: %d tensors + %d scalars, host orchestration mode", tensor_count, scalar_count); + LOG_DEBUG("RT2 bind: %d tensors + %d scalars, host orchestration mode", tensor_count, scalar_count); int64_t t_total_start = _now_ms(); @@ -680,7 +680,7 @@ extern "C" int bind_callable_to_runtime_impl( } const std::string task_window_log = format_ring_array(eff_task_window_sizes); const std::string heap_log = format_ring_array(eff_heap_sizes); - LOG_INFO_V0("Ring buffer sizes: task_window=%s heap=%s", task_window_log.c_str(), heap_log.c_str()); + LOG_DEBUG("Ring buffer sizes: task_window=%s heap=%s", task_window_log.c_str(), heap_log.c_str()); // Build device args: copy from input, replace host tensor pointers with device pointers ChipStorageTaskArgs device_args; @@ -855,7 +855,7 @@ extern "C" int bind_callable_to_runtime_impl( return -1; } runtime->host_total_tasks = total_tasks; - LOG_INFO_V0("host-orch: submitted %d tasks on host", total_tasks); + LOG_DEBUG("host-orch: submitted %d tasks on host", total_tasks); } // Stash the layout inside the PTO2Runtime image so the AICPU can recover @@ -873,15 +873,15 @@ extern "C" int bind_callable_to_runtime_impl( runtime->set_prebuilt_arena(runtime_arena_dev, layout.off_runtime); int64_t t_prebuilt_end = _now_ms(); - LOG_INFO_V0("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); + LOG_DEBUG("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); int64_t t_total_end = _now_ms(); - LOG_INFO_V0("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); - LOG_INFO_V0("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); - LOG_INFO_V0("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); - LOG_INFO_V0("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); - LOG_INFO_V0("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); - LOG_INFO_V0("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); + LOG_DEBUG("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); + LOG_DEBUG("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); + LOG_DEBUG("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); + LOG_DEBUG("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); + LOG_DEBUG("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); + LOG_DEBUG("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); return 0; } @@ -910,13 +910,13 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e int rc = 0; - LOG_INFO_V0("=== Copying Results Back to Host ==="); + LOG_DEBUG("=== Copying Results Back to Host ==="); // Copy all recorded tensors from device back to host TensorPair *tensor_pairs = runtime->tensor_pairs_.data(); int tensor_pair_count = static_cast(runtime->tensor_pairs_.size()); - LOG_INFO_V0("Tensor pairs to process: %d", tensor_pair_count); + LOG_DEBUG("Tensor pairs to process: %d", tensor_pair_count); bool skip_tensor_copy_back = execution_rc != 0; int32_t runtime_status = 0; @@ -969,7 +969,7 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e } // Cleanup device tensors - LOG_INFO_V0("=== Cleaning Up ==="); + LOG_DEBUG("=== Cleaning Up ==="); for (int i = 0; i < tensor_pair_count; i++) { if (tensor_pairs[i].dev_ptr != nullptr) { // Release the SVM host mapping installed at staging time before @@ -979,7 +979,7 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e api->device_free(tensor_pairs[i].dev_ptr); } } - LOG_INFO_V0("Freed %d device allocations", tensor_pair_count); + LOG_DEBUG("Freed %d device allocations", tensor_pair_count); // Clear the per-run dispatch-table entries staged by register_callable_impl. // The underlying chip-callable device buffer is pool-managed by @@ -992,14 +992,14 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e runtime->set_function_bin_addr(func_id, 0); } if (kernel_count > 0) { - LOG_INFO_V0("Cleared %d kernel dispatch-table entries", kernel_count); + LOG_DEBUG("Cleared %d kernel dispatch-table entries", kernel_count); } runtime->clear_registered_kernels(); // Clear tensor pairs runtime->tensor_pairs_.clear(); - LOG_INFO_V0("=== Finalize Complete ==="); + LOG_DEBUG("=== Finalize Complete ==="); if (rc == 0 && runtime_status != 0) { rc = runtime_status; diff --git a/src/a2a3/runtime/host_build_graph/orchestration/pto_orchestration_api.h b/src/a2a3/runtime/host_build_graph/orchestration/pto_orchestration_api.h index 0eb0d4ad62..92171d11e4 100644 --- a/src/a2a3/runtime/host_build_graph/orchestration/pto_orchestration_api.h +++ b/src/a2a3/runtime/host_build_graph/orchestration/pto_orchestration_api.h @@ -74,9 +74,9 @@ typedef struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. @@ -259,20 +259,10 @@ static inline bool rt_is_fatal() { #define LOG_ERROR(fmt, ...) current_runtime()->ops->log_error(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) current_runtime()->ops->log_warn(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_TIMING(fmt, ...) current_runtime()->ops->log_timing(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) current_runtime()->ops->log_info(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) current_runtime()->ops->log_debug(__FUNCTION__, fmt, ##__VA_ARGS__) -// INFO verbosity tiers. v=0 most verbose, v=9 must-see, v=5 default. -#define LOG_INFO_V0(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 0, fmt, ##__VA_ARGS__) -#define LOG_INFO_V1(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 1, fmt, ##__VA_ARGS__) -#define LOG_INFO_V2(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 2, fmt, ##__VA_ARGS__) -#define LOG_INFO_V3(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 3, fmt, ##__VA_ARGS__) -#define LOG_INFO_V4(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 4, fmt, ##__VA_ARGS__) -#define LOG_INFO_V5(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 5, fmt, ##__VA_ARGS__) -#define LOG_INFO_V6(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 6, fmt, ##__VA_ARGS__) -#define LOG_INFO_V7(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 7, fmt, ##__VA_ARGS__) -#define LOG_INFO_V8(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 8, fmt, ##__VA_ARGS__) -#define LOG_INFO_V9(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 9, fmt, ##__VA_ARGS__) - // ============================================================================= // Cross-Layer Data Access // ============================================================================= diff --git a/src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_runtime2.cpp b/src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_runtime2.cpp index 8359d650f9..41e7396cdf 100644 --- a/src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_runtime2.cpp +++ b/src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_runtime2.cpp @@ -296,8 +296,9 @@ static const PTO2RuntimeOps s_runtime_ops = { .report_fatal = rt_report_fatal, .log_error = unified_log_error, .log_warn = unified_log_warn, + .log_timing = unified_log_timing, + .log_info = unified_log_info, .log_debug = unified_log_debug, - .log_info_v = unified_log_info_v, .get_tensor_data = get_tensor_data, .set_tensor_data = set_tensor_data, .alloc_tensors = alloc_tensors_impl, diff --git a/src/a2a3/runtime/host_build_graph/runtime/pto_runtime2.h b/src/a2a3/runtime/host_build_graph/runtime/pto_runtime2.h index 1f5c04a284..1fc66c88cb 100644 --- a/src/a2a3/runtime/host_build_graph/runtime/pto_runtime2.h +++ b/src/a2a3/runtime/host_build_graph/runtime/pto_runtime2.h @@ -77,9 +77,9 @@ struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. diff --git a/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp b/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp index 3cc67f03bd..3ec1f82dd1 100644 --- a/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp +++ b/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp @@ -75,7 +75,7 @@ LoopAction SchedulerContext::handle_orchestrator_exit( task_count = total_tasks_; if (task_count > 0 && completed_tasks_.load(std::memory_order_relaxed) >= task_count) { completed_.store(true, std::memory_order_release); - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: PTO2 completed tasks %d/%d", thread_idx, completed_tasks_.load(std::memory_order_relaxed), task_count ); @@ -273,7 +273,7 @@ void SchedulerContext::log_stall_diagnostics( if (is_running) { cnt_running++; if (cnt_running > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=RUNNING fanin_met=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] " "running_on=[owner_thread=%d cores=[%s]]", @@ -284,7 +284,7 @@ void SchedulerContext::log_stall_diagnostics( if (rc >= fi) { cnt_ready++; if (cnt_ready > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=READY fanin_met=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d]", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1 @@ -293,7 +293,7 @@ void SchedulerContext::log_stall_diagnostics( } cnt_waiting++; if (cnt_waiting > STALL_DUMP_WAIT_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=WAIT fanin_met=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] missing_deps=%d", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1, fi - rc @@ -302,7 +302,7 @@ void SchedulerContext::log_stall_diagnostics( } int32_t effective_total = task_count > 0 ? task_count : submitted_in_ring; int32_t c = completed_tasks_.load(std::memory_order_relaxed); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] SUMMARY completed=%d/%d last_progress_iteration=%d " "scan_ready=%d scan_waiting=%d scan_running=%d", thread_idx, idle_iterations, c, effective_total, last_progress_count, cnt_ready, cnt_waiting, cnt_running @@ -334,7 +334,7 @@ void SchedulerContext::log_stall_diagnostics( aiv1_buf, sizeof(aiv1_buf), aiv1_id, aiv1_idle, &core_exec_states_[aiv1_id], core_exec_states_[aiv1_id].reg_addr ); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] CLUSTER cluster_id=%d aic=%s aiv0=%s aiv1=%s", thread_idx, idle_iterations, cluster_id, aic_buf, aiv0_buf, aiv1_buf ); @@ -399,7 +399,7 @@ int32_t SchedulerContext::handle_timeout_exit( } #if SIMPLER_DFX uint64_t sched_timeout_ts = get_sys_cnt_aicpu(); - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end(timeout)=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(sched_start_ts), static_cast(sched_timeout_ts), cycles_to_us(sched_timeout_ts - sched_start_ts) @@ -412,7 +412,7 @@ int32_t SchedulerContext::handle_timeout_exit( void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, int32_t cur_thread_completed) { auto &l2_swimlane = sched_l2_swimlane_[thread_idx]; uint64_t sched_end_ts = get_sys_cnt_aicpu(); - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(l2_swimlane.sched_start_ts), static_cast(sched_end_ts), cycles_to_us(sched_end_ts - l2_swimlane.sched_start_ts) @@ -436,7 +436,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, int32_t cur_t l2_swimlane.sched_dispatch_setup_cycle) : 0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: === Scheduler Phase Breakdown: total=%.3fus, %d tasks ===", thread_idx, cycles_to_us(sched_total), cur_thread_completed ); @@ -444,7 +444,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, int32_t cur_t // fanout / fanin per-thread aggregates live in // sched_overhead_analysis.compute_dag_stats_from_deps (deps.json edges // × core_to_thread). - LOG_INFO_V9( + LOG_INFO( "Thread %d: complete : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle), l2_swimlane.sched_complete_cycle * 100.0 / sched_total ); @@ -456,76 +456,76 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, int32_t cur_t double complete_hit_rate = l2_swimlane.complete_probe_count > 0 ? l2_swimlane.complete_hit_count * 100.0 / l2_swimlane.complete_probe_count : 0.0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%) hit=%" PRIu64 ", miss=%" PRIu64 ", hit_rate=%.1f%%", thread_idx, cycles_to_us(complete_poll), complete_poll * 100.0 / c_parent, static_cast(l2_swimlane.complete_hit_count), static_cast(complete_miss_count), complete_hit_rate ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_lock : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.lock_cycle), sp.lock_cycle * 100.0 / c_parent, cycles_to_us(sp.lock_cycle - sp.lock_wait_cycle), cycles_to_us(sp.lock_wait_cycle), static_cast(sp.lock_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanout : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanout_cycle), sp.fanout_cycle * 100.0 / c_parent, cycles_to_us(sp.fanout_cycle - sp.push_wait_cycle), cycles_to_us(sp.push_wait_cycle), static_cast(sp.fanout_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanin : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanin_cycle), sp.fanin_cycle * 100.0 / c_parent, static_cast(sp.fanin_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_self : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.self_consumed_cycle), sp.self_consumed_cycle * 100.0 / c_parent, static_cast(sp.self_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: perf : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_perf_cycle), l2_swimlane.sched_complete_perf_cycle * 100.0 / c_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: dispatch : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_cycle), l2_swimlane.sched_dispatch_cycle * 100.0 / sched_total ); uint64_t d_parent = l2_swimlane.sched_dispatch_cycle > 0 ? l2_swimlane.sched_dispatch_cycle : 1; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%)", thread_idx, cycles_to_us(dispatch_poll), dispatch_poll * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: pop : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle), l2_swimlane.sched_dispatch_pop_cycle * 100.0 / d_parent, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle - sp.pop_wait_cycle), cycles_to_us(sp.pop_wait_cycle), static_cast(sp.pop_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: setup : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_setup_cycle), l2_swimlane.sched_dispatch_setup_cycle * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: idle : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_idle_cycle), l2_swimlane.sched_idle_cycle * 100.0 / sched_total ); if (cur_thread_completed > 0) { - LOG_INFO_V9( + LOG_INFO( "Thread %d: avg/complete : %.3fus", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle) / cur_thread_completed ); } } #endif - LOG_INFO_V9( + LOG_INFO( "Thread %d: Scheduler summary: total_time=%.3fus, loops=%" PRIu64 ", tasks_scheduled=%d", thread_idx, cycles_to_us(sched_total), static_cast(l2_swimlane.sched_loop_count), cur_thread_completed ); @@ -548,7 +548,7 @@ int32_t SchedulerContext::shutdown(int32_t thread_idx) { } #endif - LOG_INFO_V0("Thread %d: Shutting down %d cores", thread_idx, core_num); + LOG_DEBUG("Thread %d: Shutting down %d cores", thread_idx, core_num); int32_t rc = 0; for (int32_t i = 0; i < core_num; i++) { int32_t core_id = cores[i]; @@ -712,7 +712,7 @@ bool SchedulerContext::assign_cores_to_threads() { return false; } - LOG_INFO_V0( + LOG_DEBUG( "Assigning cores (round-robin): %d clusters across %d sched threads (%d AIC, %d AIV)", cluster_count, active_sched_threads_, aic_count_, aiv_count_ ); @@ -750,7 +750,7 @@ bool SchedulerContext::assign_cores_to_threads() { ); } - LOG_INFO_V0( + LOG_DEBUG( "Config: threads=%d, cores=%d, cores_per_thread=%d", aicpu_thread_num_, cores_total_num_, thread_cores_num ); return true; @@ -833,7 +833,7 @@ int32_t SchedulerContext::pre_handshake_init(Runtime *runtime, int32_t aicpu_thr aiv_count_ = 0; handshake_failed_.store(false, std::memory_order_release); - LOG_INFO_V0("Handshaking with %d cores", cores_total_num_); + LOG_DEBUG("Handshaking with %d cores", cores_total_num_); return 0; } @@ -863,7 +863,7 @@ int32_t SchedulerContext::post_handshake_init(Runtime *runtime) { memcpy(aiv_worker_ids_, local_aiv, static_cast(lv) * sizeof(int32_t)); aic_count_ = la; aiv_count_ = lv; - LOG_INFO_V0("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); + LOG_DEBUG("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); if (!assign_cores_to_threads()) { return -1; diff --git a/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp b/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp index 17fc4738ed..b3bff5e3d1 100644 --- a/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp +++ b/src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp @@ -870,7 +870,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ Handshake *hank = static_cast(runtime->workers); - LOG_INFO_V0("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, core_trackers_[thread_idx].core_num()); + LOG_DEBUG("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, core_trackers_[thread_idx].core_num()); int32_t cur_thread_completed = 0; // Non-zero once a scheduler-hang timeout latches; returned in place of the // completed count so the caller still sees the negative error rc while the @@ -1023,7 +1023,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ if (thread_idx == 0 && task_count > 0) { if (new_total <= PROGRESS_VERBOSE_THRESHOLD || new_total / PROGRESS_LOG_INTERVAL != prev / PROGRESS_LOG_INTERVAL || new_total >= task_count) { - LOG_INFO_V9( + LOG_INFO( "PTO2 progress: completed=%d total=%d (%.1f%%)", new_total, task_count, 100.0 * new_total / task_count ); diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp index 67357a0801..03dd76b986 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp @@ -237,7 +237,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { const bool is_leader = (tidx == 0); if (is_leader) { - LOG_INFO_V0("AicpuExecutor: Initializing"); + LOG_DEBUG("AicpuExecutor: Initializing"); // The 0 → 1 fixup already applied above; derive scheduler count from it. aicpu_thread_num_ = nthreads; sched_thread_num_ = nthreads - 1; @@ -332,7 +332,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { return -1; } init_done_.store(true, std::memory_order_release); - LOG_INFO_V0("AicpuExecutor: Init complete"); + LOG_DEBUG("AicpuExecutor: Init complete"); } else { while (!init_done_.load(std::memory_order_acquire)) { if (init_failed_.load(std::memory_order_acquire)) return -1; @@ -359,7 +359,7 @@ int32_t AicpuExecutor::load_orch_so( // simpler_run launch, but loading now happens in the separate // register_callable launch which has no phase buffer (the run-path SoLoad // slot is simply 0 now that run never loads). - LOG_INFO_V0("Thread %d: New orch SO detected (callable_id=%d), (re)loading", thread_idx, callable_id); + LOG_DEBUG("Thread %d: New orch SO detected (callable_id=%d), (re)loading", thread_idx, callable_id); if (entry.handle != nullptr) { dlclose(entry.handle); } @@ -387,13 +387,13 @@ int32_t AicpuExecutor::load_orch_so( int32_t fd = create_orch_so_file(candidate_dirs[i], callable_id, get_orch_device_id(), so_path, sizeof(so_path)); if (fd < 0) { - LOG_INFO_V0("Thread %d: Cannot create SO at %s (errno=%d), trying next path", thread_idx, so_path, errno); + LOG_DEBUG("Thread %d: Cannot create SO at %s (errno=%d), trying next path", thread_idx, so_path, errno); continue; } ssize_t written = write(fd, so_data, so_size); close(fd); if (written != static_cast(so_size)) { - LOG_INFO_V0("Thread %d: Cannot write SO to %s (errno=%d), trying next path", thread_idx, so_path, errno); + LOG_DEBUG("Thread %d: Cannot write SO to %s (errno=%d), trying next path", thread_idx, so_path, errno); unlink(so_path); continue; } @@ -725,56 +725,56 @@ int32_t AicpuExecutor::run(Runtime *runtime) { uint64_t total = p.sync_cycle + p.alloc_cycle + p.args_cycle + p.lookup_cycle + p.insert_cycle + p.fanin_cycle; if (total == 0) total = 1; // avoid div-by-zero - LOG_INFO_V9( + LOG_INFO( "Thread %d: === Orchestrator Profiling: %" PRId64 " tasks, total=%.3fus ===", thread_idx, static_cast(p.submit_count), cycles_to_us(total) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: task+heap_alloc: %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(p.alloc_cycle), p.alloc_cycle * 100.0 / total, cycles_to_us(p.alloc_cycle - p.alloc_wait_cycle), cycles_to_us(p.alloc_wait_cycle), static_cast(p.alloc_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: sync_tensormap : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.sync_cycle), p.sync_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: lookup+dep : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.lookup_cycle), p.lookup_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: tensormap_ins : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.insert_cycle), p.insert_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: param_copy : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(p.args_cycle), p.args_cycle * 100.0 / total, static_cast(p.args_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: fanin+ready : %.3fus (%.1f%%) work=%.3fus wait=%.3fus", thread_idx, cycles_to_us(p.fanin_cycle), p.fanin_cycle * 100.0 / total, cycles_to_us(p.fanin_cycle - p.fanin_wait_cycle), cycles_to_us(p.fanin_wait_cycle) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: avg/task : %.3fus", thread_idx, p.submit_count > 0 ? cycles_to_us(total) / p.submit_count : 0.0 ); #if SIMPLER_TENSORMAP_PROFILING PTO2TensorMapProfilingData tp = pto2_tensormap_get_profiling(); - LOG_INFO_V9("Thread %d: === TensorMap Lookup Stats ===", thread_idx); - LOG_INFO_V9( + LOG_INFO("Thread %d: === TensorMap Lookup Stats ===", thread_idx); + LOG_INFO( "Thread %d: lookups : %" PRIu64 ", inserts: %" PRIu64 "", thread_idx, static_cast(tp.lookup_count), static_cast(tp.insert_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: chain walked : total=%" PRIu64 ", avg=%.1f, max=%d", thread_idx, static_cast(tp.lookup_chain_total), tp.lookup_count > 0 ? static_cast(tp.lookup_chain_total) / tp.lookup_count : 0.0, tp.lookup_chain_max ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: overlap checks : %" PRIu64 ", hits=%" PRIu64 " (%.1f%%)", thread_idx, static_cast(tp.overlap_checks), static_cast(tp.overlap_hits), tp.overlap_checks > 0 ? tp.overlap_hits * 100.0 / tp.overlap_checks : 0.0 @@ -785,7 +785,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { // Latch task count from PTO2 shared memory to hand off to the // scheduler. The orchestrator's run window (start_time / end_time / // submit_count) is no longer published to shared memory — the - // device LOG_INFO_V9 "orch_start=… orch_end=… orch_cost=…" line + // device LOG_INFO "orch_start=… orch_end=… orch_cost=…" line // below carries the same envelope info for debugging, and // host-side swimlane derives per-phase timing from the per-event // L2SwimlaneAicpuSchedPhaseRecord[] + L2SwimlaneAicpuOrchPhaseRecord[] @@ -814,20 +814,20 @@ int32_t AicpuExecutor::run(Runtime *runtime) { // per-thread device-log line below is now opt-in deep-dive. aicpu_phase_set_window(AicpuPhase::OrchWindow, static_cast(orch_cycle_start), orch_end_ts); #if SIMPLER_ORCH_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: orch_start=%" PRIu64 " orch_end=%" PRIu64 " orch_cost=%.3fus", thread_idx, static_cast(orch_cycle_start), static_cast(orch_end_ts), cycles_to_us(orch_end_ts - orch_cycle_start) ); if (pto2_submitted_tasks >= 0) { - LOG_INFO_V9( + LOG_INFO( "PTO2 total submitted tasks = %d, already executed %d tasks", pto2_submitted_tasks, sched_ctx_.completed_tasks_count() ); } #endif // SIMPLER_ORCH_PROFILING #endif // SIMPLER_DFX - LOG_INFO_V0("Thread %d: Orchestrator completed", thread_idx); + LOG_DEBUG("Thread %d: Orchestrator completed", thread_idx); } // Scheduler thread (orchestrator thread skips dispatch and exits after orchestration) @@ -848,7 +848,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { LOG_ERROR("Thread %d: Scheduler failed with rc=%d", thread_idx, completed); run_rc = completed; } else { - LOG_INFO_V0("Thread %d: Executed %d tasks from runtime", thread_idx, completed); + LOG_DEBUG("Thread %d: Executed %d tasks from runtime", thread_idx, completed); } } } @@ -861,7 +861,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { run_rc = shutdown_rc; } - LOG_INFO_V0("Thread %d: Completed", thread_idx); + LOG_DEBUG("Thread %d: Completed", thread_idx); // Check if this is the last thread to finish int32_t prev_finished = finished_count_.fetch_add(1, std::memory_order_acq_rel); @@ -917,7 +917,7 @@ void AicpuExecutor::deinit(Runtime *runtime) { // Clear dep_gen file-local bookkeeping. No-op when dep_gen is disabled. dep_gen_aicpu_finalize(); - LOG_INFO_V0("DeInit: Runtime execution state reset"); + LOG_DEBUG("DeInit: Runtime execution state reset"); init_done_.store(false, std::memory_order_release); init_failed_.store(false, std::memory_order_release); @@ -927,7 +927,7 @@ void AicpuExecutor::deinit(Runtime *runtime) { thread_idx_.store(0, std::memory_order_release); finished_.store(false, std::memory_order_release); - LOG_INFO_V0("DeInit: AicpuExecutor reset complete"); + LOG_DEBUG("DeInit: AicpuExecutor reset complete"); } // ===== Public Entry Point ===== @@ -953,7 +953,7 @@ extern "C" __attribute__((visibility("default"))) int simpler_aicpu_register_cal LOG_ERROR("simpler_aicpu_register_callable: SO load failed with rc=%d", rc); return rc; } - LOG_INFO_V0("simpler_aicpu_register_callable: completed for callable_id=%d", args->active_callable_id); + LOG_DEBUG("simpler_aicpu_register_callable: completed for callable_id=%d", args->active_callable_id); return 0; } @@ -977,7 +977,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return -1; } - LOG_INFO_V0("%s", "aicpu_execute: Starting AICPU kernel execution"); + LOG_DEBUG("%s", "aicpu_execute: Starting AICPU kernel execution"); // Each phase is bracketed by its own scope so the start/end boundaries are // visible and an early `return` still records the end via the guard dtor. @@ -1013,7 +1013,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { int32_t runtime_rc = read_pto2_runtime_status(runtime); if (g_aicpu_executor.finished_.load(std::memory_order_acquire)) { AicpuPhaseScope post_orch(AicpuPhase::PostOrch); - LOG_INFO_V0("aicpu_execute: Last thread finished, cleaning up"); + LOG_DEBUG("aicpu_execute: Last thread finished, cleaning up"); g_aicpu_executor.deinit(runtime); } @@ -1026,6 +1026,6 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return rc; } - LOG_INFO_V0("%s", "aicpu_execute: Kernel execution completed successfully"); + LOG_DEBUG("%s", "aicpu_execute: Kernel execution completed successfully"); return 0; } diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md index af661d440f..52596c68c3 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md @@ -2,7 +2,7 @@ ## How to Find Device Logs -AICPU logs (via `LOG_INFO_V9`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: +AICPU logs (via `LOG_INFO`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: ```text $HOME/ascend/log/debug/device-/device-_.log diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md index 3baab75553..5f0c29f59f 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md @@ -90,7 +90,7 @@ Each sub-level macro requires `SIMPLER_DFX=1`: `sched_*` and `Scheduler summary` by `SIMPLER_SCHED_PROFILING` (Level 2). Level 1 only feeds the host-side `Orch` / `Sched` `[STRACE]` timeline. -**LOG_INFO_V9 count (normal run):** +**LOG_INFO count (normal run):** - `0` (device-side profiling logs). The timeline is delivered host-side via the phase windows, not through per-thread device logs. @@ -397,8 +397,8 @@ definitions to runtime headers. > Example: `paged_attention` on Ascend hardware, 2 sched threads + 2 orch threads, normal run (no stall/timeout). -| Level | Macro Settings | LOG_INFO_V9 Count | Description | -| ----- | -------------- | ----------------- | ----------- | +| Level | Macro Settings | LOG_INFO Count | Description | +| ----- | -------------- | -------------- | ----------- | | 0 | `SIMPLER_DFX=0` | 0 | No timing output | | 1 | `SIMPLER_DFX=1` | 0 | Host-side `Orch`/`Sched` `[STRACE]` windows only; no device logs | | 2 | `+SIMPLER_SCHED_PROFILING=1` | per sched thread | `sched_start` + phase breakdown + `Scheduler summary` | diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp index d416931e3b..83c70e5f7b 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp @@ -455,7 +455,7 @@ dep_gen_replay_emit_deps_json(const DepGenRecord *records, size_t num_records, c LOG_ERROR("dep_gen replay: num_records=%zu but records pointer is null", num_records); return -1; } - LOG_INFO_V0("dep_gen replay: processing %zu in-memory records (dual-pass)", num_records); + LOG_DEBUG("dep_gen replay: processing %zu in-memory records (dual-pass)", num_records); // Per-ring task window sizes — tensormap masks slot indices and requires // each to be a power of two. Auto-size from the records themselves so each @@ -782,7 +782,7 @@ dep_gen_replay_emit_deps_json(const DepGenRecord *records, size_t num_records, c if (!write_deps_json(deps_json_path, task_table, tensor_table, annot_edges)) { return -5; } - LOG_INFO_V0( + LOG_DEBUG( "dep_gen replay: wrote deps.json to %s (tasks=%zu, tensors=%zu, edges=%zu)", deps_json_path, task_table.size(), tensor_table.size(), annot_edges.size() ); diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp index c7ce87c6c4..72f7fd4e71 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp @@ -414,7 +414,7 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const *out = CallableArtifacts{}; out->signature.assign(callable->signature_, callable->signature_ + callable->sig_count()); - LOG_INFO_V0("Registering %d kernel(s) in register_callable_impl", callable->child_count()); + LOG_DEBUG("Registering %d kernel(s) in register_callable_impl", callable->child_count()); if (upload_and_collect_child_addrs( callable, upload_fn, &out->kernel_addrs, &out->chip_buffer_dev, &out->chip_buffer_hash ) != 0) { @@ -440,7 +440,7 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const out->orch_so_size = orch_so_size; out->func_name = callable->func_name(); out->config_name = callable->config_name(); - LOG_INFO_V0("Orchestration SO: %zu bytes staged (host-only)", orch_so_size); + LOG_DEBUG("Orchestration SO: %zu bytes staged (host-only)", orch_so_size); return 0; } @@ -516,7 +516,7 @@ static bool resolve_arena_sizing( const std::string task_window_log = format_ring_array(out->task_window_sizes); const std::string heap_log = format_ring_array(out->heap_sizes); const std::string dep_pool_log = format_ring_array(out->dep_pool_capacities); - LOG_INFO_V0( + LOG_DEBUG( "Ring buffer sizes: task_window=%s heap=%s dep_pool=%s", task_window_log.c_str(), heap_log.c_str(), dep_pool_log.c_str() ); @@ -620,7 +620,7 @@ static bool stage_device_args( out->add_scalar(orch_args->scalar(i)); } int64_t t_args_end = _now_ms(); - LOG_INFO_V0("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); + LOG_DEBUG("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); return true; } @@ -631,7 +631,7 @@ static void apply_orch_sched_env_flags(Runtime *runtime) { const char *serial_env = std::getenv("SIMPLER_TMR_SERIAL_ORCH_SCHED_ENABLE"); runtime->dev.serial_orch_sched = serial_env && (serial_env[0] == '1' || serial_env[0] == 't' || serial_env[0] == 'T'); - LOG_INFO_V0( + LOG_DEBUG( "Serial orchestrator-to-scheduler start gate: %s", runtime->dev.serial_orch_sched ? "enabled" : "disabled" ); } @@ -678,9 +678,9 @@ static bool ensure_static_arenas( return false; } - LOG_INFO_V0("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); - LOG_INFO_V0("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); - LOG_INFO_V0("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); + LOG_DEBUG("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); + LOG_DEBUG("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); + LOG_DEBUG("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); return true; } @@ -858,7 +858,7 @@ extern "C" int bind_callable_to_runtime_impl( int tensor_count = orch_args->tensor_count(); int scalar_count = orch_args->scalar_count(); - LOG_INFO_V0("RT2 bind: %d tensors + %d scalars, device orchestration mode", tensor_count, scalar_count); + LOG_DEBUG("RT2 bind: %d tensors + %d scalars, device orchestration mode", tensor_count, scalar_count); runtime->tensor_leases_.clear(); int64_t t_total_start = _now_ms(); @@ -920,11 +920,11 @@ extern "C" int bind_callable_to_runtime_impl( } int64_t t_prebuilt_end = _now_ms(); - LOG_INFO_V0("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); + LOG_DEBUG("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); int64_t t_total_end = _now_ms(); - LOG_INFO_V0("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); - LOG_INFO_V0("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); + LOG_DEBUG("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); + LOG_DEBUG("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); bind_cleanup.dismiss(); return 0; @@ -980,13 +980,13 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e int rc = 0; - LOG_INFO_V0("=== Copying Results Back to Host ==="); + LOG_DEBUG("=== Copying Results Back to Host ==="); // Copy all recorded tensors from device back to host TensorLease *tensor_leases = runtime->tensor_leases_.data(); int tensor_lease_count = static_cast(runtime->tensor_leases_.size()); - LOG_INFO_V0("Tensor leases to process: %d", tensor_lease_count); + LOG_DEBUG("Tensor leases to process: %d", tensor_lease_count); bool skip_tensor_copy_back = execution_rc != 0; int32_t runtime_status = 0; @@ -1057,10 +1057,10 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e } // Cleanup device tensors - LOG_INFO_V0("=== Cleaning Up ==="); + LOG_DEBUG("=== Cleaning Up ==="); release_tensor_leases(runtime, api); - LOG_INFO_V0("=== Finalize Complete ==="); + LOG_DEBUG("=== Finalize Complete ==="); if (rc == 0 && runtime_status != 0) { rc = runtime_status; diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h b/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h index 0eb0d4ad62..92171d11e4 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h @@ -74,9 +74,9 @@ typedef struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. @@ -259,20 +259,10 @@ static inline bool rt_is_fatal() { #define LOG_ERROR(fmt, ...) current_runtime()->ops->log_error(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) current_runtime()->ops->log_warn(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_TIMING(fmt, ...) current_runtime()->ops->log_timing(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) current_runtime()->ops->log_info(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) current_runtime()->ops->log_debug(__FUNCTION__, fmt, ##__VA_ARGS__) -// INFO verbosity tiers. v=0 most verbose, v=9 must-see, v=5 default. -#define LOG_INFO_V0(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 0, fmt, ##__VA_ARGS__) -#define LOG_INFO_V1(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 1, fmt, ##__VA_ARGS__) -#define LOG_INFO_V2(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 2, fmt, ##__VA_ARGS__) -#define LOG_INFO_V3(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 3, fmt, ##__VA_ARGS__) -#define LOG_INFO_V4(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 4, fmt, ##__VA_ARGS__) -#define LOG_INFO_V5(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 5, fmt, ##__VA_ARGS__) -#define LOG_INFO_V6(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 6, fmt, ##__VA_ARGS__) -#define LOG_INFO_V7(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 7, fmt, ##__VA_ARGS__) -#define LOG_INFO_V8(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 8, fmt, ##__VA_ARGS__) -#define LOG_INFO_V9(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 9, fmt, ##__VA_ARGS__) - // ============================================================================= // Cross-Layer Data Access // ============================================================================= diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp index 4ce048dfcc..d6780ff84d 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp @@ -270,8 +270,9 @@ static const PTO2RuntimeOps s_runtime_ops = { .report_fatal = rt_report_fatal, .log_error = unified_log_error, .log_warn = unified_log_warn, + .log_timing = unified_log_timing, + .log_info = unified_log_info, .log_debug = unified_log_debug, - .log_info_v = unified_log_info_v, .get_tensor_data = get_tensor_data, .set_tensor_data = set_tensor_data, .alloc_tensors = alloc_tensors_impl, diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h index cb5f2b3178..f4ed273e50 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h @@ -77,9 +77,9 @@ struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp index cb8c96f085..04e9bd1cb0 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp @@ -85,7 +85,7 @@ LoopAction SchedulerContext::handle_orchestrator_exit( task_count = total_tasks_; if (task_count > 0 && completed_tasks_.load(std::memory_order_relaxed) >= task_count) { completed_.store(true, std::memory_order_release); - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: PTO2 completed tasks %d/%d", thread_idx, completed_tasks_.load(std::memory_order_relaxed), task_count ); @@ -277,7 +277,7 @@ void SchedulerContext::log_stall_diagnostics( if (is_running) { cnt_running++; if (cnt_running > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=RUNNING fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] " "running_on=[owner_thread=%d cores=[%s]]", @@ -288,7 +288,7 @@ void SchedulerContext::log_stall_diagnostics( if (rc >= fi) { cnt_ready++; if (cnt_ready > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=READY fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d]", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1 @@ -297,7 +297,7 @@ void SchedulerContext::log_stall_diagnostics( } cnt_waiting++; if (cnt_waiting > STALL_DUMP_WAIT_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=WAIT fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] missing_deps=%d", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1, fi - rc @@ -306,7 +306,7 @@ void SchedulerContext::log_stall_diagnostics( } int32_t effective_total = task_count > 0 ? task_count : submitted_in_ring; int32_t c = completed_tasks_.load(std::memory_order_relaxed); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] SUMMARY completed=%d/%d last_progress_iteration=%d " "scan_ready=%d scan_waiting=%d scan_running=%d", thread_idx, idle_iterations, c, effective_total, last_progress_count, cnt_ready, cnt_waiting, cnt_running @@ -338,7 +338,7 @@ void SchedulerContext::log_stall_diagnostics( aiv1_buf, sizeof(aiv1_buf), aiv1_id, aiv1_idle, &core_exec_states_[aiv1_id], core_exec_states_[aiv1_id].reg_addr ); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] CLUSTER cluster_id=%d aic=%s aiv0=%s aiv1=%s", thread_idx, idle_iterations, cluster_id, aic_buf, aiv0_buf, aiv1_buf ); @@ -480,7 +480,7 @@ int32_t SchedulerContext::handle_timeout_exit( AicpuPhase::SchedWindow, static_cast(sched_start_ts), static_cast(sched_timeout_ts) ); #if SIMPLER_SCHED_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end(timeout)=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(sched_start_ts), static_cast(sched_timeout_ts), cycles_to_us(sched_timeout_ts - sched_start_ts) @@ -501,7 +501,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse AicpuPhase::SchedWindow, static_cast(l2_swimlane.sched_start_ts), static_cast(sched_end_ts) ); #if SIMPLER_SCHED_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(l2_swimlane.sched_start_ts), static_cast(sched_end_ts), cycles_to_us(sched_end_ts - l2_swimlane.sched_start_ts) @@ -524,7 +524,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse l2_swimlane.sched_dispatch_setup_cycle) : 0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: === Scheduler Phase Breakdown: total=%.3fus, %d tasks ===", thread_idx, cycles_to_us(sched_total), cur_thread_completed ); @@ -532,7 +532,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse // fanout / fanin per-thread aggregates live in // sched_overhead_analysis.compute_dag_stats_from_deps (deps.json edges // × core_to_thread). - LOG_INFO_V9( + LOG_INFO( "Thread %d: complete : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle), l2_swimlane.sched_complete_cycle * 100.0 / sched_total ); @@ -544,80 +544,80 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse double complete_hit_rate = l2_swimlane.complete_probe_count > 0 ? l2_swimlane.complete_hit_count * 100.0 / l2_swimlane.complete_probe_count : 0.0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%) hit=%" PRIu64 ", miss=%" PRIu64 ", hit_rate=%.1f%%", thread_idx, cycles_to_us(complete_poll), complete_poll * 100.0 / c_parent, static_cast(l2_swimlane.complete_hit_count), static_cast(complete_miss_count), complete_hit_rate ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_lock : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.lock_cycle), sp.lock_cycle * 100.0 / c_parent, cycles_to_us(sp.lock_cycle - sp.lock_wait_cycle), cycles_to_us(sp.lock_wait_cycle), static_cast(sp.lock_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanout : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanout_cycle), sp.fanout_cycle * 100.0 / c_parent, cycles_to_us(sp.fanout_cycle - sp.push_wait_cycle), cycles_to_us(sp.push_wait_cycle), static_cast(sp.fanout_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanin : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanin_cycle), sp.fanin_cycle * 100.0 / c_parent, static_cast(sp.fanin_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_self : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.self_consumed_cycle), sp.self_consumed_cycle * 100.0 / c_parent, static_cast(sp.self_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: perf : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_perf_cycle), l2_swimlane.sched_complete_perf_cycle * 100.0 / c_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: async_poll : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_async_cycle), l2_swimlane.sched_async_cycle * 100.0 / sched_total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: dispatch : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_cycle), l2_swimlane.sched_dispatch_cycle * 100.0 / sched_total ); uint64_t d_parent = l2_swimlane.sched_dispatch_cycle > 0 ? l2_swimlane.sched_dispatch_cycle : 1; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%)", thread_idx, cycles_to_us(dispatch_poll), dispatch_poll * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: pop : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle), l2_swimlane.sched_dispatch_pop_cycle * 100.0 / d_parent, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle - sp.pop_wait_cycle), cycles_to_us(sp.pop_wait_cycle), static_cast(sp.pop_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: setup : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_setup_cycle), l2_swimlane.sched_dispatch_setup_cycle * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: idle : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_idle_cycle), l2_swimlane.sched_idle_cycle * 100.0 / sched_total ); if (cur_thread_completed > 0) { - LOG_INFO_V9( + LOG_INFO( "Thread %d: avg/complete : %.3fus", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle) / cur_thread_completed ); } } - LOG_INFO_V9( + LOG_INFO( "Thread %d: Scheduler summary: total_time=%.3fus, loops=%" PRIu64 ", tasks_scheduled=%d", thread_idx, cycles_to_us(sched_total), static_cast(l2_swimlane.sched_loop_count), cur_thread_completed ); @@ -641,7 +641,7 @@ int32_t SchedulerContext::shutdown(int32_t thread_idx) { } #endif - LOG_INFO_V0("Thread %d: Shutting down %d cores", thread_idx, core_num); + LOG_DEBUG("Thread %d: Shutting down %d cores", thread_idx, core_num); int32_t rc = 0; for (int32_t i = 0; i < core_num; i++) { int32_t core_id = cores[i]; @@ -999,7 +999,7 @@ bool SchedulerContext::assign_cores_to_threads() { return false; } - LOG_INFO_V0( + LOG_DEBUG( "Assigning cores (round-robin): %d clusters across %d sched threads (%d AIC, %d AIV)", cluster_count, active_sched_threads_, aic_count_, aiv_count_ ); @@ -1037,7 +1037,7 @@ bool SchedulerContext::assign_cores_to_threads() { ); } - LOG_INFO_V0( + LOG_DEBUG( "Config: threads=%d, cores=%d, cores_per_thread=%d", aicpu_thread_num_, cores_total_num_, thread_cores_num ); return true; @@ -1162,7 +1162,7 @@ int32_t SchedulerContext::pre_handshake_init( total_tasks_ = 0; } - LOG_INFO_V0("Handshaking with %d cores", cores_total_num_); + LOG_DEBUG("Handshaking with %d cores", cores_total_num_); return 0; } @@ -1192,7 +1192,7 @@ int32_t SchedulerContext::post_handshake_init(Runtime *runtime) { memcpy(aiv_worker_ids_, local_aiv, static_cast(lv) * sizeof(int32_t)); aic_count_ = la; aiv_count_ = lv; - LOG_INFO_V0("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); + LOG_DEBUG("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); if (!assign_cores_to_threads()) { return -1; diff --git a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp index 00bf111d0c..2266b13114 100644 --- a/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp +++ b/src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp @@ -873,7 +873,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ Handshake *hank = static_cast(runtime->dev.workers); - LOG_INFO_V0("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, core_trackers_[thread_idx].core_num()); + LOG_DEBUG("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, core_trackers_[thread_idx].core_num()); int32_t cur_thread_completed = 0; // Non-zero once a scheduler-hang timeout latches; returned in place of the // completed count so the caller still sees the negative error rc while the @@ -1031,7 +1031,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ if (thread_idx == 0 && task_count > 0) { if (new_total <= PROGRESS_VERBOSE_THRESHOLD || new_total / PROGRESS_LOG_INTERVAL != prev / PROGRESS_LOG_INTERVAL || new_total >= task_count) { - LOG_INFO_V9( + LOG_INFO( "PTO2 progress: completed=%d total=%d (%.1f%%)", new_total, task_count, 100.0 * new_total / task_count ); diff --git a/src/a5/platform/include/common/kernel_args.h b/src/a5/platform/include/common/kernel_args.h index a51dabc64d..8aa106b316 100644 --- a/src/a5/platform/include/common/kernel_args.h +++ b/src/a5/platform/include/common/kernel_args.h @@ -130,8 +130,7 @@ static_assert(offsetof(KernelArgs, regs) == 8, "KernelArgs::regs offset drift"); */ struct InitArgs { uint32_t device_id{0}; // ACL device ordinal -> set_orch_device_id - uint32_t log_level{1}; // Severity floor: 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR, 4=NUL - uint32_t log_info_v{5}; // INFO verbosity threshold (0..9); default V5 + uint32_t log_level{25}; // Threshold: DEBUG=10, INFO=20, TIMING=25, WARN=30, ERROR=40, NUL=60 int32_t scheduler_timeout_ms{0}; // AICPU no-progress watchdog (ms); 0 -> compile default // Per-engine async-DMA workspace dev addrs -> set_dma_workspace_addr(kind, .); // indexed by DmaWorkspaceKind; 0 = that engine unavailable. diff --git a/src/a5/platform/include/host/pmu_collector.h b/src/a5/platform/include/host/pmu_collector.h index 4243376be5..1ffcd6be1d 100644 --- a/src/a5/platform/include/host/pmu_collector.h +++ b/src/a5/platform/include/host/pmu_collector.h @@ -349,7 +349,7 @@ inline PmuEventType resolve_pmu_event_type(int requested_event_type) { int val = std::atoi(pmu_env); if (val > 0 && pmu_resolve_event_config_a5(static_cast(val)) != nullptr) { resolved = static_cast(val); - LOG_INFO_V0("PMU event type set to %u from SIMPLER_PMU_EVENT_TYPE", static_cast(resolved)); + LOG_DEBUG("PMU event type set to %u from SIMPLER_PMU_EVENT_TYPE", static_cast(resolved)); return resolved; } LOG_WARN("Invalid SIMPLER_PMU_EVENT_TYPE=%s, using default (PIPE_UTILIZATION=%u)", pmu_env, PMU_EVENT_TYPE_DEFAULT); diff --git a/src/a5/platform/onboard/aicpu/kernel.cpp b/src/a5/platform/onboard/aicpu/kernel.cpp index baa73def97..07853805f3 100644 --- a/src/a5/platform/onboard/aicpu/kernel.cpp +++ b/src/a5/platform/onboard/aicpu/kernel.cpp @@ -155,7 +155,6 @@ extern "C" __attribute__((visibility("default"))) int simpler_aicpu_init(void *a InitArgs *init_args = reinterpret_cast(arg); set_log_level(static_cast(init_args->log_level)); - set_log_info_v(static_cast(init_args->log_info_v)); set_orch_device_id(static_cast(init_args->device_id)); set_scheduler_timeout_ms(static_cast(init_args->scheduler_timeout_ms)); for (int k = 0; k < DMA_WORKSPACE_KIND_COUNT; ++k) { diff --git a/src/a5/platform/onboard/host/aicpu_topology_probe.cpp b/src/a5/platform/onboard/host/aicpu_topology_probe.cpp index b2f4e22ad5..12df93790f 100644 --- a/src/a5/platform/onboard/host/aicpu_topology_probe.cpp +++ b/src/a5/platform/onboard/host/aicpu_topology_probe.cpp @@ -190,7 +190,7 @@ bool probe_aicpu_topology(uint32_t device_id, std::vector &out_ return false; } - LOG_INFO_V0("AICPU topology probed for device %u: %zu user-schedulable cpu_ids (cached)", device_id, probed.size()); + LOG_DEBUG("AICPU topology probed for device %u: %zu user-schedulable cpu_ids (cached)", device_id, probed.size()); { std::lock_guard lk(s_topo_cache_mu); diff --git a/src/a5/platform/onboard/host/comm_hccl.cpp b/src/a5/platform/onboard/host/comm_hccl.cpp index 8cf6734ac2..bc830c99cb 100644 --- a/src/a5/platform/onboard/host/comm_hccl.cpp +++ b/src/a5/platform/onboard/host/comm_hccl.cpp @@ -205,7 +205,7 @@ wait_for_rootinfo(const std::string &path, HcclRootInfo *root_info, uint64_t *ru return true; } if (i > 0 && i % (kLogEverySec * 10) == 0) { - LOG_INFO_V0("[comm] wait_for_rootinfo: still waiting (%ds elapsed) path=%s", i / 10, path.c_str()); + LOG_DEBUG("[comm] wait_for_rootinfo: still waiting (%ds elapsed) path=%s", i / 10, path.c_str()); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/a5/platform/onboard/host/device_runner.cpp b/src/a5/platform/onboard/host/device_runner.cpp index fd3193d7b3..d8a758c973 100644 --- a/src/a5/platform/onboard/host/device_runner.cpp +++ b/src/a5/platform/onboard/host/device_runner.cpp @@ -256,7 +256,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { dump += std::to_string(allowed[i]); if (i + 1 == allowed.size()) dump += "(orch)"; } - LOG_INFO_V0( + LOG_DEBUG( "AICPU ALLOWED_CPUS = [%s] (n_sched=%d, n_orch=%d, launch=%d, user_cpus=%zu)", dump.c_str(), n_sched, n_orch, launch_n, user_cpus.size() ); @@ -385,7 +385,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { } } - LOG_INFO_V0("=== launch_aicore_kernel ==="); + LOG_DEBUG("=== launch_aicore_kernel ==="); rc = kernel_args_.init_device_kernel_args(mem_alloc_); if (rc != 0) { LOG_ERROR("init_device_kernel_args failed: %d", rc); @@ -398,7 +398,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { return rc; } - LOG_INFO_V0("=== launch_aicpu_kernel %s ===", host::KernelNames::RunName); + LOG_DEBUG("=== launch_aicpu_kernel %s ===", host::KernelNames::RunName); // launch_count = popcount(OCCUPY) from the topology probe — one thread // per user-schedulable cpu_id. The filter gate barriers exactly this // many threads (runtime.aicpu_launch_count is read on the device side diff --git a/src/a5/platform/shared/host/pmu_collector.cpp b/src/a5/platform/shared/host/pmu_collector.cpp index 835fece4d1..f582e93501 100644 --- a/src/a5/platform/shared/host/pmu_collector.cpp +++ b/src/a5/platform/shared/host/pmu_collector.cpp @@ -229,7 +229,7 @@ int PmuCollector::init( csv_header_ = std::move(header); } - LOG_INFO_V0( + LOG_DEBUG( "PMU collector initialized: %d cores, %d threads, SHM=0x%lx, CSV=%s (opened on first record)", num_cores, num_threads, reinterpret_cast(shm_dev_local), csv_path_.c_str() ); @@ -558,7 +558,7 @@ void PmuCollector::reconcile_counters() { static_cast(total_device) - static_cast(accounted) ); } else { - LOG_INFO_V0( + LOG_DEBUG( "PMU reconcile: record counts match (collected=%lu, dropped=%lu, mismatch=%lu, device_total=%lu)", static_cast(collected), static_cast(dropped_device), static_cast(mismatch_device), static_cast(total_device) diff --git a/src/a5/platform/sim/host/device_runner.cpp b/src/a5/platform/sim/host/device_runner.cpp index 1ace457e95..eb3a3d48ae 100644 --- a/src/a5/platform/sim/host/device_runner.cpp +++ b/src/a5/platform/sim/host/device_runner.cpp @@ -38,6 +38,7 @@ #include "common/platform_config.h" #include "common/unified_log.h" #include "cpu_sim_context.h" +#include "host_log.h" #include "host/raii_scope_guard.h" #include "host/runtime_timeout_config.h" #include "runtime.h" @@ -140,12 +141,15 @@ int DeviceRunner::ensure_binaries_loaded() { if (!load_sym("set_platform_scope_stats_base", reinterpret_cast(&set_platform_scope_stats_base_func_))) return -1; - // Log config travels via the RTLD_GLOBAL HostLogger singleton in - // libsimpler_log.so — already seeded by simpler_log_init() before the - // AICPU sim SO was dlopen'd, so no per-SO setter forwarding is needed. + // The AICPU sim SO owns its level flags because it is RTLD_LOCAL. + // Forward the process-wide HostLogger threshold explicitly. + using SetLogLevelFunc = void (*)(int); + SetLogLevelFunc set_log_level_func = nullptr; + if (!load_sym("set_log_level", reinterpret_cast(&set_log_level_func))) return -1; + set_log_level_func(HostLogger::get_instance().level()); aicpu_so_loaded_ = true; - LOG_INFO_V0("DeviceRunner(sim): Loaded aicpu_execute from %s", aicpu_so_path_.c_str()); + LOG_DEBUG("DeviceRunner(sim): Loaded aicpu_execute from %s", aicpu_so_path_.c_str()); } // AICore kernel .so: reload every run — kernel binary varies per case. @@ -181,7 +185,7 @@ int DeviceRunner::ensure_binaries_loaded() { LOG_ERROR("dlsym failed for aicore_execute_wrapper: %s", dlerror()); return -1; } - LOG_INFO_V0("DeviceRunner(sim): Loaded aicore_execute_wrapper from %s", aicore_so_path_.c_str()); + LOG_DEBUG("DeviceRunner(sim): Loaded aicore_execute_wrapper from %s", aicore_so_path_.c_str()); auto set_identity_helpers = reinterpret_cast(dlsym(aicore_so_handle_, "set_sim_core_identity_helpers")); @@ -409,7 +413,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { } constexpr int over_launch = PLATFORM_MAX_AICPU_THREADS_JUST_FOR_LAUNCH; - LOG_INFO_V0("Launching %d AICPU threads (logical=%d)", over_launch, launch_aicpu_num); + LOG_DEBUG("Launching %d AICPU threads (logical=%d)", over_launch, launch_aicpu_num); std::vector aicpu_threads; aicpu_threads.reserve(over_launch); std::atomic aicpu_rc{0}; @@ -456,7 +460,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { })); } - LOG_INFO_V0("Launching %d AICore thread(s)", num_aicore); + LOG_DEBUG("Launching %d AICore thread(s)", num_aicore); std::vector aicore_threads; for (int i = 0; i < num_aicore; i++) { CoreType core_type = runtime.get_workers()[i].core_type; @@ -476,7 +480,7 @@ int DeviceRunner::run(Runtime &runtime, const CallConfig &config) { t.join(); } - LOG_INFO_V0("All threads completed"); + LOG_DEBUG("All threads completed"); device_wall_ns_ = 0; if (device_wall_dev_ptr_ != nullptr) { diff --git a/src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cpp b/src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cpp index 6a395bfddf..f01601bc61 100644 --- a/src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cpp +++ b/src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cpp @@ -256,7 +256,7 @@ inline bool AicpuExecutor::try_dispatch_task( ready_count--; const char *core_type_str = (core_type == CoreType::AIC) ? "AIC" : "AIV"; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Dispatching %s task %d to core %d (running_id=%d)", thread_idx, core_type_str, task_id, core_id, running_task_ids_[core_id] ); @@ -326,7 +326,7 @@ int AicpuExecutor::init(Runtime *runtime) { return 0; } - LOG_INFO_V0("AicpuExecutor: Initializing"); + LOG_DEBUG("AicpuExecutor: Initializing"); if (runtime == nullptr) { LOG_ERROR("runtime is nullptr"); @@ -358,7 +358,7 @@ int AicpuExecutor::init(Runtime *runtime) { return -1; } - LOG_INFO_V0("Config: threads=%d, cores=%d", aicpu_thread_num_, cores_total_num_); + LOG_DEBUG("Config: threads=%d, cores=%d", aicpu_thread_num_, cores_total_num_); for (int i = 0; i < cores_total_num_; i++) { pending_task_ids_[i] = AICPU_TASK_INVALID; @@ -385,12 +385,12 @@ int AicpuExecutor::init(Runtime *runtime) { } if (is_pmu_enabled()) { pmu_aicpu_init(physical_core_ids_, cores_total_num_); - LOG_INFO_V0("PMU profiling started on %d cores", cores_total_num_); + LOG_DEBUG("PMU profiling started on %d cores", cores_total_num_); } #endif init_done_.store(true, std::memory_order_release); - LOG_INFO_V0("AicpuExecutor: Init complete"); + LOG_DEBUG("AicpuExecutor: Init complete"); return 0; } @@ -423,7 +423,7 @@ int AicpuExecutor::handshake_all_cores(Runtime *runtime) { aic_count_ = 0; aiv_count_ = 0; - LOG_INFO_V0("Core Discovery: Handshaking with %d cores", cores_total_num_); + LOG_DEBUG("Core Discovery: Handshaking with %d cores", cores_total_num_); // Step 1: Send handshake signal to all cores for (int i = 0; i < cores_total_num_; i++) { @@ -493,7 +493,7 @@ int AicpuExecutor::handshake_all_cores(Runtime *runtime) { physical_core_ids_[i] = physical_core_id; #endif - LOG_INFO_V0( + LOG_DEBUG( " Core %d: type=%s, physical_id=%u, reg_addr=0x%lx", i, core_type_to_string(type), physical_core_id, reg_addr ); @@ -504,7 +504,7 @@ int AicpuExecutor::handshake_all_cores(Runtime *runtime) { return -1; } - LOG_INFO_V0("Discovery complete: AIC=%d, AIV=%d, Total=%d", aic_count_, aiv_count_, cores_total_num_); + LOG_DEBUG("Discovery complete: AIC=%d, AIV=%d, Total=%d", aic_count_, aiv_count_, cores_total_num_); return 0; } @@ -516,7 +516,7 @@ void AicpuExecutor::assign_cores_to_threads() { aic_per_thread_ = (aic_count_ + aicpu_thread_num_ - 1) / aicpu_thread_num_; aiv_per_thread_ = (aiv_count_ + aicpu_thread_num_ - 1) / aicpu_thread_num_; - LOG_INFO_V0( + LOG_DEBUG( "Core Assignment: %d AIC cores, %d AIV cores across %d threads (max %d AIC/thread, %d AIV/thread)", aic_count_, aiv_count_, aicpu_thread_num_, aic_per_thread_, aiv_per_thread_ ); @@ -557,7 +557,7 @@ void AicpuExecutor::assign_cores_to_threads() { offset += snprintf(log_buffer + offset, sizeof(log_buffer) - offset, "]"); - LOG_INFO_V0("%s", log_buffer); + LOG_DEBUG("%s", log_buffer); } } @@ -599,7 +599,7 @@ void AicpuExecutor::classify_and_distribute_initial_tasks(Runtime *runtime) { cur_ready_queue_aiv_[thread_idx][*tail_ptr] = task_id; } *tail_ptr = (*tail_ptr + 1) % MAX_CORES_PER_THREAD; - LOG_INFO_V0( + LOG_DEBUG( "Init: %s task %d -> Thread %d local queue (size=%d)", core_type == CoreType::AIC ? "AIC" : "AIV", task_id, thread_idx, cur_size + 1 ); @@ -633,16 +633,16 @@ void AicpuExecutor::classify_and_distribute_initial_tasks(Runtime *runtime) { } } - LOG_INFO_V0("Init: Found %d initially ready tasks", initial_count); - LOG_INFO_V0("Init: Initial ready tasks by type: AIC=%d, AIV=%d", initial_aic_count, initial_aiv_count); + LOG_DEBUG("Init: Found %d initially ready tasks", initial_count); + LOG_DEBUG("Init: Initial ready tasks by type: AIC=%d, AIV=%d", initial_aic_count, initial_aiv_count); ready_count_aic_.store(aic_shared_count, std::memory_order_release); ready_count_aiv_.store(aiv_shared_count, std::memory_order_release); - LOG_INFO_V0( + LOG_DEBUG( "Init: Task distribution complete - AIC: %d in local queues, %d in shared queue", initial_aic_count - aic_shared_count, aic_shared_count ); - LOG_INFO_V0( + LOG_DEBUG( "Init: Task distribution complete - AIV: %d in local queues, %d in shared queue", initial_aiv_count - aiv_shared_count, aiv_shared_count ); @@ -652,7 +652,7 @@ void AicpuExecutor::classify_and_distribute_initial_tasks(Runtime *runtime) { (cur_ready_queue_aic_tail_[t] - cur_ready_queue_aic_head_[t] + MAX_CORES_PER_THREAD) % MAX_CORES_PER_THREAD; int aiv_size = (cur_ready_queue_aiv_tail_[t] - cur_ready_queue_aiv_head_[t] + MAX_CORES_PER_THREAD) % MAX_CORES_PER_THREAD; - LOG_INFO_V0("Init: Thread %d local queues - AIC: %d tasks, AIV: %d tasks", t, aic_size, aiv_size); + LOG_DEBUG("Init: Thread %d local queues - AIC: %d tasks, AIV: %d tasks", t, aic_size, aiv_size); } } @@ -662,12 +662,12 @@ void AicpuExecutor::classify_and_distribute_initial_tasks(Runtime *runtime) { int AicpuExecutor::shutdown_aicore(Runtime *runtime, int thread_idx, const int *cur_thread_cores) { Handshake *all_handshakes = reinterpret_cast(runtime->workers); - LOG_INFO_V0("Thread %d: Shutting down %d cores", thread_idx, thread_cores_num_[thread_idx]); + LOG_DEBUG("Thread %d: Shutting down %d cores", thread_idx, thread_cores_num_[thread_idx]); for (int i = 0; i < thread_cores_num_[thread_idx]; i++) { int core_id = cur_thread_cores[i]; Handshake *hank = &all_handshakes[core_id]; - LOG_INFO_V0("Thread %d: AICPU hank addr = 0x%lx", thread_idx, reinterpret_cast(hank)); + LOG_DEBUG("Thread %d: AICPU hank addr = 0x%lx", thread_idx, reinterpret_cast(hank)); uint64_t reg_addr = core_id_to_reg_addr_[core_id]; if (reg_addr != 0) { @@ -676,7 +676,7 @@ int AicpuExecutor::shutdown_aicore(Runtime *runtime, int thread_idx, const int * LOG_ERROR("Thread %d: Core %d has invalid register address", thread_idx, core_id); } } - LOG_INFO_V0("Thread %d: Shutdown complete", thread_idx); + LOG_DEBUG("Thread %d: Shutdown complete", thread_idx); return 0; } @@ -697,7 +697,7 @@ static inline void fold_task_finish(Runtime &runtime, int task_id, int thread_id int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const int *cur_thread_cores, int core_num) { Handshake *hank = reinterpret_cast(runtime.workers); - LOG_INFO_V0("Thread %d: Starting execution with %d cores", thread_idx, core_num); + LOG_DEBUG("Thread %d: Starting execution with %d cores", thread_idx, core_num); int cur_thread_completed = 0; int task_count = total_tasks_.load(std::memory_order_acquire); @@ -728,7 +728,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const int cur_aic_ready_count = (cur_aic_tail - cur_aic_head + MAX_CORES_PER_THREAD) % MAX_CORES_PER_THREAD; int cur_aiv_ready_count = (cur_aiv_tail - cur_aiv_head + MAX_CORES_PER_THREAD) % MAX_CORES_PER_THREAD; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Initial state - local queue: %d AIC, %d AIV", thread_idx, cur_aic_ready_count, cur_aiv_ready_count ); @@ -759,7 +759,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const // Case 1: Pending task finished directly if (reg_task_id == pending_task_ids_[core_id] && reg_state == TASK_FIN_STATE) { - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Core %d completed task %d (running_id=%d)", thread_idx, core_id, pending_task_ids_[core_id], running_task_ids_[core_id] ); @@ -845,9 +845,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const cur_aic_tail, cur_aic_ready_count, cur_ready_queue_aiv, cur_aiv_tail, cur_aiv_ready_count ); - LOG_INFO_V0( - "Thread %d: Core %d resolved old running task %d", thread_idx, core_id, prev_running_id - ); + LOG_DEBUG("Thread %d: Core %d resolved old running task %d", thread_idx, core_id, prev_running_id); } Task *task = runtime.get_task(completed_task_id); @@ -864,7 +862,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const } } else if (reg_task_id == pending_task_ids_[core_id] && reg_state == TASK_ACK_STATE) { // Case 2: Pending task received ACK - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Core %d ACKed task %d (running_id=%d)", thread_idx, core_id, pending_task_ids_[core_id], running_task_ids_[core_id] ); @@ -911,16 +909,14 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const cur_aic_tail, cur_aic_ready_count, cur_ready_queue_aiv, cur_aiv_tail, cur_aiv_ready_count ); - LOG_INFO_V0( - "Thread %d: Core %d resolved old running task %d", thread_idx, core_id, prev_running_id - ); + LOG_DEBUG("Thread %d: Core %d resolved old running task %d", thread_idx, core_id, prev_running_id); } // Core can accept new task now (pipeline!) // Continue to Case 4 to dispatch next task } else if (reg_task_id == running_task_ids_[core_id] && reg_state == TASK_FIN_STATE) { // Case 3: Running task finished - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Core %d completed task %d (pending_id=%d)", thread_idx, core_id, running_task_ids_[core_id], pending_task_ids_[core_id] ); @@ -1015,7 +1011,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const ready_count_aic_.fetch_sub(to_grab, std::memory_order_release); cur_aic_ready_count += to_grab; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Grabbed %d AIC tasks from shared queue (available=%d)", thread_idx, to_grab, available ); } @@ -1036,7 +1032,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const ready_count_aiv_.fetch_sub(to_grab, std::memory_order_release); cur_aiv_ready_count += to_grab; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Grabbed %d AIV tasks from shared queue (available=%d)", thread_idx, to_grab, available ); } @@ -1113,7 +1109,7 @@ int AicpuExecutor::resolve_and_dispatch(Runtime &runtime, int thread_idx, const made_progress = false; } - LOG_INFO_V0("Thread %d: Execution complete, completed %d tasks", thread_idx, cur_thread_completed); + LOG_DEBUG("Thread %d: Execution complete, completed %d tasks", thread_idx, cur_thread_completed); return cur_thread_completed; } @@ -1127,13 +1123,13 @@ int AicpuExecutor::run(Runtime *runtime) { int affinity_exec_idx = platform_aicpu_affinity_thread_idx(); int thread_idx = (affinity_exec_idx >= 0) ? affinity_exec_idx : (thread_idx_++); - LOG_INFO_V0("Thread %d: Start (exec_idx=%d)", thread_idx, affinity_exec_idx); + LOG_DEBUG("Thread %d: Start (exec_idx=%d)", thread_idx, affinity_exec_idx); const int *cur_thread_cores = core_assignments_[thread_idx]; - LOG_INFO_V0("Thread %d: Runtime has %d tasks", thread_idx, runtime->get_task_count()); + LOG_DEBUG("Thread %d: Runtime has %d tasks", thread_idx, runtime->get_task_count()); int completed = resolve_and_dispatch(*runtime, thread_idx, cur_thread_cores, thread_cores_num_[thread_idx]); - LOG_INFO_V0("Thread %d: Executed %d tasks from runtime", thread_idx, completed); + LOG_DEBUG("Thread %d: Executed %d tasks from runtime", thread_idx, completed); // Flush performance buffers for cores managed by this thread. if (is_l2_swimlane_enabled()) { @@ -1160,12 +1156,12 @@ int AicpuExecutor::run(Runtime *runtime) { return rc; } - LOG_INFO_V0("Thread %d: Completed", thread_idx); + LOG_DEBUG("Thread %d: Completed", thread_idx); int prev_finished = finished_count_.fetch_add(1, std::memory_order_acq_rel); if (prev_finished + 1 == aicpu_thread_num_) { finished_.store(true, std::memory_order_release); - LOG_INFO_V0("Thread %d: Last thread, marking executor finished", thread_idx); + LOG_DEBUG("Thread %d: Last thread, marking executor finished", thread_idx); } return 0; @@ -1218,7 +1214,7 @@ void AicpuExecutor::deinit(Runtime * /*runtime*/) { thread_idx_.store(0, std::memory_order_release); finished_.store(false, std::memory_order_release); - LOG_INFO_V0("DeInit: AicpuExecutor reset complete"); + LOG_DEBUG("DeInit: AicpuExecutor reset complete"); } void AicpuExecutor::emergency_shutdown(Runtime *runtime) { @@ -1353,7 +1349,7 @@ extern "C" int aicpu_execute(Runtime *runtime) { return -1; } - LOG_INFO_V0("%s", "aicpu_execute: Starting AICPU kernel execution"); + LOG_DEBUG("%s", "aicpu_execute: Starting AICPU kernel execution"); // Get platform register addresses from platform-level global g_aicpu_executor.regs_ = get_platform_regs(); @@ -1375,10 +1371,10 @@ extern "C" int aicpu_execute(Runtime *runtime) { // Last thread cleans up if (g_aicpu_executor.finished_.load(std::memory_order_acquire)) { - LOG_INFO_V0("aicpu_execute: Last thread finished, cleaning up"); + LOG_DEBUG("aicpu_execute: Last thread finished, cleaning up"); g_aicpu_executor.deinit(runtime); } - LOG_INFO_V0("%s", "aicpu_execute: Kernel execution completed successfully"); + LOG_DEBUG("%s", "aicpu_execute: Kernel execution completed successfully"); return 0; } diff --git a/src/a5/runtime/host_build_graph/host/runtime_maker.cpp b/src/a5/runtime/host_build_graph/host/runtime_maker.cpp index e3b55486aa..c05476ea8b 100644 --- a/src/a5/runtime/host_build_graph/host/runtime_maker.cpp +++ b/src/a5/runtime/host_build_graph/host/runtime_maker.cpp @@ -262,7 +262,7 @@ int upload_tensor_info_storage(Runtime *runtime, const HostApi *api, const Tenso } runtime->set_tensor_info_storage(dev_tensor_info_storage, tensor_info_bytes); - LOG_INFO_V0("Uploaded %zu tensor info entries (%zu bytes)", compact_tensor_info.size(), tensor_info_bytes); + LOG_DEBUG("Uploaded %zu tensor info entries (%zu bytes)", compact_tensor_info.size(), tensor_info_bytes); return 0; } @@ -289,7 +289,7 @@ int upload_tensor_allocation_storage(Runtime *runtime, const HostApi *api, const runtime->set_tensor_allocation_storage( dev_allocation_storage, static_cast(builder.allocations.size()), allocation_bytes ); - LOG_INFO_V0("Uploaded %zu tensor allocation ranges (%zu bytes)", builder.allocations.size(), allocation_bytes); + LOG_DEBUG("Uploaded %zu tensor allocation ranges (%zu bytes)", builder.allocations.size(), allocation_bytes); return 0; } @@ -320,7 +320,7 @@ int register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(c *out = CallableArtifacts{}; out->signature.assign(callable->signature_, callable->signature_ + callable->sig_count()); - LOG_INFO_V0("Registering %d kernel(s) in register_callable_impl", callable->child_count()); + LOG_DEBUG("Registering %d kernel(s) in register_callable_impl", callable->child_count()); if (upload_and_collect_child_addrs( callable, upload_fn, &out->kernel_addrs, &out->chip_buffer_dev, &out->chip_buffer_hash ) != 0) { @@ -368,7 +368,7 @@ int register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(c return -1; } - LOG_INFO_V0("Loaded orchestration function: %s", orch_func_name); + LOG_DEBUG("Loaded orchestration function: %s", orch_func_name); out->host_dlopen_handle = handle; out->host_orch_func_ptr = reinterpret_cast(orch_func); @@ -406,7 +406,7 @@ int bind_callable_to_runtime_impl( runtime->tensor_pairs_.clear(); - LOG_INFO_V0("=== Calling Orchestration Function ==="); + LOG_DEBUG("=== Calling Orchestration Function ==="); LOG_DEBUG( "Args count: %d (%d tensors + %d scalars)", orch_args->tensor_count() + orch_args->scalar_count(), orch_args->tensor_count(), orch_args->scalar_count() @@ -454,7 +454,7 @@ int bind_callable_to_runtime_impl( return rc; } - LOG_INFO_V0("Runtime initialized. Ready for execution from Python."); + LOG_DEBUG("Runtime initialized. Ready for execution from Python."); return 0; } @@ -482,7 +482,7 @@ int validate_runtime_impl(Runtime *runtime, const HostApi *api, int execution_rc int rc = 0; - LOG_INFO_V0("=== Copying Results Back to Host ==="); + LOG_DEBUG("=== Copying Results Back to Host ==="); // Copy all recorded tensors from device back to host TensorPair *tensor_pairs = runtime->tensor_pairs_.data(); @@ -507,11 +507,11 @@ int validate_runtime_impl(Runtime *runtime, const HostApi *api, int execution_rc // Note: print_handshake_results() is called in DeviceRunner::run() // Cleanup device tensors - LOG_INFO_V0("=== Cleaning Up ==="); + LOG_DEBUG("=== Cleaning Up ==="); for (int i = 0; i < tensor_pair_count; i++) { api->device_free(tensor_pairs[i].dev_ptr); } - LOG_INFO_V0("Freed %d device tensors", tensor_pair_count); + LOG_DEBUG("Freed %d device tensors", tensor_pair_count); if (runtime->get_tensor_info_storage() != nullptr) { api->device_free(runtime->get_tensor_info_storage()); @@ -525,7 +525,7 @@ int validate_runtime_impl(Runtime *runtime, const HostApi *api, int execution_rc // Clear tensor pairs runtime->tensor_pairs_.clear(); - LOG_INFO_V0("=== Finalize Complete ==="); + LOG_DEBUG("=== Finalize Complete ==="); return rc; } diff --git a/src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp b/src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp index cafa57242f..e5655dc5fb 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp @@ -239,7 +239,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { const bool is_leader = (tidx == 0); if (is_leader) { - LOG_INFO_V0("AicpuExecutor: Initializing"); + LOG_DEBUG("AicpuExecutor: Initializing"); // The 0 → 1 fixup already applied above; derive scheduler count from it. aicpu_thread_num_ = nthreads; sched_thread_num_ = nthreads - 1; @@ -334,7 +334,7 @@ int32_t AicpuExecutor::init(Runtime *runtime) { return -1; } init_done_.store(true, std::memory_order_release); - LOG_INFO_V0("AicpuExecutor: Init complete"); + LOG_DEBUG("AicpuExecutor: Init complete"); } else { while (!init_done_.load(std::memory_order_acquire)) { if (init_failed_.load(std::memory_order_acquire)) return -1; @@ -361,7 +361,7 @@ int32_t AicpuExecutor::load_orch_so( // simpler_run launch, but loading now happens in the separate // register_callable launch which has no phase buffer (the run-path SoLoad // slot is simply 0 now that run never loads). - LOG_INFO_V0("Thread %d: New orch SO detected (callable_id=%d), (re)loading", thread_idx, callable_id); + LOG_DEBUG("Thread %d: New orch SO detected (callable_id=%d), (re)loading", thread_idx, callable_id); if (entry.handle != nullptr) { dlclose(entry.handle); } @@ -388,13 +388,13 @@ int32_t AicpuExecutor::load_orch_so( int32_t fd = create_orch_so_file(candidate_dirs[i], callable_id, get_orch_device_id(), so_path, sizeof(so_path)); if (fd < 0) { - LOG_INFO_V0("Thread %d: Cannot create SO at %s (errno=%d), trying next path", thread_idx, so_path, errno); + LOG_DEBUG("Thread %d: Cannot create SO at %s (errno=%d), trying next path", thread_idx, so_path, errno); continue; } ssize_t written = write(fd, so_data, so_size); close(fd); if (written != static_cast(so_size)) { - LOG_INFO_V0("Thread %d: Cannot write SO to %s (errno=%d), trying next path", thread_idx, so_path, errno); + LOG_DEBUG("Thread %d: Cannot write SO to %s (errno=%d), trying next path", thread_idx, so_path, errno); unlink(so_path); continue; } @@ -720,56 +720,56 @@ int32_t AicpuExecutor::run(Runtime *runtime) { uint64_t total = p.sync_cycle + p.alloc_cycle + p.args_cycle + p.lookup_cycle + p.insert_cycle + p.fanin_cycle; if (total == 0) total = 1; // avoid div-by-zero - LOG_INFO_V9( + LOG_INFO( "Thread %d: === Orchestrator Profiling: %" PRId64 " tasks, total=%.3fus ===", thread_idx, static_cast(p.submit_count), cycles_to_us(total) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: task+heap_alloc: %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(p.alloc_cycle), p.alloc_cycle * 100.0 / total, cycles_to_us(p.alloc_cycle - p.alloc_wait_cycle), cycles_to_us(p.alloc_wait_cycle), static_cast(p.alloc_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: sync_tensormap : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.sync_cycle), p.sync_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: lookup+dep : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.lookup_cycle), p.lookup_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: tensormap_ins : %.3fus (%.1f%%)", thread_idx, cycles_to_us(p.insert_cycle), p.insert_cycle * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: param_copy : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(p.args_cycle), p.args_cycle * 100.0 / total, static_cast(p.args_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: fanin+ready : %.3fus (%.1f%%) work=%.3fus wait=%.3fus", thread_idx, cycles_to_us(p.fanin_cycle), p.fanin_cycle * 100.0 / total, cycles_to_us(p.fanin_cycle - p.fanin_wait_cycle), cycles_to_us(p.fanin_wait_cycle) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: avg/task : %.3fus", thread_idx, p.submit_count > 0 ? cycles_to_us(total) / p.submit_count : 0.0 ); #if SIMPLER_TENSORMAP_PROFILING PTO2TensorMapProfilingData tp = pto2_tensormap_get_profiling(); - LOG_INFO_V9("Thread %d: === TensorMap Lookup Stats ===", thread_idx); - LOG_INFO_V9( + LOG_INFO("Thread %d: === TensorMap Lookup Stats ===", thread_idx); + LOG_INFO( "Thread %d: lookups : %" PRIu64 ", inserts: %" PRIu64 "", thread_idx, static_cast(tp.lookup_count), static_cast(tp.insert_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: chain walked : total=%" PRIu64 ", avg=%.1f, max=%d", thread_idx, static_cast(tp.lookup_chain_total), tp.lookup_count > 0 ? static_cast(tp.lookup_chain_total) / tp.lookup_count : 0.0, tp.lookup_chain_max ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: overlap checks : %" PRIu64 ", hits=%" PRIu64 " (%.1f%%)", thread_idx, static_cast(tp.overlap_checks), static_cast(tp.overlap_hits), tp.overlap_checks > 0 ? tp.overlap_hits * 100.0 / tp.overlap_checks : 0.0 @@ -780,7 +780,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { // Latch task count from PTO2 shared memory to hand off to the // scheduler. The orchestrator's run window (start_time / end_time / // submit_count) is no longer published to shared memory — the - // device LOG_INFO_V9 "orch_start=… orch_end=… orch_cost=…" line + // device LOG_INFO "orch_start=… orch_end=… orch_cost=…" line // below carries the same envelope info for debugging, and // host-side swimlane derives per-phase timing from the per-event // L2SwimlaneAicpuOrchPhaseRecord[] stream that already covers everything inside @@ -809,20 +809,20 @@ int32_t AicpuExecutor::run(Runtime *runtime) { // per-thread device-log line below is now opt-in deep-dive. aicpu_phase_set_window(AicpuPhase::OrchWindow, static_cast(orch_cycle_start), orch_end_ts); #if SIMPLER_ORCH_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: orch_start=%" PRIu64 " orch_end=%" PRIu64 " orch_cost=%.3fus", thread_idx, static_cast(orch_cycle_start), static_cast(orch_end_ts), cycles_to_us(orch_end_ts - orch_cycle_start) ); if (submitted_tasks >= 0) { - LOG_INFO_V9( + LOG_INFO( "PTO2 total submitted tasks = %d, already executed %d tasks", submitted_tasks, sched_ctx_.completed_tasks_count() ); } #endif // SIMPLER_ORCH_PROFILING #endif // SIMPLER_DFX - LOG_INFO_V0("Thread %d: Orchestrator completed", thread_idx); + LOG_DEBUG("Thread %d: Orchestrator completed", thread_idx); } // Scheduler thread (orchestrator thread skips dispatch and exits after orchestration) @@ -843,7 +843,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { LOG_ERROR("Thread %d: Scheduler failed with rc=%d", thread_idx, completed); run_rc = completed; } else { - LOG_INFO_V0("Thread %d: Executed %d tasks from runtime", thread_idx, completed); + LOG_DEBUG("Thread %d: Executed %d tasks from runtime", thread_idx, completed); } } } @@ -856,7 +856,7 @@ int32_t AicpuExecutor::run(Runtime *runtime) { run_rc = shutdown_rc; } - LOG_INFO_V0("Thread %d: Completed", thread_idx); + LOG_DEBUG("Thread %d: Completed", thread_idx); // Check if this is the last thread to finish int32_t prev_finished = finished_count_.fetch_add(1, std::memory_order_acq_rel); @@ -906,7 +906,7 @@ void AicpuExecutor::deinit(Runtime * /*runtime*/) { // Clear dep_gen file-local bookkeeping. No-op when dep_gen is disabled. dep_gen_aicpu_finalize(); - LOG_INFO_V0("DeInit: Runtime execution state reset"); + LOG_DEBUG("DeInit: Runtime execution state reset"); init_done_.store(false, std::memory_order_release); init_failed_.store(false, std::memory_order_release); @@ -916,7 +916,7 @@ void AicpuExecutor::deinit(Runtime * /*runtime*/) { thread_idx_.store(0, std::memory_order_release); finished_.store(false, std::memory_order_release); - LOG_INFO_V0("DeInit: AicpuExecutor reset complete"); + LOG_DEBUG("DeInit: AicpuExecutor reset complete"); } // ===== Public Entry Point ===== @@ -942,7 +942,7 @@ extern "C" __attribute__((visibility("default"))) int simpler_aicpu_register_cal LOG_ERROR("simpler_aicpu_register_callable: SO load failed with rc=%d", rc); return rc; } - LOG_INFO_V0("simpler_aicpu_register_callable: completed for callable_id=%d", args->active_callable_id); + LOG_DEBUG("simpler_aicpu_register_callable: completed for callable_id=%d", args->active_callable_id); return 0; } @@ -966,7 +966,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return -1; } - LOG_INFO_V0("%s", "aicpu_execute: Starting AICPU kernel execution"); + LOG_DEBUG("%s", "aicpu_execute: Starting AICPU kernel execution"); // Each phase is bracketed by its own scope so the start/end boundaries are // visible and an early `return` still records the end via the guard dtor. @@ -1002,7 +1002,7 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { int32_t runtime_rc = read_runtime_status(runtime); if (g_aicpu_executor.finished_.load(std::memory_order_acquire)) { AicpuPhaseScope post_orch(AicpuPhase::PostOrch); - LOG_INFO_V0("aicpu_execute: Last thread finished, cleaning up"); + LOG_DEBUG("aicpu_execute: Last thread finished, cleaning up"); g_aicpu_executor.deinit(runtime); } @@ -1015,6 +1015,6 @@ extern "C" int32_t aicpu_execute(Runtime *runtime) { return rc; } - LOG_INFO_V0("%s", "aicpu_execute: Kernel execution completed successfully"); + LOG_DEBUG("%s", "aicpu_execute: Kernel execution completed successfully"); return 0; } diff --git a/src/a5/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md b/src/a5/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md index af661d440f..52596c68c3 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md +++ b/src/a5/runtime/tensormap_and_ringbuffer/docs/device_log_profiling.md @@ -2,7 +2,7 @@ ## How to Find Device Logs -AICPU logs (via `LOG_INFO_V9`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: +AICPU logs (via `LOG_INFO`) are written by CANN's **dlog** subsystem and do **not** appear in the `python test_*.py` / pytest terminal output. They are written to CANN's device log directory: ```text $HOME/ascend/log/debug/device-/device-_.log diff --git a/src/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md b/src/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md index 0c96b841b2..934c6f46e4 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md +++ b/src/a5/runtime/tensormap_and_ringbuffer/docs/profiling_levels.md @@ -90,7 +90,7 @@ Each sub-level macro requires `SIMPLER_DFX=1`: `sched_*` and `Scheduler summary` by `SIMPLER_SCHED_PROFILING` (Level 2). Level 1 only feeds the host-side `Orch` / `Sched` `[STRACE]` timeline. -**LOG_INFO_V9 count (normal run):** +**LOG_INFO count (normal run):** - `0` (device-side profiling logs). The timeline is delivered host-side via the phase windows, not through per-thread device logs. @@ -367,8 +367,8 @@ definitions to runtime headers. > Example: `paged_attention` on Ascend hardware, 2 sched threads + 2 orch threads, normal run (no stall/timeout). -| Level | Macro Settings | LOG_INFO_V9 Count | Description | -| ----- | -------------- | ----------------- | ----------- | +| Level | Macro Settings | LOG_INFO Count | Description | +| ----- | -------------- | -------------- | ----------- | | 0 | `SIMPLER_DFX=0` | 0 | No timing output | | 1 | `SIMPLER_DFX=1` | 0 | Host-side `Orch`/`Sched` `[STRACE]` windows only; no device logs | | 2 | `+SIMPLER_SCHED_PROFILING=1` | per sched thread | `sched_start` + phase breakdown + `Scheduler summary` | diff --git a/src/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp b/src/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp index d416931e3b..83c70e5f7b 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp @@ -455,7 +455,7 @@ dep_gen_replay_emit_deps_json(const DepGenRecord *records, size_t num_records, c LOG_ERROR("dep_gen replay: num_records=%zu but records pointer is null", num_records); return -1; } - LOG_INFO_V0("dep_gen replay: processing %zu in-memory records (dual-pass)", num_records); + LOG_DEBUG("dep_gen replay: processing %zu in-memory records (dual-pass)", num_records); // Per-ring task window sizes — tensormap masks slot indices and requires // each to be a power of two. Auto-size from the records themselves so each @@ -782,7 +782,7 @@ dep_gen_replay_emit_deps_json(const DepGenRecord *records, size_t num_records, c if (!write_deps_json(deps_json_path, task_table, tensor_table, annot_edges)) { return -5; } - LOG_INFO_V0( + LOG_DEBUG( "dep_gen replay: wrote deps.json to %s (tasks=%zu, tensors=%zu, edges=%zu)", deps_json_path, task_table.size(), tensor_table.size(), annot_edges.size() ); diff --git a/src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp b/src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp index 187a66d91f..f171ce05b9 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp @@ -391,7 +391,7 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const *out = CallableArtifacts{}; out->signature.assign(callable->signature_, callable->signature_ + callable->sig_count()); - LOG_INFO_V0("Registering %d kernel(s) in register_callable_impl", callable->child_count()); + LOG_DEBUG("Registering %d kernel(s) in register_callable_impl", callable->child_count()); if (upload_and_collect_child_addrs( callable, upload_fn, &out->kernel_addrs, &out->chip_buffer_dev, &out->chip_buffer_hash ) != 0) { @@ -417,7 +417,7 @@ register_callable_impl(const ChipCallable *callable, uint64_t (*upload_fn)(const out->orch_so_size = orch_so_size; out->func_name = callable->func_name(); out->config_name = callable->config_name(); - LOG_INFO_V0("Orchestration SO: %zu bytes staged (host-only)", orch_so_size); + LOG_DEBUG("Orchestration SO: %zu bytes staged (host-only)", orch_so_size); return 0; } @@ -493,7 +493,7 @@ static bool resolve_arena_sizing( const std::string task_window_log = format_ring_array(out->task_window_sizes); const std::string heap_log = format_ring_array(out->heap_sizes); const std::string dep_pool_log = format_ring_array(out->dep_pool_capacities); - LOG_INFO_V0( + LOG_DEBUG( "Ring buffer sizes: task_window=%s heap=%s dep_pool=%s", task_window_log.c_str(), heap_log.c_str(), dep_pool_log.c_str() ); @@ -597,7 +597,7 @@ static bool stage_device_args( out->add_scalar(orch_args->scalar(i)); } int64_t t_args_end = _now_ms(); - LOG_INFO_V0("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); + LOG_DEBUG("TIMING: args_malloc_copy = %" PRId64 "ms", t_args_end - t_args_start); return true; } @@ -608,7 +608,7 @@ static void apply_orch_sched_env_flags(Runtime *runtime) { const char *serial_env = std::getenv("SIMPLER_TMR_SERIAL_ORCH_SCHED_ENABLE"); runtime->dev.serial_orch_sched = serial_env && (serial_env[0] == '1' || serial_env[0] == 't' || serial_env[0] == 'T'); - LOG_INFO_V0( + LOG_DEBUG( "Serial orchestrator-to-scheduler start gate: %s", runtime->dev.serial_orch_sched ? "enabled" : "disabled" ); } @@ -657,9 +657,9 @@ static bool ensure_static_arenas( return false; } - LOG_INFO_V0("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); - LOG_INFO_V0("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); - LOG_INFO_V0("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); + LOG_DEBUG("TIMING: static_arena_setup = %" PRId64 "ms", t_setup_end - t_setup_start); + LOG_DEBUG("TIMING: gm_heap_acquire = %" PRId64 "ms", t_heap_end - t_heap_start); + LOG_DEBUG("TIMING: shared_mem_acquire = %" PRId64 "ms", t_sm_end - t_sm_start); return true; } @@ -810,7 +810,7 @@ extern "C" int bind_callable_to_runtime_impl( int tensor_count = orch_args->tensor_count(); int scalar_count = orch_args->scalar_count(); - LOG_INFO_V0("RT2 bind: %d tensors + %d scalars, device orchestration mode", tensor_count, scalar_count); + LOG_DEBUG("RT2 bind: %d tensors + %d scalars, device orchestration mode", tensor_count, scalar_count); runtime->tensor_leases_.clear(); int64_t t_total_start = _now_ms(); @@ -878,11 +878,11 @@ extern "C" int bind_callable_to_runtime_impl( } int64_t t_prebuilt_end = _now_ms(); - LOG_INFO_V0("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); + LOG_DEBUG("Device orchestration ready: %d tensors + %d scalars", tensor_count, scalar_count); int64_t t_total_end = _now_ms(); - LOG_INFO_V0("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); - LOG_INFO_V0("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); + LOG_DEBUG("TIMING: prebuilt_runtime_arena = %" PRId64 "ms", t_prebuilt_end - t_prebuilt_start); + LOG_DEBUG("TIMING: total_init_runtime_impl = %" PRId64 "ms", t_total_end - t_total_start); bind_cleanup.dismiss(); return 0; @@ -912,13 +912,13 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e int rc = 0; - LOG_INFO_V0("=== Copying Results Back to Host ==="); + LOG_DEBUG("=== Copying Results Back to Host ==="); // Copy all recorded tensors from device back to host TensorLease *tensor_leases = runtime->tensor_leases_.data(); int tensor_lease_count = static_cast(runtime->tensor_leases_.size()); - LOG_INFO_V0("Tensor leases to process: %d", tensor_lease_count); + LOG_DEBUG("Tensor leases to process: %d", tensor_lease_count); bool skip_tensor_copy_back = execution_rc != 0; int32_t runtime_status = 0; @@ -989,10 +989,10 @@ extern "C" int validate_runtime_impl(Runtime *runtime, const HostApi *api, int e } // Cleanup device tensors - LOG_INFO_V0("=== Cleaning Up ==="); + LOG_DEBUG("=== Cleaning Up ==="); release_tensor_leases(runtime, api); - LOG_INFO_V0("=== Finalize Complete ==="); + LOG_DEBUG("=== Finalize Complete ==="); if (rc == 0 && runtime_status != 0) { rc = runtime_status; diff --git a/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h b/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h index 6edb50c202..17fc637713 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/orchestration/pto_orchestration_api.h @@ -74,9 +74,9 @@ typedef struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. @@ -259,20 +259,10 @@ static inline bool rt_is_fatal() { #define LOG_ERROR(fmt, ...) current_runtime()->ops->log_error(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) current_runtime()->ops->log_warn(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_TIMING(fmt, ...) current_runtime()->ops->log_timing(__FUNCTION__, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) current_runtime()->ops->log_info(__FUNCTION__, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) current_runtime()->ops->log_debug(__FUNCTION__, fmt, ##__VA_ARGS__) -// INFO verbosity tiers. v=0 most verbose, v=9 must-see, v=5 default. -#define LOG_INFO_V0(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 0, fmt, ##__VA_ARGS__) -#define LOG_INFO_V1(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 1, fmt, ##__VA_ARGS__) -#define LOG_INFO_V2(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 2, fmt, ##__VA_ARGS__) -#define LOG_INFO_V3(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 3, fmt, ##__VA_ARGS__) -#define LOG_INFO_V4(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 4, fmt, ##__VA_ARGS__) -#define LOG_INFO_V5(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 5, fmt, ##__VA_ARGS__) -#define LOG_INFO_V6(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 6, fmt, ##__VA_ARGS__) -#define LOG_INFO_V7(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 7, fmt, ##__VA_ARGS__) -#define LOG_INFO_V8(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 8, fmt, ##__VA_ARGS__) -#define LOG_INFO_V9(fmt, ...) current_runtime()->ops->log_info_v(__FUNCTION__, 9, fmt, ##__VA_ARGS__) - // ============================================================================= // Cross-Layer Data Access // ============================================================================= diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp index 4ce048dfcc..d6780ff84d 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.cpp @@ -270,8 +270,9 @@ static const PTO2RuntimeOps s_runtime_ops = { .report_fatal = rt_report_fatal, .log_error = unified_log_error, .log_warn = unified_log_warn, + .log_timing = unified_log_timing, + .log_info = unified_log_info, .log_debug = unified_log_debug, - .log_info_v = unified_log_info_v, .get_tensor_data = get_tensor_data, .set_tensor_data = set_tensor_data, .alloc_tensors = alloc_tensors_impl, diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h index f0b37e9bc9..f9354dc85c 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2.h @@ -77,9 +77,9 @@ struct PTO2RuntimeOps { // Logging (populated by runtime, called by orchestration) void (*log_error)(const char *func, const char *fmt, ...); void (*log_warn)(const char *func, const char *fmt, ...); + void (*log_timing)(const char *func, const char *fmt, ...); + void (*log_info)(const char *func, const char *fmt, ...); void (*log_debug)(const char *func, const char *fmt, ...); - // INFO with explicit verbosity tier (v ∈ [0,9]; gating done inside). - void (*log_info_v)(const char *func, int v, const char *fmt, ...); // Cross-layer data access (orchestration reads/writes tensor values via runtime) // Placed after logging to avoid shifting hot-path field offsets. diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp b/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp index 8ad38a3fb4..6d73f2a336 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp @@ -85,7 +85,7 @@ LoopAction SchedulerContext::handle_orchestrator_exit( task_count = total_tasks_; if (task_count > 0 && completed_tasks_.load(std::memory_order_relaxed) >= task_count) { completed_.store(true, std::memory_order_release); - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: PTO2 completed tasks %d/%d", thread_idx, completed_tasks_.load(std::memory_order_relaxed), task_count ); @@ -274,7 +274,7 @@ void SchedulerContext::log_stall_diagnostics( if (is_running) { cnt_running++; if (cnt_running > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=RUNNING fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] " "running_on=[owner_thread=%d cores=[%s]]", @@ -285,7 +285,7 @@ void SchedulerContext::log_stall_diagnostics( if (rc >= fi) { cnt_ready++; if (cnt_ready > STALL_DUMP_READY_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=READY fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d]", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1 @@ -294,7 +294,7 @@ void SchedulerContext::log_stall_diagnostics( } cnt_waiting++; if (cnt_waiting > STALL_DUMP_WAIT_MAX) continue; - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] TASK ring=%d task_id=%" PRId64 " state=WAIT fanin_refcount=%d/%d kernels=[aic:%d aiv0:%d aiv1:%d] missing_deps=%d", thread_idx, idle_iterations, r, task_id, rc, fi, kid_aic, kid_aiv0, kid_aiv1, fi - rc @@ -303,7 +303,7 @@ void SchedulerContext::log_stall_diagnostics( } int32_t effective_total = task_count > 0 ? task_count : submitted_in_ring; int32_t c = completed_tasks_.load(std::memory_order_relaxed); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] SUMMARY completed=%d/%d last_progress_iteration=%d " "scan_ready=%d scan_waiting=%d scan_running=%d", thread_idx, idle_iterations, c, effective_total, last_progress_count, cnt_ready, cnt_waiting, cnt_running @@ -335,7 +335,7 @@ void SchedulerContext::log_stall_diagnostics( aiv1_buf, sizeof(aiv1_buf), aiv1_id, aiv1_idle, &core_exec_states_[aiv1_id], core_exec_states_[aiv1_id].reg_addr ); - LOG_INFO_V9( + LOG_INFO( "[STALL thread=%d idle_iterations=%d] CLUSTER cluster_id=%d aic=%s aiv0=%s aiv1=%s", thread_idx, idle_iterations, cluster_id, aic_buf, aiv0_buf, aiv1_buf ); @@ -477,7 +477,7 @@ int32_t SchedulerContext::handle_timeout_exit( AicpuPhase::SchedWindow, static_cast(sched_start_ts), static_cast(sched_timeout_ts) ); #if SIMPLER_SCHED_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end(timeout)=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(sched_start_ts), static_cast(sched_timeout_ts), cycles_to_us(sched_timeout_ts - sched_start_ts) @@ -498,7 +498,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse AicpuPhase::SchedWindow, static_cast(l2_swimlane.sched_start_ts), static_cast(sched_end_ts) ); #if SIMPLER_SCHED_PROFILING - LOG_INFO_V9( + LOG_INFO( "Thread %d: sched_start=%" PRIu64 " sched_end=%" PRIu64 " sched_cost=%.3fus", thread_idx, static_cast(l2_swimlane.sched_start_ts), static_cast(sched_end_ts), cycles_to_us(sched_end_ts - l2_swimlane.sched_start_ts) @@ -522,7 +522,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse l2_swimlane.sched_dispatch_setup_cycle) : 0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: === Scheduler Phase Breakdown: total=%.3fus, %d tasks ===", thread_idx, cycles_to_us(sched_total), cur_thread_completed ); @@ -530,7 +530,7 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse // fanout / fanin per-thread aggregates live in // sched_overhead_analysis.compute_dag_stats_from_deps (deps.json edges // × core_to_thread). - LOG_INFO_V9( + LOG_INFO( "Thread %d: complete : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle), l2_swimlane.sched_complete_cycle * 100.0 / sched_total ); @@ -542,85 +542,85 @@ void SchedulerContext::log_l2_swimlane_summary(int32_t thread_idx, [[maybe_unuse double complete_hit_rate = l2_swimlane.complete_probe_count > 0 ? l2_swimlane.complete_hit_count * 100.0 / l2_swimlane.complete_probe_count : 0.0; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%) hit=%" PRIu64 ", miss=%" PRIu64 ", hit_rate=%.1f%%", thread_idx, cycles_to_us(complete_poll), complete_poll * 100.0 / c_parent, static_cast(l2_swimlane.complete_hit_count), static_cast(complete_miss_count), complete_hit_rate ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_lock : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.lock_cycle), sp.lock_cycle * 100.0 / c_parent, cycles_to_us(sp.lock_cycle - sp.lock_wait_cycle), cycles_to_us(sp.lock_wait_cycle), static_cast(sp.lock_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanout : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanout_cycle), sp.fanout_cycle * 100.0 / c_parent, cycles_to_us(sp.fanout_cycle - sp.push_wait_cycle), cycles_to_us(sp.push_wait_cycle), static_cast(sp.fanout_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_fanin : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.fanin_cycle), sp.fanin_cycle * 100.0 / c_parent, static_cast(sp.fanin_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: otc_self : %.3fus (%.1f%%) atomics=%" PRIu64 "", thread_idx, cycles_to_us(sp.self_consumed_cycle), sp.self_consumed_cycle * 100.0 / c_parent, static_cast(sp.self_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: perf : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_complete_perf_cycle), l2_swimlane.sched_complete_perf_cycle * 100.0 / c_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: async_poll : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_async_cycle), l2_swimlane.sched_async_cycle * 100.0 / sched_total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: dispatch : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_cycle), l2_swimlane.sched_dispatch_cycle * 100.0 / sched_total ); uint64_t d_parent = l2_swimlane.sched_dispatch_cycle > 0 ? l2_swimlane.sched_dispatch_cycle : 1; - LOG_INFO_V9( + LOG_INFO( "Thread %d: poll : %.3fus (%.1f%%)", thread_idx, cycles_to_us(dispatch_poll), dispatch_poll * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: pop : %.3fus (%.1f%%) work=%.3fus wait=%.3fus atomics=%" PRIu64 "", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle), l2_swimlane.sched_dispatch_pop_cycle * 100.0 / d_parent, cycles_to_us(l2_swimlane.sched_dispatch_pop_cycle - sp.pop_wait_cycle), cycles_to_us(sp.pop_wait_cycle), static_cast(sp.pop_atomic_count) ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: setup : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_dispatch_setup_cycle), l2_swimlane.sched_dispatch_setup_cycle * 100.0 / d_parent ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: scan : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_scan_cycle), l2_swimlane.sched_scan_cycle * 100.0 / sched_total ); - LOG_INFO_V9( + LOG_INFO( "Thread %d: idle : %.3fus (%.1f%%)", thread_idx, cycles_to_us(l2_swimlane.sched_idle_cycle), l2_swimlane.sched_idle_cycle * 100.0 / sched_total ); if (cur_thread_completed > 0) { - LOG_INFO_V9( + LOG_INFO( "Thread %d: avg/complete : %.3fus", thread_idx, cycles_to_us(l2_swimlane.sched_complete_cycle) / cur_thread_completed ); } } - LOG_INFO_V9( + LOG_INFO( "Thread %d: Scheduler summary: total_time=%.3fus, loops=%" PRIu64 ", tasks_scheduled=%d", thread_idx, cycles_to_us(sched_total), static_cast(l2_swimlane.sched_loop_count), cur_thread_completed ); @@ -645,7 +645,7 @@ int32_t SchedulerContext::shutdown(int32_t thread_idx) { } #endif - LOG_INFO_V0("Thread %d: Shutting down %d cores", thread_idx, core_num); + LOG_DEBUG("Thread %d: Shutting down %d cores", thread_idx, core_num); int32_t rc = 0; for (int32_t i = 0; i < core_num; i++) { int32_t core_id = cores[i]; @@ -991,7 +991,7 @@ bool SchedulerContext::assign_cores_to_threads() { return false; } - LOG_INFO_V0( + LOG_DEBUG( "Assigning cores (round-robin): %d clusters across %d sched threads (%d AIC, %d AIV)", cluster_count, active_sched_threads_, aic_count_, aiv_count_ ); @@ -1029,7 +1029,7 @@ bool SchedulerContext::assign_cores_to_threads() { ); } - LOG_INFO_V0( + LOG_DEBUG( "Config: threads=%d, cores=%d, cores_per_thread=%d", aicpu_thread_num_, cores_total_num_, thread_cores_num ); return true; @@ -1158,7 +1158,7 @@ int32_t SchedulerContext::pre_handshake_init( total_tasks_ = 0; } - LOG_INFO_V0("Handshaking with %d cores", cores_total_num_); + LOG_DEBUG("Handshaking with %d cores", cores_total_num_); return 0; } @@ -1188,7 +1188,7 @@ int32_t SchedulerContext::post_handshake_init(Runtime *runtime) { memcpy(aiv_worker_ids_, local_aiv, static_cast(lv) * sizeof(int32_t)); aic_count_ = la; aiv_count_ = lv; - LOG_INFO_V0("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); + LOG_DEBUG("Core discovery complete: %d AIC, %d AIV", aic_count_, aiv_count_); if (!assign_cores_to_threads()) { return -1; diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp b/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp index 05397cb428..8e5735611d 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp @@ -734,7 +734,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ Handshake *hank = static_cast(runtime->dev.workers); - LOG_INFO_V0("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, tracker.core_num()); + LOG_DEBUG("Thread %d: PTO2 dispatch starting with %d cores", thread_idx, tracker.core_num()); int32_t cur_thread_completed = 0; // Non-zero once a scheduler-hang timeout latches; returned in place of the // completed count so the caller still sees the negative error rc while the @@ -886,7 +886,7 @@ int32_t SchedulerContext::resolve_and_dispatch(Runtime *runtime, int32_t thread_ if (thread_idx == 0 && task_count > 0) { if (new_total <= PROGRESS_VERBOSE_THRESHOLD || new_total / PROGRESS_LOG_INTERVAL != prev / PROGRESS_LOG_INTERVAL || new_total >= task_count) { - LOG_INFO_V9( + LOG_INFO( "PTO2 progress: completed=%d total=%d (%.1f%%)", new_total, task_count, 100.0 * new_total / task_count ); diff --git a/src/common/aicpu_loader/host/load_aicpu_op.cpp b/src/common/aicpu_loader/host/load_aicpu_op.cpp index e456717d18..88a711b4ee 100644 --- a/src/common/aicpu_loader/host/load_aicpu_op.cpp +++ b/src/common/aicpu_loader/host/load_aicpu_op.cpp @@ -113,7 +113,7 @@ int LoadAicpuOp::BootstrapDispatcher( { std::lock_guard lk(BootstrappedFpsMutex()); if (BootstrappedFps().count({inner_fp_, device_id_}) > 0) { - LOG_INFO_V2( + LOG_DEBUG( "BootstrapDispatcher: inner SO fp=%016lx dev=%d already bootstrapped, skipping", inner_fp_, device_id_ ); return 0; @@ -210,7 +210,7 @@ int LoadAicpuOp::BootstrapDispatcher( LOG_ERROR("BootstrapDispatcher: aclrtSynchronizeStream failed: %d", rc); return rc; } - LOG_INFO_V0( + LOG_DEBUG( "BootstrapDispatcher: bundled dispatcher (%zu B) + inner SO (%zu B) uploaded; inner SO at %s", dispatcher_len, inner_len, inner_so_basename_.c_str() ); @@ -346,7 +346,7 @@ int LoadAicpuOp::Init(const std::vector &extra_symbols) { load_config.options = &option; load_config.numOpt = 1; - LOG_INFO_V2("LoadAicpuOp::Init: JSON=%s inner_basename=%s", json_file_path_.c_str(), inner_so_basename_.c_str()); + LOG_DEBUG("LoadAicpuOp::Init: JSON=%s inner_basename=%s", json_file_path_.c_str(), inner_so_basename_.c_str()); rtError_t rc = rtsBinaryLoadFromFile(json_file_path_.c_str(), &load_config, &binary_handle_); if (rc != RT_ERROR_NONE) { @@ -354,7 +354,7 @@ int LoadAicpuOp::Init(const std::vector &extra_symbols) { // binary_handle_ stays null; json_guard removes the JSON file. return rc; } - LOG_INFO_V2("LoadAicpuOp: Loaded inner SO via JSON, handle=%p", binary_handle_); + LOG_DEBUG("LoadAicpuOp: Loaded inner SO via JSON, handle=%p", binary_handle_); // Resolve every registered symbol. The set is exactly what this runtime // declares it exports (base + runtime-reported extras), so each one must @@ -371,7 +371,7 @@ int LoadAicpuOp::Init(const std::vector &extra_symbols) { return rc; } func_handles_[name] = func_handle; - LOG_INFO_V2( + LOG_DEBUG( "LoadAicpuOp: resolved handle for %s (opType=%s): %p", name.c_str(), lookup_name.c_str(), func_handle ); } diff --git a/src/common/log/host_log.cpp b/src/common/log/host_log.cpp index 27474583b0..aacebbf1f7 100644 --- a/src/common/log/host_log.cpp +++ b/src/common/log/host_log.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -29,38 +30,36 @@ HostLogger &HostLogger::get_instance() { } HostLogger::HostLogger() : - current_level_(LogLevel::INFO), - current_info_v_(simpler::log::kDefaultInfoV) {} + current_level_(LogLevel::TIMING) {} void HostLogger::set_level(LogLevel level) { std::scoped_lock lock(mutex_); current_level_ = level; } -void HostLogger::set_info_v(int v) { - if (v < 0) v = 0; - if (v > 9) v = 9; - std::scoped_lock lock(mutex_); - current_info_v_ = v; -} - int HostLogger::level() const { return static_cast(current_level_); } -int HostLogger::info_v() const { return current_info_v_; } +int HostLogger::cann_level() const { return simpler::log::to_cann_log_level(current_level_); } -bool HostLogger::is_severity_enabled(LogLevel level) const { +void HostLogger::configure_cann_log_level(int (*set_level)(int, int, int)) const { + if (std::getenv("ASCEND_GLOBAL_LOG_LEVEL") == nullptr) { + set_level(-1, cann_level(), 0); + } +} + +bool HostLogger::is_enabled(LogLevel level) const { // current_level_ is the floor: messages with severity >= floor are kept. return static_cast(level) >= static_cast(current_level_) && current_level_ != LogLevel::NUL; } -bool HostLogger::is_info_v_enabled(int v) const { return is_severity_enabled(LogLevel::INFO) && v >= current_info_v_; } - const char *HostLogger::level_name(LogLevel level) const { switch (level) { case LogLevel::DEBUG: return "DEBUG"; case LogLevel::INFO: return "INFO"; + case LogLevel::TIMING: + return "TIMING"; case LogLevel::WARN: return "WARN"; case LogLevel::ERROR: @@ -94,21 +93,12 @@ void HostLogger::emit(const char *level_tag, const char *func, const char *fmt, } void HostLogger::vlog(LogLevel level, const char *func, const char *fmt, va_list args) { - if (!is_severity_enabled(level)) { + if (!is_enabled(level)) { return; } emit(level_name(level), func, fmt, args); } -void HostLogger::vlog_info_v(int v, const char *func, const char *fmt, va_list args) { - if (!is_info_v_enabled(v)) { - return; - } - char tag[8]; - snprintf(tag, sizeof(tag), "INFO_V%d", v); - emit(tag, func, fmt, args); -} - void HostLogger::log(LogLevel level, const char *func, const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -116,13 +106,6 @@ void HostLogger::log(LogLevel level, const char *func, const char *fmt, ...) { va_end(args); } -void HostLogger::log_info_v(int v, const char *func, const char *fmt, ...) { - va_list args; - va_start(args, fmt); - vlog_info_v(v, func, fmt, args); - va_end(args); -} - // --------------------------------------------------------------------------- // C ABI entry — resolved by ChipWorker via dlsym from libsimpler_log.so. // @@ -130,20 +113,16 @@ void HostLogger::log_info_v(int v, const char *func, const char *fmt, ...) { // dlopen'd) to seed the process-wide HostLogger from the user's // `simpler` Python logger snapshot. Consumers that need the current value // later (host_runtime.so populating InitArgs.log_level at device init) read it -// via HostLogger::get_instance().level() / .info_v() directly; the value never +// via HostLogger::get_instance().level() directly; the value never // has to travel through any other SO's C ABI. // -// Severity layout matches CANN dlog (0=DEBUG..4=NUL); info_v ∈ [0,9]. -// Returns 0 on success, negative on out-of-range input. +// Level values match Python logging thresholds. +// Returns 0 on success, negative for an unsupported threshold. // --------------------------------------------------------------------------- -extern "C" int simpler_log_init(int log_level, int log_info_v) { - if (log_level < static_cast(LogLevel::DEBUG) || log_level > static_cast(LogLevel::NUL)) { - return -1; - } - if (log_info_v < 0 || log_info_v > 9) { +extern "C" int simpler_log_init(int log_level) { + if (!simpler::log::is_valid_level(log_level)) { return -1; } HostLogger::get_instance().set_level(static_cast(log_level)); - HostLogger::get_instance().set_info_v(log_info_v); return 0; } diff --git a/src/common/log/include/common/log_level.h b/src/common/log/include/common/log_level.h new file mode 100644 index 0000000000..df7a78c41c --- /dev/null +++ b/src/common/log/include/common/log_level.h @@ -0,0 +1,53 @@ +/* + * 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. + * ----------------------------------------------------------------------------------------------------------- + */ + +#ifndef PLATFORM_LOG_LEVEL_H_ +#define PLATFORM_LOG_LEVEL_H_ + +namespace simpler::log { + +enum class LogLevel : int { + DEBUG = 10, + INFO = 20, + TIMING = 25, + WARN = 30, + ERROR = 40, + NUL = 60, +}; + +constexpr int kDefaultThreshold = static_cast(LogLevel::TIMING); + +constexpr bool is_valid_level(int level) { + return level == static_cast(LogLevel::DEBUG) || level == static_cast(LogLevel::INFO) || + level == static_cast(LogLevel::TIMING) || level == static_cast(LogLevel::WARN) || + level == static_cast(LogLevel::ERROR) || level == static_cast(LogLevel::NUL); +} + +constexpr int to_cann_log_level(LogLevel level) { + switch (level) { + case LogLevel::DEBUG: + return 0; + case LogLevel::INFO: + return 1; + case LogLevel::TIMING: + case LogLevel::WARN: + return 2; + case LogLevel::ERROR: + return 3; + case LogLevel::NUL: + return 4; + } + return 4; +} + +} // namespace simpler::log + +#endif // PLATFORM_LOG_LEVEL_H_ diff --git a/src/common/log/include/common/strace.h b/src/common/log/include/common/strace.h index acfa96a157..a21a8482e4 100644 --- a/src/common/log/include/common/strace.h +++ b/src/common/log/include/common/strace.h @@ -43,7 +43,7 @@ * comparable. STRACE_A appends caller-supplied "k=v" attrs verbatim. * * Gated on SIMPLER_HOST_STRACE (default on, see profiling_config.h — no env var) - * and emitted at LOG_INFO_V9 (the must-see tier, default-visible). In a + * and emitted at LOG_TIMING (the default-visible timing tier). In a * non-profiling build the macros compile to nothing. */ @@ -128,7 +128,7 @@ class StraceScope { // depth printed is the scope's own level (post-decrement so the // outermost scope prints depth=0). const int d = --depth(); - LOG_INFO_V9( + LOG_TIMING( "[STRACE] v=1 pid=%d tid=%ld inv=%u hid=%llx depth=%d name=%s ts=%lld dur=%lld %s", static_cast(getpid()), strace_tid(), inv(), static_cast(hid()), d, name_, ts, dur, attrs_ @@ -181,7 +181,7 @@ class StraceScope { */ inline void emit_span_at(const char *name, long long ts_ns, long long dur_ns, int depth, const char *attrs = "clk=dev") { - LOG_INFO_V9( + LOG_TIMING( "[STRACE] v=1 pid=%d tid=%ld inv=%u hid=%llx depth=%d name=%s ts=%lld dur=%lld %s", static_cast(getpid()), strace_tid(), StraceScope::current_inv(), static_cast(StraceScope::current_hid()), depth, name, ts_ns, dur_ns, attrs diff --git a/src/common/log/include/common/unified_log.h b/src/common/log/include/common/unified_log.h index 90885d0f29..55738b645b 100644 --- a/src/common/log/include/common/unified_log.h +++ b/src/common/log/include/common/unified_log.h @@ -15,10 +15,8 @@ * One adapter ABI for both host and device. Host build links unified_log_host.cpp, * device build links unified_log_device.cpp. * - * Severity macros (LOG_DEBUG/WARN/ERROR) plus 10 INFO verbosity tiers - * (LOG_INFO_V0..V9). v=0 is the most verbose (sub-INFO), v=9 is the most - * must-see (above-INFO). v=5 is the default threshold and aliases Python's - * standard INFO level. + * The single severity axis is DEBUG/INFO/TIMING/WARN/ERROR. TIMING is the + * default threshold and is reserved for stable performance markers. */ #ifndef PLATFORM_UNIFIED_LOG_H_ @@ -32,8 +30,9 @@ extern "C" { void unified_log_error(const char *func, const char *fmt, ...); void unified_log_warn(const char *func, const char *fmt, ...); +void unified_log_timing(const char *func, const char *fmt, ...); +void unified_log_info(const char *func, const char *fmt, ...); void unified_log_debug(const char *func, const char *fmt, ...); -void unified_log_info_v(const char *func, int v, const char *fmt, ...); #ifdef __cplusplus } @@ -41,21 +40,10 @@ void unified_log_info_v(const char *func, int v, const char *fmt, ...); #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) -// Severity-only macros #define LOG_ERROR(fmt, ...) unified_log_error(__FUNCTION__, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) #define LOG_WARN(fmt, ...) unified_log_warn(__FUNCTION__, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) +#define LOG_TIMING(fmt, ...) unified_log_timing(__FUNCTION__, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) unified_log_info(__FUNCTION__, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) unified_log_debug(__FUNCTION__, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -// INFO verbosity tiers (v ∈ [0,9]). 0=most verbose, 9=must-see, 5=default threshold. -#define LOG_INFO_V0(fmt, ...) unified_log_info_v(__FUNCTION__, 0, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V1(fmt, ...) unified_log_info_v(__FUNCTION__, 1, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V2(fmt, ...) unified_log_info_v(__FUNCTION__, 2, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V3(fmt, ...) unified_log_info_v(__FUNCTION__, 3, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V4(fmt, ...) unified_log_info_v(__FUNCTION__, 4, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V5(fmt, ...) unified_log_info_v(__FUNCTION__, 5, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V6(fmt, ...) unified_log_info_v(__FUNCTION__, 6, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V7(fmt, ...) unified_log_info_v(__FUNCTION__, 7, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V8(fmt, ...) unified_log_info_v(__FUNCTION__, 8, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) -#define LOG_INFO_V9(fmt, ...) unified_log_info_v(__FUNCTION__, 9, "[%s:%d] " fmt, __FILENAME__, __LINE__, ##__VA_ARGS__) - #endif // PLATFORM_UNIFIED_LOG_H_ diff --git a/src/common/log/include/host_log.h b/src/common/log/include/host_log.h index 3776a118a9..a52b5b6014 100644 --- a/src/common/log/include/host_log.h +++ b/src/common/log/include/host_log.h @@ -12,14 +12,9 @@ * @file host_log.h * @brief Unified Host Logging System * - * Two orthogonal axes: - * - Severity: DEBUG/INFO/WARN/ERROR/NUL (matches CANN dlog 1:1) - * - INFO verbosity: integer 0..9 (only meaningful when severity == INFO) - * - * Configuration is pushed in from Python via nanobind binding - * `set_host_log_config(severity, info_v)`; this module never reads env vars. - * The Python-facing integer level layout (V0=15..V9=24, INFO=20=V5, etc.) - * lives in the Python module — C++ only stores the two axes separately. + * One threshold controls DEBUG/INFO/TIMING/WARN/ERROR/NUL. The integer values + * match Python logging levels. CANN has no TIMING level, so onboard setup maps + * both TIMING and WARN thresholds to CANN WARN. */ #ifndef PLATFORM_HOST_LOG_H_ @@ -29,54 +24,32 @@ #include #include -namespace simpler::log { - -// Severity (matches CANN dlog enum 1:1) -enum class LogLevel : int { - DEBUG = 0, - INFO = 1, - WARN = 2, - ERROR = 3, - NUL = 4, -}; - -// Defaults — single source of truth shared with Python via nanobind binding. -// The full integer level layout (DEBUG=10, V0..V9=15..24, WARN=30, etc.) -// is Python-side; C++ only stores severity + verbosity as separate axes. -constexpr int kDefaultInfoV = 5; // V5 -constexpr int kDefaultThreshold = 20; // V5 = Python INFO - -} // namespace simpler::log +#include "common/log_level.h" class HostLogger { public: static HostLogger &get_instance(); - // Severity-only entry (DEBUG/WARN/ERROR). NOTE: caller must NOT pass INFO here; - // INFO goes through log_info_v with a verbosity tier. void log(simpler::log::LogLevel level, const char *func, const char *fmt, ...); - // INFO with verbosity tier (v ∈ [0, 9]). - void log_info_v(int v, const char *func, const char *fmt, ...); - // va_list-taking primitives — used by unified_log_* adapters to forward // a caller's variadic args without an intermediate vsnprintf-to-buffer // round-trip. Caller is responsible for `va_start` / `va_end`. void vlog(simpler::log::LogLevel level, const char *func, const char *fmt, va_list args); - void vlog_info_v(int v, const char *func, const char *fmt, va_list args); void set_level(simpler::log::LogLevel level); - void set_info_v(int v); - // Raw getters. host_runtime.so reads these via the RTLD_GLOBAL singleton - // when populating InitArgs.log_level / log_info_v at device init — that - // way the log configuration only lives in this one place (libsimpler_log.so) - // and never has to be pushed across the host_runtime.so C ABI separately. - int level() const; // returns the underlying LogLevel as int (0..4) - int info_v() const; + // host_runtime.so reads this through the RTLD_GLOBAL singleton when + // populating InitArgs.log_level at device init. + int level() const; + int cann_level() const; + + // Configure CANN before the device context is opened unless the user has + // already selected ASCEND_GLOBAL_LOG_LEVEL. The callback shape matches + // dlog_setlevel and keeps this policy independently testable. + void configure_cann_log_level(int (*set_level)(int module_id, int level, int enable_event)) const; - bool is_severity_enabled(simpler::log::LogLevel level) const; - bool is_info_v_enabled(int v) const; + bool is_enabled(simpler::log::LogLevel level) const; private: HostLogger(); @@ -91,7 +64,6 @@ class HostLogger { void emit(const char *level_tag, const char *func, const char *fmt, va_list args); simpler::log::LogLevel current_level_; - int current_info_v_; std::mutex mutex_; }; diff --git a/src/common/log/unified_log_host.cpp b/src/common/log/unified_log_host.cpp index 91caa01c22..72813f2673 100644 --- a/src/common/log/unified_log_host.cpp +++ b/src/common/log/unified_log_host.cpp @@ -13,8 +13,8 @@ * @brief Unified logging - Host implementation. * * Adapter that forwards the unified C ABI to HostLogger via va_list, avoiding - * an intermediate vsnprintf-to-buffer round-trip. HostLogger::vlog{,_info_v} - * is the single authority for level gating; this adapter does not re-check. + * an intermediate vsnprintf-to-buffer round-trip. HostLogger::vlog is the + * single authority for level gating; this adapter does not re-check. */ #include "common/unified_log.h" @@ -38,16 +38,23 @@ void unified_log_warn(const char *func, const char *fmt, ...) { va_end(args); } -void unified_log_debug(const char *func, const char *fmt, ...) { +void unified_log_timing(const char *func, const char *fmt, ...) { va_list args; va_start(args, fmt); - HostLogger::get_instance().vlog(LogLevel::DEBUG, func, fmt, args); + HostLogger::get_instance().vlog(LogLevel::TIMING, func, fmt, args); va_end(args); } -void unified_log_info_v(const char *func, int v, const char *fmt, ...) { +void unified_log_info(const char *func, const char *fmt, ...) { va_list args; va_start(args, fmt); - HostLogger::get_instance().vlog_info_v(v, func, fmt, args); + HostLogger::get_instance().vlog(LogLevel::INFO, func, fmt, args); + va_end(args); +} + +void unified_log_debug(const char *func, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + HostLogger::get_instance().vlog(LogLevel::DEBUG, func, fmt, args); va_end(args); } diff --git a/src/common/platform/include/aicpu/device_log.h b/src/common/platform/include/aicpu/device_log.h index a57f5d9a8a..c7b59b1ee6 100644 --- a/src/common/platform/include/aicpu/device_log.h +++ b/src/common/platform/include/aicpu/device_log.h @@ -18,14 +18,12 @@ * - Severity gating uses the same flag table on both backends: * onboard fills it from CheckLogLevel(AICPU,...) (CANN-managed), * sim fills it from set_log_level() called by the host (dlsym path). - * - INFO verbosity gating (V0..V9) is simpler-managed on both backends: - * g_log_info_v populated from set_log_info_v(); onboard latches the value - * once per device from InitArgs.log_info_v via simpler_aicpu_init, sim - * receives it via dlsym from the host runner. + * - TIMING is a simpler level between INFO and WARN. Onboard maps it to + * CANN WARN; sim gates it directly from the host-provided threshold. * * Platform Support: - * - a5 : Real hardware with CANN dlog API - * - a5sim : Host-based simulation using fprintf(stderr,...) + * - a2a3 / a5 : Real hardware with CANN dlog API + * - a2a3sim / a5sim : Host-based simulation using fprintf(stderr,...) */ #ifndef PLATFORM_DEVICE_LOG_H_ @@ -52,21 +50,18 @@ extern bool g_is_log_enable_debug; extern bool g_is_log_enable_info; +extern bool g_is_log_enable_timing; extern bool g_is_log_enable_warn; extern bool g_is_log_enable_error; -// INFO verbosity threshold (0..9). Default 5. -extern int g_log_info_v; - // ============================================================================= // Configuration setters (called by AICPU kernel init from KernelArgs) // ============================================================================= -// Severity. Levels are CANN-aligned ints: DEBUG=0, INFO=1, WARN=2, ERROR=3, NUL=4. -// Onboard ignores this (CANN dlog is the source); sim uses it to set the flag table. +// Levels use Python-compatible thresholds: DEBUG=10, INFO=20, TIMING=25, +// WARN=30, ERROR=40, NUL=60. Onboard ignores this because CANN dlog owns its +// flag table; sim uses it directly. extern "C" void set_log_level(int level); -extern "C" void set_log_info_v(int v); -extern "C" int get_log_info_v(); // ============================================================================= // Platform-specific logging functions (low-level layer) @@ -80,9 +75,10 @@ extern "C" int get_log_info_v(); #include void dev_vlog_debug(const char *func, const char *fmt, va_list args); +void dev_vlog_info(const char *func, const char *fmt, va_list args); +void dev_vlog_timing(const char *func, const char *fmt, va_list args); void dev_vlog_warn(const char *func, const char *fmt, va_list args); void dev_vlog_error(const char *func, const char *fmt, va_list args); -void dev_vlog_info_v(int v, const char *func, const char *fmt, va_list args); // ============================================================================= // Helper Functions @@ -90,6 +86,7 @@ void dev_vlog_info_v(int v, const char *func, const char *fmt, va_list args); inline bool is_log_enable_debug() { return g_is_log_enable_debug; } inline bool is_log_enable_info() { return g_is_log_enable_info; } +inline bool is_log_enable_timing() { return g_is_log_enable_timing; } inline bool is_log_enable_warn() { return g_is_log_enable_warn; } inline bool is_log_enable_error() { return g_is_log_enable_error; } diff --git a/src/common/platform/onboard/aicpu/device_log.cpp b/src/common/platform/onboard/aicpu/device_log.cpp index 494dd8a0ad..ecb132629c 100644 --- a/src/common/platform/onboard/aicpu/device_log.cpp +++ b/src/common/platform/onboard/aicpu/device_log.cpp @@ -17,9 +17,7 @@ * value would be overwritten by CANN at the next init anyway, and CANN is the * only authoritative source on the AICPU). * - * Verbosity (V0..V9) is simpler-managed: g_log_info_v is set by - * set_log_info_v(), latched once per device from InitArgs.log_info_v by - * simpler_aicpu_init (not re-pushed per run). + * TIMING uses CANN WARN because CANN has no intermediate level. */ #include "aicpu/device_log.h" @@ -30,14 +28,14 @@ bool g_is_log_enable_debug = false; bool g_is_log_enable_info = false; +bool g_is_log_enable_timing = false; bool g_is_log_enable_warn = false; bool g_is_log_enable_error = false; -int g_log_info_v = 5; - void init_log_switch() { g_is_log_enable_debug = CheckLogLevel(AICPU, DLOG_DEBUG); g_is_log_enable_info = CheckLogLevel(AICPU, DLOG_INFO); + g_is_log_enable_timing = CheckLogLevel(AICPU, DLOG_WARN); g_is_log_enable_warn = CheckLogLevel(AICPU, DLOG_WARN); g_is_log_enable_error = CheckLogLevel(AICPU, DLOG_ERROR); } @@ -47,14 +45,6 @@ extern "C" void set_log_level(int /*level*/) { // Severity flags are populated by init_log_switch() via CheckLogLevel. } -extern "C" void set_log_info_v(int v) { - if (v < 0) v = 0; - if (v > 9) v = 9; - g_log_info_v = v; -} - -extern "C" int get_log_info_v() { return g_log_info_v; } - // ============================================================================= // Low-level dev_log_* / dev_vlog_* (onboard: route through CANN dlog) // @@ -69,22 +59,26 @@ void dev_vlog_debug(const char *func, const char *fmt, va_list args) { dlog_debug(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); } -void dev_vlog_warn(const char *func, const char *fmt, va_list args) { +void dev_vlog_info(const char *func, const char *fmt, va_list args) { char buffer[2048]; vsnprintf(buffer, sizeof(buffer), fmt, args); - dlog_warn(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); + dlog_info(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); } -void dev_vlog_error(const char *func, const char *fmt, va_list args) { +void dev_vlog_timing(const char *func, const char *fmt, va_list args) { char buffer[2048]; vsnprintf(buffer, sizeof(buffer), fmt, args); - dlog_error(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); + dlog_warn(AICPU, "%lu %s [TIMING]\n\"%s\"", GET_TID(), func, buffer); } -void dev_vlog_info_v(int v, const char *func, const char *fmt, va_list args) { +void dev_vlog_warn(const char *func, const char *fmt, va_list args) { + char buffer[2048]; + vsnprintf(buffer, sizeof(buffer), fmt, args); + dlog_warn(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); +} + +void dev_vlog_error(const char *func, const char *fmt, va_list args) { char buffer[2048]; vsnprintf(buffer, sizeof(buffer), fmt, args); - // Tag the verbosity tier in-message so it's grep-able alongside CANN's - // own [INFO] prefix. - dlog_info(AICPU, "%lu %s [V%d]\n\"%s\"", GET_TID(), func, v, buffer); + dlog_error(AICPU, "%lu %s\n\"%s\"", GET_TID(), func, buffer); } diff --git a/src/common/platform/onboard/aicpu/platform_aicpu_affinity.cpp b/src/common/platform/onboard/aicpu/platform_aicpu_affinity.cpp index 2f48f9a164..b3def0b570 100644 --- a/src/common/platform/onboard/aicpu/platform_aicpu_affinity.cpp +++ b/src/common/platform/onboard/aicpu/platform_aicpu_affinity.cpp @@ -141,10 +141,10 @@ bool platform_aicpu_affinity_gate_filter(const int32_t *allowed_cpus, int32_t al // Diagnostic: dump the allowed table once. // (Lower-volume than a per-thread line; cheaper at INFO.) - LOG_INFO_V0("AICPU filter gate: allowed_count=%d total_launched=%d", allowed_count, total_launched); + LOG_DEBUG("AICPU filter gate: allowed_count=%d total_launched=%d", allowed_count, total_launched); for (int32_t a = 0; a < allowed_count; ++a) { const char *role = (a == allowed_count - 1) ? "orch" : "sched"; - LOG_INFO_V0("AICPU filter gate: allowed[%d] = cpu_id %d role=%s", a, allowed_cpus[a], role); + LOG_DEBUG("AICPU filter gate: allowed[%d] = cpu_id %d role=%s", a, allowed_cpus[a], role); } s_filter_classify_ready.store(1, std::memory_order_release); @@ -172,9 +172,9 @@ bool platform_aicpu_affinity_gate_filter(const int32_t *allowed_cpus, int32_t al if (survive) { const char *role = (tl_exec_idx == allowed_count - 1) ? "orch" : "sched"; - LOG_INFO_V0("AICPU filter gate: thread idx=%d cpu=%d exec_idx=%d ACTIVE(%s)", idx, cpu, tl_exec_idx, role); + LOG_DEBUG("AICPU filter gate: thread idx=%d cpu=%d exec_idx=%d ACTIVE(%s)", idx, cpu, tl_exec_idx, role); } else { - LOG_INFO_V0("AICPU filter gate: thread idx=%d cpu=%d DROPPED", idx, cpu); + LOG_DEBUG("AICPU filter gate: thread idx=%d cpu=%d DROPPED", idx, cpu); } return survive; } diff --git a/src/common/platform/onboard/host/c_api_shared.cpp b/src/common/platform/onboard/host/c_api_shared.cpp index bd8c668e95..eacb32c868 100644 --- a/src/common/platform/onboard/host/c_api_shared.cpp +++ b/src/common/platform/onboard/host/c_api_shared.cpp @@ -319,9 +319,7 @@ int simpler_init( // seeded here by libsimpler_log.so's simpler_log_init() (runs earlier in // ChipWorker::init). Skipped when ASCEND_GLOBAL_LOG_LEVEL is externally // configured — CANN keeps that. - if (std::getenv("ASCEND_GLOBAL_LOG_LEVEL") == NULL) { - dlog_setlevel(-1, HostLogger::get_instance().level(), /*enableEvent*/ 0); - } + HostLogger::get_instance().configure_cann_log_level(dlog_setlevel); int rc; try { diff --git a/src/common/platform/onboard/host/device_runner_base.cpp b/src/common/platform/onboard/host/device_runner_base.cpp index 0af3d711c2..c931771201 100644 --- a/src/common/platform/onboard/host/device_runner_base.cpp +++ b/src/common/platform/onboard/host/device_runner_base.cpp @@ -345,7 +345,7 @@ void DeviceRunnerBase::configure_aicore_op_timeout() { rc ); } else { - LOG_INFO_V0( + LOG_DEBUG( "aclrtSetOpExecuteTimeOutV2: requested=%llu us, actual=%llu us", (unsigned long long)timeout_config_.op_execute_timeout_us, (unsigned long long)actual_timeout ); @@ -389,14 +389,14 @@ int DeviceRunnerBase::ensure_device_initialized() { aicore_created_here = true; } if (aicpu_created_here || aicore_created_here) { - LOG_INFO_V0("DeviceRunner: device=%d set, streams created", device_id_); + LOG_DEBUG("DeviceRunner: device=%d set, streams created", device_id_); } // Latch the AICore stream's block_dim ceiling. resolve_block_dim() is then // pure arithmetic and can run before any per-run stream work. if (max_block_dim_ == 0) { max_block_dim_ = query_max_block_dim(stream_aicore_, &max_cube_cores_, &max_vector_cores_); - LOG_INFO_V0( + LOG_DEBUG( "DeviceRunner: device=%d max_block_dim=%d (cube=%u, vector=%u)", device_id_, max_block_dim_, max_cube_cores_, max_vector_cores_ ); @@ -416,7 +416,6 @@ int DeviceRunnerBase::ensure_aicpu_init_launched() { InitArgs init_args{}; init_args.device_id = static_cast(device_id_); init_args.log_level = static_cast(HostLogger::get_instance().level()); - init_args.log_info_v = static_cast(HostLogger::get_instance().info_v()); // Per-device scheduler watchdog override, resolved once at attach into // timeout_config_. 0 -> the AICPU scheduler keeps its compile-time default. init_args.scheduler_timeout_ms = timeout_config_.scheduler_timeout_ms; @@ -428,7 +427,7 @@ int DeviceRunnerBase::ensure_aicpu_init_launched() { init_args.dma_workspace_addr[kind] = dma_workspace_addr_[kind]; } - LOG_INFO_V0("=== launch_aicpu_payload %s ===", host::KernelNames::InitName); + LOG_DEBUG("=== launch_aicpu_payload %s ===", host::KernelNames::InitName); int rc = launch_aicpu_payload( stream_aicpu_, &init_args, sizeof(init_args), host::KernelNames::InitName, /*aicpu_num=*/1 ); @@ -482,7 +481,7 @@ int DeviceRunnerBase::ensure_binaries_loaded() { LOG_ERROR("LoadAicpuOp::BootstrapDispatcher failed: %d", rc); return rc; } - LOG_INFO_V2("DeviceRunner: inner SO uploaded to preinstall via dispatcher bootstrap"); + LOG_DEBUG("DeviceRunner: inner SO uploaded to preinstall via dispatcher bootstrap"); // JSON-register the inner SO and resolve its runtime entry handles. The // runtime reports any AICPU entries it exports beyond the base set so the @@ -498,7 +497,7 @@ int DeviceRunnerBase::ensure_binaries_loaded() { LOG_ERROR("LoadAicpuOp::Init failed: %d", rc); return rc; } - LOG_INFO_V2("DeviceRunner: inner SO registered (runtime entry handles ready)"); + LOG_DEBUG("DeviceRunner: inner SO registered (runtime entry handles ready)"); // Release host bytes — bootstrap is done. Per-task launches go through // the cached rtFuncHandle owned by LoadAicpuOp; dispatcher SO bytes are @@ -511,7 +510,7 @@ int DeviceRunnerBase::ensure_binaries_loaded() { aicpu_so_binary_.shrink_to_fit(); binaries_loaded_ = true; - LOG_INFO_V0("DeviceRunner: binaries loaded"); + LOG_DEBUG("DeviceRunner: binaries loaded"); return 0; } @@ -674,7 +673,7 @@ int DeviceRunnerBase::commit_device_register(int32_t cid) { const bool inserted = aicpu_seen_callable_ids_.insert(cid).second; if (inserted) { ++aicpu_dlopen_total_; - LOG_INFO_V0("AICPU callable load committed cid=%d (count=%zu)", cid, aicpu_dlopen_total_); + LOG_DEBUG("AICPU callable load committed cid=%d (count=%zu)", cid, aicpu_dlopen_total_); } return 0; } @@ -708,7 +707,7 @@ int DeviceRunnerBase::launch_device_register(int32_t callable_id) { reg_args.device_orch_config_name, sizeof(reg_args.device_orch_config_name), "%s", state.config_name.c_str() ); - LOG_INFO_V0("=== launch_aicpu_payload %s ===", host::KernelNames::RegisterCallableName); + LOG_DEBUG("=== launch_aicpu_payload %s ===", host::KernelNames::RegisterCallableName); rc = launch_aicpu_payload( stream_aicpu_, ®_args, sizeof(reg_args), host::KernelNames::RegisterCallableName, /*aicpu_num=*/1 ); @@ -774,7 +773,7 @@ int DeviceRunnerBase::record_device_orch_callable( state.kernel_addrs = std::move(kernel_addrs); state.signature = std::move(signature); callables_.emplace(callable_id, std::move(state)); - LOG_INFO_V0( + LOG_DEBUG( "record_device_orch_callable: cid=%d orch_hash=0x%lx chip_hash=0x%lx %zu bytes", callable_id, hash, chip_buffer_hash, orch_so_size ); @@ -812,7 +811,7 @@ int DeviceRunnerBase::record_host_orch_callable( state.signature = std::move(signature); callables_.emplace(callable_id, std::move(state)); ++host_dlopen_total_; - LOG_INFO_V0("record_host_orch_callable: cid=%d (host dlopen #%zu)", callable_id, host_dlopen_total_); + LOG_DEBUG("record_host_orch_callable: cid=%d (host dlopen #%zu)", callable_id, host_dlopen_total_); return 0; } @@ -1207,7 +1206,7 @@ int DeviceRunnerBase::resolve_block_dim() { return -1; } block_dim_ = max_block_dim_; - LOG_INFO_V0("block_dim resolved to %d (cube=%u, vector=%u)", block_dim_, max_cube_cores_, max_vector_cores_); + LOG_DEBUG("block_dim resolved to %d (cube=%u, vector=%u)", block_dim_, max_cube_cores_, max_vector_cores_); return block_dim_; } @@ -1259,7 +1258,7 @@ void DeviceRunnerBase::resolve_task_binary_addrs(Runtime &runtime) { int DeviceRunnerBase::sync_run_streams() { return sync_stream_pair(stream_aicpu_, stream_aicore_); } int DeviceRunnerBase::sync_stream_pair(rtStream_t aicpu_stream, rtStream_t aicore_stream) { - LOG_INFO_V0("=== aclrtSynchronizeStreamWithTimeout AICPU stream ==="); + LOG_DEBUG("=== aclrtSynchronizeStreamWithTimeout AICPU stream ==="); int rc = aclrtSynchronizeStreamWithTimeout(aicpu_stream, timeout_config_.stream_sync_timeout_ms); if (rc == ACL_ERROR_RT_STREAM_SYNC_TIMEOUT) { LOG_ERROR( @@ -1275,7 +1274,7 @@ int DeviceRunnerBase::sync_stream_pair(rtStream_t aicpu_stream, rtStream_t aicor return rc; } - LOG_INFO_V0("=== aclrtSynchronizeStreamWithTimeout AICore stream ==="); + LOG_DEBUG("=== aclrtSynchronizeStreamWithTimeout AICore stream ==="); rc = aclrtSynchronizeStreamWithTimeout(aicore_stream, timeout_config_.stream_sync_timeout_ms); if (rc == ACL_ERROR_RT_STREAM_SYNC_TIMEOUT) { LOG_ERROR( diff --git a/src/common/platform/shared/aicpu/args_dump_aicpu.cpp b/src/common/platform/shared/aicpu/args_dump_aicpu.cpp index df0a0ddf09..c4f2172ec6 100644 --- a/src/common/platform/shared/aicpu/args_dump_aicpu.cpp +++ b/src/common/platform/shared/aicpu/args_dump_aicpu.cpp @@ -546,7 +546,7 @@ void dump_args_init(int num_dump_threads) { // FULL_JSON_ONLY → every task, metadata only (no payload copied into arena). g_dump_args_level = static_cast(s_dump_header->dump_args_level); - LOG_INFO_V0("Initializing args dump for %d threads", num_dump_threads); + LOG_DEBUG("Initializing args dump for %d threads", num_dump_threads); // Pop initial metadata buffer from free_queue for each thread for (int t = 0; t < num_dump_threads; t++) { @@ -713,7 +713,7 @@ void dump_args_flush(int thread_idx) { s_buffers_flushed[thread_idx]++; uint32_t dropped = s_dump_states[thread_idx] ? s_dump_states[thread_idx]->dropped_record_count : 0; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: dump_args_flush (records=%u, buf_switches=%u, flushes=%u, dropped=%u)", thread_idx, s_records_written[thread_idx], s_buffers_switched[thread_idx], s_buffers_flushed[thread_idx], dropped ); diff --git a/src/common/platform/shared/aicpu/dep_gen_collector_aicpu.cpp b/src/common/platform/shared/aicpu/dep_gen_collector_aicpu.cpp index 573b59216c..db408afb5b 100644 --- a/src/common/platform/shared/aicpu/dep_gen_collector_aicpu.cpp +++ b/src/common/platform/shared/aicpu/dep_gen_collector_aicpu.cpp @@ -156,7 +156,7 @@ void dep_gen_aicpu_init() { if (head != tail) { (void)try_pop_dep_gen_buffer(0); uint64_t buf_ptr = s_dep_gen_state->current_buf_ptr; - LOG_INFO_V0("dep_gen: popped initial buffer addr=0x%lx", buf_ptr); + LOG_DEBUG("dep_gen: popped initial buffer addr=0x%lx", buf_ptr); } else { LOG_ERROR("dep_gen: free_queue empty during init"); s_dep_gen_state->current_buf_ptr = 0; @@ -400,7 +400,7 @@ void dep_gen_aicpu_flush() { uint32_t seq = s_dep_gen_state->current_buf_seq; int rc = enqueue_dep_gen_ready_buffer(buf_ptr, seq); if (rc == 0) { - LOG_INFO_V0("dep_gen: flushed buffer with %u records", buf->count); + LOG_DEBUG("dep_gen: flushed buffer with %u records", buf->count); s_dep_gen_state->current_buf_ptr = 0; wmb(); } else { diff --git a/src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp b/src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp index 3f716408fa..5b85f0b2b5 100644 --- a/src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp +++ b/src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp @@ -211,12 +211,12 @@ struct L2SwimlaneDeviceModule { return; } if (is_phase(ctx)) { - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: switched to new %s phase buffer for pool %u (addr=0x%lx)", ctx.thread_idx, phase_label(ctx.kind), ctx.core_index, reinterpret_cast(buffer) ); } else { - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Core %u switched to new buffer (addr=0x%lx)", ctx.thread_idx, ctx.core_index, reinterpret_cast(buffer) ); @@ -311,7 +311,7 @@ void l2_swimlane_aicpu_init(int worker_count) { // the binary g_enable_l2_swimlane via the bitmask bit. g_l2_swimlane_level = static_cast(s_l2_swimlane_header->l2_swimlane_level); - LOG_INFO_V0( + LOG_DEBUG( "Initializing performance profiling for %d cores (free queue), l2_swimlane_level=%u", worker_count, static_cast(g_l2_swimlane_level) ); @@ -394,7 +394,7 @@ void l2_swimlane_aicpu_init(int worker_count) { wmb(); - LOG_INFO_V0("Performance profiling initialized for %d cores (with AICore rotation)", worker_count); + LOG_DEBUG("Performance profiling initialized for %d cores (with AICore rotation)", worker_count); } /** @@ -413,7 +413,7 @@ static void switch_task_buffer(int core_id, int thread_idx) { if (full_buf == nullptr) { return; } - LOG_INFO_V0("Thread %d: Core %d buffer is full (count=%u)", thread_idx, core_id, full_buf->count); + LOG_DEBUG("Thread %d: Core %d buffer is full (count=%u)", thread_idx, core_id, full_buf->count); L2SwimlaneTaskEngine::switch_buffer( l2_task_context( thread_idx, static_cast(core_id), L2SwimlaneBufferKind::AicpuTask, @@ -657,7 +657,7 @@ void l2_swimlane_aicpu_flush(int thread_idx, const int *cur_thread_cores, int co rmb(); - LOG_INFO_V0("Thread %d: Flushing performance buffers for %d cores", thread_idx, core_num); + LOG_DEBUG("Thread %d: Flushing performance buffers for %d cores", thread_idx, core_num); int flushed_count = 0; @@ -678,7 +678,7 @@ void l2_swimlane_aicpu_flush(int thread_idx, const int *cur_thread_cores, int co s_l2_swimlane_header, thread_idx, core_id, buf_ptr, seq, L2SwimlaneBufferKind::AicpuTask ); if (rc == 0) { - LOG_INFO_V0("Thread %d: Core %d flushed buffer with %u records", thread_idx, core_id, buf->count); + LOG_DEBUG("Thread %d: Core %d flushed buffer with %u records", thread_idx, core_id, buf->count); flushed_count++; state->head.current_buf_ptr = 0; s_current_aicpu_task_buffers[core_id] = nullptr; @@ -752,7 +752,7 @@ void l2_swimlane_aicpu_flush(int thread_idx, const int *cur_thread_cores, int co s_l2_swimlane_header, thread_idx, core_id, ac_buf_ptr, ac_seq, L2SwimlaneBufferKind::AicoreTask ); if (rc == 0) { - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: Core %d flushed AICore buffer (seq=%u, count=%u)", thread_idx, core_id, ac_seq, ac_mark ); ac_state->head.current_buf_ptr = 0; @@ -767,7 +767,7 @@ void l2_swimlane_aicpu_flush(int thread_idx, const int *cur_thread_cores, int co wmb(); - LOG_INFO_V0("Thread %d: Performance buffer flush complete, %d buffers flushed", thread_idx, flushed_count); + LOG_DEBUG("Thread %d: Performance buffer flush complete, %d buffers flushed", thread_idx, flushed_count); } // Pop the first buffer from a pool's free_queue and cache it as the current @@ -843,7 +843,7 @@ void l2_swimlane_aicpu_init_phase(int worker_count, int num_sched_phase_threads, wmb(); - LOG_INFO_V0( + LOG_DEBUG( "Phase profiling initialized: %d sched threads, %d orch threads, %d records/thread", num_sched_phase_threads, num_orch_phase_threads, PLATFORM_PHASE_RECORDS_PER_THREAD ); @@ -867,7 +867,7 @@ static void switch_phase_buffer( Buffer *full_buf = *current_buf_out; if (state == nullptr || full_buf == nullptr) return; - LOG_INFO_V0("Thread %d: %s phase buffer is full (count=%u)", thread_idx, kind_label, full_buf->count); + LOG_DEBUG("Thread %d: %s phase buffer is full (count=%u)", thread_idx, kind_label, full_buf->count); auto ctx = l2_buffer_context(thread_idx, pool_idx, kind, current_buf_out); profiling_device::DeviceProfilerEngine>::switch_buffer(ctx, state); @@ -889,7 +889,7 @@ static Record *acquire_phase_slot( ctx, state, state->head.current_buf_seq ); if (buf != nullptr) { - LOG_INFO_V0("Thread %d: recovered %s phase buffer", thread_idx, kind_label); + LOG_DEBUG("Thread %d: recovered %s phase buffer", thread_idx, kind_label); } if (buf == nullptr) return nullptr; } @@ -1034,7 +1034,7 @@ static void flush_phase_pool( uint32_t seq = state->head.current_buf_seq; int rc = enqueue_ready_buffer(s_l2_swimlane_header, thread_idx, pool_idx, buf_ptr, seq, kind); if (rc == 0) { - LOG_INFO_V0("Thread %d: flushed %s phase buffer with %u records", thread_idx, kind_label, *count_ptr); + LOG_DEBUG("Thread %d: flushed %s phase buffer with %u records", thread_idx, kind_label, *count_ptr); } else { LOG_ERROR( "Thread %d: failed to enqueue %s phase buffer (queue full), %u records lost!", thread_idx, kind_label, @@ -1073,7 +1073,7 @@ void l2_swimlane_aicpu_init_core_assignments(int total_cores) { memset(s_l2_swimlane_header->core_to_thread, -1, sizeof(s_l2_swimlane_header->core_to_thread)); s_l2_swimlane_header->num_phase_cores = static_cast(total_cores); wmb(); - LOG_INFO_V0("Core-to-thread mapping init: %d cores", total_cores); + LOG_DEBUG("Core-to-thread mapping init: %d cores", total_cores); } void l2_swimlane_aicpu_write_core_assignments_for_thread(int thread_idx, const int *core_ids, int core_num) { diff --git a/src/common/platform/shared/aicpu/scope_stats_collector_aicpu.cpp b/src/common/platform/shared/aicpu/scope_stats_collector_aicpu.cpp index 2682dab701..9d1710ed8d 100644 --- a/src/common/platform/shared/aicpu/scope_stats_collector_aicpu.cpp +++ b/src/common/platform/shared/aicpu/scope_stats_collector_aicpu.cpp @@ -260,7 +260,7 @@ void scope_stats_aicpu_flush_buffers() { uint32_t seq = s_scope_stats_state->current_buf_seq; int rc = enqueue_ready_buffer(buf_ptr, seq); if (rc == 0) { - LOG_INFO_V0("scope_stats: flushed buffer with %u records", buf->count); + LOG_DEBUG("scope_stats: flushed buffer with %u records", buf->count); } else { LOG_ERROR("scope_stats: flush failed (ready_queue full), %u records dropped", buf->count); s_scope_stats_state->dropped_record_count += buf->count; diff --git a/src/common/platform/shared/aicpu/unified_log_device.cpp b/src/common/platform/shared/aicpu/unified_log_device.cpp index c75552a663..34398f2c79 100644 --- a/src/common/platform/shared/aicpu/unified_log_device.cpp +++ b/src/common/platform/shared/aicpu/unified_log_device.cpp @@ -17,8 +17,7 @@ * dev_vlog_* is a single vfprintf (buffer-free); on onboard, it still * buffers internally because CANN's dlog has no va_list variant. * - * Severity flags and verbosity threshold come from device_log.cpp's globals - * (set at init time from KernelArgs). + * Level flags come from device_log.cpp's globals (set at init time). */ #include "common/unified_log.h" @@ -46,22 +45,32 @@ void unified_log_warn(const char *func, const char *fmt, ...) { va_end(args); } -void unified_log_debug(const char *func, const char *fmt, ...) { - if (!is_log_enable_debug()) { +void unified_log_timing(const char *func, const char *fmt, ...) { + if (!is_log_enable_timing()) { return; } va_list args; va_start(args, fmt); - dev_vlog_debug(func, fmt, args); + dev_vlog_timing(func, fmt, args); va_end(args); } -void unified_log_info_v(const char *func, int v, const char *fmt, ...) { - if (!is_log_enable_info() || v < g_log_info_v) { +void unified_log_info(const char *func, const char *fmt, ...) { + if (!is_log_enable_info()) { return; } va_list args; va_start(args, fmt); - dev_vlog_info_v(v, func, fmt, args); + dev_vlog_info(func, fmt, args); + va_end(args); +} + +void unified_log_debug(const char *func, const char *fmt, ...) { + if (!is_log_enable_debug()) { + return; + } + va_list args; + va_start(args, fmt); + dev_vlog_debug(func, fmt, args); va_end(args); } diff --git a/src/common/platform/shared/host/args_dump_collector.cpp b/src/common/platform/shared/host/args_dump_collector.cpp index 04afd9f625..c114f6b8ee 100644 --- a/src/common/platform/shared/host/args_dump_collector.cpp +++ b/src/common/platform/shared/host/args_dump_collector.cpp @@ -172,7 +172,7 @@ int ArgsDumpCollector::initialize( state->arena_write_offset = 0; state->dropped_record_count = 0; - LOG_INFO_V0( + LOG_DEBUG( "Thread %d: dump arena allocated (dev=%p, host=%p, size=%lu MB)", t, ai.dev_ptr, ai.host_ptr, arena_size / (1024 * 1024) ); @@ -216,7 +216,7 @@ int ArgsDumpCollector::initialize( shm_dev_local, shm_host_local, shm_size, device_id ); - LOG_INFO_V0( + LOG_DEBUG( "Args dump initialized: %d threads, arena=%lu MB/thread, %d buffers/thread", num_dump_threads, arena_size / (1024 * 1024), PLATFORM_DUMP_BUFFERS_PER_THREAD ); @@ -409,7 +409,7 @@ void ArgsDumpCollector::on_buffer_collected(const DumpReadyBufferInfo &info, int if (now_ms - last_ms >= 5000 && last_progress_ms_.compare_exchange_strong(last_ms, now_ms, std::memory_order_relaxed)) { auto elapsed_s = std::chrono::duration_cast(now - run_start_time_).count(); - LOG_INFO_V0( + LOG_DEBUG( "Collecting: %lu args, %.1f GB written (%lds)", static_cast(total_metadata_collected_.load(std::memory_order_relaxed)), bytes_written_.load() / 1e9, elapsed_s @@ -622,7 +622,7 @@ int ArgsDumpCollector::export_dump_files() { auto elapsed_s = std::chrono::duration_cast(std::chrono::steady_clock::now() - run_start_time_) .count(); - LOG_INFO_V0( + LOG_DEBUG( "Writing to disk: %.1f GB written, %zu args remaining (%lds)", bytes_written_.load() / 1e9, write_queue_.size(), elapsed_s ); @@ -636,7 +636,7 @@ int ArgsDumpCollector::export_dump_files() { auto elapsed_ms = std::chrono::duration_cast(std::chrono::steady_clock::now() - run_start_time_) .count(); - LOG_INFO_V0( + LOG_DEBUG( "Collected %lu args, wrote %.1f GB to disk (%.1fs)", static_cast(total_metadata_collected_.load(std::memory_order_relaxed)), bytes_written_.load() / 1e9, elapsed_ms / 1000.0 @@ -662,7 +662,7 @@ int ArgsDumpCollector::export_dump_files() { return static_cast(a.role) < static_cast(b.role); }); - LOG_INFO_V0("Writing JSON manifest for %zu args...", collected_.size()); + LOG_DEBUG("Writing JSON manifest for %zu args...", collected_.size()); uint32_t num_before_dispatch = 0; uint32_t num_after_completion = 0; @@ -755,7 +755,7 @@ int ArgsDumpCollector::export_dump_files() { auto export_end = std::chrono::steady_clock::now(); auto total_ms = std::chrono::duration_cast(export_end - export_start).count(); - LOG_INFO_V0("Wrote JSON manifest (%zu args) to %s (%ldms)", collected_.size(), run_dir_.c_str(), total_ms); + LOG_DEBUG("Wrote JSON manifest (%zu args) to %s (%ldms)", collected_.size(), run_dir_.c_str(), total_ms); uint32_t truncated = total_truncated_count_.load(std::memory_order_relaxed); uint32_t dropped = total_dropped_record_count_.load(std::memory_order_relaxed); diff --git a/src/common/platform/shared/host/dep_gen_collector.cpp b/src/common/platform/shared/host/dep_gen_collector.cpp index 44544de427..c672889ec0 100644 --- a/src/common/platform/shared/host/dep_gen_collector.cpp +++ b/src/common/platform/shared/host/dep_gen_collector.cpp @@ -126,7 +126,7 @@ int DepGenCollector::init( // free_queue contents) to device. profiling_copy_to_device(shm_dev_local, shm_host_local, shm_size); - LOG_INFO_V0( + LOG_DEBUG( "DepGen collector initialized: %d threads, SHM=0x%lx (records held in memory until replay)", num_threads, reinterpret_cast(shm_dev_local) ); @@ -235,7 +235,7 @@ bool DepGenCollector::reconcile_counters() { ); clean = false; } else { - LOG_INFO_V0( + LOG_DEBUG( "dep_gen reconcile: counts match (collected=%lu, dropped=%lu, device_total=%lu, overflow=%lu)", static_cast(total_collected_), static_cast(dropped_device), static_cast(total_device), static_cast(overflow_device) @@ -314,5 +314,5 @@ void DepGenCollector::finalize(DepGenUnregisterCallback unregister_cb, const Dep shm_size_ = 0; total_collected_ = 0; clear_memory_context(); - LOG_INFO_V0("DepGen collector finalized"); + LOG_DEBUG("DepGen collector finalized"); } diff --git a/src/common/platform/shared/host/l2_swimlane_collector.cpp b/src/common/platform/shared/host/l2_swimlane_collector.cpp index 10c4519fd5..200576bf28 100644 --- a/src/common/platform/shared/host/l2_swimlane_collector.cpp +++ b/src/common/platform/shared/host/l2_swimlane_collector.cpp @@ -99,7 +99,7 @@ int L2SwimlaneCollector::initialize( return -1; } - LOG_INFO_V0("Initializing performance profiling"); + LOG_DEBUG("Initializing performance profiling"); if (num_aicore <= 0 || num_aicore > PLATFORM_MAX_CORES) { LOG_ERROR("Invalid number of AICores: %d (max=%d)", num_aicore, PLATFORM_MAX_CORES); @@ -442,7 +442,7 @@ int L2SwimlaneCollector::initialize( // make is_initialized() report true and finalize() double-free. reset_collector_shards(); - LOG_INFO_V0("Performance profiling initialized (dynamic buffer mode)"); + LOG_DEBUG("Performance profiling initialized (dynamic buffer mode)"); guard.commit(); // Publish device-buffer members + memory context only after the rollback // guard is disarmed: on a failed init they stay nullptr / shm_host_ stays @@ -772,7 +772,7 @@ void L2SwimlaneCollector::reconcile_counters() { static_cast(total_device), static_cast(total_device) - static_cast(accounted) ); } else { - LOG_INFO_V0( + LOG_DEBUG( "L2Swimlane reconcile: %s counts match (collected=%lu, dropped=%lu, device_total=%lu)", kind, static_cast(collected), static_cast(dropped_device), static_cast(total_device) @@ -840,7 +840,7 @@ void L2SwimlaneCollector::read_phase_header_metadata() { int num_sched = static_cast(header->num_sched_phase_threads); int num_orch = static_cast(header->num_orch_phase_threads); if (num_sched == 0 && num_orch == 0) { - LOG_INFO_V0("No phase profiling data found (sched/orch phase thread counts both 0; phase init never ran)"); + LOG_DEBUG("No phase profiling data found (sched/orch phase thread counts both 0; phase init never ran)"); return; } if (num_sched > PLATFORM_MAX_AICPU_THREADS || num_orch > PLATFORM_MAX_AICPU_THREADS) { @@ -858,18 +858,16 @@ void L2SwimlaneCollector::read_phase_header_metadata() { // [1, PLATFORM_MAX_AICPU_THREADS] before initialize()), so the subtraction // can't go negative. This is a log-only display value, never an index. const int orch_thread = aicpu_thread_num_ - 1; - LOG_INFO_V0( - "Collecting phase metadata: scheduler threads 0-%d, orchestrator thread %d", num_sched - 1, orch_thread - ); + LOG_DEBUG("Collecting phase metadata: scheduler threads 0-%d, orchestrator thread %d", num_sched - 1, orch_thread); for (size_t t = 0; t < collected_sched_phase_records_.size(); t++) { if (!collected_sched_phase_records_[t].empty()) { - LOG_INFO_V0(" Sched thread %zu: %zu records", t, collected_sched_phase_records_[t].size()); + LOG_DEBUG(" Sched thread %zu: %zu records", t, collected_sched_phase_records_[t].size()); } } for (size_t t = 0; t < collected_orch_phase_records_.size(); t++) { if (!collected_orch_phase_records_[t].empty()) { - LOG_INFO_V0(" Orch thread %d: %zu records", orch_thread, collected_orch_phase_records_[t].size()); + LOG_DEBUG(" Orch thread %d: %zu records", orch_thread, collected_orch_phase_records_[t].size()); } } @@ -881,10 +879,10 @@ void L2SwimlaneCollector::read_phase_header_metadata() { int num_phase_cores = static_cast(header->num_phase_cores); if (num_phase_cores > 0 && num_phase_cores <= PLATFORM_MAX_CORES) { core_to_thread_.assign(header->core_to_thread, header->core_to_thread + num_phase_cores); - LOG_INFO_V0(" Core-to-thread mapping: %d cores", num_phase_cores); + LOG_DEBUG(" Core-to-thread mapping: %d cores", num_phase_cores); } - LOG_INFO_V0("Phase metadata collection complete: has_phase_data=%s", has_phase_data_ ? "yes" : "no"); + LOG_DEBUG("Phase metadata collection complete: has_phase_data=%s", has_phase_data_ ? "yes" : "no"); } void L2SwimlaneCollector::set_core_types(const CoreType *types, int n) { @@ -996,7 +994,7 @@ int L2SwimlaneCollector::export_swimlane_json() { } if (!first) outfile << "\n "; outfile << "]"; - LOG_INFO_V0(" aicore_tasks: %zu records", total); + LOG_DEBUG(" aicore_tasks: %zu records", total); } { outfile << ",\n \"aicpu_tasks\": ["; @@ -1013,7 +1011,7 @@ int L2SwimlaneCollector::export_swimlane_json() { } if (!first) outfile << "\n "; outfile << "]"; - LOG_INFO_V0(" aicpu_tasks: %zu records", total); + LOG_DEBUG(" aicpu_tasks: %zu records", total); } // Phase records keep their per-thread sub-array shape so the python @@ -1126,8 +1124,8 @@ int L2SwimlaneCollector::export_swimlane_json() { return -1; } - LOG_INFO_V0("=== JSON Export Complete ==="); - LOG_INFO_V0("File: %s", filepath.c_str()); + LOG_DEBUG("=== JSON Export Complete ==="); + LOG_DEBUG("File: %s", filepath.c_str()); return 0; } diff --git a/src/common/platform/shared/host/scope_stats_collector.cpp b/src/common/platform/shared/host/scope_stats_collector.cpp index 919c57d052..46302919a3 100644 --- a/src/common/platform/shared/host/scope_stats_collector.cpp +++ b/src/common/platform/shared/host/scope_stats_collector.cpp @@ -140,7 +140,7 @@ int ScopeStatsCollector::init( shm_dev_local, shm_host_local, shm_size, device_id ); - LOG_INFO_V0( + LOG_DEBUG( "ScopeStats collector initialized: %d threads, SHM=0x%lx", num_threads, reinterpret_cast(shm_dev_) ); @@ -237,7 +237,7 @@ bool ScopeStatsCollector::reconcile_counters() { ); clean = false; } else { - LOG_INFO_V0( + LOG_DEBUG( "scope_stats reconcile: counts match (collected=%lu, dropped=%lu, device_total=%lu)", static_cast(total_collected_), static_cast(dropped_device), static_cast(total_device) @@ -320,7 +320,7 @@ int ScopeStatsCollector::write_jsonl(const std::string &output_dir) { std::fwrite(out.data(), 1, out.size(), fp); std::fclose(fp); - LOG_INFO_V1( + LOG_DEBUG( "scope_stats: wrote %lu records (dropped=%u) to %s", static_cast(records_.size()), state->dropped_record_count, path.c_str() ); @@ -388,5 +388,5 @@ void ScopeStatsCollector::finalize(ScopeStatsUnregisterCallback unregister_cb, c initialized_ = false; total_collected_ = 0; clear_memory_context(); - LOG_INFO_V0("ScopeStats collector finalized"); + LOG_DEBUG("ScopeStats collector finalized"); } diff --git a/src/common/platform/sim/aicpu/device_log.cpp b/src/common/platform/sim/aicpu/device_log.cpp index 8f3c265061..4407796593 100644 --- a/src/common/platform/sim/aicpu/device_log.cpp +++ b/src/common/platform/sim/aicpu/device_log.cpp @@ -12,9 +12,8 @@ * @file device_log.cpp (sim) * @brief Simulation Platform Log Implementation * - * Severity and verbosity flags are populated by host via set_log_level() / - * set_log_info_v() at AICPU kernel init (see kernel.cpp / aicpu_executor.cpp); - * this file does not read env vars. + * Level flags are populated by host via set_log_level() at AICPU kernel init + * (see kernel.cpp / aicpu_executor.cpp); this file does not read env vars. */ #include "aicpu/device_log.h" @@ -23,38 +22,27 @@ #include // ============================================================================= -// Severity enable flags + verbosity threshold (mutated by setters below) +// Level enable flags (mutated by the setter below) // ============================================================================= bool g_is_log_enable_debug = false; -bool g_is_log_enable_info = true; // default INFO+ on +bool g_is_log_enable_info = false; +bool g_is_log_enable_timing = true; bool g_is_log_enable_warn = true; bool g_is_log_enable_error = true; -// Default V5 (matches HostLogger / Python defaults). -int g_log_info_v = 5; - // ============================================================================= // Setters (called by AICPU init from KernelArgs) // ============================================================================= extern "C" void set_log_level(int level) { - // CANN-aligned: DEBUG=0, INFO=1, WARN=2, ERROR=3, NUL=4. Floor semantics: - // messages with severity >= floor are kept. - g_is_log_enable_debug = (level <= 0) && (level != 4); - g_is_log_enable_info = (level <= 1) && (level != 4); - g_is_log_enable_warn = (level <= 2) && (level != 4); - g_is_log_enable_error = (level <= 3) && (level != 4); -} - -extern "C" void set_log_info_v(int v) { - if (v < 0) v = 0; - if (v > 9) v = 9; - g_log_info_v = v; + g_is_log_enable_debug = level <= 10; + g_is_log_enable_info = level <= 20; + g_is_log_enable_timing = level <= 25; + g_is_log_enable_warn = level <= 30; + g_is_log_enable_error = level <= 40; } -extern "C" int get_log_info_v() { return g_log_info_v; } - // ============================================================================= // init_log_switch: sim respects host-pushed config — this is now a no-op // (kept for ABI compatibility with onboard, where it queries CANN dlog). @@ -62,7 +50,7 @@ extern "C" int get_log_info_v() { return g_log_info_v; } void init_log_switch() { // Sim has no env / dlog to consult. Defaults already applied at static - // init; host overrides via set_log_level()/set_log_info_v() before this + // init; host overrides via set_log_level() before this // is called. } @@ -76,20 +64,26 @@ void dev_vlog_debug(const char *func, const char *fmt, va_list args) { fputc('\n', stderr); } -void dev_vlog_warn(const char *func, const char *fmt, va_list args) { - fprintf(stderr, "[WARN] %s: ", func); +void dev_vlog_info(const char *func, const char *fmt, va_list args) { + fprintf(stderr, "[INFO] %s: ", func); vfprintf(stderr, fmt, args); fputc('\n', stderr); } -void dev_vlog_error(const char *func, const char *fmt, va_list args) { - fprintf(stderr, "[ERROR] %s: ", func); +void dev_vlog_timing(const char *func, const char *fmt, va_list args) { + fprintf(stderr, "[TIMING] %s: ", func); vfprintf(stderr, fmt, args); fputc('\n', stderr); } -void dev_vlog_info_v(int v, const char *func, const char *fmt, va_list args) { - fprintf(stderr, "[INFO_V%d] %s: ", v, func); +void dev_vlog_warn(const char *func, const char *fmt, va_list args) { + fprintf(stderr, "[WARN] %s: ", func); + vfprintf(stderr, fmt, args); + fputc('\n', stderr); +} + +void dev_vlog_error(const char *func, const char *fmt, va_list args) { + fprintf(stderr, "[ERROR] %s: ", func); vfprintf(stderr, fmt, args); fputc('\n', stderr); } diff --git a/src/common/platform/sim/aicpu/platform_aicpu_affinity.cpp b/src/common/platform/sim/aicpu/platform_aicpu_affinity.cpp index 81e45021a6..ff036032db 100644 --- a/src/common/platform/sim/aicpu/platform_aicpu_affinity.cpp +++ b/src/common/platform/sim/aicpu/platform_aicpu_affinity.cpp @@ -27,7 +27,7 @@ bool platform_aicpu_affinity_gate(int32_t logical_count, int32_t total_launched) bool survive = (idx < logical_count); if (!survive) { - LOG_INFO_V0( + LOG_DEBUG( "AICPU affinity gate (sim): thread idx=%d DROPPED (logical=%d, launched=%d)", idx, logical_count, total_launched ); @@ -69,7 +69,7 @@ bool platform_aicpu_affinity_gate_filter( tl_filter_exec_idx = survive ? idx : -1; if (!survive) { - LOG_INFO_V0( + LOG_DEBUG( "AICPU filter gate (sim): thread idx=%d DROPPED (allowed=%d, launched=%d)", idx, allowed_count, total_launched ); diff --git a/src/common/platform/sim/host/device_runner_base.cpp b/src/common/platform/sim/host/device_runner_base.cpp index fc7d1a9964..46315f5eec 100644 --- a/src/common/platform/sim/host/device_runner_base.cpp +++ b/src/common/platform/sim/host/device_runner_base.cpp @@ -253,7 +253,7 @@ int SimDeviceRunnerBase::prepare_launch_shape(Runtime &runtime, const CallConfig // A run always takes the whole simulated device; orchestration sizes its // cohorts from rt_available_cluster_count() rather than a per-call width. const int block_dim = SIM_AUTO_BLOCKDIM; - LOG_INFO_V0("block_dim resolved to %d", block_dim); + LOG_DEBUG("block_dim resolved to %d", block_dim); int num_aicore = block_dim * cores_per_blockdim_; if (num_aicore > RUNTIME_MAX_WORKER) { @@ -356,7 +356,7 @@ int SimDeviceRunnerBase::commit_device_register(int32_t cid) { const bool inserted = aicpu_seen_callable_ids_.insert(cid).second; if (inserted) { ++aicpu_dlopen_total_; - LOG_INFO_V0("AICPU callable load committed cid=%d (count=%zu)", cid, aicpu_dlopen_total_); + LOG_DEBUG("AICPU callable load committed cid=%d (count=%zu)", cid, aicpu_dlopen_total_); } return 0; } @@ -438,7 +438,7 @@ int SimDeviceRunnerBase::record_device_orch_callable( state.kernel_addrs = std::move(kernel_addrs); state.signature = std::move(signature); callables_.emplace(callable_id, std::move(state)); - LOG_INFO_V0( + LOG_DEBUG( "record_device_orch_callable: cid=%d orch_hash=0x%lx chip_hash=0x%lx %zu bytes", callable_id, hash, chip_buffer_hash, orch_so_size ); @@ -476,7 +476,7 @@ int SimDeviceRunnerBase::record_host_orch_callable( state.signature = std::move(signature); callables_.emplace(callable_id, std::move(state)); ++host_dlopen_total_; - LOG_INFO_V0("record_host_orch_callable: cid=%d (host dlopen #%zu)", callable_id, host_dlopen_total_); + LOG_DEBUG("record_host_orch_callable: cid=%d (host dlopen #%zu)", callable_id, host_dlopen_total_); return 0; } diff --git a/src/common/platform/sim/sim_context/cpu_sim_context.cpp b/src/common/platform/sim/sim_context/cpu_sim_context.cpp index 1556626c8f..9db7c20aaa 100644 --- a/src/common/platform/sim/sim_context/cpu_sim_context.cpp +++ b/src/common/platform/sim/sim_context/cpu_sim_context.cpp @@ -161,10 +161,10 @@ extern "C" void pto_cpu_sim_acquire_device(int device_id) { std::lock_guard lock(g_registry_mutex); if (g_device_contexts.find(device_id) == g_device_contexts.end()) { g_device_contexts[device_id] = new DeviceSimContext(); - // Verifies process-wide HostLogger singleton: this LOG_INFO_V0 call + // Verifies process-wide HostLogger singleton: this LOG_DEBUG call // resolves into libsimpler_log.so loaded by ChipWorker with // RTLD_GLOBAL — same instance as host_runtime.so writes to. - LOG_INFO_V0("cpu_sim_context: acquired device %d", device_id); + LOG_DEBUG("cpu_sim_context: acquired device %d", device_id); } } diff --git a/src/common/worker/pto_runtime_c_api.h b/src/common/worker/pto_runtime_c_api.h index d137733985..e0e32b72a3 100644 --- a/src/common/worker/pto_runtime_c_api.h +++ b/src/common/worker/pto_runtime_c_api.h @@ -167,8 +167,9 @@ int copy_from_device_ctx(DeviceContextHandle ctx, void *host_ptr, const void *de * One-shot platform-side init. Called once by ChipWorker::init() right * after dlopen, before any other entry. Three responsibilities, in order: * - * 1. (Onboard only) Sync CANN dlog with HostLogger::get_instance().level() - * via dlog_setlevel(-1, level, 0), unless ASCEND_GLOBAL_LOG_LEVEL was + * 1. (Onboard only) Sync CANN dlog with + * HostLogger::get_instance().cann_level() via + * dlog_setlevel(-1, level, 0), unless ASCEND_GLOBAL_LOG_LEVEL was * externally configured, in which case CANN keeps the user's choice. * This must run before step 2 because CANN snapshots the device-side * log session's level at context-open time (rtSetDevice); a later diff --git a/tests/st/a2a3/host_build_graph/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp b/tests/st/a2a3/host_build_graph/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp index fa8136a14a..7207c9ac46 100644 --- a/tests/st/a2a3/host_build_graph/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp +++ b/tests/st/a2a3/host_build_graph/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const int32_t cluster_count = rt_available_cluster_count(); const int32_t aiv_count = rt_available_aiv_count(); - LOG_INFO_V0("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); + LOG_DEBUG("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); MixedKernels mk; mk.aic_kernel_id = FUNC_SPMD_MIX_AIC; diff --git a/tests/st/a2a3/host_build_graph/bgemm/kernels/orchestration/bgemm_orch.cpp b/tests/st/a2a3/host_build_graph/bgemm/kernels/orchestration/bgemm_orch.cpp index 0cb8114c93..5994dcf960 100644 --- a/tests/st/a2a3/host_build_graph/bgemm/kernels/orchestration/bgemm_orch.cpp +++ b/tests/st/a2a3/host_build_graph/bgemm/kernels/orchestration/bgemm_orch.cpp @@ -96,7 +96,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V9("[bgemm_orch] Submitted tiled C = A @ B"); + LOG_INFO("[bgemm_orch] Submitted tiled C = A @ B"); } } // extern "C" diff --git a/tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp b/tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp index d060239360..ce80007b28 100644 --- a/tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp +++ b/tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp @@ -61,7 +61,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta p1.add_scalar(sconv.u64); rt_submit_aiv_task(FUNC_ADD_SCALAR_INPLACE, p1); - LOG_INFO_V9("[dump_args_orch] Submitted f = (a + b) + 1"); + LOG_INFO("[dump_args_orch] Submitted f = (a + b) + 1"); } } // extern "C" diff --git a/tests/st/a2a3/host_build_graph/matmul/kernels/orchestration/matmul_orch.cpp b/tests/st/a2a3/host_build_graph/matmul/kernels/orchestration/matmul_orch.cpp index 9e6e2e8bba..5035b0bf1a 100644 --- a/tests/st/a2a3/host_build_graph/matmul/kernels/orchestration/matmul_orch.cpp +++ b/tests/st/a2a3/host_build_graph/matmul/kernels/orchestration/matmul_orch.cpp @@ -83,7 +83,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta p3.add_output(f); rt_submit_aiv_task(FUNC_ADD_EXP, p3); - LOG_INFO_V9("[matmul_orch] Submitted 4-task diamond"); + LOG_INFO("[matmul_orch] Submitted 4-task diamond"); } } // extern "C" diff --git a/tests/st/a2a3/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp index 2ed86cdf2f..e87df0bf14 100644 --- a/tests/st/a2a3/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -105,7 +105,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint64_t q_loop = (q_head_num + q_tile - 1) / q_tile; CYCLE_COUNT_LAP(prof_param_extract); - LOG_INFO_V9(">>>>>> batch = %" PRIu64, batch); + LOG_INFO(">>>>>> batch = %" PRIu64, batch); // Reshape tensors for kernel consumption (2D flattened) void *query_ptr = orch_args.tensor(0).ref().data_as(); @@ -254,33 +254,33 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); - LOG_INFO_V9( + LOG_INFO(" scope : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope), prof_scope * 100.0 / total); + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 diff --git a/tests/st/a2a3/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp b/tests/st/a2a3/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp index e13d57d224..3f2fc1d73e 100644 --- a/tests/st/a2a3/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp +++ b/tests/st/a2a3/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp @@ -85,7 +85,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta p_mul.add_output(f); rt_submit_aiv_task(FUNC_MUL, p_mul); - LOG_INFO_V9("[example_orch] Submitted 4 tasks for f = (a + b + 1) * (a + b + 2)"); + LOG_INFO("[example_orch] Submitted 4 tasks for f = (a + b + 1) * (a + b + 2)"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp index d08f7645bc..cdc0c91c3c 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp @@ -62,7 +62,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta int matmul_batch = static_cast(orch_args.scalar(3)); int add_batch = static_cast(orch_args.scalar(4)); - LOG_INFO_V0( + LOG_DEBUG( "[alternating_orch] Batch: %d, M: %d, N: %d, matmul_batch: %d, add_batch: %d", batch, M, N, matmul_batch, add_batch ); @@ -120,7 +120,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V9("[alternating_orch] Submitted %d matmul groups and %d add groups", total_matmul, total_add); + LOG_INFO("[alternating_orch] Submitted %d matmul groups and %d add groups", total_matmul, total_add); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp index fa8136a14a..7207c9ac46 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const int32_t cluster_count = rt_available_cluster_count(); const int32_t aiv_count = rt_available_aiv_count(); - LOG_INFO_V0("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); + LOG_DEBUG("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); MixedKernels mk; mk.aic_kernel_id = FUNC_SPMD_MIX_AIC; diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp index 1717ebc48a..dcad33785f 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp @@ -74,7 +74,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint64_t q_loop = (num_heads + q_tile - 1) / q_tile; uint64_t elem_size = get_element_size(data_type); - LOG_INFO_V0("batch_paged_attention: batch=%" PRIu64 ", num_heads=%" PRIu64, batch, num_heads); + LOG_DEBUG("batch_paged_attention: batch=%" PRIu64 ", num_heads=%" PRIu64, batch, num_heads); void *query_ptr = orch_args.tensor(0).ref().data_as(); void *kc_ptr = orch_args.tensor(1).ref().data_as(); @@ -205,7 +205,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V0( + LOG_DEBUG( "batch_paged_attention: %" PRIu64 " tasks (batch=%" PRIu64 ", max_bn=%" PRIu64 ", chunks=%" PRIu64 ", IN_CORE_BATCH=%" PRIu64 ")", static_cast(num_chunks * (1 + max_bn * 4)), batch, max_bn, num_chunks, IN_CORE_BATCH diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp index 333cabcbe0..00407a83ac 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp @@ -73,7 +73,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta Tensor ws_aiv_slot0 = ext_ws_aiv.view(slot_shape, off_slot0); Tensor ws_aiv_slot1 = ext_ws_aiv.view(slot_shape, off_slot1); - LOG_INFO_V0("[chained_mix_orch] launching 3-step chained MIX (AIC + AIV)"); + LOG_DEBUG("[chained_mix_orch] launching 3-step chained MIX (AIC + AIV)"); // Step 1: heads of both chains read external inputs. { diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp index f041c5523d..a67db3614d 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp @@ -68,7 +68,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_W = orch_args.tensor(2).ref(); uint64_t case_id = orch_args.scalar(0); - LOG_INFO_V0("[dummy_task_orch] case_id=%llu", static_cast(case_id)); + LOG_DEBUG("[dummy_task_orch] case_id=%llu", static_cast(case_id)); if (case_id == 1) { // producer writes X diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp index 6e3d53054c..e135c00fa7 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp @@ -71,7 +71,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint32_t total_elems = orch_args.tensor(2).ref().shapes[0]; int num_iters = static_cast(total_elems / TILE_ELEMS); - LOG_INFO_V0("[mixed_orch] num_iters=%d", num_iters); + LOG_DEBUG("[mixed_orch] num_iters=%d", num_iters); for (int i = 0; i < num_iters; i++) { PTO2_SCOPE() { @@ -157,7 +157,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V0("[mixed_orch] Submitted %d iterations x 5 shapes = %d tasks", num_iters, num_iters * 5); + LOG_DEBUG("[mixed_orch] Submitted %d iterations x 5 shapes = %d tasks", num_iters, num_iters * 5); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp index 0978073d96..f6d6d14e67 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp @@ -334,38 +334,38 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = g_prof.param_extract + g_prof.ext_tensor + g_prof.make_tensor + g_prof.tensor_view + g_prof.param_setup + g_prof.submit_task + g_prof.scope_and_loop; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", g_prof.submit_count, g_prof.make_count, g_prof.view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(g_prof.param_extract), g_prof.param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(g_prof.ext_tensor), g_prof.ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", g_prof.make_count, cycles_to_us(g_prof.make_tensor), g_prof.make_tensor * 100.0 / total, g_prof.make_count > 0 ? cycles_to_us(g_prof.make_tensor) / g_prof.make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", g_prof.view_count, cycles_to_us(g_prof.tensor_view), g_prof.tensor_view * 100.0 / total, g_prof.view_count > 0 ? cycles_to_us(g_prof.tensor_view) / g_prof.view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(g_prof.param_setup), g_prof.param_setup * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", g_prof.submit_count, cycles_to_us(g_prof.submit_task), g_prof.submit_task * 100.0 / total, g_prof.submit_count > 0 ? cycles_to_us(g_prof.submit_task) / g_prof.submit_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " scope_and_loop : %7.3fus (%5.1f%%)", cycles_to_us(g_prof.scope_and_loop), g_prof.scope_and_loop * 100.0 / total ); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp index 6b92c3b1f7..d1bb823e6d 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp @@ -50,7 +50,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta rt_submit_task(mk, args); - LOG_INFO_V9("[spmd_basic_orch] Submitted 1 MIX task (AIC+AIV0+AIV1)"); + LOG_INFO("[spmd_basic_orch] Submitted 1 MIX task (AIC+AIV0+AIV1)"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp index 47cd60ce74..3bbfeac6a3 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta submit_spmd_mix(ext_output, 48, 0); submit_spmd_mix(ext_output, 48, 144); - LOG_INFO_V9("[spmd_batch_dispatch_oob] Submitted 2 MIX tasks: block_num=48,48"); + LOG_INFO("[spmd_batch_dispatch_oob] Submitted 2 MIX tasks: block_num=48,48"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp index 188317cb9d..4b2b44e8bd 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp @@ -65,7 +65,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // T4: 96 blocks — two full rounds of all AIV cores submit_spmd_aiv(FUNC_SPMD_WRITE_AIV, ext_output, 96, 92); - LOG_INFO_V9("[spmd_multiblock_aiv] Submitted 5 AIV tasks: block_num=4,16,24,48,96"); + LOG_INFO("[spmd_multiblock_aiv] Submitted 5 AIV tasks: block_num=4,16,24,48,96"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp index bf875a1571..8b8877cf9d 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp @@ -74,7 +74,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // T4: 48 blocks (144 CL) — two full rounds of all clusters submit_spmd_mix(FUNC_SPMD_MIX_AIC, FUNC_SPMD_MIX_AIV0, FUNC_SPMD_MIX_AIV1, ext_output, 48, 138); - LOG_INFO_V9("[spmd_multiblock_mix] Submitted 5 MIX tasks: block_num=2,8,12,24,48"); + LOG_INFO("[spmd_multiblock_mix] Submitted 5 MIX tasks: block_num=2,8,12,24,48"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp index 07e90500b8..a503c295f3 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp @@ -77,7 +77,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint64_t q_loop = (num_heads + q_tile - 1) / q_tile; int64_t total_logical_blocks = static_cast(batch * q_loop); - LOG_INFO_V0( + LOG_DEBUG( "SPMD PA TPUSH/TPOP: batch=%" PRIu64 " heads=%" PRIu64 " hd=%" PRIu64 " bs=%" PRIu64 " q_tile=%" PRIu64 " q_loop=%" PRIu64 " hw_blocks=%d logical_blocks=%" PRId64, batch, num_heads, head_dim, block_size, q_tile, q_loop, SPMD_BLOCK_NUM, total_logical_blocks @@ -150,7 +150,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta rt_submit_task(mk, args); } - LOG_INFO_V0( + LOG_DEBUG( "SPMD PA TPUSH/TPOP: submitted 1 MixedKernels task, hw_blocks=%d logical=%" PRId64, static_cast(SPMD_BLOCK_NUM), total_logical_blocks ); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention_highperf/kernels/orchestration/paged_attention_highperf_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention_highperf/kernels/orchestration/paged_attention_highperf_orch.cpp index 2c27e131aa..6bfec2a8e1 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention_highperf/kernels/orchestration/paged_attention_highperf_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention_highperf/kernels/orchestration/paged_attention_highperf_orch.cpp @@ -28,7 +28,7 @@ __attribute__((visibility("default"))) PTO2OrchestrationConfig aicpu_orchestrati __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2TaskArgs &orch_args) { int64_t block_dim = static_cast(orch_args.scalar(0)); - LOG_INFO_V1("SPMD PA highperf: block_dim=%" PRId64, block_dim); + LOG_DEBUG("SPMD PA highperf: block_dim=%" PRId64, block_dim); const Tensor &query = orch_args.tensor(0).ref(); const Tensor &key_cache = orch_args.tensor(1).ref(); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp index f1e66c425a..3883c939c3 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp @@ -89,7 +89,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta for (int i = 0; i < 6; i++, cl += NORMAL_CL) submit_mix(ext_output, NORMAL_BLOCK_NUM, cl, false); - LOG_INFO_V9("[spmd_starvation] Submitted 20 tasks (18 normal + 2 sync_start)"); + LOG_INFO("[spmd_starvation] Submitted 20 tasks (18 normal + 2 sync_start)"); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp index 0a67f2994e..48edea2aea 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp @@ -95,7 +95,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * SLOTS_PER_BLOCK; } - LOG_INFO_V9("[spmd_sync_start] Submitted 4 tasks over %d clusters", clusters); + LOG_INFO("[spmd_sync_start] Submitted 4 tasks over %d clusters", clusters); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp index 4f41537e43..2b7d72b629 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp @@ -85,7 +85,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * 1; } - LOG_INFO_V9("[spmd_sync_start_aiv] Submitted 4 tasks over %d units", aiv_cores); + LOG_INFO("[spmd_sync_start_aiv] Submitted 4 tasks over %d units", aiv_cores); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp index 5dc5bb094b..0e597f1550 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp @@ -96,7 +96,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint32_t idx[1] = {0}; set_tensor_data(layout, 1, idx, sync_blocks); - LOG_INFO_V9( + LOG_INFO( "[spmd_sync_start_early_dispatch] producer (%d) + MIX sync_start consumer (%d)", PRODUCER_BLOCKS, sync_blocks ); } diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp index e89f50b18a..370ad2a954 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp @@ -87,7 +87,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * 3; } - LOG_INFO_V9("[spmd_sync_start_edge] Submitted 5 tasks over %d units", clusters); + LOG_INFO("[spmd_sync_start_edge] Submitted 5 tasks over %d units", clusters); } } // extern "C" diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp index 29ec44da29..80ce9f481a 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp @@ -109,7 +109,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta idx[0] = 1; set_tensor_data(layout, 1, idx, consumer_blocks); - LOG_INFO_V9( + LOG_INFO( "[spmd_sync_start_mix_spill] flagged AIV producer (%d) + sync_start MIX consumer (%d) submitted", producer_blocks, consumer_blocks ); diff --git a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp index ed5471b289..cba3913efa 100644 --- a/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp +++ b/tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp @@ -119,7 +119,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta cl += normal_aiv_bn; } - LOG_INFO_V9("[spmd_sync_start_stress] Submitted %d tasks over %d rounds", 9 * ROUNDS, ROUNDS); + LOG_INFO("[spmd_sync_start_stress] Submitted %d tasks over %d rounds", 9 * ROUNDS, ROUNDS); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp index fa8136a14a..7207c9ac46 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp @@ -58,7 +58,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const int32_t cluster_count = rt_available_cluster_count(); const int32_t aiv_count = rt_available_aiv_count(); - LOG_INFO_V0("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); + LOG_DEBUG("[available_aicore_counts] clusters=%d aiv=%d", cluster_count, aiv_count); MixedKernels mk; mk.aic_kernel_id = FUNC_SPMD_MIX_AIC; diff --git a/tests/st/a5/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp index 333cabcbe0..00407a83ac 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/dfx/l2_swimlane/kernels/orchestration/chained_mix_orch.cpp @@ -73,7 +73,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta Tensor ws_aiv_slot0 = ext_ws_aiv.view(slot_shape, off_slot0); Tensor ws_aiv_slot1 = ext_ws_aiv.view(slot_shape, off_slot1); - LOG_INFO_V0("[chained_mix_orch] launching 3-step chained MIX (AIC + AIV)"); + LOG_DEBUG("[chained_mix_orch] launching 3-step chained MIX (AIC + AIV)"); // Step 1: heads of both chains read external inputs. { diff --git a/tests/st/a5/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp index f041c5523d..a67db3614d 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp @@ -68,7 +68,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta const Tensor &ext_W = orch_args.tensor(2).ref(); uint64_t case_id = orch_args.scalar(0); - LOG_INFO_V0("[dummy_task_orch] case_id=%llu", static_cast(case_id)); + LOG_DEBUG("[dummy_task_orch] case_id=%llu", static_cast(case_id)); if (case_id == 1) { // producer writes X diff --git a/tests/st/a5/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp index 6e3d53054c..e135c00fa7 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp @@ -71,7 +71,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint32_t total_elems = orch_args.tensor(2).ref().shapes[0]; int num_iters = static_cast(total_elems / TILE_ELEMS); - LOG_INFO_V0("[mixed_orch] num_iters=%d", num_iters); + LOG_DEBUG("[mixed_orch] num_iters=%d", num_iters); for (int i = 0; i < num_iters; i++) { PTO2_SCOPE() { @@ -157,7 +157,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta } } - LOG_INFO_V0("[mixed_orch] Submitted %d iterations x 5 shapes = %d tasks", num_iters, num_iters * 5); + LOG_DEBUG("[mixed_orch] Submitted %d iterations x 5 shapes = %d tasks", num_iters, num_iters * 5); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp index 4fd91db8c9..7ff9da70fb 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp @@ -274,37 +274,37 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta #ifdef ENABLE_PROFILING uint64_t total = prof_param_extract + prof_ext_tensor + prof_make_tensor + prof_tensor_view + prof_param_setup + prof_submit_task + prof_scope_and_loop; - LOG_INFO_V9( + LOG_INFO( "=== PagedAttn Orch Profiling: %d submits, %d makes, %d views, total=%.3fus ===", prof_submit_count, prof_make_count, prof_view_count, cycles_to_us(total) ); if (total > 0) { - LOG_INFO_V9( + LOG_INFO( " param_extract : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_extract), prof_param_extract * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " ext_tensor(x4) : %7.3fus (%5.1f%%)", cycles_to_us(prof_ext_tensor), prof_ext_tensor * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " create_info(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_make_count, cycles_to_us(prof_make_tensor), prof_make_tensor * 100.0 / total, prof_make_count > 0 ? cycles_to_us(prof_make_tensor) / prof_make_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " tensor_view(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_view_count, cycles_to_us(prof_tensor_view), prof_tensor_view * 100.0 / total, prof_view_count > 0 ? cycles_to_us(prof_tensor_view) / prof_view_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " param_setup : %7.3fus (%5.1f%%)", cycles_to_us(prof_param_setup), prof_param_setup * 100.0 / total ); - LOG_INFO_V9( + LOG_INFO( " submit_task(x%d) : %7.3fus (%5.1f%%) avg=%.3fus", prof_submit_count, cycles_to_us(prof_submit_task), prof_submit_task * 100.0 / total, prof_submit_count > 0 ? cycles_to_us(prof_submit_task) / prof_submit_count : 0.0 ); - LOG_INFO_V9( + LOG_INFO( " scope_and_loop : %7.3fus (%5.1f%%)", cycles_to_us(prof_scope_and_loop), prof_scope_and_loop * 100.0 / total ); diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp index 6b92c3b1f7..d1bb823e6d 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp @@ -50,7 +50,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta rt_submit_task(mk, args); - LOG_INFO_V9("[spmd_basic_orch] Submitted 1 MIX task (AIC+AIV0+AIV1)"); + LOG_INFO("[spmd_basic_orch] Submitted 1 MIX task (AIC+AIV0+AIV1)"); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp index cb2b5a50a0..9e3426e5db 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp @@ -65,7 +65,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // T4: 96 blocks — two full rounds of all AIV cores submit_spmd_aiv(FUNC_SPMD_WRITE_AIV, ext_output, 96, 92); - LOG_INFO_V9("[spmd_multiblock_aiv] Submitted 5 AIV tasks: block_num=4,16,24,48,96"); + LOG_INFO("[spmd_multiblock_aiv] Submitted 5 AIV tasks: block_num=4,16,24,48,96"); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp index 627e3569a7..cb448307a2 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp @@ -74,7 +74,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta // T4: 48 blocks (144 CL) — two full rounds of all clusters submit_spmd_mix(FUNC_SPMD_MIX_AIC, FUNC_SPMD_MIX_AIV0, FUNC_SPMD_MIX_AIV1, ext_output, 48, 138); - LOG_INFO_V9("[spmd_multiblock_mix] Submitted 5 MIX tasks: block_num=2,8,12,24,48"); + LOG_INFO("[spmd_multiblock_mix] Submitted 5 MIX tasks: block_num=2,8,12,24,48"); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp index a9c459a4e5..527606be47 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp @@ -89,7 +89,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta for (int i = 0; i < 6; i++, cl += NORMAL_CL) submit_mix(ext_output, NORMAL_BLOCK_NUM, cl, false); - LOG_INFO_V9("[spmd_starvation] Submitted 20 tasks (18 normal + 2 sync_start)"); + LOG_INFO("[spmd_starvation] Submitted 20 tasks (18 normal + 2 sync_start)"); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp index 711145e51f..2c77407d51 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp @@ -95,7 +95,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * SLOTS_PER_BLOCK; } - LOG_INFO_V9("[spmd_sync_start] Submitted 4 tasks over %d clusters", clusters); + LOG_INFO("[spmd_sync_start] Submitted 4 tasks over %d clusters", clusters); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp index 1970644a84..d57cc67ec8 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp @@ -85,7 +85,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * 1; } - LOG_INFO_V9("[spmd_sync_start_aiv] Submitted 4 tasks over %d units", aiv_cores); + LOG_INFO("[spmd_sync_start_aiv] Submitted 4 tasks over %d units", aiv_cores); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp index 5cb9441bdb..81943ba499 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp @@ -91,7 +91,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta uint32_t idx[1] = {0}; set_tensor_data(layout, 1, idx, sync_blocks); - LOG_INFO_V9( + LOG_INFO( "[spmd_sync_start_early_dispatch] early_on=%d producer (%d) + MIX sync_start consumer (%d)", early_on ? 1 : 0, PRODUCER_BLOCKS, sync_blocks ); diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp index d09791ab3a..b1e7cd304d 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp @@ -87,7 +87,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta base_cl += block_nums[i] * 3; } - LOG_INFO_V9("[spmd_sync_start_edge] Submitted 5 tasks over %d units", clusters); + LOG_INFO("[spmd_sync_start_edge] Submitted 5 tasks over %d units", clusters); } } // extern "C" diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp index 33fe30079c..f9d2c5c16b 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp @@ -91,7 +91,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta idx[0] = 1; set_tensor_data(layout, 1, idx, consumer_blocks); - LOG_INFO_V9( + LOG_INFO( "[spmd_sync_start_mix_spill] early_on=%d AIV producer (%d) + sync_start MIX consumer (%d) submitted", early_on ? 1 : 0, producer_blocks, consumer_blocks ); diff --git a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp index 003ae7b225..67084fe91b 100644 --- a/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp +++ b/tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp @@ -119,7 +119,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta cl += normal_aiv_bn; } - LOG_INFO_V9("[spmd_sync_start_stress] Submitted %d tasks over %d rounds", 9 * ROUNDS, ROUNDS); + LOG_INFO("[spmd_sync_start_stress] Submitted %d tasks over %d rounds", 9 * ROUNDS, ROUNDS); } } // extern "C" diff --git a/tests/st/aicore_op_timeout/kernels/orchestration/aicore_op_timeout_orch.cpp b/tests/st/aicore_op_timeout/kernels/orchestration/aicore_op_timeout_orch.cpp index e5b025a9b3..cf9c2c107c 100644 --- a/tests/st/aicore_op_timeout/kernels/orchestration/aicore_op_timeout_orch.cpp +++ b/tests/st/aicore_op_timeout/kernels/orchestration/aicore_op_timeout_orch.cpp @@ -44,7 +44,7 @@ __attribute__((visibility("default"))) void aicpu_orchestration_entry(const L2Ta args.add_output(ci); rt_submit_aic_task(FUNC_AIC_HANG, args); - LOG_INFO_V9("[aicore_op_timeout] dispatched hanging AIC task"); + LOG_INFO("[aicore_op_timeout] dispatched hanging AIC task"); } } // extern "C" diff --git a/tests/ut/cpp/a2a3/test_a2a3_fatal.cpp b/tests/ut/cpp/a2a3/test_a2a3_fatal.cpp index f403e7a3dc..5f53c428dd 100644 --- a/tests/ut/cpp/a2a3/test_a2a3_fatal.cpp +++ b/tests/ut/cpp/a2a3/test_a2a3_fatal.cpp @@ -79,7 +79,6 @@ void fake_report_fatal(PTO2Runtime *rt, int32_t error_code, const char *func, co } void fake_log(const char *, const char *, ...) {} -void fake_log_v(const char *, int, const char *, ...) {} uint64_t fake_get_tensor_data(PTO2Runtime *rt, const Tensor &, uint32_t, const uint32_t[]) { as_fake(rt)->get_calls++; @@ -106,8 +105,9 @@ const PTO2RuntimeOps kFakeOps = { .report_fatal = fake_report_fatal, .log_error = fake_log, .log_warn = fake_log, + .log_timing = fake_log, + .log_info = fake_log, .log_debug = fake_log, - .log_info_v = fake_log_v, .get_tensor_data = fake_get_tensor_data, .set_tensor_data = fake_set_tensor_data, .alloc_tensors = fake_alloc_tensors, diff --git a/tests/ut/cpp/a2a3/test_aicpu_affinity_select.cpp b/tests/ut/cpp/a2a3/test_aicpu_affinity_select.cpp index b67eda2ed2..c4bbc36dcf 100644 --- a/tests/ut/cpp/a2a3/test_aicpu_affinity_select.cpp +++ b/tests/ut/cpp/a2a3/test_aicpu_affinity_select.cpp @@ -32,13 +32,15 @@ // Minimal logger stubs so aicpu_topology_probe.cpp links without pulling in // HostLogger. compute_allowed_cpus only emits LOG_WARN; the probe path (not -// exercised here) also uses LOG_INFO_V0. The unified_log symbols have C +// exercised here) also uses LOG_DEBUG. The unified_log symbols have C // linkage (see common/unified_log.h), so match it. No-ops — these tests // assert on return values, not log text. extern "C" { void unified_log_error(const char *, const char *, ...) {} void unified_log_warn(const char *, const char *, ...) {} -void unified_log_info_v(const char *, int, const char *, ...) {} +void unified_log_timing(const char *, const char *, ...) {} +void unified_log_info(const char *, const char *, ...) {} +void unified_log_debug(const char *, const char *, ...) {} } using pto::a2a3::AicpuLogicalCpu; diff --git a/tests/ut/cpp/a5/test_a5_fatal.cpp b/tests/ut/cpp/a5/test_a5_fatal.cpp index a303b6b52c..6a88930751 100644 --- a/tests/ut/cpp/a5/test_a5_fatal.cpp +++ b/tests/ut/cpp/a5/test_a5_fatal.cpp @@ -73,7 +73,6 @@ void fake_report_fatal(PTO2Runtime *rt, int32_t error_code, const char *func, co } void fake_log(const char *, const char *, ...) {} -void fake_log_v(const char *, int, const char *, ...) {} uint64_t fake_get_tensor_data(PTO2Runtime *rt, const Tensor &, uint32_t, const uint32_t[]) { as_fake(rt)->get_calls++; @@ -100,8 +99,9 @@ const PTO2RuntimeOps kFakeOps = { .report_fatal = fake_report_fatal, .log_error = fake_log, .log_warn = fake_log, + .log_timing = fake_log, + .log_info = fake_log, .log_debug = fake_log, - .log_info_v = fake_log_v, .get_tensor_data = fake_get_tensor_data, .set_tensor_data = fake_set_tensor_data, .alloc_tensors = fake_alloc_tensors, diff --git a/tests/ut/cpp/a5/test_host_log_off.cpp b/tests/ut/cpp/a5/test_host_log_off.cpp index 3c7d3a9d1d..b8facd1138 100644 --- a/tests/ut/cpp/a5/test_host_log_off.cpp +++ b/tests/ut/cpp/a5/test_host_log_off.cpp @@ -9,9 +9,9 @@ * ----------------------------------------------------------------------------------------------------------- */ -// HostLogger filtering: severity floor + INFO verbosity threshold. -// Drives the singleton via direct setters (no env vars; Python pushes via -// nanobind in production), captures stderr, and asserts on the buffered output. +// HostLogger filtering: one Python-compatible threshold. +// Drives the singleton via a direct setter, captures stderr, and asserts on +// the buffered output. #include #include @@ -31,7 +31,24 @@ struct CapturedStdio { std::string err; }; -CapturedStdio run_with_config(LogLevel level, int info_v, void (*fn)()) { +struct CannLogLevelCall { + int count; + int module_id; + int level; + int enable_event; +}; + +CannLogLevelCall g_cann_log_level_call{}; + +int capture_cann_log_level(int module_id, int level, int enable_event) { + g_cann_log_level_call.count++; + g_cann_log_level_call.module_id = module_id; + g_cann_log_level_call.level = level; + g_cann_log_level_call.enable_event = enable_event; + return 0; +} + +CapturedStdio run_with_config(LogLevel level, void (*fn)()) { fflush(stdout); fflush(stderr); FILE *out_tmp = tmpfile(); @@ -42,7 +59,6 @@ CapturedStdio run_with_config(LogLevel level, int info_v, void (*fn)()) { dup2(fileno(err_tmp), fileno(stderr)); HostLogger::get_instance().set_level(level); - HostLogger::get_instance().set_info_v(info_v); fn(); @@ -70,46 +86,82 @@ CapturedStdio run_with_config(LogLevel level, int info_v, void (*fn)()) { } // namespace TEST(HostLogTest, NulLevelMutesAllSeverities) { - auto captured = run_with_config(LogLevel::NUL, 0, [] { + auto captured = run_with_config(LogLevel::NUL, [] { HostLogger::get_instance().log(LogLevel::ERROR, "fn", "err-msg"); HostLogger::get_instance().log(LogLevel::WARN, "fn", "warn-msg"); + HostLogger::get_instance().log(LogLevel::TIMING, "fn", "timing-msg"); + HostLogger::get_instance().log(LogLevel::INFO, "fn", "info-msg"); HostLogger::get_instance().log(LogLevel::DEBUG, "fn", "dbg-msg"); - HostLogger::get_instance().log_info_v(9, "fn", "v9-msg"); - HostLogger::get_instance().log_info_v(0, "fn", "v0-msg"); }); EXPECT_EQ(captured.out, ""); EXPECT_EQ(captured.err, ""); } TEST(HostLogTest, ErrorLevelEmitsErrorOnly) { - auto captured = run_with_config(LogLevel::ERROR, 5, [] { + auto captured = run_with_config(LogLevel::ERROR, [] { HostLogger::get_instance().log(LogLevel::ERROR, "fn", "err-msg"); HostLogger::get_instance().log(LogLevel::WARN, "fn", "warn-msg"); - HostLogger::get_instance().log_info_v(9, "fn", "v9-msg"); + HostLogger::get_instance().log(LogLevel::TIMING, "fn", "timing-msg"); }); EXPECT_EQ(captured.out, ""); EXPECT_NE(captured.err.find("err-msg"), std::string::npos); EXPECT_EQ(captured.err.find("warn-msg"), std::string::npos); - EXPECT_EQ(captured.err.find("v9-msg"), std::string::npos); + EXPECT_EQ(captured.err.find("timing-msg"), std::string::npos); } -TEST(HostLogTest, InfoVerbosityCutsBelowThreshold) { - // Threshold V5: V0..V4 silenced, V5..V9 printed. - auto captured = run_with_config(LogLevel::INFO, 5, [] { - HostLogger::get_instance().log_info_v(0, "fn", "v0-msg"); - HostLogger::get_instance().log_info_v(4, "fn", "v4-msg"); - HostLogger::get_instance().log_info_v(5, "fn", "v5-msg"); - HostLogger::get_instance().log_info_v(9, "fn", "v9-msg"); +TEST(HostLogTest, TimingLevelKeepsTimingAndHigher) { + auto captured = run_with_config(LogLevel::TIMING, [] { + HostLogger::get_instance().log(LogLevel::DEBUG, "fn", "debug-msg"); + HostLogger::get_instance().log(LogLevel::INFO, "fn", "info-msg"); + HostLogger::get_instance().log(LogLevel::TIMING, "fn", "timing-msg"); + HostLogger::get_instance().log(LogLevel::WARN, "fn", "warn-msg"); + HostLogger::get_instance().log(LogLevel::ERROR, "fn", "error-msg"); }); EXPECT_EQ(captured.out, ""); - EXPECT_EQ(captured.err.find("v0-msg"), std::string::npos); - EXPECT_EQ(captured.err.find("v4-msg"), std::string::npos); - EXPECT_NE(captured.err.find("v5-msg"), std::string::npos); - EXPECT_NE(captured.err.find("v9-msg"), std::string::npos); + EXPECT_EQ(captured.err.find("debug-msg"), std::string::npos); + EXPECT_EQ(captured.err.find("info-msg"), std::string::npos); + EXPECT_NE(captured.err.find("timing-msg"), std::string::npos); + EXPECT_NE(captured.err.find("warn-msg"), std::string::npos); + EXPECT_NE(captured.err.find("error-msg"), std::string::npos); +} + +TEST(HostLogTest, CannLevelMappingSuppressesInfoAtDefault) { + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::DEBUG), 0); + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::INFO), 1); + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::TIMING), 2); + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::WARN), 2); + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::ERROR), 3); + EXPECT_EQ(simpler::log::to_cann_log_level(LogLevel::NUL), 4); +} + +TEST(HostLogTest, CannConfigurationUsesGlobalModuleAndRespectsExternalOverride) { + const char *old_env = std::getenv("ASCEND_GLOBAL_LOG_LEVEL"); + const bool had_old_env = old_env != nullptr; + const std::string old_value = had_old_env ? old_env : ""; + + unsetenv("ASCEND_GLOBAL_LOG_LEVEL"); + HostLogger::get_instance().set_level(LogLevel::TIMING); + g_cann_log_level_call = {}; + HostLogger::get_instance().configure_cann_log_level(capture_cann_log_level); + EXPECT_EQ(g_cann_log_level_call.count, 1); + EXPECT_EQ(g_cann_log_level_call.module_id, -1); + EXPECT_EQ(g_cann_log_level_call.level, 2); + EXPECT_EQ(g_cann_log_level_call.enable_event, 0); + + setenv("ASCEND_GLOBAL_LOG_LEVEL", "1", 1); + g_cann_log_level_call = {}; + HostLogger::get_instance().configure_cann_log_level(capture_cann_log_level); + EXPECT_EQ(g_cann_log_level_call.count, 0); + + if (had_old_env) { + setenv("ASCEND_GLOBAL_LOG_LEVEL", old_value.c_str(), 1); + } else { + unsetenv("ASCEND_GLOBAL_LOG_LEVEL"); + } } TEST(HostLogTest, EmitPrefixHasTimestampAndTid) { - auto captured = run_with_config(LogLevel::INFO, 5, [] { + auto captured = run_with_config(LogLevel::INFO, [] { HostLogger::get_instance().log(LogLevel::ERROR, "fn", "marker"); }); // Expected shape: "[YYYY-MM-DD HH:MM:SS.uuuuuu][T0x...][ERROR] fn: marker\n" @@ -132,17 +184,17 @@ TEST(HostLogTest, EmitPrefixHasTimestampAndTid) { } TEST(HostLogTest, AllOutputGoesToStderr) { - auto captured = run_with_config(LogLevel::DEBUG, 0, [] { - HostLogger::get_instance().log(LogLevel::ERROR, "fn", "e"); - HostLogger::get_instance().log(LogLevel::WARN, "fn", "w"); - HostLogger::get_instance().log(LogLevel::DEBUG, "fn", "d"); - HostLogger::get_instance().log_info_v(0, "fn", "i0"); - HostLogger::get_instance().log_info_v(9, "fn", "i9"); + auto captured = run_with_config(LogLevel::DEBUG, [] { + HostLogger::get_instance().log(LogLevel::ERROR, "fn", "error-output-marker"); + HostLogger::get_instance().log(LogLevel::WARN, "fn", "warn-output-marker"); + HostLogger::get_instance().log(LogLevel::TIMING, "fn", "timing-output-marker"); + HostLogger::get_instance().log(LogLevel::INFO, "fn", "info-output-marker"); + HostLogger::get_instance().log(LogLevel::DEBUG, "fn", "debug-output-marker"); }); EXPECT_EQ(captured.out, ""); - EXPECT_NE(captured.err.find("e"), std::string::npos); - EXPECT_NE(captured.err.find("w"), std::string::npos); - EXPECT_NE(captured.err.find("d"), std::string::npos); - EXPECT_NE(captured.err.find("i0"), std::string::npos); - EXPECT_NE(captured.err.find("i9"), std::string::npos); + EXPECT_NE(captured.err.find("error-output-marker"), std::string::npos); + EXPECT_NE(captured.err.find("warn-output-marker"), std::string::npos); + EXPECT_NE(captured.err.find("timing-output-marker"), std::string::npos); + EXPECT_NE(captured.err.find("info-output-marker"), std::string::npos); + EXPECT_NE(captured.err.find("debug-output-marker"), std::string::npos); } diff --git a/tests/ut/cpp/stubs/test_stubs.cpp b/tests/ut/cpp/stubs/test_stubs.cpp index 63054f6b25..d282ddfbcc 100644 --- a/tests/ut/cpp/stubs/test_stubs.cpp +++ b/tests/ut/cpp/stubs/test_stubs.cpp @@ -29,7 +29,7 @@ #include "aicpu/platform_regs.h" // get_reg_ptr / RegId (arch header picked up via rt_objs include path) // ============================================================================= -// unified_log.h stubs (5 log-level functions) +// unified_log.h stubs // ============================================================================= extern "C" { @@ -52,23 +52,28 @@ void unified_log_warn(const char *func, const char *fmt, ...) { va_end(args); } -void unified_log_debug(const char * /* func */, const char * /* fmt */, ...) { - // Suppress debug in tests +void unified_log_timing(const char *func, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + fprintf(stderr, "[TIMING] %s: ", func); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); } -void unified_log_info_v(const char *func, int v, const char *fmt, ...) { - // Only emit V9 (must-see) in tests; quieter tiers are suppressed. - if (v < 9) { - return; - } +void unified_log_info(const char *func, const char *fmt, ...) { va_list args; va_start(args, fmt); - fprintf(stderr, "[INFO_V%d] %s: ", v, func); + fprintf(stderr, "[INFO] %s: ", func); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); } +void unified_log_debug(const char * /* func */, const char * /* fmt */, ...) { + // Suppress debug in tests +} + } // extern "C" // ============================================================================= diff --git a/tests/ut/py/test_log_config.py b/tests/ut/py/test_log_config.py index e9ce7134e7..0c376c590e 100644 --- a/tests/ut/py/test_log_config.py +++ b/tests/ut/py/test_log_config.py @@ -6,12 +6,12 @@ # 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. # ----------------------------------------------------------------------------------------------------------- -"""Tests for simpler_setup.log_config + simpler._log integer-threshold logic.""" +"""Tests for simpler's single-axis log-level configuration.""" import logging import pytest -from simpler._log import _split_threshold +from simpler._log import TIMING, _normalize_threshold from simpler_setup.log_config import ( DEFAULT_LOG_LEVEL, @@ -21,17 +21,17 @@ ) -def test_default_level_is_v5(): - assert DEFAULT_LOG_LEVEL == "v5" - assert parse_level("v5") == 20 # = logging.INFO +def test_default_level_is_timing(): + assert DEFAULT_LOG_LEVEL == "timing" + assert TIMING == 25 + assert parse_level("timing") == TIMING assert parse_level("info") == 20 -def test_choices_cover_severity_and_v_tiers(): - for name in ("debug", "info", "warn", "error", "null"): - assert name in LOG_LEVEL_CHOICES +def test_choices_are_single_axis(): + assert LOG_LEVEL_CHOICES == ["debug", "info", "timing", "warn", "error", "null"] for v in range(10): - assert f"v{v}" in LOG_LEVEL_CHOICES + assert f"v{v}" not in LOG_LEVEL_CHOICES def test_null_mutes_severity(): @@ -40,25 +40,28 @@ def test_null_mutes_severity(): assert sim.getEffectiveLevel() >= 60 -def test_v0_lets_everything_through(): - configure_logging("v0") +def test_timing_hides_info_but_keeps_timing(): + configure_logging("timing") sim = logging.getLogger("simpler") - # V0 = 15, so DEBUG-tagged records are still suppressed by Python (DEBUG=10), - # but every V tier and INFO/WARN/ERROR pass. - assert sim.getEffectiveLevel() == 15 + assert not sim.isEnabledFor(logging.INFO) + assert sim.isEnabledFor(TIMING) @pytest.mark.parametrize( "threshold, expected", [ - (10, (0, 0)), # DEBUG → severity DEBUG - (15, (1, 0)), # V0 → severity INFO, info_v=0 - (20, (1, 5)), # V5 → severity INFO, info_v=5 (default) - (24, (1, 9)), # V9 → severity INFO, info_v=9 - (30, (2, 0)), # WARN → severity WARN - (40, (3, 0)), # ERROR → severity ERROR - (60, (4, 0)), # NUL → severity NUL + (10, 10), + (11, 20), + (20, 20), + (21, 25), + (25, 25), + (26, 30), + (30, 30), + (31, 40), + (40, 40), + (41, 60), + (60, 60), ], ) -def test_split_threshold(threshold, expected): - assert _split_threshold(threshold) == expected +def test_normalize_threshold(threshold, expected): + assert _normalize_threshold(threshold) == expected diff --git a/tests/ut/py/test_worker/test_host_worker.py b/tests/ut/py/test_worker/test_host_worker.py index ad7a4cbc61..e8fd58dd08 100644 --- a/tests/ut/py/test_worker/test_host_worker.py +++ b/tests/ut/py/test_worker/test_host_worker.py @@ -132,8 +132,8 @@ def test_chip_process_loop_inits_runs_and_finalizes(monkeypatch): events: list[tuple] = [] class FakeChipWorker: - def init(self, device_id, bins, *, log_level, log_info_v, prewarm_config=None, enable_sdma=False): - events.append(("init", device_id, bins, log_level, log_info_v, prewarm_config, enable_sdma)) + def init(self, device_id, bins, *, log_level, prewarm_config=None, enable_sdma=False): + events.append(("init", device_id, bins, log_level, prewarm_config, enable_sdma)) def finalize(self) -> None: events.append(("finalize",)) @@ -161,7 +161,7 @@ def fake_run_chip_main_loop(cw, *_args, chip_platform, chip_runtime, prepared=No shm.close() shm.unlink() - assert events[0] == ("init", 7, "bins", 1, 5, None, False) + assert events[0] == ("init", 7, "bins", 25, None, False) assert events[1][0] == "main_loop" assert events[1][2:] == ("a2a3", "tensormap_and_ringbuffer") assert events[2] == ("finalize",)