LLVM OpenMP 20.0.0git
|
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. | |
These functions support copyin/out and thread private data.
void __kmpc_copyprivate | ( | ident_t * | loc, |
kmp_int32 | gtid, | ||
size_t | cpy_size, | ||
void * | cpy_data, | ||
void(*)(void *, void *) | cpy_func, | ||
kmp_int32 | didit | ||
) |
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:
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 2272 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.
loc | source location information |
gtid | global thread number |
cpy_data | pointer to the data to be saved/copied or 0 |
__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 2348 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.
void * __kmpc_threadprivate_cached | ( | ident_t * | loc, |
kmp_int32 | global_tid, | ||
void * | data, | ||
size_t | size, | ||
void *** | cache | ||
) |
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 |
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.
void __kmpc_threadprivate_register | ( | ident_t * | loc, |
void * | data, | ||
kmpc_ctor | ctor, | ||
kmpc_cctor | cctor, | ||
kmpc_dtor | dtor | ||
) |
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.
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.
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 | ||
) |
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.
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.