---
title: kpccl_set_kernel_concurrency
description: "设置全局的算子并发度。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/KunoengHPCKit_developer_046.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/KunoengHPCKit_developer_046.html
indexId: 732ba13844fab8e881c007c9e157d4fc7bf28c00cbc2aec25945c7b13b2f8d9f73
---
# kpccl_set_kernel_concurrency

设置全局的算子并发度。

#### 接口定义

void kpccl_set_kernel_concurrency(int num);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| num | int | 需要设置的算子并发度的值 约束：1≤num≤kpccl\_get\_num\_executors()；当输入不在约束范围内时，内部设置num为kpccl\_get\_num\_executors() | 输入 |


#### 示例

```
#include <stdio.h>
#include "kpccl.h"
int main()
{
kpccl_set_kernel_concurrency
(2);
int num = kpccl_get_kernel_concurrency();
printf("kpccl kernel concurrency = %d\n", num);
return 0;
}
```

运行结果如下。

```
kpccl kernel concurrency = 2
```

- 上述示例设置并打印了全局算子并发度的值。上述kpccl_set_kernel_concurrency函数将算子并发度设置为2。
- 除了通过kpccl_set_kernel_concurrency函数接口设置算子并发度外，还可以通过环境变量KPCCL_KERNEL_CONCURRENCY来设置算子并发度。
