aclrtLaunchKernelWithHostArgs

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

Configures the compute task of an operator and starts the task. This is an asynchronous API.

Prototype

1
aclError aclrtLaunchKernelWithHostArgs(aclrtFuncHandle funcHandle, uint32_t numBlocks, aclrtStream stream, aclrtLaunchKernelCfg *cfg, void *hostArgs, size_t argsSize, aclrtPlaceHolderInfo *placeHolderArray, size_t placeHolderNum)

Parameters

Parameter

Input/Output

Description

funcHandle

Input

Kernel function handle. For details about the type definition, see aclrtFuncHandle.

numBlocks

Input

Number of cores on which the kernel function will be executed.

stream

Input

Stream for executing the task. For details about the type definition, see aclrtStream.

cfg

Input

Task configuration. For details about the type definition, see aclrtLaunchKernelCfg.

If no configuration is specified, NULL can be passed.

hostArgs

Input

Pointer to the host memory address that stores all input parameters of the kernel function.

argsSize

Input

Size of parameter values in hostArgs, in bytes.

placeHolderArray

Input

placeholder parameter array.

aclrtPlaceHolderInfo is defined as follows:

typedef struct {
    uint32_t addrOffset;
    uint32_t dataOffset;
} aclrtPlaceHolderInfo;

The member variables are described as follows:

  • addrOffset: After the data area pointed to by placeholder is copied to the device, the actual device memory address needs to be updated to hostArgs during launch. This parameter specifies the location offset to be updated.
  • dataOffset: The data area pointed to by placeholder needs to be copied to the device. This parameter specifies the address offset of the data area based on hostArgs.

placeHolderNum

Input

Size of the placeholder parameter array.

Returns

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

API Call Example

For the API call example, see AI Core Custom Operator Loading.

Reference

All the APIs listed in the table below can start the compute task of an operator. However, their functions and usage methods are different.

API

How Kernel Function Parameter Values Are Passed

Where Kernel Function Parameter Values Are Stored

Task Configurable

aclrtLaunchKernel

Specify the pointer to the device memory address that stores all input parameters of the kernel function.

Device memory

No

aclrtLaunchKernelV2

Specify the pointer to the device memory address that stores all input parameters of the kernel function.

Device memory

Yes

aclrtLaunchKernelWithConfig

Specify the parameter list handle aclrtArgsHandle.

Host memory

Yes

aclrtLaunchKernelWithHostArgs

Specify the pointer to the host memory address that stores all input parameters of the kernel function.

Host memory

Yes

aclrtLaunchKernelWithArgsArray

Specify the parameter array that stores all input parameters of the kernel function. Each element in the array points to the data of a kernel function parameter.

Host memory

Yes