Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-12-19 23:38:32

0001 #ifndef HeterogeneousCore_CUDAServices_CUDAService_h
0002 #define HeterogeneousCore_CUDAServices_CUDAService_h
0003 
0004 #include <utility>
0005 #include <vector>
0006 
0007 #include "FWCore/Utilities/interface/StreamID.h"
0008 
0009 namespace edm {
0010   class ParameterSet;
0011   class ActivityRegistry;
0012   class ConfigurationDescriptions;
0013 }  // namespace edm
0014 
0015 class CUDAService {
0016 public:
0017   CUDAService(edm::ParameterSet const& iConfig);
0018   ~CUDAService();
0019 
0020   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0021 
0022   bool enabled() const { return enabled_; }
0023 
0024   int numberOfDevices() const { return numberOfDevices_; }
0025 
0026   // major, minor
0027   std::pair<int, int> computeCapability(int device) const { return computeCapabilities_.at(device); }
0028 
0029   // Returns the id of device with most free memory. If none is found, returns -1.
0030   int deviceWithMostFreeMemory() const;
0031 
0032 private:
0033   int numberOfDevices_ = 0;
0034   std::vector<std::pair<int, int>> computeCapabilities_;
0035   bool enabled_ = false;
0036   bool verbose_ = false;
0037 };
0038 
0039 namespace edm {
0040   namespace service {
0041     inline bool isProcessWideService(CUDAService const*) { return true; }
0042   }  // namespace service
0043 }  // namespace edm
0044 
0045 #endif