OmpThreadNum
- Set the number of concurrent OMP threads:
int32_t KVSIP_SetOmpThreadNum(int32_t num);
- Obtain the current number of concurrent OMP threads:
int32_t KVSIP_GetOmpThreadNum(void);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
num |
Maximum number of threads |
> 0 |
Input |
Return Value
KVSIP_SetOmpThreadNum:
- Success: The value 0 is returned.
- Failure: The value -1 is returned.
KVSIP_GetOmpThreadNum:
The number of OMP threads is returned.
Example
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "kvsip.h"
#include "vsip.h"
#include "vsip_type.h"
void OmpThreadNumExample()
{
int32_t originNum = KVSIP_GetOmpThreadNum();
printf("KVSIP_GetOmpThreadNum originNum = %d\n", originNum);
const int32_t num = 0x7;
int32_t ret = KVSIP_SetOmpThreadNum(num);
int32_t newNum = KVSIP_GetOmpThreadNum();
printf("KVSIP_SetOmpThreadNum result = %d, newNum = %d\n", ret, newNum);
int32_t resumeRet = KVSIP_SetOmpThreadNum(originNum);
int32_t lastNum = KVSIP_GetOmpThreadNum();
printf("resume omp resumeRet = %d, lastNum = %d\n", resumeRet, lastNum);
}
int main(void) {
OmpThreadNumExample();
return 0;
}
Output:
KVSIP_GetOmpThreadNum originNum = 1 KVSIP_SetOmpThreadNum result = 0, newNum = 7 resume omp resumeRet = 0, lastNum = 1
Parent topic: Basic Functions