Synchronization

## Functions

void | __kmpc_flush (ident_t *loc)
void | __kmpc_barrier (ident_t *loc, kmp_int32 global_tid)
kmp_int32 | __kmpc_barrier_master (ident_t *loc, kmp_int32 global_tid)
void | __kmpc_end_barrier_master (ident_t *loc, kmp_int32 global_tid)
kmp_int32 | __kmpc_barrier_master_nowait (ident_t *loc, kmp_int32 global_tid)
kmp_int32 | __kmpc_reduce_nowait (ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars, size_t reduce_size, void *reduce_data, void(*reduce_func)(void *lhs_data, void *rhs_data), kmp_critical_name *lck)
void | __kmpc_end_reduce_nowait (ident_t *loc, kmp_int32 global_tid, kmp_critical_name *lck)
kmp_int32 | __kmpc_reduce (ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars, size_t reduce_size, void *reduce_data, void(*reduce_func)(void *lhs_data, void *rhs_data), kmp_critical_name *lck)
void | __kmpc_end_reduce (ident_t *loc, kmp_int32 global_tid, kmp_critical_name *lck)

## Detailed Description

These functions are used for implementing barriers.

## Function Documentation

## __kmpc_barrier()

void __kmpc_barrier | ( | ident_t * | loc,
|  | kmp_int32 | global_tid
| ) |  |

Parameters

  loc | source location information
  global_tid | thread id.

Execute a barrier.

Definition at line 726 of file kmp_csupport.cpp.

## __kmpc_barrier_master()

kmp_int32 __kmpc_barrier_master | ( | ident_t * | loc,
|  | kmp_int32 | global_tid
| ) |  |

Parameters

  loc | source location information
  global_tid | thread id.

Returns
  one if the thread should execute the master block, zero otherwise

Start execution of a combined barrier and master. The barrier is executed inside this function.

Definition at line 1713 of file kmp_csupport.cpp.

## __kmpc_barrier_master_nowait()

kmp_int32 __kmpc_barrier_master_nowait | ( | ident_t * | loc,
|  | kmp_int32 | global_tid
| ) |  |

Parameters

  loc | source location information
  global_tid | thread id.

Returns
  one if the thread should execute the master block, zero otherwise

Start execution of a combined barrier and master(nowait) construct. The barrier is executed inside this function. There is no equivalent "end" function, since the

Definition at line 1773 of file kmp_csupport.cpp.

## __kmpc_end_barrier_master()

void __kmpc_end_barrier_master | ( | ident_t * | loc,
|  | kmp_int32 | global_tid
| ) |  |

Parameters

  loc | source location information
  global_tid | thread id.

Complete the execution of a combined barrier and master. This function should only be called at the completion of the `master` code. Other threads will still be waiting at the barrier and this call releases them.

Definition at line 1757 of file kmp_csupport.cpp.

## __kmpc_end_reduce()

void __kmpc_end_reduce | ( | ident_t * | loc,
|  | kmp_int32 | global_tid,
|  | kmp_critical_name * | lck
| ) |  |

Parameters

  loc | source location information
  global_tid | global thread id.
  lck | pointer to the unique lock data structure

Finish the execution of a blocking reduce. The `lck` pointer must be the same as that used in the corresponding start function.

Definition at line 3826 of file kmp_csupport.cpp.

## __kmpc_end_reduce_nowait()

void __kmpc_end_reduce_nowait | ( | ident_t * | loc,
|  | kmp_int32 | global_tid,
|  | kmp_critical_name * | lck
| ) |  |

Parameters

  loc | source location information
  global_tid | global thread id.
  lck | pointer to the unique lock data structure

Finish the execution of a reduce nowait.

Definition at line 3635 of file kmp_csupport.cpp.

## __kmpc_flush()

void __kmpc_flush | ( | ident_t * | loc | ) |

Parameters

  loc | source location information.

Execute `flush`. This is implemented as a full memory fence. (Though depending on the memory ordering convention obeyed by the compiler even that may not be necessary).

Definition at line 666 of file kmp_csupport.cpp.

## __kmpc_reduce()

kmp_int32 __kmpc_reduce | ( | ident_t * | loc,
|  | kmp_int32 | global_tid,
|  | kmp_int32 | num_vars,
|  | size_t | reduce_size,
|  | void * | reduce_data,
|  | void(*)(void *lhs_data, void *rhs_data) | reduce_func,
|  | kmp_critical_name * | lck
| ) |  |

Parameters

  loc | source location information
  global_tid | global thread number
  num_vars | number of items (variables) to be reduced
  reduce_size | size of data in bytes to be reduced
  reduce_data | pointer to data to be reduced
  reduce_func | callback function providing reduction operation on two operands and returning result of reduction in lhs_data
  lck | pointer to the unique lock data structure

Returns
  1 for the primary thread, 0 for all other team threads, 2 for all team threads if atomic reduction needed

A blocking reduce that includes an implicit barrier.

Definition at line 3704 of file kmp_csupport.cpp.

## __kmpc_reduce_nowait()

kmp_int32 __kmpc_reduce_nowait | ( | ident_t * | loc,
|  | kmp_int32 | global_tid,
|  | kmp_int32 | num_vars,
|  | size_t | reduce_size,
|  | void * | reduce_data,
|  | void(*)(void *lhs_data, void *rhs_data) | reduce_func,
|  | kmp_critical_name * | lck
| ) |  |

Parameters

  loc | source location information
  global_tid | global thread number
  num_vars | number of items (variables) to be reduced
  reduce_size | size of data in bytes to be reduced
  reduce_data | pointer to data to be reduced
  reduce_func | callback function providing reduction operation on two operands and returning result of reduction in lhs_data
  lck | pointer to the unique lock data structure

Returns
  1 for the primary thread, 0 for all other team threads, 2 for all team threads if atomic reduction needed

The nowait version is used for a reduce clause with the nowait argument.

Definition at line 3475 of file kmp_csupport.cpp.