PlatformAscendCManager

Function Usage

To call operators in the basic mode (kernel launch) based on the kernel launch operator project, you may need to obtain hardware platform information, such as the number of cores on the hardware platform. The PlatformAscendCManager class provides the function of obtaining platform information. You can use the GetInstance method of this class to obtain a pointer of 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:
      #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 Training Series Product

Prototype

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.

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

Returns

None

Constraints

None

Example

GetInfoFun() {
    ...
    auto coreNum = platform_ascendc::PlatformAscendCManager::GetInstance()->GetCoreNum();
    ...
    return;
}