Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-01 23:46:51

0001 #include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
0002 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0003 #include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0005 #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h"
0006 
0007 namespace testTrackingRecHit2D {
0008 
0009   void runKernels(TrackingRecHit2DSOAView* hits);
0010 
0011 }
0012 
0013 int main() {
0014   cms::cudatest::requireDevices();
0015 
0016   cudaStream_t stream;
0017   cudaCheck(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
0018 
0019   auto nHits = 200;
0020   // inner scope to deallocate memory before destroying the stream
0021   {
0022     TrackingRecHit2DGPU tkhit(nHits, false, 0, nullptr, nullptr, stream);
0023     testTrackingRecHit2D::runKernels(tkhit.view());
0024 
0025     TrackingRecHit2DGPU tkhitPhase2(nHits, true, 0, nullptr, nullptr, stream);
0026     testTrackingRecHit2D::runKernels(tkhitPhase2.view());
0027 
0028     TrackingRecHit2DHost tkhitH(nHits, false, 0, nullptr, nullptr, stream, &tkhit);
0029     cudaStreamSynchronize(stream);
0030     assert(tkhitH.view());
0031     assert(tkhitH.view()->nHits() == unsigned(nHits));
0032     assert(tkhitH.view()->nMaxModules() == phase1PixelTopology::numberOfModules);
0033 
0034     TrackingRecHit2DHost tkhitHPhase2(nHits, true, 0, nullptr, nullptr, stream, &tkhit);
0035     cudaStreamSynchronize(stream);
0036     assert(tkhitHPhase2.view());
0037     assert(tkhitHPhase2.view()->nHits() == unsigned(nHits));
0038     assert(tkhitHPhase2.view()->nMaxModules() == phase2PixelTopology::numberOfModules);
0039   }
0040 
0041   cudaCheck(cudaStreamDestroy(stream));
0042 
0043   return 0;
0044 }