CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
CUDAService.cc File Reference
#include <iomanip>
#include <iostream>
#include <limits>
#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/Utilities/interface/ReusableObjectHolder.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.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"

Go to the source code of this file.

Functions

std::string decodeVersion (int version)
 
constexpr unsigned int getCudaCoresPerSM (unsigned int major, unsigned int minor)
 
void setCudaLimit (cudaLimit limit, const char *name, size_t request)
 

Function Documentation

std::string decodeVersion ( int  version)

Definition at line 95 of file CUDAService.cc.

Referenced by CUDAService::CUDAService().

95  {
96  return std::to_string(version / 1000) + '.' + std::to_string(version % 1000 / 10);
97 }
constexpr unsigned int getCudaCoresPerSM ( unsigned int  major,
unsigned int  minor 
)

Definition at line 46 of file CUDAService.cc.

Referenced by CUDAService::CUDAService().

46  {
47  switch (major * 10 + minor) {
48  // Fermi architecture
49  case 20: // SM 2.0: GF100 class
50  return 32;
51  case 21: // SM 2.1: GF10x class
52  return 48;
53 
54  // Kepler architecture
55  case 30: // SM 3.0: GK10x class
56  case 32: // SM 3.2: GK10x class
57  case 35: // SM 3.5: GK11x class
58  case 37: // SM 3.7: GK21x class
59  return 192;
60 
61  // Maxwell architecture
62  case 50: // SM 5.0: GM10x class
63  case 52: // SM 5.2: GM20x class
64  case 53: // SM 5.3: GM20x class
65  return 128;
66 
67  // Pascal architecture
68  case 60: // SM 6.0: GP100 class
69  return 64;
70  case 61: // SM 6.1: GP10x class
71  case 62: // SM 6.2: GP10x class
72  return 128;
73 
74  // Volta architecture
75  case 70: // SM 7.0: GV100 class
76  case 72: // SM 7.2: GV11b class
77  return 64;
78 
79  // Turing architecture
80  case 75: // SM 7.5: TU10x class
81  return 64;
82 
83  // Ampere architecture
84  case 80: // SM 8.0: GA100 class
85  return 64;
86  case 86: // SM 8.6: GA10x class
87  return 128;
88 
89  // unknown architecture, return a default value
90  default:
91  return 64;
92  }
93 }
void setCudaLimit ( cudaLimit  limit,
const char *  name,
size_t  request 
)

Definition at line 24 of file CUDAService.cc.

References cudaCheck, mps_fire::result, and relativeConstraints::value.

Referenced by CUDAService::CUDAService().

24  {
25  // read the current device
26  int device;
27  cudaCheck(cudaGetDevice(&device));
28  // try to set the requested limit
29  auto result = cudaDeviceSetLimit(limit, request);
30  if (cudaErrorUnsupportedLimit == result) {
31  edm::LogWarning("CUDAService") << "CUDA device " << device << ": unsupported limit \"" << name << "\"";
32  return;
33  }
34  // read back the limit value
35  size_t value;
36  result = cudaDeviceGetLimit(&value, limit);
37  if (cudaSuccess != result) {
38  edm::LogWarning("CUDAService") << "CUDA device " << device << ": failed to set limit \"" << name << "\" to "
39  << request << ", current value is " << value;
40  } else if (value != request) {
41  edm::LogWarning("CUDAService") << "CUDA device " << device << ": limit \"" << name << "\" set to " << value
42  << " instead of requested " << request;
43  }
44 }
tuple result
Definition: mps_fire.py:311
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
Log< level::Warning, false > LogWarning