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 )
- Include a header file:
- 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.
|
Returns
None
Constraints
None
Example
GetInfoFun() {
...
auto coreNum = platform_ascendc::PlatformAscendCManager::GetInstance()->GetCoreNum();
...
return;
}
Parent topic: Platform Information Acquisition