PlatformAscendCManager
功能说明
基于Kernel Launch算子工程,通过基础调用(Kernel Launch)方式调用算子的场景下,可能需要获取硬件平台相关信息,比如获取硬件平台的核数。PlatformAscendCManager类提供获取平台信息的功能:通过该类的GetInstance方法可以获取一个PlatformAscendC类的指针,再通过该指针获取硬件平台相关信息,支持获取的信息可参考PlatformAscendC。

- 使用该功能需要包含"tiling/platform/platform_ascendc.h"头文件,并在编译脚本中链接tiling_api、platform动态库。
- 包含头文件的样例如下:
1
#include "tiling/platform/platform_ascendc.h"
- 链接动态库的样例如下:
1 2 3 4 5 6 7
add_executable(main main.cpp) target_link_libraries(main PRIVATE kernels tiling_api platform )
- 包含头文件的样例如下:
- 当前该类仅支持如下型号:
Atlas 推理系列产品 Atlas 训练系列产品 Atlas A2 训练系列产品/Atlas 800I A2 推理产品
函数原型
1 2 3 4 5 6 7 8 | class PlatformAscendCManager { public: static PlatformAscendC* GetInstance(); // 在仅有CPU环境、无对应的NPU硬件环境时,需要传入customSocVersion来指定对应的AI处理器型号。注意:因为GetInstance实现属于单例模式,仅在第一次调用时传入的customSocVersion生效。 static PlatformAscendC* GetInstance(const char *customSocVersion); private: ... } |
参数说明
参数 |
输入/输出 |
说明 |
---|---|---|
customSocVersion |
输入 |
AI处理器型号。
|
返回值说明
无
约束说明
无
调用示例
1 2 3 4 5 6 | GetInfoFun() { ... auto coreNum = platform_ascendc::PlatformAscendCManager::GetInstance()->GetCoreNum(); ... return; } |
父主题: 平台信息获取