PlatformAscendCManager

Function

Obtains hardware platform information, such as the number of cores on the hardware platform, to call operators in kernel launch mode based on the kernel launch operator project. The PlatformAscendCManager class provides the function of obtaining platform information. You can use the GetInstance method of this class to obtain a pointer to the PlatformAscendC class, and then use the pointer to obtain hardware platform information. For further details about the information that can be obtained, see PlatformAscendC.

  • To use this function, the tiling/platform/platform_ascendc.h header file must be included and the tiling_api and platform dynamic libraries should be linked to the compilation script.
    • Include a header file:
      1
      #include "tiling/platform/platform_ascendc.h"
      
    • Link to dynamic libraries:
      add_executable(main main.cpp)
      
      target_link_libraries(main PRIVATE
        kernels
        tiling_api
        platform
      )
  • Currently, only the following models are supported:
    • Atlas inference products
    • Atlas training products
    • Atlas A2 training products/Atlas A2 inference products
    • Atlas A3 training products/Atlas A3 inference products

Prototype

1
2
3
4
5
6
7
8
class PlatformAscendCManager {
public:
    static PlatformAscendC* GetInstance();
    // If there is only a CPU environment but no corresponding NPU hardware environment, customSocVersion needs to be passed to specify the corresponding AI Processor model. Note: Because the GetInstance implementation is in the singleton mode, only the customSocVersion input during the first call takes effect.
    static PlatformAscendC* GetInstance(const char *customSocVersion);
private:
...
}

Parameters

Parameter

Input/Output

Description

customSocVersion

Input

AI Processor model.

  • For the following products: Run the npu-smi info command on the server where Ascend AI Processor is installed to obtain the Name information. The actual value is AscendName. For example, if Name is xxxyy, the actual value is Ascendxxxyy.

    Atlas A2 training products/Atlas A2 inference products

    Atlas 200I/500 A2 inference products

    Atlas inference products

    Atlas training products

  • For the following products: Run the npu-smi info -t board -i id -c chip_id command on the server where Ascend AI Processor is installed to obtain the Chip Name and NPU Name information. The actual value is Chip Name_NPU Name. For example, if the value of Chip Name is Ascendxxx and the value of NPU Name is 1234, the actual value is Ascendxxx_1234. Note that:
    • id: device ID, which is the NPU ID obtained by running the npu-smi info -l command.
    • chip_id: chip ID, which is obtained by running the npu-smi info -m command.

    Atlas A3 training products/Atlas A3 inference products

Returns

None

Constraints

None

Examples

1
2
3
4
5
6
GetInfoFun() {
    ...
    auto coreNum = platform_ascendc::PlatformAscendCManager::GetInstance()->GetCoreNum();
    ...
    return;
}