---
title: aclrtLaunchKernelWithHostArgs
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclcppdevg_03_1961.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_1961.html
indexId: 6bea7a443e2a081ee454b9b223bfb569e667e1347cebc8fc0f6bdf252239758e68
---
# aclrtLaunchKernelWithHostArgs

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 功能说明

指定任务下发的配置信息，并启动对应算子的计算任务。异步接口。


#### 函数原型

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


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| funcHandle | 输入 | 核函数句柄。类型定义请参见aclrtFuncHandle。 |
| numBlocks | 输入 | 指定核函数将会在几个核上执行。 |
| stream | 输入 | 指定执行任务的Stream。类型定义请参见aclrtStream。 |
| cfg | 输入 | 任务下发的配置信息。类型定义请参见aclrtLaunchKernelCfg。 不指定配置时，此处可传NULL。 |
| hostArgs | 输入 | 存放核函数所有入参数据的Host内存地址指针。 |
| argsSize | 输入 | hostArgs参数值的大小，单位为Byte。 |
| placeHolderArray | 输入 | placeholder参数数组。 aclrtPlaceHolderInfo定义如下： typedef struct { uint32\_t addrOffset; uint32\_t dataOffset; } aclrtPlaceHolderInfo; 成员变量说明如下： addrOffset：placeholder指向的数据区拷贝到Device后，其真实Device内存地址在launch时需要刷新到hostArgs中，该参数用于指定需刷新的位置偏移 dataOffset：placeholder指向的数据区需拷贝到Device侧，该参数用于指定数据区基于hostArgs的地址偏移 |
| placeHolderNum | 输入 | placeholder参数数组的大小。 |


#### 返回值说明

返回0表示成功，返回其他值表示失败，请参见aclError。


#### 接口调用示例

接口调用示例，参见AI Core自定义算子加载(https://www.hiascend.comdocument/detail/zh/canncommercial/900/programug/acldevg/runtime_doc_dev_0019.html)。


#### 参考资源

下表的几个接口都用于启用对应算子的计算任务，但功能和使用方式有所不同：

| 接口 | 核函数参数值的传入方式 | 核函数参数值的存放位置 | 是否可指定任务下发的配置信息 |
| --- | --- | --- | --- |
| aclrtLaunchKernel | 在接口中指定存放核函数所有入参数据的Device内存地址指针 | Device内存 | 否 |
| aclrtLaunchKernelV2 | 在接口中指定存放核函数所有入参数据的Device内存地址指针 | Device内存 | 是 |
| aclrtLaunchKernelWithConfig | 在接口中指定参数列表句柄aclrtArgsHandle | Host内存 | 是 |
| aclrtLaunchKernelWithHostArgs | 在接口中指定存放核函数所有入参数据的Host内存地址指针 | Host内存 | 是 |
