| 26 | namespace paddle::experimental { |
| 27 | |
| 28 | void DeviceContextPool::SyncDeviceContext(const Place& place) { |
| 29 | if (!phi::DeviceContextPool::IsInitialized()) { |
| 30 | phi::memory_utils::InitDevices(); |
| 31 | } |
| 32 | // only when we need the specific DeviceContext, get and cache it |
| 33 | auto* dev_ctx = phi::DeviceContextPool::Instance().Get(place); |
| 34 | { |
| 35 | std::lock_guard<std::mutex> lock(mutex_); |
| 36 | context_map_[place] = dev_ctx; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | DeviceContextPool& DeviceContextPool::Instance() { |
| 41 | static DeviceContextPool g_device_context_pool; |
no test coverage detected