CMS 3D CMS Logo

Functions
CUDAService.cc File Reference
#include <iomanip>
#include <iostream>
#include <limits>
#include <cuda.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/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/EventCache.h"
#include "HeterogeneousCore/CUDAUtilities/interface/StreamCache.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/currentDevice.h"
#include "HeterogeneousCore/CUDAUtilities/src/getCachingDeviceAllocator.h"
#include "HeterogeneousCore/CUDAUtilities/src/getCachingHostAllocator.h"

Go to the source code of this file.

Functions

constexpr unsigned int getCudaCoresPerSM (unsigned int major, unsigned int minor)
 
void setCudaLimit (cudaLimit limit, const char *name, size_t request)
 

Function Documentation

◆ getCudaCoresPerSM()

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

Definition at line 44 of file CUDAService.cc.

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

Referenced by CUDAService::CUDAService().

◆ setCudaLimit()

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

Definition at line 22 of file CUDAService.cc.

22  {
23  // read the current device
24  int device;
25  cudaCheck(cudaGetDevice(&device));
26  // try to set the requested limit
27  auto result = cudaDeviceSetLimit(limit, request);
28  if (cudaErrorUnsupportedLimit == result) {
29  edm::LogWarning("CUDAService") << "CUDA device " << device << ": unsupported limit \"" << name << "\"";
30  return;
31  }
32  // read back the limit value
33  size_t value;
34  cudaCheck(cudaDeviceGetLimit(&value, limit));
35  if (cudaSuccess != result) {
36  edm::LogWarning("CUDAService") << "CUDA device " << device << ": failed to set limit \"" << name << "\" to "
37  << request << ", current value is " << value;
38  } else if (value != request) {
39  edm::LogWarning("CUDAService") << "CUDA device " << device << ": limit \"" << name << "\" set to " << value
40  << " instead of requested " << request;
41  }
42 }

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

Referenced by CUDAService::CUDAService().

edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
value
Definition: value.py:1
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
mps_fire.result
result
Definition: mps_fire.py:311