DEENESPTFRRUARHIKOZHNL

命名空间 ara::shwa

Diese Seite wurde vollständig KI-generiert auf Basis von SWS Safe Hardware Acceleration (R25-11) — kein offizieller AUTOSAR-Text und keine automatisch extrahierte API-Seite wie die übrigen Module. Als Interpretation gekennzeichnete Aussagen sind Schlussfolgerungen aus den Quellen.

160 API-Records in Kapitel 8: 18 Klassen, 120 Funktionen, 4 Enumerationen und 3 Typ-Aliasse.

用户指南人工智能生成

实现将计算密集型任务安全卸载到专用硬件加速器。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 94872e9e2305 来源 未决问题(2)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

实现将计算密集型任务安全卸载到专用硬件加速器。

命名空间 ara::shwa 提供用于安全硬件加速(Safe Hardware Acceleration)的接口,并允许通过目标格式 Target 将并行计算任务有针对性地卸载到 GPU 或 CPU 等设备([AP_SWS_SHWA_00102])。应用程序通过选择器选择加速器,创建独占管理的执行队列,并通过缓冲区访问器控制内存访问。核心边界条件是具有不可复制资源的严格所有权模型,以及通过 ShwaErrorCode 的无异常错误指示([AP_SWS_SHWA_01301])。

上下文

命名空间 ara::shwa(Safe Hardware Acceleration)在 AUTOSAR Adaptive Platform 内提供接口,以便将计算密集型任务卸载到专用硬件加速器。该模块允许集成不同类型的加速器,例如图形处理器(GPU)、数字信号处理器或专用主处理器(CPU)。

系统环境的检测通过类 Platform 进行,该类确定电子控制单元(ECU)上可用的硬件平台并列出关联的 Device 实例。合适设备的选择可以通过专用选择器动态或静态控制:DeviceSelector 作为可调用函数对象,根据整数等级对可用单元进行优先级排序,而 CpuSelector、GpuSelector 和 AcceleratorSelector 则有针对性地寻址特定的执行单元。加速器的当前运行状态通过枚举 DeviceStatus([AP_SWS_SHWA_00103])映射。

Queue 负责计算操作的并行执行。计算作业通过 TaskHandler 封装,其中执行位置通过 Target([AP_SWS_SHWA_00102])可选地指定在加速器(kDevice)或主机 CPU(kHostTask)上。用于输入和输出数据的内存区域通过 Buffer 使用维度规范 Range 进行分配。对这些缓冲区的访问由 Accessor 对象管理,这些对象通过 AccessMode([AP_SWS_SHWA_00101])限制访问模式。

context Application Application Platform Platform Application->Platform fragt ab DeviceSelector DeviceSelector Application->DeviceSelector 使用 Queue Queue Application->Queue besitzt Buffer Buffer Application->Buffer besitzt Device Device Platform->Device listet DeviceSelector->Device 选择 Queue->Device bindet TaskHandler TaskHandler Queue->TaskHandler erzeugt Event Event Queue->Event erzeugt Range Range Buffer->Range beschreibt Accessor Accessor Buffer->Accessor erzeugt

上下文图:用于硬件选择、内存管理和任务执行的核心类之间的交互。来源:[AP_SWS_SHWA_00101]、[AP_SWS_SHWA_00102]、[AP_SWS_SHWA_00103]

生命周期

ara::shwa 中的资源和生命周期模型严格区分了拥有资源的对象、描述性句柄和依赖于队列的组件:

  • 拥有资源的类:Queue、Buffer 和 Accessor 独占管理硬件资源和内存区域。它们不可复制(not copyable),且必须强制通过 std::unique_ptr 进行管理。仅允许通过移动语义进行传递或转交。
  • 描述性句柄和辅助类:Platform、Device、DeviceMonitor、Id、Range 和 PropertyList 不独占拥有硬件资源。它们被设计为可复制。Device 的实例仅代表对设备的访问接口,但不独占控制该设备。解释:执行队列(Queue)的初始化绑定到先前选择的特定 Device,因为 Queue 独占管理资源。 问题 Q-c38811a811f133d0 (未决)
  • 依赖组件:类 Event(用于同步)和 TaskHandler(用于任务处理)只能在 Queue 内部创建;在队列上下文之外,它们不具有任何功能意义。

设备的生命周期反映在 DeviceStatus([AP_SWS_SHWA_00103])中:除了就绪状态 kReady 之外,设备还可以被标示为不可访问(kNotAccesible)、故障(kFailure)或未知(kUnknown)。解释:设备在 kReady、kNotAccesible 和 kFailure 之间的状态变化在运行时通过辅助类(如 DeviceMonitor)或平台来检测。 问题 Q-8fc0dc95534dc8bc (未决)

使用路径

使用 ara::shwa 执行加速计算的典型过程分为五个步骤:

  1. 平台和设备选择:应用程序通过 Platform 查询现有的硬件平台及其关联的 Device 实例。选择器(如 DeviceSelector、GpuSelector 或 CpuSelector)确定最合适的设备,该设备的 DeviceStatus([AP_SWS_SHWA_00103])具有状态 kReady。
  2. 实例化队列:为所选的 Device 创建 Queue 并作为 std::unique_ptr 持有。
  3. 分配并准备内存:对于输入和输出数据,通过 Range 创建具有所需维度的 Buffer。为了填充或求值,应用程序请求一个 Accessor,其中访问模式通过 AccessMode([AP_SWS_SHWA_00101])声明为 kRead、kWrite 或 kReadWrite。
  4. 注册并执行任务:在 Queue 内创建一个 TaskHandler。启动执行,其中通过 Target([AP_SWS_SHWA_00102])指定任务是在加速器(kDevice)上还是在主机(kHostTask)上运行。
  5. 同步:Queue 提供一个 Event,主机应用程序通过它监控硬件加速器上计算的异步完成情况,并同步数据比对。
ara::shwa 中任务处理的使用路径应用PlatformDeviceSelectorQueueBuffer查询可用设备Liste von Device-Objekten选择设备所选设备为设备实例化队列创建带有范围的缓冲区请求带有 AccessMode 的 AccessorAccessor bereitstellen传入带有 Target 的 TaskHandler创建用于同步的事件

时序图:从平台查询到缓冲区分配直至同步执行的流程。来源:[AP_SWS_SHWA_00101]、[AP_SWS_SHWA_00102]、[AP_SWS_SHWA_00103]

错误场景

ara::shwa 的编程接口采用无异常(exception-free)设计。错误状态通过 ara::core::ErrorCode 同步返回。错误码的创建通过工厂函数 MakeErrorCode([AP_SWS_SHWA_01312])并参考错误域 GetShwaDomain([AP_SWS_SHWA_01311])进行。如果应用程序架构采用基于异常的错误模型,则可以将错误码转换为 ShwaException 并抛出。

枚举 ShwaErrorCode([AP_SWS_SHWA_01301])指定了标准化的错误原因:

  • 内存和访问问题:主内存分配失败会导致 kMemoryNotAllocated。若无法维持缓冲区的数据一致性,则会报告 kIntegrityCorrupted。非法访问模式或对 Accessor 对象的操作失败会导致 kInvalidAccessMode 或 kAccessorFailure。
  • 执行和同步错误:目标设备上的任务处理失败时会指示 kTaskExecutionFailure。对同步对象的非法操作会导致 kEventInvalidOperation,而阻塞的资源会触发 kResourceBusy。如果超过配置的执行时间,则返回 kTimedOut。
  • 无效参数和对象状态:对已销毁或无效对象调用方法会导致 kInvalidObject。无效索引或参数通过 kInvalidIndex 或 kInvalidParameter 予以拒绝。不支持的功能报告 kFeatureNotSupported,而一般错误则通过 kRuntime 捕获。

为了处理在加速器上进行异步计算期间发生的错误,使用类 ErrorHandler。

本指南仅基于 AUTOSAR R25-11 中 ara::shwa 的规范。

主题图

KI-gestützte Gruppierung auf Basis der Records und Spezifikationsauszüge; keine Gliederung aus der AUTOSAR-Spezifikation.

详细视图

请在大纲中选择一个条目。

Geräteauswahl

AcceleratorSelector manages accelerator selection for operations on HWA if available.

CpuSelector manages CPU selection for operations on HWA if available Allows to get a device from any supported backends for which the device type is CPU.

Class allowing to choose the most appropriate device of the available ones. This is a callable object taking a device reference and returning an integer rank. One of the device with the highest non-negative value is selected.

GpuSelector manages GPU selection for operations on HWA if available Select a device from any supported backends for which the device type is GPU.

Geräteabstraktion

Device 类

Device class represents HWA device. Provides access to the device but not controlling it. Designed as copyable since not owning resources.

DeviceMonitor API class. Designed as copyable since not owning resources.

Id 类

Id API class. Designed as copyable since not owning resources.

Platform class is responsible for extracting different HWA platforms available for current application and listing Devices bind to each platform. Designed as copyable since not owning resources.

Die Enumeration definiert die folgenden standardisierten Werte.

enum class DeviceStatus : std::uint32_t {...};

Speicherzugriff

Accessor manages read and write access to allocated memory by Buffer. Designed as not copyable, since it’s owning resources. Intended to be managed exclusively by std::unique_ptr, which may be moved. ≙ std::unique_ptr

Buffer 类

Buffer manages memory allocation for operations on the host or/and HWA. Designed as not copyable, since it’s owning resources. Intended to be managed exclusively by std::unique_ptr, which may be moved. ≙ std::unique_ptr

Range 类

Defines size of Buffer for one, two or three dimensions. Designed as copyable since not owning resources.

AccessMode 枚举

Die Enumeration definiert die folgenden standardisierten Werte.

enum class AccessMode : std::uint32_t {...};
Target 枚举

Die Enumeration definiert die folgenden standardisierten Werte.

enum class Target : std::uint32_t {...};

Auftragsausführung

Event 类

Event class helps to manage task execution synchronization between HWA and Host application. Can be created only inside of the Queue otherwise it’s meaningless.

Queue 类

Queue API provides the functionality for parallel processing on selected Device. Designed as not copyable, since it’s owning resources. Intended to be managed exclusively by std::unique_ ptr, which may be moved. ≙ std::unique_

Handles tasks execution on the selected Device Can be created only inside of the Queue otherwise it’s meaningless.

Fehlerbehandlung

ErrorHandler manages asynchronous error handling for operations on HWA.

Defines the error domain for Safe Hardware Acceleration.

Exception type could be thrown by application or other FC using Safe Hardware Acceleration. Safe Hardware Acceleration API is exception free and can only return an ErrorCode, but user code can transform this error to exception and throw if it’s alligned with system error handling architecture.

Liest die durch die Signatur bezeichnete Information oder Eigenschaft aus dem Objekt.

constexpr const ara::core::ErrorDomain & GetShwaDomain () noexcept;

Die Spezifikation definiert diese Deklaration mit der in der Signatur ausgewiesenen Semantik.

constexpr ara::core::ErrorCode MakeErrorCode (ShwaErrorCode code, ara::core::ErrorDomain::SupportDataType data) noexcept;

Die Enumeration definiert die folgenden standardisierten Werte.

enum class ShwaErrorCode : ara::core::ErrorDomain::CodeType {...};

Herstellereigenschaften

Property List class is designed to enable vendor specific SHWA functionality extension and adjustment. Properties are not standardized and can be defined by Vendor. Class using Property list is obliged to have HasProperty() and GetProperty() methods defined.

枚举

枚举 AccessMode [AP_SWS_SHWA_00101] Upstream: RS_SHWA_00017

enum class AccessMode : std::uint32_t {...};

Die Enumeration definiert die folgenden standardisierten Werte.

Werte

  • kRead — Nur-Lesen-Modus.
  • kWrite — Nur-Schreiben-Modus.
  • kReadWrite — Lese-/Schreibmodus.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00101
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00101@rel:R25-11#52ae33bf
Content hash
52ae33bf
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00101
Status: valid/unmigrated Version: rel:R25-11#08a7ea1b Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00101@rel:R25-11#08a7ea1b
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

枚举 DeviceStatus [AP_SWS_SHWA_00103] Upstream: RS_SHWA_00004

enum class DeviceStatus : std::uint32_t {...};

Die Enumeration definiert die folgenden standardisierten Werte.

Werte

  • kReady (= 0) — Device ist für die Task-Ausführung bereit.
  • kNotAccesible (= 1) — Device ist nicht zugänglich.
  • kFailure (= 2) — Device im Fehlerzustand.
  • kUnknown (= 255) — Status kann nicht bestimmt werden.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00103
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00103@rel:R25-11#92321b24
Content hash
92321b24
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00103
Status: valid/unmigrated Version: rel:R25-11#41762982 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00103@rel:R25-11#41762982
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

枚举 Target [AP_SWS_SHWA_00102] Upstream: RS_SHWA_00001, RS_SHWA_00017

enum class Target : std::uint32_t {...};

Die Enumeration definiert die folgenden standardisierten Werte.

Werte

  • kDevice — Task läuft auf dem Gerät beziehungsweise Beschleuniger.
  • kHostTask — Task läuft auf dem Host (CPU).

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00102
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00102@rel:R25-11#00ea677f
Content hash
00ea677f
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00102
Status: valid/unmigrated Version: rel:R25-11#8cd54cba Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00102@rel:R25-11#8cd54cba
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

枚举 ShwaErrorCode [AP_SWS_SHWA_01301] Upstream: RS_AP_00122, RS_AP_00125, RS_AP_00127, RS_AP_00149

enum class ShwaErrorCode : ara::core::ErrorDomain::CodeType {...};

Die Enumeration definiert die folgenden standardisierten Werte.

Werte

  • kRuntime (= 1) — allgemeiner Laufzeitfehler.
  • kTaskExecutionFailure (= 2) — Fehler bei der Task-Ausführung.
  • kMemoryNotAllocated (= 3) — Speicherallokation fehlgeschlagen.
  • kIntegrityCorrupted (= 4) — Integrität eines Buffer-Speichers nicht herstellbar.
  • kResourceBusy (= 5) — Ressource ist belegt.
  • kInvalidAccessMode (= 6) — Zugriffsmodus ist unzulässig.
  • kAccessorFailure (= 7) — Accessor-Nutzung oder -Erzeugung fehlgeschlagen.
  • kEventInvalidOperation (= 8) — unzulässige Event-Operation.
  • kFeatureNotSupported (= 9) — Feature wird nicht unterstützt.
  • kInvalidIndex (= 10) — Index ist ungültig.
  • kInvalidParameter (= 11) — ungültiger API-Parameter.
  • kInvalidObject (= 12) — ungültiges oder zerstörtes Objekt verwendet.
  • kTimedOut (= 13) — Operation überschritt die Zeitgrenze.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_01301
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_01301@rel:R25-11#cc267161
Content hash
cc267161
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_01301
Status: valid/unmigrated Version: rel:R25-11#cfa33aae Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_01301@rel:R25-11#cfa33aae
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

自由函数文档

函数 GetShwaDomain [AP_SWS_SHWA_01311] Upstream: RS_AP_00119, RS_AP_00120, RS_AP_00159

constexpr const ara::core::ErrorDomain & GetShwaDomain () noexcept;

Liest die durch die Signatur bezeichnete Information oder Eigenschaft aus dem Objekt.

Thread Safetythread-safe
Exception Safetyexception safe

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_01311
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_01311@rel:R25-11#6ecdfdf0
Content hash
6ecdfdf0
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_01311
Status: valid/unmigrated Version: rel:R25-11#733e648e Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_01311@rel:R25-11#733e648e
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 MakeErrorCode [AP_SWS_SHWA_01312] Upstream: RS_AP_00119, RS_AP_00120, RS_AP_00121, RS_AP_00135

constexpr ara::core::ErrorCode MakeErrorCode (ShwaErrorCode code, ara::core::ErrorDomain::SupportDataType data) noexcept;

Die Spezifikation definiert diese Deklaration mit der in der Signatur ausgewiesenen Semantik.

Thread Safetythread-safe
Exception Safetyexception safe

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_01312
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_01312@rel:R25-11#237a5159
Content hash
237a5159
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_01312
Status: valid/unmigrated Version: rel:R25-11#a5d8ab39 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_01312@rel:R25-11#a5d8ab39
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill