aclrtMemcpyToSymbol

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

Synchronously copies memory from the host to a device variable. This is used to write data to a device variable.

This is an encapsulated API that applies only to C++ programs. It internally calls the C API aclrtMemcpyToSymbol.

Prototype

1
2
template <typename T>
aclError aclrtMemcpyToSymbol(const T &symbol, const void *src, size_t count, size_t offset, aclrtMemcpyKind kind)

Parameters

Parameter

Input/Output

Description

symbol

Input

Device variable.

The device variable is declared with __gm__.

src

Input

Pointer to the source memory address.

count

Input

Size in bytes to copy.

The following condition must be met: offset + count ≤ Device variable size. The device variable size can be obtained by calling aclrtGetSymbolSize.

offset

Input

Device variable address offset, in bytes.

The following condition must be met: offset + count ≤ Device variable size. The device variable size can be obtained by calling aclrtGetSymbolSize.

kind

Input

Memory copy kind. For details about the type definition, see aclrtMemcpyKind.

This API only supports ACL_MEMCPY_HOST_TO_DEVICE and ACL_MEMCPY_DEFAULT.

Returns

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

Restrictions

The restrictions are the same as those in aclrtGetSymbolAddress.