1 #ifndef CAFFE2_CORE_NET_GPU_H_ 2 #define CAFFE2_CORE_NET_GPU_H_ 4 #include "caffe2/core/context_gpu.h" 5 #include "caffe2/core/net.h" 15 explicit Event(
const DeviceOption& device_option);
18 CUDA_ENFORCE(cudaEventDestroy(event_));
22 void record(
const Stream& stream);
25 cudaEvent_t event_{
nullptr};
26 bool outstanding_{
false};
27 bool neverRecorded_{
true};
28 DISABLE_COPY_AND_ASSIGN(
Event);
39 bool RunAt(
const std::vector<int>& chain)
override;
45 std::vector<int32_t> eventRecorded_;
46 std::vector<std::unique_ptr<internal::Event>> events_;
50 namespace gpu_single_thread {
53 std::vector<std::unique_ptr<OperatorBase>>* ops_;
54 std::condition_variable* cv_;
62 explicit GPUExecutor(
int gpu_id) : gpu_id_(gpu_id) {}
69 void RunJob(
Task* task) {
74 thread_ = std::thread(&GPUExecutor::WorkerFunction,
this);
77 static std::shared_ptr<GPUExecutor> Get(
int gpu);
78 static void Release(
int gpu);
82 void WorkerFunction();
87 static std::shared_ptr<GPUExecutor> executors_[CAFFE2_COMPILE_TIME_MAX_GPUS];
88 static std::mutex gpu_mtx_[CAFFE2_COMPILE_TIME_MAX_GPUS];
94 #endif // CAFFE2_CORE_NET_GPU_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Simple registry implementation in Caffe2 that uses static variables to register object creators durin...