4 // Tool related code below
8 ompt_id_t next_op_id
= 0x8000000000000001;
12 // Synchronous callbacks
13 static void on_ompt_callback_device_initialize(int device_num
, const char *type
,
14 ompt_device_t
*device
,
15 ompt_function_lookup_t lookup
,
16 const char *documentation
) {
17 printf("Callback Init: device_num=%d type=%s device=%p lookup=%p doc=%p\n",
18 device_num
, type
, device
, lookup
, documentation
);
21 static void on_ompt_callback_device_finalize(int device_num
) {
22 printf("Callback Fini: device_num=%d\n", device_num
);
25 static void on_ompt_callback_device_load(int device_num
, const char *filename
,
26 int64_t offset_in_file
,
27 void *vma_in_file
, size_t bytes
,
28 void *host_addr
, void *device_addr
,
30 printf("Callback Load: device_num:%d module_id:%lu filename:%s host_adddr:%p "
31 "device_addr:%p bytes:%lu\n",
32 device_num
, module_id
, filename
, host_addr
, device_addr
, bytes
);
35 static void on_ompt_callback_target_data_op(
36 ompt_id_t target_id
, ompt_id_t host_op_id
, ompt_target_data_op_t optype
,
37 void *src_addr
, int src_device_num
, void *dest_addr
, int dest_device_num
,
38 size_t bytes
, const void *codeptr_ra
) {
39 assert(codeptr_ra
!= 0 && "Unexpected null codeptr");
40 // Both src and dest must not be null
41 assert((src_addr
!= 0 || dest_addr
!= 0) && "Both src and dest addr null");
42 printf(" Callback DataOp: target_id=%lu host_op_id=%lu optype=%d src=%p "
44 "dest=%p dest_device_num=%d bytes=%lu code=%p\n",
45 target_id
, host_op_id
, optype
, src_addr
, src_device_num
, dest_addr
,
46 dest_device_num
, bytes
, codeptr_ra
);
49 static void on_ompt_callback_target(ompt_target_t kind
,
50 ompt_scope_endpoint_t endpoint
,
51 int device_num
, ompt_data_t
*task_data
,
53 const void *codeptr_ra
) {
54 assert(codeptr_ra
!= 0 && "Unexpected null codeptr");
55 printf("Callback Target: target_id=%lu kind=%d endpoint=%d device_num=%d "
57 target_id
, kind
, endpoint
, device_num
, codeptr_ra
);
60 static void on_ompt_callback_target_submit(ompt_id_t target_id
,
62 unsigned int requested_num_teams
) {
63 printf(" Callback Submit: target_id=%lu host_op_id=%lu req_num_teams=%d\n",
64 target_id
, host_op_id
, requested_num_teams
);
67 static void on_ompt_callback_target_map(ompt_id_t target_id
,
68 unsigned int nitems
, void **host_addr
,
69 void **device_addr
, size_t *bytes
,
70 unsigned int *mapping_flags
,
71 const void *codeptr_ra
) {
72 printf("Target map callback is unimplemented\n");
76 static void on_ompt_callback_target_data_op_emi(
77 ompt_scope_endpoint_t endpoint
, ompt_data_t
*target_task_data
,
78 ompt_data_t
*target_data
, ompt_id_t
*host_op_id
,
79 ompt_target_data_op_t optype
, void *src_addr
, int src_device_num
,
80 void *dest_addr
, int dest_device_num
, size_t bytes
,
81 const void *codeptr_ra
) {
82 assert(codeptr_ra
!= 0 && "Unexpected null codeptr");
83 // Both src and dest must not be null
84 assert((src_addr
!= 0 || dest_addr
!= 0) && "Both src and dest addr null");
85 if (endpoint
== ompt_scope_begin
)
86 *host_op_id
= next_op_id
++;
87 printf(" Callback DataOp EMI: endpoint=%d optype=%d target_task_data=%p "
88 "(0x%lx) target_data=%p (0x%lx) host_op_id=%p (0x%lx) src=%p "
90 "dest=%p dest_device_num=%d bytes=%lu code=%p\n",
91 endpoint
, optype
, target_task_data
, target_task_data
->value
,
92 target_data
, target_data
->value
, host_op_id
, *host_op_id
, src_addr
,
93 src_device_num
, dest_addr
, dest_device_num
, bytes
, codeptr_ra
);
96 static void on_ompt_callback_target_emi(ompt_target_t kind
,
97 ompt_scope_endpoint_t endpoint
,
98 int device_num
, ompt_data_t
*task_data
,
99 ompt_data_t
*target_task_data
,
100 ompt_data_t
*target_data
,
101 const void *codeptr_ra
) {
102 assert(codeptr_ra
!= 0 && "Unexpected null codeptr");
103 if (endpoint
== ompt_scope_begin
)
104 target_data
->value
= next_op_id
++;
105 printf("Callback Target EMI: kind=%d endpoint=%d device_num=%d task_data=%p "
106 "(0x%lx) target_task_data=%p (0x%lx) target_data=%p (0x%lx) code=%p\n",
107 kind
, endpoint
, device_num
, task_data
, task_data
->value
,
108 target_task_data
, target_task_data
->value
, target_data
,
109 target_data
->value
, codeptr_ra
);
112 static void on_ompt_callback_target_submit_emi(
113 ompt_scope_endpoint_t endpoint
, ompt_data_t
*target_data
,
114 ompt_id_t
*host_op_id
, unsigned int requested_num_teams
) {
115 printf(" Callback Submit EMI: endpoint=%d req_num_teams=%d target_data=%p "
116 "(0x%lx) host_op_id=%p (0x%lx)\n",
117 endpoint
, requested_num_teams
, target_data
, target_data
->value
,
118 host_op_id
, *host_op_id
);
121 static void on_ompt_callback_target_map_emi(ompt_data_t
*target_data
,
124 void **device_addr
, size_t *bytes
,
125 unsigned int *mapping_flags
,
126 const void *codeptr_ra
) {
127 printf("Target map emi callback is unimplemented\n");