Skip to content

Commit

Permalink
Move supportedCudaDevices to CUDAUtilities and rename to supportedCUD…
Browse files Browse the repository at this point in the history
…ADevices

Check for available supported devices also in exitSansCUDADevices.
  • Loading branch information
fwyzard committed Mar 14, 2019
1 parent 68089fb commit fff1f68
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion HeterogeneousCore/CUDAServices/bin/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

<bin name="cudaIsEnabled" file="cudaIsEnabled.cpp">
<use name="cuda"/>
<use name="HeterogeneousCore/CUDAServices"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
</bin>
4 changes: 2 additions & 2 deletions HeterogeneousCore/CUDAServices/bin/cudaIsEnabled.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "HeterogeneousCore/CUDAServices/interface/supportedCudaDevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/supportedCUDADevices.h"

int main() {
return supportedCudaDevices().empty() ? EXIT_FAILURE : EXIT_SUCCESS;
return supportedCUDADevices().empty() ? EXIT_FAILURE : EXIT_SUCCESS;
}

This file was deleted.

4 changes: 2 additions & 2 deletions HeterogeneousCore/CUDAServices/src/CUDAService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/ReusableObjectHolder.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h"
#include "HeterogeneousCore/CUDAServices/interface/supportedCudaDevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/supportedCUDADevices.h"

#include "CachingDeviceAllocator.h"
#include "CachingHostAllocator.h"
Expand Down Expand Up @@ -122,7 +122,7 @@ CUDAService::CUDAService(edm::ParameterSet const& config, edm::ActivityRegistry&
return;
}

auto supportedDevices = supportedCudaDevices();
auto supportedDevices = supportedCUDADevices();
numberOfDevices_ = supportedDevices.size();
if (numberOfDevices_ == 0) {
edm::LogWarning("CUDAService") << "Failed to initialize the CUDA runtime.\n" << "Disabling the CUDAService.";
Expand Down
4 changes: 2 additions & 2 deletions HeterogeneousCore/CUDAServices/test/testCUDAService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h"
#include "HeterogeneousCore/CUDAServices/interface/supportedCudaDevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/supportedCUDADevices.h"

namespace {
CUDAService makeCUDAService(edm::ParameterSet ps, edm::ActivityRegistry& ar) {
Expand All @@ -30,7 +30,7 @@ TEST_CASE("Tests of CUDAService", "[CUDAService]") {

// Test setup: check if a simple CUDA runtime API call fails:
// if so, skip the test with the CUDAService enabled
int deviceCount = supportedCudaDevices().size();
int deviceCount = supportedCUDADevices().size();

if (deviceCount == 0) {
WARN("No supported CUDA devices available. Running only tests not requiring devices.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef HeterogeneousCore_CUDAUtilities_interface_supportedCUDADevices_h
#define HeterogeneousCore_CUDAUtilities_interface_supportedCUDADevices_h

#include <map>

std::map<int, std::pair<int, int>> supportedCUDADevices(bool reset = true);

#endif // HeterogeneousCore_CUDAUtilities_interface_supportedCUDADevices_h
6 changes: 6 additions & 0 deletions HeterogeneousCore/CUDAUtilities/src/exitSansCUDADevices.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cuda_runtime.h>

#include "HeterogeneousCore/CUDAUtilities/interface/exitSansCUDADevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/supportedCUDADevices.h"

void exitSansCUDADevices() {
int devices = 0;
Expand All @@ -16,4 +17,9 @@ void exitSansCUDADevices() {
std::cerr << "No CUDA devices available, the test will be skipped." << "\n";
exit(EXIT_SUCCESS);
}
int supported = supportedCUDADevices().size();
if (supported == 0) {
std::cerr << "No supported CUDA devices available, the test will be skipped." << "\n";
exit(EXIT_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include <cuda_runtime.h>

#include "HeterogeneousCore/CUDAServices/interface/supportedCudaDevices.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/supportedCUDADevices.h"

__global__
void isSupported(bool * result) {
* result = true;
}

std::map<int, std::pair<int, int>> supportedCudaDevices(bool reset) {
std::map<int, std::pair<int, int>> supportedCUDADevices(bool reset) {
std::map<int, std::pair<int, int>> capabilities;

int devices = 0;
Expand Down

0 comments on commit fff1f68

Please sign in to comment.