| 32 | namespace cl { |
| 33 | |
| 34 | class Environment { |
| 35 | public: |
| 36 | Environment() = default; |
| 37 | explicit Environment(CLDevice&& device, CLContext&& context, |
| 38 | CLCommandQueue&& queue, |
| 39 | ProfilingCommandQueue&& profiling_queue); |
| 40 | |
| 41 | // Move only |
| 42 | Environment(Environment&& environment); |
| 43 | Environment& operator=(Environment&& environment); |
| 44 | Environment(const Environment&) = delete; |
| 45 | Environment& operator=(const Environment&) = delete; |
| 46 | |
| 47 | const CLDevice& device() const { return device_; } |
| 48 | CLDevice* GetDevicePtr() { return &device_; } |
| 49 | const CLDevice* GetDevicePtr() const { return &device_; } |
| 50 | CLContext& context() { return context_; } |
| 51 | CLCommandQueue* queue() { return &queue_; } |
| 52 | ProfilingCommandQueue* profiling_queue() { return &profiling_queue_; } |
| 53 | ProgramCache* program_cache() { return &program_cache_; } |
| 54 | const ProgramCache* program_cache() const { return &program_cache_; } |
| 55 | |
| 56 | std::vector<CalculationsPrecision> GetSupportedPrecisions() const; |
| 57 | bool IsSupported(CalculationsPrecision precision) const; |
| 58 | std::vector<TensorStorageType> GetSupportedTextureStorages() const; |
| 59 | std::vector<TensorStorageType> GetSupportedStorages() const; |
| 60 | |
| 61 | void SetHighPerformance() const; |
| 62 | void SetDefaultPerformance() const; |
| 63 | void SetLowPerformance() const; // for energy saving |
| 64 | |
| 65 | private: |
| 66 | CLDevice device_; |
| 67 | CLContext context_; |
| 68 | CLCommandQueue queue_; |
| 69 | ProfilingCommandQueue profiling_queue_; |
| 70 | ProgramCache program_cache_; |
| 71 | }; |
| 72 | |
| 73 | TensorStorageType GetOptimalStorageType(const CLDevice& gpu); |
| 74 | |