Compare commits

...
3 Commits
Author SHA1 Message Date
Tom Stellard 2ffeb0a2b6 Merging r361158:
------------------------------------------------------------------------
r361158 | jprotze | 2019-05-20 07:21:42 -0700 (Mon, 20 May 2019) | 11 lines

[OpenMP][OMPT] Fix locking testcases for 32 bit architectures

https://reviews.llvm.org/D58454 did not fix the problem for a typical use
case of building LLVM with gcc or icc and then testing with the newly built
clang compiler.
The compilers do not agree on how to extend a 32-bit pointer to uint64, so
make the pointer unsigned first, before adjusting the size.

Patch by Joachim Protze

Differential Revision: https://reviews.llvm.org/D58506
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_80@363628 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-17 22:57:11 +00:00
Hans Wennborg 3983bd2eb3 Merging r351431:
------------------------------------------------------------------------
r351431 | hans | 2019-01-17 12:31:03 +0100 (Thu, 17 Jan 2019) | 19 lines

Revert r351311 "[OMPT] Make sure that OMPT is enabled when accessing internals of the runtime"

and also the follow-up r351315.

The new test is failing on the buildbots.

> Make sure that OMPT is enabled in runtime entry points that access internals
> of the runtime. Else, return an appropiate value indicating an error or that
> the data is not available.
>
> Patch provided by @sconvent
>
> Reviewers: jlpeyton, omalyshe, hbae, Hahnfeld, joachim.protze
>
> Reviewed By: joachim.protze
>
> Tags: #openmp, #ompt
>
> Differential Revision: https://reviews.llvm.org/D47717
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_80@351432 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-17 11:31:57 +00:00
Hans Wennborg bd09ac8dc8 Creating release_80 branch off revision 351319
git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_80@351321 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-16 11:00:55 +00:00
7 changed files with 80 additions and 230 deletions
+3 -3
View File
@@ -364,7 +364,7 @@ static inline void __kmp_acquire_atomic_lock(kmp_atomic_lock_t *lck,
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_atomic, 0, kmp_mutex_impl_queuing, (ompt_wait_id_t)lck,
ompt_mutex_atomic, 0, kmp_mutex_impl_queuing, (ompt_wait_id_t)(uintptr_t)lck,
OMPT_GET_RETURN_ADDRESS(0));
}
#endif
@@ -374,7 +374,7 @@ static inline void __kmp_acquire_atomic_lock(kmp_atomic_lock_t *lck,
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_atomic, (ompt_wait_id_t)lck, OMPT_GET_RETURN_ADDRESS(0));
ompt_mutex_atomic, (ompt_wait_id_t)(uintptr_t)lck, OMPT_GET_RETURN_ADDRESS(0));
}
#endif
}
@@ -390,7 +390,7 @@ static inline void __kmp_release_atomic_lock(kmp_atomic_lock_t *lck,
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_atomic, (ompt_wait_id_t)lck, OMPT_GET_RETURN_ADDRESS(0));
ompt_mutex_atomic, (ompt_wait_id_t)(uintptr_t)lck, OMPT_GET_RETURN_ADDRESS(0));
}
#endif
}
+70 -61
View File
@@ -848,7 +848,7 @@ void __kmpc_ordered(ident_t *loc, kmp_int32 gtid) {
if (ompt_enabled.enabled) {
OMPT_STORE_RETURN_ADDRESS(gtid);
team = __kmp_team_from_gtid(gtid);
lck = (ompt_wait_id_t)&team->t.t_ordered.dt.t_value;
lck = (ompt_wait_id_t)(uintptr_t)&team->t.t_ordered.dt.t_value;
/* OMPT state update */
th->th.ompt_thread_info.wait_id = lck;
th->th.ompt_thread_info.state = ompt_state_wait_ordered;
@@ -857,8 +857,8 @@ void __kmpc_ordered(ident_t *loc, kmp_int32 gtid) {
codeptr_ra = OMPT_LOAD_RETURN_ADDRESS(gtid);
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_ordered, omp_lock_hint_none, kmp_mutex_impl_spin,
(ompt_wait_id_t)lck, codeptr_ra);
ompt_mutex_ordered, omp_lock_hint_none, kmp_mutex_impl_spin, lck,
codeptr_ra);
}
}
#endif
@@ -877,7 +877,7 @@ void __kmpc_ordered(ident_t *loc, kmp_int32 gtid) {
/* OMPT event callback */
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_ordered, (ompt_wait_id_t)lck, codeptr_ra);
ompt_mutex_ordered, (ompt_wait_id_t)(uintptr_t)lck, codeptr_ra);
}
}
#endif
@@ -917,7 +917,8 @@ void __kmpc_end_ordered(ident_t *loc, kmp_int32 gtid) {
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_ordered,
(ompt_wait_id_t)&__kmp_team_from_gtid(gtid)->t.t_ordered.dt.t_value,
(ompt_wait_id_t)(uintptr_t)&__kmp_team_from_gtid(gtid)
->t.t_ordered.dt.t_value,
OMPT_LOAD_RETURN_ADDRESS(gtid));
}
#endif
@@ -1188,7 +1189,7 @@ void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
ti = __kmp_threads[global_tid]->th.ompt_thread_info;
/* OMPT state update */
prev_state = ti.state;
ti.wait_id = (ompt_wait_id_t)lck;
ti.wait_id = (ompt_wait_id_t)(uintptr_t)lck;
ti.state = ompt_state_wait_critical;
/* OMPT event callback */
@@ -1196,7 +1197,7 @@ void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_critical, omp_lock_hint_none, __ompt_get_mutex_impl_type(),
(ompt_wait_id_t)crit, codeptr_ra);
(ompt_wait_id_t)(uintptr_t)lck, codeptr_ra);
}
}
#endif
@@ -1216,7 +1217,7 @@ void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
/* OMPT event callback */
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_critical, (ompt_wait_id_t)crit, codeptr_ra);
ompt_mutex_critical, (ompt_wait_id_t)(uintptr_t)lck, codeptr_ra);
}
}
#endif
@@ -1402,14 +1403,15 @@ void __kmpc_critical_with_hint(ident_t *loc, kmp_int32 global_tid,
ti = __kmp_threads[global_tid]->th.ompt_thread_info;
/* OMPT state update */
prev_state = ti.state;
ti.wait_id = (ompt_wait_id_t)lck;
ti.wait_id = (ompt_wait_id_t)(uintptr_t)lck;
ti.state = ompt_state_wait_critical;
/* OMPT event callback */
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_critical, (unsigned int)hint,
__ompt_get_mutex_impl_type(crit), (ompt_wait_id_t)crit, codeptr);
__ompt_get_mutex_impl_type(crit), (ompt_wait_id_t)(uintptr_t)lck,
codeptr);
}
}
#endif
@@ -1440,14 +1442,15 @@ void __kmpc_critical_with_hint(ident_t *loc, kmp_int32 global_tid,
ti = __kmp_threads[global_tid]->th.ompt_thread_info;
/* OMPT state update */
prev_state = ti.state;
ti.wait_id = (ompt_wait_id_t)lck;
ti.wait_id = (ompt_wait_id_t)(uintptr_t)lck;
ti.state = ompt_state_wait_critical;
/* OMPT event callback */
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_critical, (unsigned int)hint,
__ompt_get_mutex_impl_type(0, ilk), (ompt_wait_id_t)crit, codeptr);
__ompt_get_mutex_impl_type(0, ilk), (ompt_wait_id_t)(uintptr_t)lck,
codeptr);
}
}
#endif
@@ -1467,7 +1470,7 @@ void __kmpc_critical_with_hint(ident_t *loc, kmp_int32 global_tid,
/* OMPT event callback */
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_critical, (ompt_wait_id_t)crit, codeptr);
ompt_mutex_critical, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
}
#endif
@@ -1565,7 +1568,8 @@ void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid,
OMPT_STORE_RETURN_ADDRESS(global_tid);
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_critical, (ompt_wait_id_t)crit, OMPT_LOAD_RETURN_ADDRESS(0));
ompt_mutex_critical, (ompt_wait_id_t)(uintptr_t)lck,
OMPT_LOAD_RETURN_ADDRESS(0));
}
#endif
@@ -2189,8 +2193,8 @@ void __kmpc_init_lock_with_hint(ident_t *loc, kmp_int32 gtid, void **user_lock,
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_lock, (omp_lock_hint_t)hint,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
}
@@ -2213,8 +2217,8 @@ void __kmpc_init_nest_lock_with_hint(ident_t *loc, kmp_int32 gtid,
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_nest_lock, (omp_lock_hint_t)hint,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
}
@@ -2239,8 +2243,8 @@ void __kmpc_init_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2282,7 +2286,7 @@ void __kmpc_init_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_lock, omp_lock_hint_none, __ompt_get_mutex_impl_type(),
(ompt_wait_id_t)user_lock, codeptr);
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2311,8 +2315,8 @@ void __kmpc_init_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_nest_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2357,7 +2361,7 @@ void __kmpc_init_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_lock_init) {
ompt_callbacks.ompt_callback(ompt_callback_lock_init)(
ompt_mutex_nest_lock, omp_lock_hint_none, __ompt_get_mutex_impl_type(),
(ompt_wait_id_t)user_lock, codeptr);
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2393,7 +2397,7 @@ void __kmpc_destroy_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
lck = (kmp_user_lock_p)user_lock;
}
ompt_callbacks.ompt_callback(ompt_callback_lock_destroy)(
ompt_mutex_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
KMP_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
@@ -2421,7 +2425,7 @@ void __kmpc_destroy_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_lock_destroy) {
ompt_callbacks.ompt_callback(ompt_callback_lock_destroy)(
ompt_mutex_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2461,7 +2465,7 @@ void __kmpc_destroy_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_lock_destroy) {
ompt_callbacks.ompt_callback(ompt_callback_lock_destroy)(
ompt_mutex_nest_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
KMP_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
@@ -2493,7 +2497,7 @@ void __kmpc_destroy_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_lock_destroy) {
ompt_callbacks.ompt_callback(ompt_callback_lock_destroy)(
ompt_mutex_nest_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2538,8 +2542,8 @@ void __kmpc_set_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
#if KMP_USE_INLINED_TAS
@@ -2560,7 +2564,7 @@ void __kmpc_set_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2593,7 +2597,7 @@ void __kmpc_set_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_lock, omp_lock_hint_none, __ompt_get_mutex_impl_type(),
(ompt_wait_id_t)lck, codeptr);
(ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -2606,7 +2610,7 @@ void __kmpc_set_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -2628,8 +2632,8 @@ void __kmpc_set_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_nest_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
}
#endif
@@ -2646,13 +2650,14 @@ void __kmpc_set_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquired) {
// lock_first
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_nest_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)user_lock,
codeptr);
}
} else {
if (ompt_enabled.ompt_callback_nest_lock) {
// lock_next
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_scope_begin, (ompt_wait_id_t)user_lock, codeptr);
ompt_scope_begin, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
}
}
@@ -2690,7 +2695,8 @@ void __kmpc_set_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_nest_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(), (ompt_wait_id_t)lck, codeptr);
__ompt_get_mutex_impl_type(), (ompt_wait_id_t)(uintptr_t)lck,
codeptr);
}
}
#endif
@@ -2707,13 +2713,13 @@ void __kmpc_set_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquired) {
// lock_first
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_nest_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
} else {
if (ompt_enabled.ompt_callback_nest_lock) {
// lock_next
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_scope_begin, (ompt_wait_id_t)lck, codeptr);
ompt_scope_begin, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
}
}
@@ -2749,7 +2755,7 @@ void __kmpc_unset_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
@@ -2778,7 +2784,7 @@ void __kmpc_unset_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -2810,7 +2816,7 @@ void __kmpc_unset_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
codeptr = OMPT_GET_RETURN_ADDRESS(0);
if (ompt_enabled.ompt_callback_mutex_released) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -2838,12 +2844,13 @@ void __kmpc_unset_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_released) {
// release_lock_last
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_nest_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)user_lock,
codeptr);
}
} else if (ompt_enabled.ompt_callback_nest_lock) {
// release_lock_prev
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_scope_end, (ompt_wait_id_t)user_lock, codeptr);
ompt_scope_end, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
}
#endif
@@ -2887,12 +2894,12 @@ void __kmpc_unset_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_released) {
// release_lock_last
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_nest_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
} else if (ompt_enabled.ompt_callback_nest_lock) {
// release_lock_previous
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_mutex_scope_end, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_scope_end, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
}
#endif
@@ -2929,12 +2936,12 @@ void __kmpc_unset_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_released) {
// release_lock_last
ompt_callbacks.ompt_callback(ompt_callback_mutex_released)(
ompt_mutex_nest_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
} else if (ompt_enabled.ompt_callback_nest_lock) {
// release_lock_previous
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_mutex_scope_end, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_scope_end, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
}
#endif
@@ -2960,8 +2967,8 @@ int __kmpc_test_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
#if KMP_USE_INLINED_TAS
@@ -2983,7 +2990,7 @@ int __kmpc_test_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
return FTN_TRUE;
@@ -3024,7 +3031,7 @@ int __kmpc_test_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_lock, omp_lock_hint_none, __ompt_get_mutex_impl_type(),
(ompt_wait_id_t)lck, codeptr);
(ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -3039,7 +3046,7 @@ int __kmpc_test_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (rc && ompt_enabled.ompt_callback_mutex_acquired) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
#endif
@@ -3065,8 +3072,8 @@ int __kmpc_test_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_nest_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(user_lock), (ompt_wait_id_t)user_lock,
codeptr);
__ompt_get_mutex_impl_type(user_lock),
(ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
#endif
rc = KMP_D_LOCK_FUNC(user_lock, test)((kmp_dyna_lock_t *)user_lock, gtid);
@@ -3083,13 +3090,14 @@ int __kmpc_test_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquired) {
// lock_first
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_nest_lock, (ompt_wait_id_t)user_lock, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)user_lock,
codeptr);
}
} else {
if (ompt_enabled.ompt_callback_nest_lock) {
// lock_next
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_scope_begin, (ompt_wait_id_t)user_lock, codeptr);
ompt_scope_begin, (ompt_wait_id_t)(uintptr_t)user_lock, codeptr);
}
}
}
@@ -3130,7 +3138,8 @@ int __kmpc_test_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
ompt_enabled.ompt_callback_mutex_acquire) {
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquire)(
ompt_mutex_nest_lock, omp_lock_hint_none,
__ompt_get_mutex_impl_type(), (ompt_wait_id_t)lck, codeptr);
__ompt_get_mutex_impl_type(), (ompt_wait_id_t)(uintptr_t)lck,
codeptr);
}
#endif
@@ -3148,13 +3157,13 @@ int __kmpc_test_nest_lock(ident_t *loc, kmp_int32 gtid, void **user_lock) {
if (ompt_enabled.ompt_callback_mutex_acquired) {
// lock_first
ompt_callbacks.ompt_callback(ompt_callback_mutex_acquired)(
ompt_mutex_nest_lock, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_nest_lock, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
} else {
if (ompt_enabled.ompt_callback_nest_lock) {
// lock_next
ompt_callbacks.ompt_callback(ompt_callback_nest_lock)(
ompt_mutex_scope_begin, (ompt_wait_id_t)lck, codeptr);
ompt_mutex_scope_begin, (ompt_wait_id_t)(uintptr_t)lck, codeptr);
}
}
}
+4 -15
View File
@@ -450,9 +450,6 @@ OMPT_API_ROUTINE ompt_set_result_t ompt_set_callback(ompt_callbacks_t which,
OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which,
ompt_callback_t *callback) {
if (!ompt_enabled.enabled)
return ompt_get_callback_failure;
switch (which) {
#define ompt_event_macro(event_name, callback_type, event_id) \
@@ -460,7 +457,7 @@ OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which,
if (ompt_event_implementation_status(event_name)) { \
ompt_callback_t mycb = \
(ompt_callback_t)ompt_callbacks.ompt_callback(event_name); \
if (ompt_enabled.event_name && mycb) { \
if (mycb) { \
*callback = mycb; \
return ompt_get_callback_success; \
} \
@@ -483,15 +480,11 @@ OMPT_API_ROUTINE int ompt_get_callback(ompt_callbacks_t which,
OMPT_API_ROUTINE int ompt_get_parallel_info(int ancestor_level,
ompt_data_t **parallel_data,
int *team_size) {
if (!ompt_enabled.enabled)
return 0;
return __ompt_get_parallel_info_internal(ancestor_level, parallel_data,
team_size);
}
OMPT_API_ROUTINE int ompt_get_state(ompt_wait_id_t *wait_id) {
if (!ompt_enabled.enabled)
return ompt_state_work_serial;
int thread_state = __ompt_get_state_internal(wait_id);
if (thread_state == ompt_state_undefined) {
@@ -506,8 +499,6 @@ OMPT_API_ROUTINE int ompt_get_state(ompt_wait_id_t *wait_id) {
****************************************************************************/
OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(void) {
if (!ompt_enabled.enabled)
return NULL;
return __ompt_get_thread_data_internal();
}
@@ -516,8 +507,6 @@ OMPT_API_ROUTINE int ompt_get_task_info(int ancestor_level, int *type,
ompt_frame_t **task_frame,
ompt_data_t **parallel_data,
int *thread_num) {
if (!ompt_enabled.enabled)
return 0;
return __ompt_get_task_info_internal(ancestor_level, type, task_data,
task_frame, parallel_data, thread_num);
}
@@ -592,7 +581,7 @@ OMPT_API_ROUTINE int ompt_get_place_num(void) {
#if !KMP_AFFINITY_SUPPORTED
return -1;
#else
if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
if (__kmp_get_gtid() < 0)
return -1;
int gtid;
@@ -613,7 +602,7 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size,
#if !KMP_AFFINITY_SUPPORTED
return 0;
#else
if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
if (__kmp_get_gtid() < 0)
return 0;
int i, gtid, place_num, first_place, last_place, start, end;
@@ -648,7 +637,7 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size,
****************************************************************************/
OMPT_API_ROUTINE int ompt_get_proc_id(void) {
if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
if (__kmp_get_gtid() < 0)
return -1;
#if KMP_OS_LINUX
return sched_getcpu();
+1 -1
View File
@@ -211,7 +211,7 @@ ompt_data_t *__ompt_get_thread_data_internal() {
void __ompt_thread_assign_wait_id(void *variable) {
kmp_info_t *ti = ompt_get_thread();
ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)variable;
ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)(uintptr_t)variable;
}
int __ompt_get_state_internal(ompt_wait_id_t *omp_wait_id) {
@@ -1,148 +0,0 @@
// RUN: %libomp-compile-and-run | FileCheck %s
// REQUIRES: ompt
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <inttypes.h>
#include <omp.h>
#include <ompt.h>
static ompt_set_callback_t ompt_set_callback;
static ompt_get_callback_t ompt_get_callback;
static ompt_get_state_t ompt_get_state;
static ompt_get_task_info_t ompt_get_task_info;
static ompt_get_thread_data_t ompt_get_thread_data;
static ompt_get_parallel_info_t ompt_get_parallel_info;
static ompt_get_unique_id_t ompt_get_unique_id;
static ompt_get_num_procs_t ompt_get_num_procs;
static ompt_get_num_places_t ompt_get_num_places;
static ompt_get_place_proc_ids_t ompt_get_place_proc_ids;
static ompt_get_place_num_t ompt_get_place_num;
static ompt_get_partition_place_nums_t ompt_get_partition_place_nums;
static ompt_get_proc_id_t ompt_get_proc_id;
static ompt_enumerate_states_t ompt_enumerate_states;
static ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls;
int main() {
// Call OpenMP API function to force initialization of OMPT.
// (omp_get_thread_num() does not work because it just returns 0 if the
// runtime isn't initialized yet...)
omp_get_num_threads();
ompt_data_t *tdata = ompt_get_thread_data();
uint64_t tvalue = tdata ? tdata->value : 0;
printf("%" PRIu64 ": ompt_get_num_places()=%d\n", tvalue,
ompt_get_num_places());
printf("%" PRIu64 ": ompt_get_place_proc_ids()=%d\n", tvalue,
ompt_get_place_proc_ids(0, 0, NULL));
printf("%" PRIu64 ": ompt_get_place_num()=%d\n", tvalue,
ompt_get_place_num());
printf("%" PRIu64 ": ompt_get_partition_place_nums()=%d\n", tvalue,
ompt_get_partition_place_nums(0, NULL));
printf("%" PRIu64 ": ompt_get_proc_id()=%d\n", tvalue, ompt_get_proc_id());
printf("%" PRIu64 ": ompt_get_num_procs()=%d\n", tvalue,
ompt_get_num_procs());
ompt_callback_t callback;
printf("%" PRIu64 ": ompt_get_callback()=%d\n", tvalue,
ompt_get_callback(ompt_callback_thread_begin, &callback));
printf("%" PRIu64 ": ompt_get_state()=%d\n", tvalue, ompt_get_state(NULL));
int state = omp_state_undefined;
const char *state_name;
printf("%" PRIu64 ": ompt_enumerate_states()=%d\n", tvalue,
ompt_enumerate_states(state, &state, &state_name));
int impl = ompt_mutex_impl_unknown;
const char *impl_name;
printf("%" PRIu64 ": ompt_enumerate_mutex_impls()=%d\n", tvalue,
ompt_enumerate_mutex_impls(impl, &impl, &impl_name));
printf("%" PRIu64 ": ompt_get_thread_data()=%p\n", tvalue,
ompt_get_thread_data());
printf("%" PRIu64 ": ompt_get_parallel_info()=%d\n", tvalue,
ompt_get_parallel_info(0, NULL, NULL));
printf("%" PRIu64 ": ompt_get_task_info()=%d\n", tvalue,
ompt_get_task_info(0, NULL, NULL, NULL, NULL, NULL));
// Check if libomp supports the callbacks for this test.
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_get_num_places()={{[0-9]+}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids()={{[0-9]+}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=-1
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_partition_place_nums()=0
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=-1
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()={{[0-9]+}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_callback()=0
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_state()=0
// CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_states()=1
// CHECK: {{^}}[[MASTER_ID]]: ompt_enumerate_mutex_impls()=1
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_thread_data()=[[NULL]]
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_parallel_info()=0
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_task_info()=0
return 0;
}
int ompt_initialize(ompt_function_lookup_t lookup, ompt_data_t *tool_data) {
ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback");
ompt_get_callback = (ompt_get_callback_t)lookup("ompt_get_callback");
ompt_get_state = (ompt_get_state_t)lookup("ompt_get_state");
ompt_get_task_info = (ompt_get_task_info_t)lookup("ompt_get_task_info");
ompt_get_thread_data = (ompt_get_thread_data_t)lookup("ompt_get_thread_data");
ompt_get_parallel_info =
(ompt_get_parallel_info_t)lookup("ompt_get_parallel_info");
ompt_get_unique_id = (ompt_get_unique_id_t)lookup("ompt_get_unique_id");
ompt_get_num_procs = (ompt_get_num_procs_t)lookup("ompt_get_num_procs");
ompt_get_num_places = (ompt_get_num_places_t)lookup("ompt_get_num_places");
ompt_get_place_proc_ids =
(ompt_get_place_proc_ids_t)lookup("ompt_get_place_proc_ids");
ompt_get_place_num = (ompt_get_place_num_t)lookup("ompt_get_place_num");
ompt_get_partition_place_nums =
(ompt_get_partition_place_nums_t)lookup("ompt_get_partition_place_nums");
ompt_get_proc_id = (ompt_get_proc_id_t)lookup("ompt_get_proc_id");
ompt_enumerate_states =
(ompt_enumerate_states_t)lookup("ompt_enumerate_states");
ompt_enumerate_mutex_impls =
(ompt_enumerate_mutex_impls_t)lookup("ompt_enumerate_mutex_impls");
printf("0: NULL_POINTER=%p\n", (void *)NULL);
return 0; // no success -> OMPT not enabled
}
void ompt_finalize(ompt_data_t *tool_data) {
printf("0: ompt_event_runtime_shutdown\n");
}
ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
const char *runtime_version) {
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
&ompt_finalize, 0};
return &ompt_start_tool_result;
}
+1 -1
View File
@@ -10,7 +10,7 @@ int main()
print_ids(0);
omp_lock_t lock;
printf("%" PRIu64 ": &lock: %" PRIu64 "\n", ompt_get_thread_data()->value, (uint64_t) &lock);
printf("%" PRIu64 ": &lock: %" PRIu64 "\n", ompt_get_thread_data()->value, (ompt_wait_id_t)(uintptr_t) &lock);
omp_init_lock(&lock);
print_fuzzy_address(1);
omp_set_lock(&lock);
@@ -10,7 +10,7 @@ int main()
print_ids(0);
omp_nest_lock_t nest_lock;
printf("%" PRIu64 ": &nest_lock: %lli\n", ompt_get_thread_data()->value, (long long) &nest_lock);
printf("%" PRIu64 ": &nest_lock: %lli\n", ompt_get_thread_data()->value, (ompt_wait_id_t)(uintptr_t) &nest_lock);
omp_init_nest_lock(&nest_lock);
print_fuzzy_address(1);
omp_set_nest_lock(&nest_lock);