1 /* Test the 'valid_bytes' magic. */
9 #define DEBUG_printf(...) //__builtin_printf (__VA_ARGS__)
12 static int ev_count_data
;
14 static void cb_data_event (acc_prof_info
*prof_info
, acc_event_info
*event_info
, acc_api_info
*api_info
)
16 DEBUG_printf ("%s %d\n", __FUNCTION__
, prof_info
->event_type
);
18 assert (prof_info
->valid_bytes
== _ACC_PROF_INFO_VALID_BYTES
);
19 assert (event_info
->data_event
.valid_bytes
== _ACC_DATA_EVENT_INFO_VALID_BYTES
);
20 assert (api_info
->valid_bytes
== _ACC_API_INFO_VALID_BYTES
);
25 static int ev_count_launch
;
27 static void cb_launch_event (acc_prof_info
*prof_info
, acc_event_info
*event_info
, acc_api_info
*api_info
)
29 DEBUG_printf ("%s %d\n", __FUNCTION__
, prof_info
->event_type
);
31 assert (prof_info
->valid_bytes
== _ACC_PROF_INFO_VALID_BYTES
);
32 assert (event_info
->launch_event
.valid_bytes
== _ACC_LAUNCH_EVENT_INFO_VALID_BYTES
);
33 assert (api_info
->valid_bytes
== _ACC_API_INFO_VALID_BYTES
);
38 static int ev_count_other
;
40 static void cb_other_event (acc_prof_info
*prof_info
, acc_event_info
*event_info
, acc_api_info
*api_info
)
42 DEBUG_printf ("%s %d\n", __FUNCTION__
, prof_info
->event_type
);
44 assert (prof_info
->valid_bytes
== _ACC_PROF_INFO_VALID_BYTES
);
45 assert (event_info
->other_event
.valid_bytes
== _ACC_OTHER_EVENT_INFO_VALID_BYTES
);
46 assert (api_info
->valid_bytes
== _ACC_API_INFO_VALID_BYTES
);
52 void acc_register_library (acc_prof_reg reg_
, acc_prof_reg unreg_
, acc_prof_lookup_func lookup_
)
54 DEBUG_printf ("%s\n", __FUNCTION__
);
56 reg_ (acc_ev_device_init_start
, cb_other_event
, acc_reg
);
57 reg_ (acc_ev_device_init_end
, cb_other_event
, acc_reg
);
58 reg_ (acc_ev_device_shutdown_start
, cb_other_event
, acc_reg
);
59 reg_ (acc_ev_device_shutdown_end
, cb_other_event
, acc_reg
);
60 reg_ (acc_ev_runtime_shutdown
, cb_other_event
, acc_reg
);
61 reg_ (acc_ev_create
, cb_data_event
, acc_reg
);
62 reg_ (acc_ev_delete
, cb_data_event
, acc_reg
);
63 reg_ (acc_ev_alloc
, cb_data_event
, acc_reg
);
64 reg_ (acc_ev_free
, cb_data_event
, acc_reg
);
65 reg_ (acc_ev_enter_data_start
, cb_other_event
, acc_reg
);
66 reg_ (acc_ev_enter_data_end
, cb_other_event
, acc_reg
);
67 reg_ (acc_ev_exit_data_start
, cb_other_event
, acc_reg
);
68 reg_ (acc_ev_exit_data_end
, cb_other_event
, acc_reg
);
69 reg_ (acc_ev_update_start
, cb_other_event
, acc_reg
);
70 reg_ (acc_ev_update_end
, cb_other_event
, acc_reg
);
71 reg_ (acc_ev_compute_construct_start
, cb_other_event
, acc_reg
);
72 reg_ (acc_ev_compute_construct_end
, cb_other_event
, acc_reg
);
73 reg_ (acc_ev_enqueue_launch_start
, cb_launch_event
, acc_reg
);
74 reg_ (acc_ev_enqueue_launch_end
, cb_launch_event
, acc_reg
);
75 reg_ (acc_ev_enqueue_upload_start
, cb_data_event
, acc_reg
);
76 reg_ (acc_ev_enqueue_upload_end
, cb_data_event
, acc_reg
);
77 reg_ (acc_ev_enqueue_download_start
, cb_data_event
, acc_reg
);
78 reg_ (acc_ev_enqueue_download_end
, cb_data_event
, acc_reg
);
79 reg_ (acc_ev_wait_start
, cb_other_event
, acc_reg
);
80 reg_ (acc_ev_wait_end
, cb_other_event
, acc_reg
);
89 #define VALID_BYTES_A \
90 _ACC_PROF_VALID_BYTES_STRUCT (A, b, \
91 _ACC_PROF_VALID_BYTES_BASICTYPE (int))
94 /* Add a 'char' field. */
100 #define VALID_BYTES_B \
101 _ACC_PROF_VALID_BYTES_STRUCT (B, c, \
102 _ACC_PROF_VALID_BYTES_BASICTYPE (char))
105 /* Add another 'char' field. */
111 #define VALID_BYTES_C \
112 _ACC_PROF_VALID_BYTES_STRUCT (C, d, \
113 _ACC_PROF_VALID_BYTES_BASICTYPE (char))
116 /* Add two 'void *' fields. */
124 #define VALID_BYTES_D \
125 _ACC_PROF_VALID_BYTES_STRUCT (D, f, \
126 _ACC_PROF_VALID_BYTES_BASICTYPE (void *))
129 /* Add another three 'char' fields. */
138 #define VALID_BYTES_E \
139 _ACC_PROF_VALID_BYTES_STRUCT (E, i, \
140 _ACC_PROF_VALID_BYTES_BASICTYPE (char))
146 acc_register_library (acc_prof_register
, acc_prof_unregister
, acc_prof_lookup
);
149 DEBUG_printf ("s=%zd, vb=%zd\n", sizeof A1
, VALID_BYTES_A
);
150 assert (VALID_BYTES_A
<= sizeof A1
);
151 DEBUG_printf ("&A1=%p, &A1.b=%p\n", &A1
, &A1
.b
);
152 assert (((char *) &A1
) + VALID_BYTES_A
== (char *) (&A1
.b
+ 1));
155 DEBUG_printf ("s=%zd, vb=%zd\n", sizeof B1
, VALID_BYTES_B
);
156 assert (VALID_BYTES_B
<= sizeof B1
);
157 DEBUG_printf ("&B1=%p, &B1.c=%p\n", &B1
, &B1
.c
);
158 assert (((char *) &B1
) + VALID_BYTES_B
== (char *) (&B1
.c
+ 1));
160 assert (VALID_BYTES_B
== VALID_BYTES_A
+ 1 * sizeof (char));
163 DEBUG_printf ("s=%zd, vb=%zd\n", sizeof C1
, VALID_BYTES_C
);
164 assert (VALID_BYTES_C
<= sizeof C1
);
165 DEBUG_printf ("&C1=%p, &C1.d=%p\n", &C1
, &C1
.d
);
166 assert (((char *) &C1
) + VALID_BYTES_C
== (char *) (&C1
.d
+ 1));
168 assert (VALID_BYTES_C
== VALID_BYTES_B
+ 1 * sizeof (char));
171 DEBUG_printf ("s=%zd, vb=%zd\n", sizeof D1
, VALID_BYTES_D
);
172 assert (VALID_BYTES_D
<= sizeof D1
);
173 DEBUG_printf ("&D1=%p, &D1.f=%p\n", &D1
, &D1
.f
);
174 assert (((char *) &D1
) + VALID_BYTES_D
== (char *) (&D1
.f
+ 1));
176 assert (VALID_BYTES_D
> VALID_BYTES_C
);
179 DEBUG_printf ("s=%zd, vb=%zd\n", sizeof E1
, VALID_BYTES_E
);
180 assert (VALID_BYTES_E
<= sizeof E1
);
181 DEBUG_printf ("&E1=%p, &E1.i=%p\n", &E1
, &E1
.i
);
182 assert (((char *) &E1
) + VALID_BYTES_E
== (char *) (&E1
.i
+ 1));
184 assert (VALID_BYTES_E
== VALID_BYTES_D
+ 3 * sizeof (char));
190 /* Trigger tests done in 'cb_*' functions. */
192 #pragma acc parallel copyout (host)
194 asm volatile ("" : : : "memory"); // TODO PR90488
196 host
= acc_on_device (acc_device_host
);
199 DEBUG_printf ("ev_count_data = %d\n", ev_count_data
);
201 assert (ev_count_data
== 0);
204 /* We don't know exactly how many data events to expect, but we at least
206 assert (ev_count_data
> 0);
209 DEBUG_printf ("ev_count_launch = %d\n", ev_count_launch
);
211 assert (ev_count_data
== 0);
214 /* We expect two launch events, 'acc_ev_enqueue_launch_start',
215 'acc_ev_enqueue_launch_end'. */
216 assert (ev_count_launch
== 2);
219 DEBUG_printf ("ev_count_other = %d\n", ev_count_other
);
220 /* We don't know exactly how many other events to expect, but we at least
221 expect 'acc_ev_device_init_start', 'acc_ev_device_init_end',
222 'acc_ev_compute_construct_start', 'acc_ev_compute_construct_end'. */
223 assert (ev_count_other
>= 4);