Environment Library Routines
The routines that can be used to modify the execution environment are listed below.
- omp_set_num_threads(num_threads)
 - The 
omp_set_num_threadsroutine is used to set the nthreads OpenMP internal variable. It should be called outside a parallel region. If it is called within a parallel region, its effect is implementation-defined. The argument must be a positive integer. Setting the internal variable to a particular value does not guarantee that the next parallel region will have that number of threads, because a parallel construct may have its own num_threads clause. - omp_get_num_threads
 - The 
omp_get_num_threadsroutine is not the corresponding getter foromp_set_num_threads. It can be called anywhere in the program and returns the number of threads in the innermost parallel region to which it belongs. If it is called outside a parallel region, it returns 1. - int omp_get_max_threads()
 - The 
omp_get_max_threadsroutine is the corresponding getter foromp_set_num_threads. It returns the present value of the nthreads OpenMP internal variable. It should be called outside a parallel region. If it is called within a parallel region, its result is implementation-defined. - int omp_get_thread_number()
 - The 
omp_get_thread_numberroutine returns the OpenMP thread number of the thread from which it is called. OpenMP numbers its threads from 0 to one less than the number that would be returned byomp_get_num_threadsif it were called at this point in the program. These numbers should not be confused with the numbers assigned to threads by the operating system. - int omp_get_num_procs()
 - The 
omp_get_num_procsroutine returns the number of processors (cores) available to the program. - logical omp_in_parallel()
 - The 
omp_in_parallelroutine returns the logical "or" of the if-clauses of all the enclosing parallel regions. Any parallel region that doesn't have an if-clause contributes .TRUE. to this evaluation. The routine returns .FALSE. if called outside any parallel region. When called in a C program it returns the integer equivalents (1, 0) of true and false. - omp_set_dynamic(dynamic)
 - The 
omp_set_dynamicroutine sets the dynamic OpenMP internal variable if its argument evaluates to true and if the OpenMP implementation supports dynamic scheduling of threads. It should be called outside a parallel region. If it is called within a parallel region, its effect is implementation-defined. - logical omp_get_dynamic()
 - The 
omp_get_dynamicroutine gets the dynamic OpenMP internal variable. It should be called outside a parallel region. If it is called within a parallel region, its effect is implementation-defined. If the implementation doesn't support dynamic scheduling of the number of threads, it will always return false. - omp_set_nested(nested)
 - The 
omp_set_nestedroutine sets the nested OpenMP internal variable if its argument evaluates to true and if the OpenMP implementation supports nesting of parallel regions. It should be called outside a parallel region. If it is called within a parallel region, its effect is implementation-defined. - logical omp_get nested()
 - The 
omp_get_nestedroutine gets the nested OpenMP internal variable. It should be called outside a parallel region. If it is called within a parallel region, its effect is implementation-defined. If the implementation doesn't support nesting of parallel regions, it will always return false. 
            ©
            
            
             |  
            Cornell University
                           |  
                        Center for Advanced Computing
                           |  
                        Copyright Statement
                           |  
                        Access Statement
                        
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)
    CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)