Skip to content

Commit

Permalink
Merge pull request #29061 from makortel/fixCUDAESProduct
Browse files Browse the repository at this point in the history
Fix cms::cuda::ESProduct for zero devices
  • Loading branch information
cmsbuild authored Mar 2, 2020
2 parents ac10cf6 + e752b87 commit 88badf0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions HeterogeneousCore/CUDACore/interface/ESProduct.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <vector>

#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "HeterogeneousCore/CUDAServices/interface/numberOfDevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/EventCache.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/deviceCount.h"
#include "HeterogeneousCore/CUDAUtilities/interface/currentDevice.h"
#include "HeterogeneousCore/CUDAUtilities/interface/eventWorkHasCompleted.h"

Expand All @@ -18,7 +18,7 @@ namespace cms {
template <typename T>
class ESProduct {
public:
ESProduct() : gpuDataPerDevice_(deviceCount()) {
ESProduct() : gpuDataPerDevice_(numberOfDevices()) {
for (size_t i = 0; i < gpuDataPerDevice_.size(); ++i) {
gpuDataPerDevice_[i].m_event = getEventCache().get();
}
Expand Down

This file was deleted.

14 changes: 14 additions & 0 deletions HeterogeneousCore/CUDAServices/interface/numberOfDevices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef HeterogeneousCore_CUDAServices_numberOfDevices_h
#define HeterogeneousCore_CUDAServices_numberOfDevices_h

namespace cms {
namespace cuda {
// Returns the number of CUDA devices
// The difference wrt. the standard CUDA function or
// cms::cuda::deviceCount() is that if CUDAService is disabled,
// this function returns 0.
int numberOfDevices();
} // namespace cuda
} // namespace cms

#endif
8 changes: 0 additions & 8 deletions HeterogeneousCore/CUDAServices/src/numberOfCUDADevices.cc

This file was deleted.

10 changes: 10 additions & 0 deletions HeterogeneousCore/CUDAServices/src/numberOfDevices.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "HeterogeneousCore/CUDAServices/interface/numberOfDevices.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

namespace cms::cuda {
int numberOfDevices() {
edm::Service<CUDAService> cs;
return cs->enabled() ? cs->numberOfDevices() : 0;
}
} // namespace cms::cuda

0 comments on commit 88badf0

Please sign in to comment.