1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_ENV_H_ 17 #define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_ENV_H_ 18 19 #include <vector> 20 #include "tensorflow/core/platform/types.h" 21 22 namespace tensorflow { 23 24 namespace thread { 25 class ThreadPool; 26 } // namespace thread 27 28 class CollectiveExecutorMgrInterface; 29 class Device; 30 class DeviceMgr; 31 class Env; 32 class RendezvousMgrInterface; 33 class SessionMgr; 34 35 // The worker environment class, which holds a bag of pointers to 36 // per-worker singletons. 37 // 38 // WorkerEnv does not own its member pointers. 39 struct WorkerEnv { 40 Env* env = nullptr; 41 42 // session_mgr encapsulates state for each session. 43 SessionMgr* session_mgr = nullptr; 44 45 // The local devices of this worker. Devices are owned by the device_mgr. 46 // 47 // REQUIRES: !local_devices.empty(). 48 std::vector<Device*> local_devices; 49 50 // device_mgr manages local devices (cpu and gpu). The WorkerService 51 // is the network interface for managed devices. 52 // 53 // Note: Please use the device_mgr associated with your session if appropriate 54 // instead of this one. Using this device_mgr does not support ClusterSpec 55 // propagated sessions. 56 const DeviceMgr* device_mgr = nullptr; 57 58 // A set of rendezvous keyed by step ids. 59 RendezvousMgrInterface* rendezvous_mgr = nullptr; 60 61 // Generates per-step CollectiveExecutors and has access to utilities 62 // supporting collective operations. 63 std::unique_ptr<CollectiveExecutorMgrInterface> collective_executor_mgr; 64 65 // A pool of threads for scheduling compute work. 66 thread::ThreadPool* compute_pool = nullptr; 67 }; 68 69 } // end namespace tensorflow 70 71 #endif // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_ENV_H_ 72