Skip to content

Commit

Permalink
Skip CUDA-related tests if no GPU is present (#252)
Browse files Browse the repository at this point in the history
Make unit tests that require a CUDA device skip the test and exit
succesfully if the CUDA runtime is not available, or no CUDA devices
are available.
  • Loading branch information
fwyzard committed Jan 15, 2021
1 parent b9029aa commit bc77390
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
39 changes: 20 additions & 19 deletions RecoPixelVertexing/PixelVertexFinding/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<use name="boost"/>
<use name="root"/>
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="Geometry/Records"/>
<use name="Geometry/CommonDetUnit"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="CommonTools/Clustering1D"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="RecoTracker/TkHitPairs"/>
<use name="RecoTracker/TkTrackingRegions"/>
<use name="RecoPixelVertexing/PixelTriplets"/>
<use name="RecoPixelVertexing/PixelTrackFitting"/>
<use name="MagneticField/Records"/>
<use name="MagneticField/Engine"/>
<use name="TrackingTools/TransientTrack"/>
<use name="RecoVertex/KalmanVertexFit"/>
<use name="SimDataFormats/Track"/>
<use name="boost"/>
<use name="root"/>
<use name="CommonTools/Clustering1D"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/CommonDetUnit"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="RecoPixelVertexing/PixelTrackFitting"/>
<use name="RecoPixelVertexing/PixelTriplets"/>
<use name="RecoTracker/TkHitPairs"/>
<use name="RecoTracker/TkTrackingRegions"/>
<use name="RecoVertex/KalmanVertexFit"/>
<use name="SimDataFormats/Track"/>
<use name="TrackingTools/TransientTrack"/>

<bin file="gpuVertexFinder_t.cu" name="gpuVertexFinder_t">
<use name="cuda"/>
Expand Down
25 changes: 10 additions & 15 deletions RecoPixelVertexing/PixelVertexFinding/test/gpuVertexFinder_t.cu
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include<random>
#include<vector>
#include<cstdint>
#include<cmath>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <random>
#include <vector>

#include <cuda/api_wrappers.h>

#include "HeterogeneousCore/CUDAUtilities/interface/exitSansCUDADevices.h"
#include "RecoPixelVertexing/PixelVertexFinding/src/gpuClusterTracks.h"
#include "RecoPixelVertexing/PixelVertexFinding/src/gpuFitVertices.h"
#include "RecoPixelVertexing/PixelVertexFinding/src/gpuSortByPt2.h"
#include "RecoPixelVertexing/PixelVertexFinding/src/gpuSplitVertices.h"


using namespace gpuVertexFinder;
#include <cuda/api_wrappers.h>

using namespace gpuVertexFinder;

struct Event {
std::vector<float> zvert;
Expand Down Expand Up @@ -76,14 +77,8 @@ struct ClusterGenerator {
};


#include<iostream>

int main() {

if (cuda::device::count() == 0) {
std::cerr << "No CUDA devices on this system" << "\n";
exit(EXIT_FAILURE);
}
exitSansCUDADevices();

auto current_device = cuda::device::current::get();

Expand Down

0 comments on commit bc77390

Please sign in to comment.