编程辅导 OpenMP Reference Sheet for C/C++

OpenMP Reference Sheet for C/C++

for(A=C;A

Copyright By PowCoder代写 加微信 powcoder


#pragma omp ordered {
#pragma omp sections [private(vars), firstprivate(vars), lastprivate(vars), reduction(op:vars), nowait] {
Constructs #pragma omp parallel for [shared(vars), private(vars), firstprivate(vars), lastprivate(vars), default(shared|none), reduction(op:vars), copyin(vars), if(expr), ordered, schedule(type[,chunkSize])]

for(A=C;A

#pragma omp ordered {
#pragma omp parallel sections [shared(vars), private(vars), firstprivate(vars), lastprivate(vars), default(shared|none), reduction(op:vars), copyin(vars), if(expr)] {
#pragma omp section {
#pragma omp section {

#pragma omp section {
#pragma omp section {


#pragma omp single {

Directives
shared(vars)
private(vars)
firstprivate(vars)
default(private|shared|none)
reduction(op:vars)

#pragma omp parallel [shared(vars), private(vars), firstprivate(vars), lastprivate(vars), default(private|shared|none), reduction(op:vars), copyin(vars), if(expr)] { #pragma omp for [private(vars), firstprivate(vars), lastprivate(vars), reduction(op:vars), ordered, schedule(type[,chunkSize]), nowait]

copyin(vars)
if(expr) schedule(type [,chunkSize]) Function Based Locking < nest versions allow recursive locking>
void omp_init_[nest_]lock(omp_lock_t*)
void omp_destroy_[nest_]lock(omp_lock_t*) void omp_set_[nest_]lock(omp_lock_t*) void omp_unset_[nest_]lock(omp_lock_t*)
int omp_test_[nest_]lock(omp_lock_t*)
Settings and Control
int omp_get_num_threads()
int omp_get_thread_num()
int omp_in_parallel()
int omp_get_max_threads()
int omp_get_num_procs()
int omp_get_dynamic()
int omp_get_nested()
double omp_get_wtime()
double omp_get_wtick() void omp_set_num_threads(int) void omp_set_dynamic(int)
void omp_set_nested(int)
OMP_NUM_THREADS “number” OMP_SCHEDULE “type,chunkSize”
vars is a comma separated list of variables
[optional parameters and directives]

…. above directive can be used multiple times
For mistakes, suggestions, and comments please email
type static
dynamic guided
number of iterations per thread pre-assigned at beginning of loop (typical default is number of processors)
number of iterations to allocate to a thread when available (typical default is 1)
highly dependent on specific implementation of OpenMP
nowait
Synchronization/Locking Constructs

#pragma omp master {

#pragma omp critical [(name)] {


#pragma omp barrier #pragma omp atomic
>,| on primitive data types>

#pragma omp flush[(vars)]

#pragma omp threadprivate(vars)

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com