HOME
| OPENMP API Specification: Version 5.1 November 2020

4.2.3  Initializing a First-Party Tool

To initialize the OMPT interface, the OpenMP implementation invokes the tool initializer that is specified in the ompt_start_tool_result_t structure that is indicated by the non-null pointer that ompt_start_tool returns. The initializer is invoked prior to the occurrence of any OpenMP event.

A tool initializer, described in Section 4.5.1.1, uses the function specified in its lookup argument to look up pointers to OMPT interface runtime entry points that the OpenMP implementation provides; this process is described in Section 4.2.3.1. Typically, a tool initializer obtains a pointer to the ompt_set_callback runtime entry point with type signature ompt_set_callback_t and then uses this runtime entry point to register tool callbacks for OpenMP events, as described in Section 4.2.4.

A tool initializer may use the ompt_enumerate_states runtime entry point, which has type signature ompt_enumerate_states_t, to determine the thread states that an OpenMP implementation employs. Similarly, it may use the ompt_enumerate_mutex_impls runtime entry point, which has type signature ompt_enumerate_mutex_impls_t, to determine the mutual exclusion implementations that the OpenMP implementation employs.

If a tool initializer returns a non-zero value, the OMPT interface state remains active for the execution; otherwise, the OMPT interface state changes to inactive.

Cross References

4.2.3.1 Binding Entry Points in the OMPT Callback Interface

Functions that an OpenMP implementation provides to support the OMPT interface are not defined as global function symbols. Instead, they are defined as runtime entry points that a tool can only identify through the lookup function that is provided as an argument with type signature ompt_function_lookup_t to the tool initializer. A tool can use this function to obtain a pointer to each of the runtime entry points that an OpenMP implementation provides to support the OMPT interface. Once a tool has obtained a lookup function, it may employ it at any point in the future.

For each runtime entry point in the OMPT interface for the host device, Table 4.1 provides the string name by which it is known and its associated type signature. Implementations can provide additional implementation-specific names and corresponding entry points. Any names that begin with ompt_ are reserved names.

During initialization, a tool should look up each runtime entry point in the OMPT interface by name and bind a pointer maintained by the tool that can later be used to invoke the entry point. The entry points described in Table 4.1 enable a tool to assess the thread states and mutual exclusion implementations that an OpenMP implementation supports to register tool callbacks, to inspect registered callbacks, to introspect OpenMP state associated with threads, and to use tracing to monitor computations that execute on target devices.

Detailed information about each runtime entry point listed in Table 4.1 is included as part of the description of its type signature.

Cross References


Table 4.1: OMPT Callback Interface Runtime Entry Point Names and Their Type Signatures


Entry Point String Name Type signature


ompt_enumerate_states ompt_enumerate_states_t
ompt_enumerate_mutex_impls ompt_enumerate_mutex_impls_t
ompt_set_callback ompt_set_callback_t
ompt_get_callback ompt_get_callback_t
ompt_get_thread_data ompt_get_thread_data_t
ompt_get_num_places ompt_get_num_places_t
ompt_get_place_proc_ids ompt_get_place_proc_ids_t
ompt_get_place_num ompt_get_place_num_t
ompt_get_partition_place_nums ompt_get_partition_place_nums_t
ompt_get_proc_id ompt_get_proc_id_t
ompt_get_state ompt_get_state_t
ompt_get_parallel_info ompt_get_parallel_info_t
ompt_get_task_info ompt_get_task_info_t
ompt_get_task_memory ompt_get_task_memory_t
ompt_get_num_devices ompt_get_num_devices_t
ompt_get_num_procs ompt_get_num_procs_t
ompt_get_target_info ompt_get_target_info_t
ompt_get_unique_id ompt_get_unique_id_t
ompt_finalize_tool ompt_finalize_tool_t