LLVM OpenMP 19.0.0git
Functions
Thread private data support

These functions support copyin/out and thread private data. More...

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)
 
typedef void *(* kmpc_ctor) (void *)
 Pointer to the constructor function.
 
typedef void(* kmpc_dtor) (void *)
 Pointer to the destructor function.
 
typedef void *(* kmpc_cctor) (void *, void *)
 Pointer to an alternate constructor.
 
typedef void *(* kmpc_ctor_vec) (void *, size_t)
 Array constructor.
 
typedef void(* kmpc_dtor_vec) (void *, size_t)
 Pointer to the array destructor function.
 
typedef void *(* kmpc_cctor_vec) (void *, void *, size_t)
 Array constructor.
 

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 1774 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 1796 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 1761 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 1784 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 1767 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 1790 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
locsource location information
gtidglobal thread number
cpy_sizesize of the cpy_data buffer
cpy_datapointer to data to be copied
cpy_funchelper function to call for copying data
diditflag 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 2217 of file kmp_csupport.cpp.

References __kmp_assert_valid_gtid(), __kmp_barrier(), __kmp_env_consistency_check, __kmp_team_from_gtid(), __kmp_threads, __ompt_get_task_info_internal(), bs_plain_barrier, ompt_callbacks_active_s::enabled, FALSE, KC_TRACE, KMP_MB, KMP_WARNING, loc, ompt_enabled, OMPT_GET_FRAME_ADDRESS, and kmp_team::t.

◆ __kmpc_copyprivate_light()

void * __kmpc_copyprivate_light ( ident_t loc,
kmp_int32  gtid,
void cpy_data 
)
Parameters
locsource location information
gtidglobal thread number
cpy_datapointer 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 2293 of file kmp_csupport.cpp.

References __kmp_barrier(), __kmp_env_consistency_check, __kmp_team_from_gtid(), __kmp_threads, __ompt_get_task_info_internal(), bs_plain_barrier, ompt_callbacks_active_s::enabled, FALSE, KC_TRACE, KMP_MB, KMP_WARNING, loc, ompt_enabled, OMPT_GET_FRAME_ADDRESS, and kmp_team::t.

◆ __kmpc_threadprivate_cached()

void * __kmpc_threadprivate_cached ( ident_t loc,
kmp_int32  global_tid,
void data,
size_t  size,
void ***  cache 
)
Parameters
locsource location information
global_tidglobal thread number
datapointer to data to privatize
sizesize of data to privatize
cachepointer to cache
Returns
pointer to private storage

Allocate private storage for threadprivate data.

Definition at line 614 of file kmp_threadprivate.cpp.

References __kmp_acquire_bootstrap_lock(), __kmp_acquire_lock(), __kmp_allocate, __kmp_find_cache(), __kmp_global_lock, __kmp_release_bootstrap_lock(), __kmp_release_lock(), __kmp_threadpriv_cache_list, __kmp_tp_cached, __kmp_tp_cached_lock, __kmp_tp_capacity, __kmpc_threadprivate(), kmp_cached_addr::addr, kmp_cached_addr::compiler_cache, kmp_cached_addr::data, data, KC_TRACE, KMP_ITT_IGNORE, KMP_MB, loc, kmp_cached_addr::next, ret, size, TCR_PTR, and TCW_PTR.

◆ __kmpc_threadprivate_register()

void __kmpc_threadprivate_register ( ident_t loc,
void data,
kmpc_ctor  ctor,
kmpc_cctor  cctor,
kmpc_dtor  dtor 
)
Parameters
locsource location information
datapointer to data being privatized
ctorpointer to constructor function for data
cctorpointer to copy constructor function for data
dtorpointer 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.

References __kmp_allocate, __kmp_find_shared_task_common(), __kmp_threadprivate_d_table, shared_common::cct, shared_common::cctor, shared_common::ct, shared_common::ctor, shared_table::data, data, shared_common::dt, shared_common::dtor, shared_common::gbl_addr, KC_TRACE, KMP_ASSERT, KMP_HASH, and shared_common::next.

◆ __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
locsource location information
datapointer to data being privatized
ctorpointer to constructor function for data
cctorpointer to copy constructor function for data
dtorpointer to destructor function for data
vector_lengthlength of the vector (bytes or elements?) Register vector constructors and destructors for thread private data.

Definition at line 746 of file kmp_threadprivate.cpp.

References __kmp_allocate, __kmp_find_shared_task_common(), __kmp_threadprivate_d_table, shared_common::cct, shared_common::cctor, shared_common::cctorv, shared_common::ct, shared_common::ctor, shared_common::ctorv, shared_table::data, data, shared_common::dt, shared_common::dtor, shared_common::dtorv, shared_common::gbl_addr, shared_common::is_vec, KC_TRACE, KMP_ASSERT, KMP_HASH, shared_common::next, TRUE, and shared_common::vec_len.