aclrtGetSymbolAddress

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

√

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

☓

Atlas inference products

√

Atlas training products

☓

Function

Obtains the address of a device variable.

Prototype

1
aclError aclrtGetSymbolAddress(const void *symbol, void **devPtr)

Parameters

Parameter

Input/Output

Description

symbol

Input

Address of a device variable.

The device variable is declared with __gm__.

devPtr

Output

Pointer to the device memory address associated with the symbol.

Returns

0 on success; otherwise, failure. For details, see aclError.

Restrictions

  • This API is used only when a custom operator is developed using the Ascend C language and the host and device code is compiled together using the BiSheng compiler.
  • The device variable address is valid only for the current device. After the device is switched, you need to obtain the address again.
  • Only device variables in AI Core operators are supported. The specific restrictions are as follows:
    • Only device variables (for example, __gm__ float convWeights) defined in the file where the main function is located are supported.
    • Device variables can be referenced across files using the extern keyword. For example, if __gm__ float convWeights is defined in file A, it can be declared and referenced in file B using extern __gm__ float convWeights. The compilation requirements must be met: Use the -dc mode of the BiSheng compiler to compile multiple source files into one operator binary file.
    • Basic data types, function pointers, structures, and arrays are supported. The class type is not supported. Note that function pointers can only point to pure scalar functions and cannot effectively distinguish between Cube and Vector function logic.