diff --git a/src/a2a3/platform/onboard/host/aicpu_affinity_select.cpp b/src/a2a3/platform/onboard/host/aicpu_affinity_select.cpp index 235df1017e..8ba882ede8 100644 --- a/src/a2a3/platform/onboard/host/aicpu_affinity_select.cpp +++ b/src/a2a3/platform/onboard/host/aicpu_affinity_select.cpp @@ -15,7 +15,7 @@ #include "common/unified_log.h" -namespace pto::a2a3 { +namespace simpler::a2a3 { bool resolve_aicpu_cpu_id_base(int64_t phy_die_id, int32_t &out_cpu_id_base) { out_cpu_id_base = 0; @@ -87,4 +87,4 @@ bool compute_allowed_cpus( return true; } -} // namespace pto::a2a3 +} // namespace simpler::a2a3 diff --git a/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp b/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp index 8f08d21e1c..9097a1229e 100644 --- a/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp +++ b/src/a2a3/platform/onboard/host/aicpu_topology_probe.cpp @@ -19,7 +19,7 @@ #include "common/unified_log.h" #include "common/acl_hal_device.h" -namespace pto::a2a3 { +namespace simpler::a2a3 { namespace { @@ -130,4 +130,4 @@ bool probe_aicpu_topology(uint32_t device_id, std::vector &out_ return true; } -} // namespace pto::a2a3 +} // namespace simpler::a2a3 diff --git a/src/a2a3/platform/onboard/host/aicpu_topology_probe.h b/src/a2a3/platform/onboard/host/aicpu_topology_probe.h index 89143eea18..6436efa507 100644 --- a/src/a2a3/platform/onboard/host/aicpu_topology_probe.h +++ b/src/a2a3/platform/onboard/host/aicpu_topology_probe.h @@ -14,7 +14,7 @@ #include #include -namespace pto::a2a3 { +namespace simpler::a2a3 { // Two translation units implement this header. aicpu_topology_probe.cpp owns // probe_aicpu_topology and includes the CANN driver header for it; @@ -49,4 +49,4 @@ bool compute_allowed_cpus( const std::vector &user_cpus, int32_t active_count, std::vector &out_allowed_cpus ); -} // namespace pto::a2a3 +} // namespace simpler::a2a3 diff --git a/src/a2a3/platform/onboard/host/context_preparation.cpp b/src/a2a3/platform/onboard/host/context_preparation.cpp index 95e1afc032..98b839122a 100644 --- a/src/a2a3/platform/onboard/host/context_preparation.cpp +++ b/src/a2a3/platform/onboard/host/context_preparation.cpp @@ -16,7 +16,7 @@ #include "runtime/rt.h" -namespace pto::a2a3 { +namespace simpler::a2a3 { int ensure_ctrl_table(MemoryAllocator &allocator, int device_id, uint64_t &table, bool &committed) { if (committed) return 0; const int rc = @@ -35,4 +35,4 @@ int ensure_c2c_ctrl_address(uint64_t &address, bool &valid) { valid = true; return 0; } -} // namespace pto::a2a3 +} // namespace simpler::a2a3 diff --git a/src/a2a3/platform/onboard/host/context_preparation.h b/src/a2a3/platform/onboard/host/context_preparation.h index acc64f6f7a..2e8f2e03dd 100644 --- a/src/a2a3/platform/onboard/host/context_preparation.h +++ b/src/a2a3/platform/onboard/host/context_preparation.h @@ -15,8 +15,8 @@ class MemoryAllocator; -namespace pto::a2a3 { +namespace simpler::a2a3 { int ensure_ctrl_table(MemoryAllocator &allocator, int device_id, uint64_t &table, bool &committed); // A successful zero address is still a completed query. The caller owns the snapshot. int ensure_c2c_ctrl_address(uint64_t &address, bool &valid); -} // namespace pto::a2a3 +} // namespace simpler::a2a3 diff --git a/src/a2a3/platform/onboard/host/device_runner.cpp b/src/a2a3/platform/onboard/host/device_runner.cpp index bd6e24da27..d67df3058f 100644 --- a/src/a2a3/platform/onboard/host/device_runner.cpp +++ b/src/a2a3/platform/onboard/host/device_runner.cpp @@ -197,8 +197,9 @@ int DeviceRunner::fill_persistent_arch_fields(KernelArgs *args, uint64_t device_ int DeviceRunner::ensure_aicpu_topology() { if (!aicpu_topology_.empty()) return 0; - std::vector topology; - if (!pto::a2a3::probe_aicpu_topology(static_cast(device_id_), topology)) return PTO_RUNTIME_ERR_INTERNAL; + std::vector topology; + if (!simpler::a2a3::probe_aicpu_topology(static_cast(device_id_), topology)) + return PTO_RUNTIME_ERR_INTERNAL; aicpu_topology_ = std::move(topology); return 0; } @@ -206,7 +207,7 @@ int DeviceRunner::ensure_aicpu_topology() { int DeviceRunner::prepare_kernel_arch_context(rtStream_t /*control_stream*/) { int rc = ensure_aicore_reg_table(AicoreRegKind::Ctrl); if (rc != 0) return rc; - rc = pto::a2a3::ensure_c2c_ctrl_address(c2c_ctrl_address_, c2c_ctrl_address_valid_); + rc = simpler::a2a3::ensure_c2c_ctrl_address(c2c_ctrl_address_, c2c_ctrl_address_valid_); if (rc != 0) return rc; return ensure_aicpu_topology(); } @@ -486,7 +487,7 @@ int DeviceRunner::prepare_execution( runtime.get_aicpu_thread_num(), static_cast(user_cpus.size()), PLATFORM_DEFAULT_AICPU_THREAD_NUM ); if (resolved_aicpu < 0) return PTO_RUNTIME_ERR_INTERNAL; - if (!pto::a2a3::compute_allowed_cpus(user_cpus, resolved_aicpu, allowed)) { + if (!simpler::a2a3::compute_allowed_cpus(user_cpus, resolved_aicpu, allowed)) { LOG_ERROR( "A2A3 AICPU topology has %zu user cpus, cannot fit %d active threads", user_cpus.size(), resolved_aicpu ); @@ -738,7 +739,7 @@ int DeviceRunner::ensure_run_streams() { // mid-worker is not something a per-run PMU re-query could have made safe. int DeviceRunner::ensure_aicore_reg_table(AicoreRegKind kind) { if (kind == AicoreRegKind::Ctrl) - return pto::a2a3::ensure_ctrl_table( + return simpler::a2a3::ensure_ctrl_table( mem_alloc_, device_id_, aicore_ctrl_reg_table_dev_, aicore_ctrl_reg_table_committed_ ); const bool is_pmu = kind == AicoreRegKind::Pmu; diff --git a/src/a2a3/platform/onboard/host/device_runner.h b/src/a2a3/platform/onboard/host/device_runner.h index afd4e659e9..73305685e4 100644 --- a/src/a2a3/platform/onboard/host/device_runner.h +++ b/src/a2a3/platform/onboard/host/device_runner.h @@ -327,7 +327,7 @@ class DeviceRunner : public DeviceRunnerBase { int ensure_aicpu_topology(); uint64_t c2c_ctrl_address_{0}; bool c2c_ctrl_address_valid_{false}; - std::vector aicpu_topology_; + std::vector aicpu_topology_; // Release the resources this run owns, in runtime-argument, register-buffer, // then stream order. Collectors are not among them: their device resources diff --git a/src/a5/platform/onboard/host/aicpu_affinity_select.cpp b/src/a5/platform/onboard/host/aicpu_affinity_select.cpp index f7c7c11435..61a150de23 100644 --- a/src/a5/platform/onboard/host/aicpu_affinity_select.cpp +++ b/src/a5/platform/onboard/host/aicpu_affinity_select.cpp @@ -28,7 +28,7 @@ #include "common/platform_config.h" #include "common/unified_log.h" -namespace pto::a5 { +namespace simpler::a5 { using detail::CpuTopologyData; using detail::CpuTopologyEntry; @@ -1125,4 +1125,4 @@ std::string format_aicpu_topology_json( return out.str(); } -} // namespace pto::a5 +} // namespace simpler::a5 diff --git a/src/a5/platform/onboard/host/aicpu_topology_probe.cpp b/src/a5/platform/onboard/host/aicpu_topology_probe.cpp index 80f922eee7..1853b8f9ac 100644 --- a/src/a5/platform/onboard/host/aicpu_topology_probe.cpp +++ b/src/a5/platform/onboard/host/aicpu_topology_probe.cpp @@ -18,7 +18,7 @@ #include "common/acl_hal_device.h" #include "common/unified_log.h" -namespace pto::a5 { +namespace simpler::a5 { namespace { using pto::driver::CpuTopology; @@ -107,4 +107,4 @@ bool probe_aicpu_topology( return detail::build_aicpu_topology(device_occupancy, soc_name, available, topo, out_topology); } -} // namespace pto::a5 +} // namespace simpler::a5 diff --git a/src/a5/platform/onboard/host/aicpu_topology_probe.h b/src/a5/platform/onboard/host/aicpu_topology_probe.h index b9c77c1b21..206b96134e 100644 --- a/src/a5/platform/onboard/host/aicpu_topology_probe.h +++ b/src/a5/platform/onboard/host/aicpu_topology_probe.h @@ -16,7 +16,7 @@ #include #include -namespace pto::a5 { +namespace simpler::a5 { // aicpu_topology_probe.cpp owns driver queries. aicpu_affinity_select.cpp // owns topology assembly, fallback and CPU selection without CANN dependencies. @@ -210,4 +210,4 @@ bool build_aicpu_topology( } // namespace detail -} // namespace pto::a5 +} // namespace simpler::a5 diff --git a/src/a5/platform/onboard/host/context_preparation.cpp b/src/a5/platform/onboard/host/context_preparation.cpp index 3ca4d183e5..d4d7e3c95a 100644 --- a/src/a5/platform/onboard/host/context_preparation.cpp +++ b/src/a5/platform/onboard/host/context_preparation.cpp @@ -20,7 +20,7 @@ #include "common/platform_config.h" #include "runtime_c_api.h" -namespace pto::a5 { +namespace simpler::a5 { int ensure_ctrl_table(MemoryAllocator &allocator, int device_id, uint64_t &table, bool &committed) { if (committed) return 0; const int rc = init_aicore_register_addresses(&table, static_cast(device_id), allocator); @@ -74,4 +74,4 @@ int query_device_aicpu_occupancy( out.os_sched_valid = result.os_sched_rc == 0; return 0; } -} // namespace pto::a5 +} // namespace simpler::a5 diff --git a/src/a5/platform/onboard/host/context_preparation.h b/src/a5/platform/onboard/host/context_preparation.h index 0f286864a9..60bca7de8b 100644 --- a/src/a5/platform/onboard/host/context_preparation.h +++ b/src/a5/platform/onboard/host/context_preparation.h @@ -19,7 +19,7 @@ namespace host { class LoadAicpuOp; } -namespace pto::a5 { +namespace simpler::a5 { int ensure_ctrl_table(MemoryAllocator &allocator, int device_id, uint64_t &table, bool &committed); // Scratch and pending-write state belong to the calling DeviceRunner. int query_device_aicpu_occupancy( @@ -27,4 +27,4 @@ int query_device_aicpu_occupancy( AicpuDeviceOccupancy &out ); int release_aicpu_query_result(MemoryAllocator &allocator, rtStream_t stream, void *&scratch, bool &pending); -} // namespace pto::a5 +} // namespace simpler::a5 diff --git a/src/a5/platform/onboard/host/device_runner.cpp b/src/a5/platform/onboard/host/device_runner.cpp index 441f4d90ec..86219bf1da 100644 --- a/src/a5/platform/onboard/host/device_runner.cpp +++ b/src/a5/platform/onboard/host/device_runner.cpp @@ -201,7 +201,7 @@ int DeviceRunner::destroy_comm_stream(void *stream) { int DeviceRunner::prepare_kernel_arch_context(rtStream_t control_stream) { const int rc = ensure_aicore_reg_table(); if (rc != 0) return rc; - pto::a5::AicpuTopology topology; + simpler::a5::AicpuTopology topology; return query_aicpu_topology(topology, control_stream); } @@ -212,21 +212,21 @@ int DeviceRunner::release_arch_context_resources(bool abandon_device_resources) aicpu_topology_query_stream_ = nullptr; return 0; } - const int rc = pto::a5::release_aicpu_query_result( + const int rc = simpler::a5::release_aicpu_query_result( mem_alloc_, aicpu_topology_query_stream_, aicpu_topology_query_result_, aicpu_topology_query_pending_ ); if (rc == 0) aicpu_topology_query_stream_ = nullptr; return rc; } -int DeviceRunner::query_aicpu_device_occupancy(pto::a5::AicpuDeviceOccupancy &out, rtStream_t control_stream) { +int DeviceRunner::query_aicpu_device_occupancy(simpler::a5::AicpuDeviceOccupancy &out, rtStream_t control_stream) { if (aicpu_device_occupancy_cached_) { out = aicpu_device_occupancy_; return 0; } if (!aicpu_topology_query_pending_) aicpu_topology_query_stream_ = control_stream; - pto::a5::AicpuDeviceOccupancy occupancy; - const int rc = pto::a5::query_device_aicpu_occupancy( + simpler::a5::AicpuDeviceOccupancy occupancy; + const int rc = simpler::a5::query_device_aicpu_occupancy( mem_alloc_, load_aicpu_op_, control_stream, aicpu_topology_query_result_, aicpu_topology_query_pending_, occupancy ); @@ -243,18 +243,18 @@ int DeviceRunner::query_aicpu_device_occupancy(pto::a5::AicpuDeviceOccupancy &ou return 0; } -int DeviceRunner::query_aicpu_topology(pto::a5::AicpuTopology &out, rtStream_t control_stream) { +int DeviceRunner::query_aicpu_topology(simpler::a5::AicpuTopology &out, rtStream_t control_stream) { if (aicpu_topology_cached_) { out = aicpu_topology_; return 0; } - pto::a5::AicpuDeviceOccupancy occupancy; + simpler::a5::AicpuDeviceOccupancy occupancy; int rc = query_aicpu_device_occupancy(occupancy, control_stream); if (rc != 0) return rc; - pto::a5::AicpuTopology topology; - if (!pto::a5::probe_aicpu_topology(static_cast(device_id_), occupancy, topology)) + simpler::a5::AicpuTopology topology; + if (!simpler::a5::probe_aicpu_topology(static_cast(device_id_), occupancy, topology)) return PTO_RUNTIME_ERR_INTERNAL; aicpu_topology_ = std::move(topology); @@ -429,7 +429,7 @@ int DeviceRunner::prepare_execution( // active count to the available pool, but execution keeps at least one of // each role. { - pto::a5::AicpuTopology topology; + simpler::a5::AicpuTopology topology; runtime.set_aicpu_allowed_cpu_count(0); const rtStream_t control_stream = execution_mode_latch().is_kernel() ? @@ -439,13 +439,13 @@ int DeviceRunner::prepare_execution( LOG_ERROR("AICPU topology probe failed; affinity gate will not launch"); return PTO_RUNTIME_ERR_INTERNAL; } - pto::a5::AicpuLaunchPlan launch_plan; + simpler::a5::AicpuLaunchPlan launch_plan; std::string plan_error; - if (!pto::a5::build_aicpu_launch_plan(topology, requested_aicpu_num, launch_plan, plan_error)) { + if (!simpler::a5::build_aicpu_launch_plan(topology, requested_aicpu_num, launch_plan, plan_error)) { LOG_ERROR( "cannot build AICPU launch plan: soc=%s scenario=%s occupy=0x%llx reason=%s", topology.soc_name.empty() ? "(unknown)" : topology.soc_name.c_str(), - pto::a5::aicpu_scenario_name(topology.scenario_type), + simpler::a5::aicpu_scenario_name(topology.scenario_type), static_cast(topology.device_occupancy.occupy), plan_error.c_str() ); return PTO_RUNTIME_ERR_INTERNAL; @@ -474,11 +474,11 @@ int DeviceRunner::prepare_execution( LOG_WARN( "AICPU CPU_TOPO unavailable; using %s: soc=%s occupy=0x%llx " "stable_reachable=%d requested=%d effective=%d affinity=[%s]%s", - pto::a5::aicpu_topology_source_name(topology.source), + simpler::a5::aicpu_topology_source_name(topology.source), topology.soc_name.empty() ? "(unknown)" : topology.soc_name.c_str(), static_cast(topology.device_occupancy.occupy), launch_plan.stable_reachable_count, requested_aicpu_num, active_aicpu_num, dump.c_str(), - topology.source == pto::a5::AicpuTopologySource::kOccupyFallback ? + topology.source == simpler::a5::AicpuTopologySource::kOccupyFallback ? "; physical/SMT/cluster/die placement is unknown" : "" ); @@ -488,7 +488,7 @@ int DeviceRunner::prepare_execution( "AICPU stable reachable CPUs below active capacity: soc=%s scenario=%s occupy=0x%llx " "stable_reachable=%d capacity=%d requested=%d effective=%d affinity=[%s]", topology.soc_name.empty() ? "(unknown)" : topology.soc_name.c_str(), - pto::a5::aicpu_scenario_name(topology.scenario_type), + simpler::a5::aicpu_scenario_name(topology.scenario_type), static_cast(topology.device_occupancy.occupy), launch_plan.stable_reachable_count, PLATFORM_DEFAULT_AICPU_THREAD_NUM, requested_aicpu_num, active_aicpu_num, dump.c_str() @@ -496,7 +496,7 @@ int DeviceRunner::prepare_execution( } LOG_INFO( "AICPU ALLOWED_CPUS = [%s] (scenario=%s active=%d launch=%d user_cpus=%zu)", dump.c_str(), - pto::a5::aicpu_scenario_name(topology.scenario_type), active_aicpu_num, launch_plan.launch_count, + simpler::a5::aicpu_scenario_name(topology.scenario_type), active_aicpu_num, launch_plan.launch_count, topology.os_schedulable_cpus.size() ); } @@ -1445,7 +1445,7 @@ int DeviceRunner::finalize_collectors(bool abandon_device_resources) { // halves the per-core halResMap loop and the live driver-side mappings a worker // holds. int DeviceRunner::ensure_aicore_reg_table() { - return pto::a5::ensure_ctrl_table( + return simpler::a5::ensure_ctrl_table( mem_alloc_, device_id_, aicore_ctrl_reg_table_dev_, aicore_ctrl_reg_table_committed_ ); } diff --git a/src/a5/platform/onboard/host/device_runner.h b/src/a5/platform/onboard/host/device_runner.h index dfc88aaad9..a53cd96b11 100644 --- a/src/a5/platform/onboard/host/device_runner.h +++ b/src/a5/platform/onboard/host/device_runner.h @@ -365,8 +365,8 @@ class DeviceRunner : public DeviceRunnerBase { // // dep_gen enablement is a5-specific (a2a3 carries its own copy). - int query_aicpu_device_occupancy(pto::a5::AicpuDeviceOccupancy &out, rtStream_t control_stream); - int query_aicpu_topology(pto::a5::AicpuTopology &out, rtStream_t control_stream); + int query_aicpu_device_occupancy(simpler::a5::AicpuDeviceOccupancy &out, rtStream_t control_stream); + int query_aicpu_topology(simpler::a5::AicpuTopology &out, rtStream_t control_stream); void *aicpu_topology_query_result_{nullptr}; bool aicpu_topology_query_pending_{false}; rtStream_t aicpu_topology_query_stream_{nullptr}; @@ -376,9 +376,9 @@ class DeviceRunner : public DeviceRunnerBase { // allowed CPU selection still runs per call because the requested active // count may change. Recovery, reset, and finalize clear both values. bool aicpu_device_occupancy_cached_{false}; - pto::a5::AicpuDeviceOccupancy aicpu_device_occupancy_{}; + simpler::a5::AicpuDeviceOccupancy aicpu_device_occupancy_{}; bool aicpu_topology_cached_{false}; - pto::a5::AicpuTopology aicpu_topology_{}; + simpler::a5::AicpuTopology aicpu_topology_{}; int init_pmu(int num_cores, int num_threads, int device_id, KernelArgsHelper &kernel_args); int init_scope_stats(int num_threads, int device_id, KernelArgsHelper &kernel_args); diff --git a/src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h b/src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h index 7576b761fb..b2461cccca 100644 --- a/src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h +++ b/src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h @@ -184,7 +184,7 @@ struct alignas(64) DeviceRuntimeLaunchDesc { // Filter-style affinity gate input (a5 onboard). Host fills before // launch from device-side OCCUPY + DSMI CPU_TOPO via - // pto::a5::compute_allowed_cpus. The on-device gate keeps threads whose + // simpler::a5::compute_allowed_cpus. The on-device gate keeps threads whose // sched_getcpu() lands on one of these cpu_ids; exec_idx = position in // this array drives sched/orch role assignment. Indices 0..count-2 are // scheduler slots, index count-1 is the orchestrator slot. Sized to diff --git a/tests/ut/cpp/a2a3/platform/test_aicpu_affinity_select.cpp b/tests/ut/cpp/a2a3/platform/test_aicpu_affinity_select.cpp index a14cb4d903..7f30e50acb 100644 --- a/tests/ut/cpp/a2a3/platform/test_aicpu_affinity_select.cpp +++ b/tests/ut/cpp/a2a3/platform/test_aicpu_affinity_select.cpp @@ -43,9 +43,9 @@ void unified_log_info(const char *, const char *, ...) {} void unified_log_debug(const char *, const char *, ...) {} } -using pto::a2a3::AicpuLogicalCpu; -using pto::a2a3::compute_allowed_cpus; -using pto::a2a3::resolve_aicpu_cpu_id_base; +using simpler::a2a3::AicpuLogicalCpu; +using simpler::a2a3::compute_allowed_cpus; +using simpler::a2a3::resolve_aicpu_cpu_id_base; namespace { diff --git a/tests/ut/cpp/a5/platform/test_aicpu_topology_fallback.cpp b/tests/ut/cpp/a5/platform/test_aicpu_topology_fallback.cpp index 06f9eadb4b..97082fcb4a 100644 --- a/tests/ut/cpp/a5/platform/test_aicpu_topology_fallback.cpp +++ b/tests/ut/cpp/a5/platform/test_aicpu_topology_fallback.cpp @@ -28,21 +28,21 @@ void unified_log_debug(const char *, const char *, ...) {} namespace { -using pto::a5::AicpuLaunchPlan; -using pto::a5::AicpuLogicalCpu; -using pto::a5::AicpuScenarioType; -using pto::a5::AicpuSelectionPolicy; -using pto::a5::AicpuTopology; -using pto::a5::AicpuTopologySource; -using pto::a5::build_aicpu_launch_plan; -using pto::a5::classify_aicpu_scenario; -using pto::a5::compute_allowed_cpus; -using pto::a5::compute_scenario_allowed_cpus; -using pto::a5::compute_unknown_allowed_cpus; -using pto::a5::derive_topology_from_occupy; -using pto::a5::enumerate_cpus_from_occupy; -using pto::a5::format_aicpu_topology_json; -using pto::a5::load_cpu_topo_from_json; +using simpler::a5::AicpuLaunchPlan; +using simpler::a5::AicpuLogicalCpu; +using simpler::a5::AicpuScenarioType; +using simpler::a5::AicpuSelectionPolicy; +using simpler::a5::AicpuTopology; +using simpler::a5::AicpuTopologySource; +using simpler::a5::build_aicpu_launch_plan; +using simpler::a5::classify_aicpu_scenario; +using simpler::a5::compute_allowed_cpus; +using simpler::a5::compute_scenario_allowed_cpus; +using simpler::a5::compute_unknown_allowed_cpus; +using simpler::a5::derive_topology_from_occupy; +using simpler::a5::enumerate_cpus_from_occupy; +using simpler::a5::format_aicpu_topology_json; +using simpler::a5::load_cpu_topo_from_json; std::vector make_physical_range(int32_t first_phy, int32_t last_phy) { std::vector cpus; @@ -66,7 +66,7 @@ void set_device_occupy(AicpuTopology &topology, uint64_t occupy) { } TEST(A5AicpuTopologyFallback, BuildsDriverTopologyWithOccupancyFiltering) { - pto::a5::detail::CpuTopologyData raw{}; + simpler::a5::detail::CpuTopologyData raw{}; raw.total_nums = 8; for (uint32_t i = 0; i < raw.total_nums; ++i) { const uint8_t id = static_cast(raw.total_nums - 1 - i); @@ -74,11 +74,11 @@ TEST(A5AicpuTopologyFallback, BuildsDriverTopologyWithOccupancyFiltering) { raw.cpus[i].phy_cpu_id = id / 2; raw.cpus[i].hyperthread_id = id % 2; } - pto::a5::AicpuDeviceOccupancy occupancy{}; + simpler::a5::AicpuDeviceOccupancy occupancy{}; occupancy.occupy_valid = true; occupancy.occupy = (1ULL << 3) | (1ULL << 4) | (1ULL << 5); AicpuTopology topology; - ASSERT_TRUE(pto::a5::detail::build_aicpu_topology(occupancy, "test-soc", true, raw, topology)); + ASSERT_TRUE(simpler::a5::detail::build_aicpu_topology(occupancy, "test-soc", true, raw, topology)); EXPECT_EQ(topology.source, AicpuTopologySource::kDriver); EXPECT_EQ(topology.soc_name, "test-soc"); EXPECT_EQ(topology.logical_cpu_count, 8U); @@ -91,12 +91,12 @@ TEST(A5AicpuTopologyFallback, BuildsDriverTopologyWithOccupancyFiltering) { } TEST(A5AicpuTopologyFallback, BuildsOccupancyFallbackWithoutDriverMetadata) { - pto::a5::detail::CpuTopologyData raw{}; - pto::a5::AicpuDeviceOccupancy occupancy{}; + simpler::a5::detail::CpuTopologyData raw{}; + simpler::a5::AicpuDeviceOccupancy occupancy{}; occupancy.occupy_valid = true; occupancy.occupy = (1ULL << 2) | (1ULL << 63); AicpuTopology topology; - ASSERT_TRUE(pto::a5::detail::build_aicpu_topology(occupancy, nullptr, false, raw, topology)); + ASSERT_TRUE(simpler::a5::detail::build_aicpu_topology(occupancy, nullptr, false, raw, topology)); EXPECT_EQ(topology.source, AicpuTopologySource::kOccupyFallback); EXPECT_EQ(topology.logical_cpu_count, 2U); EXPECT_EQ(topology.scenario_type, AicpuScenarioType::kUnknown); @@ -109,30 +109,30 @@ TEST(A5AicpuTopologyFallback, BuildsOccupancyFallbackWithoutDriverMetadata) { } TEST(A5AicpuTopologyFallback, RejectsDuplicateDriverCpuIdsAndClearsTopology) { - pto::a5::detail::CpuTopologyData raw{}; + simpler::a5::detail::CpuTopologyData raw{}; raw.total_nums = 2; raw.cpus[0].cpu_id = 2; raw.cpus[0].phy_cpu_id = 1; raw.cpus[1] = raw.cpus[0]; - pto::a5::AicpuDeviceOccupancy occupancy{}; + simpler::a5::AicpuDeviceOccupancy occupancy{}; occupancy.occupy_valid = true; occupancy.occupy = 1ULL << 2; AicpuTopology topology; - EXPECT_FALSE(pto::a5::detail::build_aicpu_topology(occupancy, "test-soc", true, raw, topology)); + EXPECT_FALSE(simpler::a5::detail::build_aicpu_topology(occupancy, "test-soc", true, raw, topology)); EXPECT_TRUE(topology.soc_name.empty()); EXPECT_TRUE(topology.os_schedulable_cpus.empty()); EXPECT_EQ(topology.logical_cpu_count, 0U); } TEST(A5AicpuTopologyFallback, RejectsDriverCountsOutsideBufferCapacity) { - pto::a5::detail::CpuTopologyData raw{}; - pto::a5::AicpuDeviceOccupancy occupancy{}; + simpler::a5::detail::CpuTopologyData raw{}; + simpler::a5::AicpuDeviceOccupancy occupancy{}; occupancy.occupy_valid = true; occupancy.occupy = 1ULL << 2; AicpuTopology topology; - EXPECT_FALSE(pto::a5::detail::build_aicpu_topology(occupancy, nullptr, true, raw, topology)); - raw.total_nums = pto::a5::detail::kCpuOccupancyBits + 1; - EXPECT_FALSE(pto::a5::detail::build_aicpu_topology(occupancy, nullptr, true, raw, topology)); + EXPECT_FALSE(simpler::a5::detail::build_aicpu_topology(occupancy, nullptr, true, raw, topology)); + raw.total_nums = simpler::a5::detail::kCpuOccupancyBits + 1; + EXPECT_FALSE(simpler::a5::detail::build_aicpu_topology(occupancy, nullptr, true, raw, topology)); } TEST(A5AicpuTopologyFallback, EnumeratesBoundaryCpuIdsAndRejectsEmptyMask) { diff --git a/tests/ut/cpp/common/platform/test_native_admission.cpp b/tests/ut/cpp/common/platform/test_native_admission.cpp index 2fb98c8425..9164b128e9 100644 --- a/tests/ut/cpp/common/platform/test_native_admission.cpp +++ b/tests/ut/cpp/common/platform/test_native_admission.cpp @@ -5005,21 +5005,21 @@ class ContextControlRunner : public ColdKernelRunner { #ifdef CONTEXT_ARCH_A5 void *scratch{nullptr}; bool pending{false}; - pto::a5::AicpuDeviceOccupancy occupancy{}; - pto::a5::AicpuTopology topology{}; + simpler::a5::AicpuDeviceOccupancy occupancy{}; + simpler::a5::AicpuTopology topology{}; bool selected(int threads, std::vector &allowed) { - pto::a5::AicpuLaunchPlan plan; + simpler::a5::AicpuLaunchPlan plan; std::string error; - if (!pto::a5::build_aicpu_launch_plan(topology, threads, plan, error)) return false; + if (!simpler::a5::build_aicpu_launch_plan(topology, threads, plan, error)) return false; allowed = plan.allowed_cpus; return true; } #else uint64_t c2c_address{0}; bool c2c_valid{false}; - std::vector topology; + std::vector topology; bool selected(int threads, std::vector &allowed) { - return pto::a2a3::compute_allowed_cpus(topology, threads, allowed); + return simpler::a2a3::compute_allowed_cpus(topology, threads, allowed); } #endif protected: @@ -5027,24 +5027,24 @@ class ContextControlRunner : public ColdKernelRunner { ++prepare_arch_calls; observed_control_stream = stream; #ifdef CONTEXT_ARCH_A5 - int rc = pto::a5::ensure_ctrl_table( + int rc = simpler::a5::ensure_ctrl_table( mem_alloc_, device_id_, aicore_ctrl_reg_table_dev_, aicore_ctrl_reg_table_committed_ ); if (rc != 0 || occupancy.occupy_valid) return rc; - rc = pto::a5::query_device_aicpu_occupancy(mem_alloc_, load_aicpu_op_, stream, scratch, pending, occupancy); + rc = simpler::a5::query_device_aicpu_occupancy(mem_alloc_, load_aicpu_op_, stream, scratch, pending, occupancy); if (rc != 0) return rc; - pto::a5::detail::CpuTopologyData driver{}; - return pto::a5::detail::build_aicpu_topology(occupancy, "CPU-control-fixture", false, driver, topology) ? + simpler::a5::detail::CpuTopologyData driver{}; + return simpler::a5::detail::build_aicpu_topology(occupancy, "CPU-control-fixture", false, driver, topology) ? 0 : PTO_RUNTIME_ERR_INTERNAL; #else - int rc = pto::a2a3::ensure_ctrl_table( + int rc = simpler::a2a3::ensure_ctrl_table( mem_alloc_, device_id_, aicore_ctrl_reg_table_dev_, aicore_ctrl_reg_table_committed_ ); if (rc != 0) return rc; - rc = pto::a2a3::ensure_c2c_ctrl_address(c2c_address, c2c_valid); + rc = simpler::a2a3::ensure_c2c_ctrl_address(c2c_address, c2c_valid); if (rc != 0) return rc; - if (topology.empty() && !pto::a2a3::probe_aicpu_topology(static_cast(device_id_), topology)) + if (topology.empty() && !simpler::a2a3::probe_aicpu_topology(static_cast(device_id_), topology)) return PTO_RUNTIME_ERR_INTERNAL; return 0; #endif @@ -5056,7 +5056,7 @@ class ContextControlRunner : public ColdKernelRunner { pending = false; return 0; } - return pto::a5::release_aicpu_query_result(mem_alloc_, observed_control_stream, scratch, pending); + return simpler::a5::release_aicpu_query_result(mem_alloc_, observed_control_stream, scratch, pending); #else (void)abandon; return 0; diff --git a/tests/ut/py/test_aicpu_topology_driver_headers.py b/tests/ut/py/test_aicpu_topology_driver_headers.py index e0e81e3535..3fb64c8678 100644 --- a/tests/ut/py/test_aicpu_topology_driver_headers.py +++ b/tests/ut/py/test_aicpu_topology_driver_headers.py @@ -193,11 +193,11 @@ def test_oversized_driver_topology_falls_back(tmp_path: Path) -> None: " static_cast(buffer)->total_nums = 65;\n" " return 0;\n}\n" "int main() {\n" - " pto::a5::AicpuDeviceOccupancy occupancy{};\n" + " simpler::a5::AicpuDeviceOccupancy occupancy{};\n" " occupancy.occupy = 2; occupancy.occupy_valid = true;\n" - " pto::a5::AicpuTopology topology;\n" - " if (!pto::a5::probe_aicpu_topology(0, occupancy, topology)) return 1;\n" - " return topology.source != pto::a5::AicpuTopologySource::kOccupyFallback ||\n" + " simpler::a5::AicpuTopology topology;\n" + " if (!simpler::a5::probe_aicpu_topology(0, occupancy, topology)) return 1;\n" + " return topology.source != simpler::a5::AicpuTopologySource::kOccupyFallback ||\n" " topology.os_schedulable_cpus.size() != 1 ||\n" " topology.os_schedulable_cpus[0].cpu_id != 1;\n}\n" ) diff --git a/tools/cann-examples/aicpu-device-query/host/query_device_hal.cpp b/tools/cann-examples/aicpu-device-query/host/query_device_hal.cpp index 291101e00f..b0357a965b 100644 --- a/tools/cann-examples/aicpu-device-query/host/query_device_hal.cpp +++ b/tools/cann-examples/aicpu-device-query/host/query_device_hal.cpp @@ -498,7 +498,7 @@ int main(int argc, char **argv) { ); if (json_output) { - pto::a5::AicpuDeviceOccupancy occupancy; + simpler::a5::AicpuDeviceOccupancy occupancy; occupancy.os_sched = static_cast(results[kOsSchedRequestIndex].value); occupancy.os_sched_valid = results[kOsSchedRequestIndex].rc == 0; occupancy.occupy = static_cast(results[kOccupyRequestIndex].value); @@ -506,8 +506,8 @@ int main(int argc, char **argv) { occupancy.pf_occupy = static_cast(results[kPfOccupyRequestIndex].value); occupancy.pf_occupy_valid = results[kPfOccupyRequestIndex].rc == 0; - pto::a5::AicpuTopology topology; - if (!pto::a5::probe_aicpu_topology(static_cast(device_id), occupancy, topology)) { + simpler::a5::AicpuTopology topology; + if (!simpler::a5::probe_aicpu_topology(static_cast(device_id), occupancy, topology)) { std::fprintf(stderr, "A5 AICPU topology probe failed for device %d\n", device_id); return 1; } @@ -516,25 +516,25 @@ int main(int argc, char **argv) { return 1; } - pto::a5::AicpuLaunchPlan launch_plan; + simpler::a5::AicpuLaunchPlan launch_plan; std::string plan_error; - if (!pto::a5::build_aicpu_launch_plan(topology, 0, launch_plan, plan_error)) { + if (!simpler::a5::build_aicpu_launch_plan(topology, 0, launch_plan, plan_error)) { std::fprintf(stderr, "A5 AICPU launch planning failed: %s\n", plan_error.c_str()); return 1; } - pto::a5::AicpuSelectionPolicy policy = pto::a5::AicpuSelectionPolicy::kScenario; + simpler::a5::AicpuSelectionPolicy policy = simpler::a5::AicpuSelectionPolicy::kScenario; if (topology.generic_selection_only) { - policy = pto::a5::AicpuSelectionPolicy::kGeneric; - } else if (topology.scenario_type == pto::a5::AicpuScenarioType::kUnknown) { - policy = pto::a5::AicpuSelectionPolicy::kSequentialFallback; + policy = simpler::a5::AicpuSelectionPolicy::kGeneric; + } else if (topology.scenario_type == simpler::a5::AicpuScenarioType::kUnknown) { + policy = simpler::a5::AicpuSelectionPolicy::kSequentialFallback; std::fprintf( stderr, "WARNING: AICPU topology UNKNOWN; selected %d active roles from %d stable CPUs; launch count=%d\n", launch_plan.effective_active_count, launch_plan.stable_reachable_count, launch_plan.launch_count ); } - std::fputs(pto::a5::format_aicpu_topology_json(topology, policy, launch_plan).c_str(), stdout); + std::fputs(simpler::a5::format_aicpu_topology_json(topology, policy, launch_plan).c_str(), stdout); } else { // ---- Pretty-print ---- std::printf("\n=== device=%d device-side HAL view (via dispatcher + inner SO) ===\n", device_id);