ompt-internal.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * ompt-internal.h - header of OMPT internal data structures
  3. */
  4. //===----------------------------------------------------------------------===//
  5. //
  6. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  7. // See https://llvm.org/LICENSE.txt for license information.
  8. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  9. //
  10. //===----------------------------------------------------------------------===//
  11. #ifndef __OMPT_INTERNAL_H__
  12. #define __OMPT_INTERNAL_H__
  13. #include "ompt-event-specific.h"
  14. #include "omp-tools.h"
  15. #define OMPT_VERSION 1
  16. #define _OMP_EXTERN extern "C"
  17. #define OMPT_INVOKER(x) \
  18. ((x == fork_context_gnu) ? ompt_parallel_invoker_program \
  19. : ompt_parallel_invoker_runtime)
  20. #define ompt_callback(e) e##_callback
  21. typedef struct ompt_callbacks_internal_s {
  22. #define ompt_event_macro(event, callback, eventid) \
  23. callback ompt_callback(event);
  24. FOREACH_OMPT_EVENT(ompt_event_macro)
  25. #undef ompt_event_macro
  26. } ompt_callbacks_internal_t;
  27. typedef struct ompt_callbacks_active_s {
  28. unsigned int enabled : 1;
  29. #define ompt_event_macro(event, callback, eventid) unsigned int event : 1;
  30. FOREACH_OMPT_EVENT(ompt_event_macro)
  31. #undef ompt_event_macro
  32. } ompt_callbacks_active_t;
  33. #define TASK_TYPE_DETAILS_FORMAT(info) \
  34. ((info->td_flags.task_serial || info->td_flags.tasking_ser) \
  35. ? ompt_task_undeferred \
  36. : 0x0) | \
  37. ((!(info->td_flags.tiedness)) ? ompt_task_untied : 0x0) | \
  38. (info->td_flags.final ? ompt_task_final : 0x0) | \
  39. (info->td_flags.merged_if0 ? ompt_task_mergeable : 0x0)
  40. typedef struct {
  41. ompt_frame_t frame;
  42. ompt_data_t task_data;
  43. struct kmp_taskdata *scheduling_parent;
  44. int thread_num;
  45. ompt_dispatch_chunk_t dispatch_chunk;
  46. } ompt_task_info_t;
  47. typedef struct {
  48. ompt_data_t parallel_data;
  49. void *master_return_address;
  50. } ompt_team_info_t;
  51. typedef struct ompt_lw_taskteam_s {
  52. ompt_team_info_t ompt_team_info;
  53. ompt_task_info_t ompt_task_info;
  54. int heap;
  55. struct ompt_lw_taskteam_s *parent;
  56. } ompt_lw_taskteam_t;
  57. typedef struct {
  58. ompt_data_t thread_data;
  59. ompt_data_t task_data; /* stored here from implicit barrier-begin until
  60. implicit-task-end */
  61. void *return_address; /* stored here on entry of runtime */
  62. ompt_state_t state;
  63. ompt_wait_id_t wait_id;
  64. int ompt_task_yielded;
  65. int parallel_flags; // information for the last parallel region invoked
  66. void *idle_frame;
  67. } ompt_thread_info_t;
  68. extern ompt_callbacks_internal_t ompt_callbacks;
  69. #if OMPT_SUPPORT && OMPT_OPTIONAL
  70. #if USE_FAST_MEMORY
  71. #define KMP_OMPT_DEPS_ALLOC __kmp_fast_allocate
  72. #define KMP_OMPT_DEPS_FREE __kmp_fast_free
  73. #else
  74. #define KMP_OMPT_DEPS_ALLOC __kmp_thread_malloc
  75. #define KMP_OMPT_DEPS_FREE __kmp_thread_free
  76. #endif
  77. #endif /* OMPT_SUPPORT && OMPT_OPTIONAL */
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81. void ompt_pre_init(void);
  82. void ompt_post_init(void);
  83. void ompt_fini(void);
  84. #define OMPT_GET_RETURN_ADDRESS(level) __builtin_return_address(level)
  85. #define OMPT_GET_FRAME_ADDRESS(level) __builtin_frame_address(level)
  86. int __kmp_control_tool(uint64_t command, uint64_t modifier, void *arg);
  87. extern ompt_callbacks_active_t ompt_enabled;
  88. #if KMP_OS_WINDOWS
  89. #define UNLIKELY(x) (x)
  90. #define OMPT_NOINLINE __declspec(noinline)
  91. #else
  92. #define UNLIKELY(x) __builtin_expect(!!(x), 0)
  93. #define OMPT_NOINLINE __attribute__((noinline))
  94. #endif
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif