OpenMP Reference

Embed Size (px)

Citation preview

  • 8/6/2019 OpenMP Reference

    1/2

    OpenMP Reference Sheet for C/C++

    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

  • 8/6/2019 OpenMP Reference

    2/2

    copyin(vars)

    if(expr)schedule(type [,chunkSize])

    type chunkSize

    static number of iterations per thread pre-assigned at beginning of loop(typical default is number of processors)

    dynamic number of iterations to allocate to a thread when available (typicaldefault is 1)

    guided highly dependent on specific implementation of OpenMP

    nowait

    Synchronization/Locking Constructs

    #pragma omp master {

    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 Controlint 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"

    Legendvars is a comma separated list of variables[optional parameters and directives].... above directive can be used multiple timesFor mistakes, suggestions, and comments please email [email protected]