Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip CUDA-related tests if no GPU is present #29902

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/HcalDetId/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<bin name="test_hcal_detid" file="test_hcal_detid.cu">
<use name="DataFormats/DetId"/>
<use name="DataFormats/HcalDetId"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
</bin>

</iftool>
18 changes: 8 additions & 10 deletions DataFormats/HcalDetId/test/test_hcal_detid.cu
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <cuda_runtime.h>
#include <cassert>
#include <iostream>

#include <cuda.h>
#include <cuda_runtime.h>

#include <iostream>
#include <assert.h>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"

__global__ void test_gen_detid(DetId *id) {
DetId did;
Expand Down Expand Up @@ -63,17 +65,13 @@ void test_hcal_detid() {
}

int main(int argc, char **argv) {
int nDevices;
cudaGetDeviceCount(&nDevices);
std::cout << "nDevices = " << nDevices << std::endl;
cms::cudatest::requireDevices();

// test det id functionality
if (nDevices > 0)
test_detid();
test_detid();

// test hcal det ids
if (nDevices > 0)
test_hcal_detid();
test_hcal_detid();

return 0;
}
2 changes: 1 addition & 1 deletion DataFormats/HcalDigi/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<use name="DataFormats/HcalDetId"/>
<use name="DataFormats/HcalDigi"/>
<use name="DataFormats/Common"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
</bin>

</iftool>
41 changes: 19 additions & 22 deletions DataFormats/HcalDigi/test/test_hcal_digi.cu
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <cuda_runtime.h>
#include <cassert>
#include <iostream>

#include <cuda.h>
#include <cuda_runtime.h>

#include <iostream>
#include <assert.h>
#include "DataFormats/Common/interface/DataFrame.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/Common/interface/DataFrame.h"
#include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"

__global__ void kernel_test_hcal_qiesample(HcalQIESample *sample, uint16_t value) {
printf("kernel: testing hcal qie sampel\n");
Expand Down Expand Up @@ -69,7 +71,6 @@ void test_hcal_qie1011_digis() {
constexpr int samples = 10;
constexpr int detid = 2;
HcalDataFrameContainer<TDF> coll{samples, detid};
TDF *d_dfs;
uint16_t *d_data;
uint32_t *d_out;
uint32_t h_out[size], h_test_out[size];
Expand Down Expand Up @@ -162,22 +163,18 @@ void test_hcal_qie8_hbhedf() {
}

int main(int argc, char **argv) {
int nDevices;
cudaGetDeviceCount(&nDevices);
std::cout << "nDevices = " << nDevices << std::endl;

if (nDevices > 0) {
// qie8
test_hcal_qiesample();
test_hcal_qie8_hbhedf();
test_hcal_qie8_digis<HBHEDataFrame>();
test_hcal_qie8_digis<HFDataFrame>();
test_hcal_qie8_digis<HODataFrame>();

// qie1011
test_hcal_qie1011_digis<QIE10DataFrame>();
test_hcal_qie1011_digis<QIE11DataFrame>();
}
cms::cudatest::requireDevices();

// qie8
test_hcal_qiesample();
test_hcal_qie8_hbhedf();
test_hcal_qie8_digis<HBHEDataFrame>();
test_hcal_qie8_digis<HFDataFrame>();
test_hcal_qie8_digis<HODataFrame>();

// qie1011
test_hcal_qie1011_digis<QIE10DataFrame>();
test_hcal_qie1011_digis<QIE11DataFrame>();

return 0;
}
4 changes: 2 additions & 2 deletions DataFormats/HcalRecHit/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

<iftool name="cuda-gcc-support">
<bin name="test_hcal_reco" file="test_hcal_reco.cu">
<use name="cuda"/>
<use name="DataFormats/CaloRecHit"/>
<use name="DataFormats/HcalRecHit"/>
<use name="DataFormats/HcalDetId"/>
<use name="DataFormats/HcalDigi"/>
<use name="cuda"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
</bin>

</iftool>
18 changes: 7 additions & 11 deletions DataFormats/HcalRecHit/test/test_hcal_reco.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "DataFormats/HcalRecHit/interface/HORecHit.h"
#include "DataFormats/HcalRecHit/interface/HFQIE10Info.h"
#include "DataFormats/HcalRecHit/interface/HBHEChannelInfo.h"
#include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"

template <typename T>
__global__ void kernel_test_hcal_rechits(T *other) {
Expand Down Expand Up @@ -109,18 +110,13 @@ void test_hcal_hbhechinfo() {
}

int main(int argc, char **argv) {
int nDevices;
cudaGetDeviceCount(&nDevices);
std::cout << "nDevices = " << nDevices << std::endl;
cms::cudatest::requireDevices();

if (nDevices > 0) {
test_hcal_rechits<HBHERecHit>();
test_hcal_rechits<HFRecHit>();
test_hcal_rechits<HORecHit>();
test_hcal_hbhechinfo();

std::cout << "all good" << std::endl;
}
test_hcal_rechits<HBHERecHit>();
test_hcal_rechits<HFRecHit>();
test_hcal_rechits<HORecHit>();
test_hcal_hbhechinfo();

std::cout << "all good" << std::endl;
return 0;
}