2 /* { dg-timeout 10 } */
4 /* Test the calling of 'acc_get_device_type' from within
5 'cb_device_init_start' and 'cb_device_init_end' callbacks. This occurs
6 when the CUDA 9.0 'nvprof' tool is used, and previously deadlocked. */
12 static acc_prof_reg reg
;
13 static acc_prof_reg unreg
;
14 static acc_prof_lookup_func lookup
;
16 void acc_register_library (acc_prof_reg reg_
, acc_prof_reg unreg_
, acc_prof_lookup_func lookup_
)
23 static bool expect_cb_device_init_start
;
24 static bool expect_cb_device_init_end
;
26 static void cb_device_init_start (acc_prof_info
*prof_info
, acc_event_info
*event_info
, acc_api_info
*api_info
)
28 assert (expect_cb_device_init_start
);
29 expect_cb_device_init_start
= false;
31 acc_device_t acc_device_type
;
32 acc_device_type
= acc_get_device_type ();
33 assert (acc_device_type
== acc_device_none
);
35 expect_cb_device_init_end
= true;
38 static void cb_device_init_end (acc_prof_info
*prof_info
, acc_event_info
*event_info
, acc_api_info
*api_info
)
40 assert (expect_cb_device_init_end
);
41 expect_cb_device_init_end
= false;
43 acc_device_t acc_device_type
;
44 acc_device_type
= acc_get_device_type ();
45 assert (acc_device_type
== acc_device_none
);
50 acc_register_library (acc_prof_register
, acc_prof_unregister
, acc_prof_lookup
);
52 reg (acc_ev_device_init_start
, cb_device_init_start
, acc_reg
);
53 reg (acc_ev_device_init_end
, cb_device_init_end
, acc_reg
);
55 expect_cb_device_init_start
= true;
56 expect_cb_device_init_end
= false;
57 acc_init (acc_device_host
);
58 assert (!expect_cb_device_init_start
);
59 assert (!expect_cb_device_init_end
);
61 acc_device_t acc_device_type
;
62 acc_device_type
= acc_get_device_type ();
63 assert (acc_device_type
== acc_device_host
);
65 acc_shutdown (acc_device_host
);
67 expect_cb_device_init_start
= true;
68 expect_cb_device_init_end
= false;
69 acc_init (acc_device_default
);
70 assert (!expect_cb_device_init_start
);
71 assert (!expect_cb_device_init_end
);
73 acc_device_t acc_device_type
;
74 acc_device_type
= acc_get_device_type ();
75 assert (acc_device_type
!= acc_device_none
);
77 acc_shutdown (acc_device_default
);