|
13 | 13 | // limitations under the License. |
14 | 14 | #pragma once |
15 | 15 | #include <memory> |
| 16 | +#include "paddle/fluid/framework/op_registry.h" |
16 | 17 | #include "paddle/fluid/platform/device_context.h" |
17 | 18 | #include "paddle/fluid/platform/enforce.h" |
18 | 19 | #include "paddle/fluid/platform/place.h" |
@@ -79,7 +80,7 @@ class DeviceEvent { |
79 | 80 | event_querier_[type_], |
80 | 81 | platform::errors::Unavailable( |
81 | 82 | "event_querier_[%d] shall not be nullptr.", type_)); |
82 | | - event_querier_[type_](this); |
| 83 | + return event_querier_[type_](this); |
83 | 84 | } |
84 | 85 |
|
85 | 86 | void InitEvent(std::shared_ptr<void> event) { event_ = event; } |
@@ -114,14 +115,24 @@ struct EventCreateFunctionRegisterer { |
114 | 115 | explicit EventCreateFunctionRegisterer(EventCreateFunction func) { |
115 | 116 | auto type_idx = DeviceTypeToId(device_type); |
116 | 117 | DeviceEvent::event_creator_[type_idx] = func; |
| 118 | + VLOG(2) << "register creator " << type_idx << " with " |
| 119 | + << DeviceEvent::event_creator_[type_idx]; |
117 | 120 | } |
| 121 | + void Touch() {} |
118 | 122 | }; |
119 | | -#define REGISTER_EVENT_CREATE_FUNCTION(device_type, func) \ |
120 | | - namespace { \ |
121 | | - static EventCreateFunctionRegisterer<device_type> \ |
122 | | - g_device_event_create_##type_idx(func); \ |
| 123 | + |
| 124 | +#define REGISTER_EVENT_CREATE_FUNCTION(device_type, func) \ |
| 125 | + static ::paddle::platform::EventCreateFunctionRegisterer<device_type> \ |
| 126 | + g_device_event_create_1(func); \ |
| 127 | + int touch_g_device_event_create_1() { \ |
| 128 | + g_device_event_create_1.Touch(); \ |
| 129 | + return 0; \ |
123 | 130 | } |
124 | 131 |
|
| 132 | +#define USE_EVENT(device_type) \ |
| 133 | + extern int touch_g_device_event_create_1(); \ |
| 134 | + UNUSED static int use_event_itself_1 = touch_g_device_event_create_1(); |
| 135 | + |
125 | 136 | template <DeviceType device_type> |
126 | 137 | struct EventRecordFunctionRegisterer { |
127 | 138 | explicit EventRecordFunctionRegisterer(EventRecordFunction func) { |
|
0 commit comments