GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-90a26d7490
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
omp_threads.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for omp_threads.c:

Go to the source code of this file.

Functions

int G_set_omp_num_threads (struct Option *opt)
 Set the number of threads for OpenMP The intended usage is at the beginning of a C tool when parameters are processed, namely the G_OPT_M_NPROCS standard option. More...
 

Function Documentation

◆ G_set_omp_num_threads()

int G_set_omp_num_threads ( struct Option opt)

Set the number of threads for OpenMP The intended usage is at the beginning of a C tool when parameters are processed, namely the G_OPT_M_NPROCS standard option.

If nprocs is set to 0, default OpenMP internal logic is used. If nprocs is a positive number, specified number of threads is used. If nprocs is a negative number, then maximum threads - number is used instead (e.g. to keep number of cores free for other use.

Parameters
optA nprocs Option struct to specify the number of threads
Returns
the number of threads set up for OpenMP parallel computing

Definition at line 25 of file omp_threads.c.

References _, Option::answer, G_fatal_error(), G_verbose_message(), G_warning(), Option::key, n_, and NULL.