HOME
| OPENMP API Specification: Version 5.0 November 2018

5.4.6  The Callback Interface

SummaryAll OMPD library interactions with the OpenMP program must be through a set of callbacks that the tool provides. These callbacks must also be used for allocating or releasing resources, such as memory, that the library needs.

Format

SVG-Viewer needed.

 

 
typedef struct ompd_callbacks_t { 
  ompd_callback_memory_alloc_fn_t alloc_memory; 
  ompd_callback_memory_free_fn_t free_memory; 
  ompd_callback_print_string_fn_t print_string; 
  ompd_callback_sizeof_fn_t sizeof_type; 
  ompd_callback_symbol_addr_fn_t symbol_addr_lookup; 
  ompd_callback_memory_read_fn_t read_memory; 
  ompd_callback_memory_write_fn_t write_memory; 
  ompd_callback_memory_read_fn_t read_string; 
  ompd_callback_device_host_fn_t device_to_host; 
  ompd_callback_device_host_fn_t host_to_device; 
  ompd_callback_get_thread_context_for_thread_id_fn_t 
    get_thread_context_for_thread_id; 
} ompd_callbacks_t;  

SVG-Viewer needed.

DescriptionThe set of callbacks that the OMPD library must use is collected in the ompd_callbacks_t record structure. An instance of this type is passed to the OMPD library as a parameter to ompd_initialize (see Section 5.5.1.1 on page 1544). Each field points to a function that the OMPD library must use to interact with the OpenMP program or for memory operations. The alloc_memory and free_memory fields are pointers to functions the OMPD library uses to allocate and to release dynamic memory.

print_string points to a function that prints a string.

The architectures or programming models of the OMPD library and third party tool may be different from that of the OpenMP program that is being examined. sizeof_type points to function that allows the OMPD library to determine the sizes of the basic integer and pointer types that the OpenMP program uses. Because of the differences in architecture or programming model, the conventions for representing data in the OMPD library and the OpenMP program may be different. The device_to_host field points to a function that translates data from the conventions that the OpenMP program uses to those that the tool and OMPD library use. The reverse operation is performed by the function to which the host_to_device field points.

The symbol_addr_lookup field points to a callback that the OMPD library can use to find the address of a global or thread local storage symbol. The read_memory, read_string, and write_memory fields are pointers to functions for reading from and writing to global memory or thread local storage in the OpenMP program.

The get_thread_context_for_thread_id field is a pointer to a function that the OMPD library can use to obtain a thread context that corresponds to a native thread identifier.

Cross References