---
title: kupl_in_parallel
description: "判断当前是否在并行域内。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_234.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_234.html
indexId: 92a3d511dd0639cde5651735e55c6ab130209fab7f874e38e7ed92990670fec367
---
# kupl_in_parallel

判断当前是否在并行域内。

#### 接口定义

bool kupl_in_parallel();


#### 返回值

- 在并行域内：返回true
- 不在并行域内：返回false


#### 示例

```
#include <stdio.h>
#include <assert.h>
#include "kupl.h"

static void task_int_parallel(kupl_nd_range_t *nd_range, void *args, int tid, int tnum)
{
    bool in_parallel = kupl_in_parallel();
    assert(in_parallel == true);
}

int main()
{
    kupl_parallel_for_desc_t desc = {
        .field_mask = KUPL_PARALLEL_FOR_DESC_FIELD_DEFAULT,
        .range = nullptr,
        .egroup = nullptr,
        .concurrency = 4,
        .policy = KUPL_LOOP_POLICY_STATIC
    };
    kupl_parallel_for(&desc, task_int_parallel, nullptr);
}
```


- 上述示例演示了开启并行域并判断当前是否在并行域内的流程。
- 上述在并行域内调用kupl_in_parallel函数，因此得到true的结果。
