Loading...
Searching...
No Matches
Thread private data support

## Functions

void | __kmpc_copyprivate (ident_t *loc, kmp_int32 gtid, size_t cpy_size, void *cpy_data, void(*cpy_func)(void *, void *), kmp_int32 didit)
void * | __kmpc_copyprivate_light (ident_t *loc, kmp_int32 gtid, void *cpy_data)
void | __kmpc_threadprivate_register (ident_t *loc, void *data, kmpc_ctor ctor, kmpc_cctor cctor, kmpc_dtor dtor)
void * | __kmpc_threadprivate_cached (ident_t *loc, kmp_int32 global_tid, void *data, size_t size, void ***cache)
void | __kmpc_threadprivate_register_vec (ident_t *loc, void *data, kmpc_ctor_vec ctor, kmpc_cctor_vec cctor, kmpc_dtor_vec dtor, size_t vector_length)

## Detailed Description

These functions support copyin/out and thread private data.

## Typedef Documentation

## kmpc_cctor

typedef void *(* kmpc_cctor) (void *, void *)

Pointer to an alternate constructor. The first argument is the `this` pointer.

Definition at line 1775 of file kmp.h.

## kmpc_cctor_vec

typedef void *(* kmpc_cctor_vec) (void *, void *, size_t)

Array constructor. First argument is the `this` pointer Third argument the number of array elements.

Definition at line 1797 of file kmp.h.

## kmpc_ctor

typedef void *(* kmpc_ctor) (void *)

Pointer to the constructor function. The first argument is the `this` pointer

Definition at line 1762 of file kmp.h.

## kmpc_ctor_vec

typedef void *(* kmpc_ctor_vec) (void *, size_t)

Array constructor. First argument is the `this` pointer Second argument the number of array elements.

Definition at line 1785 of file kmp.h.

## kmpc_dtor

typedef void(* kmpc_dtor) (void *)

Pointer to the destructor function. The first argument is the `this` pointer

Definition at line 1768 of file kmp.h.

## kmpc_dtor_vec

typedef void(* kmpc_dtor_vec) (void *, size_t)

Pointer to the array destructor function. The first argument is the `this` pointer Second argument the number of array elements.

Definition at line 1791 of file kmp.h.

## Function Documentation

## __kmpc_copyprivate()

void __kmpc_copyprivate | ( | ident_t * | loc,
|  | kmp_int32 | gtid,
|  | size_t | cpy_size,
|  | void * | cpy_data,
|  | void(*)(void *, void *) | cpy_func,
|  | kmp_int32 | didit
| ) |  |

Parameters

  loc | source location information
  gtid | global thread number
  cpy_size | size of the cpy_data buffer
  cpy_data | pointer to data to be copied
  cpy_func | helper function to call for copying data
  didit | flag variable: 1=single thread; 0=not single thread

__kmpc_copyprivate implements the interface for the private data broadcast needed for the copyprivate clause associated with a single region in an OpenMP* program (both C and Fortran). All threads participating in the parallel region call this routine. One of the threads (called the single thread) should have the `didit` variable set to 1 and all other threads should have that variable set to 0. All threads pass a pointer to a data buffer (cpy_data) that they have built.

The OpenMP specification forbids the use of nowait on the single region when a copyprivate clause is present. However, __kmpc_copyprivate implements a barrier internally to avoid race conditions, so the code generation for the single region should avoid generating a barrier after the call to __kmpc_copyprivate.

The `gtid` parameter is the global thread id for the current thread. The `loc` parameter is a pointer to source location information.

Internal implementation: The single thread will first copy its descriptor address (cpy_data) to a team-private location, then the other threads will each call the function pointed to by the parameter cpy_func, which carries out the copy by copying the data using the cpy_data buffer.

The cpy_func routine used for the copy and the contents of the data area defined by cpy_data and cpy_size may be built in any fashion that will allow the copy to be done. For instance, the cpy_data buffer can hold the actual data to be copied or it may hold a list of pointers to the data. The cpy_func routine must interpret the cpy_data buffer appropriately.

The interface to cpy_func is as follows:

void cpy_func( void *destination, void *source )

where void *destination is the cpy_data pointer for the thread being copied to and void *source is the cpy_data pointer for the thread being copied from.

Definition at line 2216 of file kmp_csupport.cpp.

## __kmpc_copyprivate_light()

void * __kmpc_copyprivate_light | ( | ident_t * | loc,
|  | kmp_int32 | gtid,
|  | void * | cpy_data
| ) |  |

Parameters

  loc | source location information
  gtid | global thread number
  cpy_data | pointer to the data to be saved/copied or 0

Returns
  the saved pointer to the data

__kmpc_copyprivate_light is a lighter version of __kmpc_copyprivate: __kmpc_copyprivate_light only saves the pointer it's given (if it's not 0, so coming from single), and returns that pointer in all calls (for single thread it's not needed). This version doesn't do any actual data copying. Data copying has to be done somewhere else, e.g. inline in the generated code. Due to this, this function doesn't have any barrier at the end of the function, like __kmpc_copyprivate does, so generated code needs barrier after copying of all data was done.

Definition at line 2292 of file kmp_csupport.cpp.

## __kmpc_threadprivate_cached()

void * __kmpc_threadprivate_cached | ( | ident_t * | loc,
|  | kmp_int32 | global_tid,
|  | void * | data,
|  | size_t | size,
|  | void *** | cache
| ) |  |

Parameters

  loc | source location information
  global_tid | global thread number
  data | pointer to data to privatize
  size | size of data to privatize
  cache | pointer to cache

Returns
  pointer to private storage

Allocate private storage for threadprivate data.

Definition at line 614 of file kmp_threadprivate.cpp.

## __kmpc_threadprivate_register()

void __kmpc_threadprivate_register | ( | ident_t * | loc,
|  | void * | data,
|  | kmpc_ctor | ctor,
|  | kmpc_cctor | cctor,
|  | kmpc_dtor | dtor
| ) |  |

Parameters

  loc | source location information
  data | pointer to data being privatized
  ctor | pointer to constructor function for data
  cctor | pointer to copy constructor function for data
  dtor | pointer to destructor function for data

Register constructors and destructors for thread private data. This function is called when executing in parallel, when we know the thread id.

Definition at line 504 of file kmp_threadprivate.cpp.

## __kmpc_threadprivate_register_vec()

void __kmpc_threadprivate_register_vec | ( | ident_t * | loc,
|  | void * | data,
|  | kmpc_ctor_vec | ctor,
|  | kmpc_cctor_vec | cctor,
|  | kmpc_dtor_vec | dtor,
|  | size_t | vector_length
| ) |  |

Parameters

  loc | source location information
  data | pointer to data being privatized
  ctor | pointer to constructor function for data
  cctor | pointer to copy constructor function for data
  dtor | pointer to destructor function for data
  vector_length | length of the vector (bytes or elements?) Register vector constructors and destructors for thread private data.

Definition at line 746 of file kmp_threadprivate.cpp.