Download presentation
Presentation is loading. Please wait.
Published byGregory Cook Modified over 9 years ago
1
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-2
2
Environment Variables OMP_NUM_THREADS OMP_SCHEDULE
3
Run time environment omp_get_num_threads() omp_get_thread_num() omp_in_parallel Routines related to locks
4
Lock routines ● Will only discuss simple lock: may not be locked if already in a locked state. ● Simple lock interface: ➢ Type: omp_lock_t ➢ Operations: omp_init_lock(omp_lock_t *a) omp_destroy_lock(omp_lock_t *a) omp_set_lock(omp_lock_t *a) omp_unset_lock(omp_lock_t *a) omp_test_lock(omp_lock_t *a)
5
Lock routines ● omp_init_lock initializes the lock. After the call, the lock is unset. ● omp_destroy_lock destroys the lock. The lock must be unset before this call. ● omp_set_lock attempts to set the lock. If the lock is already set by another thread, it will wait until the lock is no longer set, and then sets it. ● omp_unset_lock unsets the lock. It should only be called by the same thread that set the lock; the consequences of doing otherwise are undefined. ● omp_test_lock attempts to set the lock. If the lock is already set by another thread, it returns 0; if it managed to set the lock, it returns 1.
6
OpenMP :User level library routines omp_get_num_threads() : The omp_get_num threads library routine enables the programmer to retrieve the number of threads in the current team. omp_get_thread_num() : Returns the number of the calling thread as an integer value. omp_get_num() : procs returns, as an integer, the total number of processors available to the program at the instant in which it is called. omp_in_parallel() : returns true if it is called from within an active parallel region Otherwise, it returns false.
7
OMP_SET_NUM_THREADS Purpose: ● Sets the number of threads that will be used in the next parallel region. Must be a positive integer.
8
OMP_GET_MAX_THREADS Purpose: ● Returns the maximum value that can be returned by a call to the OMP_GET_NUM_THREADS function.
9
OMP_GET_THREAD_LIMIT Purpose: ● New with OpenMP 3.0. Returns the maximum number of OpenMP threads available to a program.
10
OMP_GET_NUM_PROCS Purpose: ● Returns the number of processors that are available to the program.
11
OMP_SET_DYNAMIC Purpose: ● Enables or disables dynamic adjustment (by the run time system) of the number of threads available for execution of parallel regions.
12
OMP_GET_DYNAMIC Purpose: ● Used to determine if dynamic thread adjustment is enabled or not.
13
OMP_SET_NESTED Purpose: ● Used to enable or disable nested parallelism.
14
OMP_GET_NESTED Purpose: ● Used to determine if nested parallelism is enabled or not.
15
OMP_SET_SCHEDULE Purpose: ● This routine is new with OpenMP version 3.0 ● This routine sets the schedule type that is applied when the loop directive specifies a runtime schedule.
16
OMP_GET_SCHEDULE Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns the schedule that is applied when the loop directive specifies a runtime schedule.
17
OMP_SET_MAX_ACTIVE_LEVELS Purpose: ● This routine is new with OpenMP version 3.0 ● This routine limits the number of nested active parallel regions.
18
OMP_GET_MAX_ACTIVE_LEVELS Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns the maximum number of nested active parallel regions.
19
OMP_GET_LEVEL Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns the number of nested parallel regions enclosing the task that contains the call.
20
OMP_GET_ANCESTOR_THREAD_NUM Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns, for a given nested level of the current thread, the thread number of the ancestor or the current thread.
21
OMP_GET_TEAM_SIZE Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns, for a given nested level of the current thread, the size of the thread team to which the ancestor or the current thread belongs.
22
OMP_GET_ACTIVE_LEVEL Purpose: ● This routine is new with OpenMP version 3.0 ● The omp_get_active_level routine returns the number of nested, active parallel regions enclosing the task that contains the call.
23
OMP_IN_FINAL Purpose: ● This routine is new with OpenMP version 3.0 ● This routine returns true if the routine is executed in a final task region; otherwise, it returns false.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.