CMS 3D CMS Logo

Classes | Namespaces | Typedefs | Functions
CUDAService.cc File Reference
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <cuda.h>
#include <cuda_runtime.h>
#include <nvml.h>
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/ResourceInformation.h"
#include "FWCore/Utilities/interface/ReusableObjectHolder.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAInterface.h"
#include "HeterogeneousCore/CUDAUtilities/interface/EventCache.h"
#include "HeterogeneousCore/CUDAUtilities/interface/StreamCache.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cachingAllocators.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/currentDevice.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/nvmlCheck.h"
#include "FWCore/ServiceRegistry/interface/ServiceMaker.h"

Go to the source code of this file.

Classes

class  CUDAService
 

Namespaces

 edm
 HLT enums.
 
 edm::service
 

Typedefs

typedef CUDAServiceMaker ::concrete_t CUDAService___t
 
typedef edm::serviceregistry::ServiceMaker< CUDAServiceMaker ::interface_t, CUDAServiceMakerCUDAService__t
 
using CUDAServiceMaker = edm::serviceregistry::ParameterSetMaker< CUDAInterface, CUDAService >
 

Functions

std::string decodeVersion (int version)
 
constexpr unsigned int getCudaCoresPerSM (unsigned int major, unsigned int minor)
 
bool edm::service::isProcessWideService (CUDAService const *)
 
static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker< edm::DescriptionFillerForServices< CUDAService___t > > s_filler__LINE__ ("CUDAService")
 
static const edm::serviceregistry::ServicePluginFactory ::PMaker< CUDAService__ts_maker__LINE__ ("CUDAService")
 
void setCudaLimit (cudaLimit limit, const char *name, size_t request)
 

Typedef Documentation

◆ CUDAService___t

typedef CUDAServiceMaker ::concrete_t CUDAService___t

Definition at line 488 of file CUDAService.cc.

◆ CUDAService__t

Definition at line 488 of file CUDAService.cc.

◆ CUDAServiceMaker

Definition at line 487 of file CUDAService.cc.

Function Documentation

◆ decodeVersion()

std::string decodeVersion ( int  version)

Definition at line 138 of file CUDAService.cc.

References cond::impl::to_string(), and BeamSplash_cfg::version.

Referenced by CUDAService::CUDAService().

138  {
139  return std::to_string(version / 1000) + '.' + std::to_string(version % 1000 / 10);
140 }
std::string to_string(const V &value)
Definition: OMSAccess.h:71

◆ getCudaCoresPerSM()

constexpr unsigned int getCudaCoresPerSM ( unsigned int  major,
unsigned int  minor 
)

Definition at line 81 of file CUDAService.cc.

Referenced by CUDAService::CUDAService().

81  {
82  switch (major * 10 + minor) {
83  // Fermi architecture
84  case 20: // SM 2.0: GF100 class
85  return 32;
86  case 21: // SM 2.1: GF10x class
87  return 48;
88 
89  // Kepler architecture
90  case 30: // SM 3.0: GK10x class
91  case 32: // SM 3.2: GK10x class
92  case 35: // SM 3.5: GK11x class
93  case 37: // SM 3.7: GK21x class
94  return 192;
95 
96  // Maxwell architecture
97  case 50: // SM 5.0: GM10x class
98  case 52: // SM 5.2: GM20x class
99  case 53: // SM 5.3: GM20x class
100  return 128;
101 
102  // Pascal architecture
103  case 60: // SM 6.0: GP100 class
104  return 64;
105  case 61: // SM 6.1: GP10x class
106  case 62: // SM 6.2: GP10x class
107  return 128;
108 
109  // Volta architecture
110  case 70: // SM 7.0: GV100 class
111  case 72: // SM 7.2: GV11b class
112  return 64;
113 
114  // Turing architecture
115  case 75: // SM 7.5: TU10x class
116  return 64;
117 
118  // Ampere architecture
119  case 80: // SM 8.0: GA100 class
120  return 64;
121  case 86: // SM 8.6: GA10x class
122  return 128;
123 
124  // Ada Lovelace architectures
125  case 89: // SM 8.9: AD10x class
126  return 128;
127 
128  // Hopper architecture
129  case 90: // SM 9.0: GH100 class
130  return 128;
131 
132  // unknown architecture, return a default value
133  default:
134  return 64;
135  }
136 }

◆ s_filler__LINE__()

static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::DescriptionFillerForServices< CUDAService___t > > s_filler__LINE__ ( "CUDAService"  )
static

◆ s_maker__LINE__()

static const edm::serviceregistry::ServicePluginFactory ::PMaker< CUDAService__t > s_maker__LINE__ ( "CUDAService"  )
static

◆ setCudaLimit()

void setCudaLimit ( cudaLimit  limit,
const char *  name,
size_t  request 
)

Definition at line 59 of file CUDAService.cc.

References cudaCheck, remoteMonitoring_LASER_era2018_cfg::limit, Skims_PA_cff::name, mps_fire::result, and relativeConstraints::value.

Referenced by CUDAService::CUDAService().

59  {
60  // read the current device
61  int device;
62  cudaCheck(cudaGetDevice(&device));
63  // try to set the requested limit
64  auto result = cudaDeviceSetLimit(limit, request);
65  if (cudaErrorUnsupportedLimit == result) {
66  edm::LogWarning("CUDAService") << "CUDA device " << device << ": unsupported limit \"" << name << "\"";
67  return;
68  }
69  // read back the limit value
70  size_t value;
71  result = cudaDeviceGetLimit(&value, limit);
72  if (cudaSuccess != result) {
73  edm::LogWarning("CUDAService") << "CUDA device " << device << ": failed to set limit \"" << name << "\" to "
74  << request << ", current value is " << value;
75  } else if (value != request) {
76  edm::LogWarning("CUDAService") << "CUDA device " << device << ": limit \"" << name << "\" set to " << value
77  << " instead of requested " << request;
78  }
79 }
Definition: value.py:1
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
Log< level::Warning, false > LogWarning