device.hpp 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm

#pragma once

#include "libgpudiscovery/cudaDeviceInfo.hpp"

#ifdef OPENCL_FOUND
#include "libgpudiscovery/openCLDeviceInfo.hpp"
#endif

#include "libgpudiscovery/genericDeviceInfo.hpp"

namespace VideoStitch {
namespace Discovery {

class DevicesInfo {
 public:
  int getNumberOfDevices() const;
  int getNumberOfOpenCLDevices() const;
  int getNumberOfCudaDevices() const;
  bool getDeviceProperties(unsigned vsDeviceIndex, DeviceProperties&) const;
  bool getCudaDeviceProperties(unsigned vsDeviceIndex, DeviceProperties&) const;
#ifdef OPENCL_FOUND
  bool getOpenCLDeviceProperties(unsigned vsDeviceIndex, OpenCLDevice&) const;
#endif
  bool getBackendDeviceIndex(int vsDeviceIndex, int& backendDeviceIndex) const;
  bool getVSDeviceIndex(int backendDeviceIndex, int& vsDeviceIndex, Framework framework) const;
  FrameworkStatus getFrameworkStatus(Framework framework) const;

  static const DevicesInfo& getInstance();

 private:
  DevicesInfo();
  void collectOpenCLDeviceInfo();
  void collectCudaDeviceInfo();
  void collectGenericDeviceInfo();
  std::vector<DeviceProperties> cudaDevices;
#ifdef OPENCL_FOUND
  std::vector<OpenCLDevice> openCLDevices;
#endif
  std::vector<DeviceProperties> genericDevices;
  FrameworkStatus cudaStatus;
  FrameworkStatus openCLStatus;
};

}  // namespace Discovery
}  // namespace VideoStitch