Skip to content

Commit 64aa1f1

Browse files
committed
Add a test for missing dictionaries with CUDA headers
Add a test to check that the framework handles correctly the case of edm::Wrapper<T> where: - T has a dictionary - edm::Wrapper<T> does not have a dictionary - the corresponding classes.h file includes CUDA headers
1 parent 275ceb6 commit 64aa1f1

File tree

7 files changed

+94
-1
lines changed

7 files changed

+94
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef HeterogeneousCore_CUDATest_interface_MissingDictionaryCUDAObject_h
2+
#define HeterogeneousCore_CUDATest_interface_MissingDictionaryCUDAObject_h
3+
4+
#include <string>
5+
6+
namespace edmtest {
7+
8+
// A simple data product used to test that the framework handles correctly the case of
9+
// edm::Wrapper<T> where
10+
// - T has a dictionary
11+
// - edm::Wrapper<T> does not have a dictionary
12+
// - the corresponding classes.h file includes CUDA headers
13+
14+
struct MissingDictionaryCUDAObject {
15+
MissingDictionaryCUDAObject() {};
16+
MissingDictionaryCUDAObject(std::string s) : value(std::move(s)) {}
17+
18+
std::string value;
19+
};
20+
21+
} // namespace edmtest
22+
23+
#endif // HeterogeneousCore_CUDATest_interface_MissingDictionaryCUDAObject_h
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "FWCore/Framework/interface/Event.h"
2+
#include "FWCore/Framework/interface/EventSetup.h"
3+
#include "FWCore/Framework/interface/global/EDProducer.h"
4+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
5+
#include "HeterogeneousCore/CUDATest/interface/MissingDictionaryCUDAObject.h"
6+
7+
namespace edmtest {
8+
9+
class MissingDictionaryCUDAProducer : public edm::global::EDProducer<> {
10+
public:
11+
explicit MissingDictionaryCUDAProducer(edm::ParameterSet const& config) : token_(produces()) {}
12+
13+
void produce(edm::StreamID sid, edm::Event& event, edm::EventSetup const& setup) const final {
14+
event.emplace(token_);
15+
}
16+
17+
private:
18+
const edm::EDPutTokenT<MissingDictionaryCUDAObject> token_;
19+
};
20+
21+
} // namespace edmtest
22+
23+
#include "FWCore/Framework/interface/MakerMacros.h"
24+
DEFINE_FWK_MODULE(edmtest::MissingDictionaryCUDAProducer);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
#include "DataFormats/Common/interface/Wrapper.h"
1+
#include <cuda_runtime.h>
2+
23
#include "CUDADataFormats/Common/interface/Product.h"
4+
#include "DataFormats/Common/interface/Wrapper.h"
5+
#include "HeterogeneousCore/CUDATest/interface/MissingDictionaryCUDAObject.h"
36
#include "HeterogeneousCore/CUDATest/interface/Thing.h"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
<lcgdict>
22
<class name="cms::cuda::Product<cms::cudatest::Thing>" persistent="false"/>
33
<class name="edm::Wrapper<cms::cuda::Product<cms::cudatest::Thing>>" persistent="false"/>
4+
5+
<!--
6+
A simple data product used to test that the framework handles correctly the case of
7+
edm::Wrapper<T> where
8+
- T has a dictionary
9+
- edm::Wrapper<T> does not have a dictionary
10+
- the corresponding classes.h file includes CUDA headers
11+
-->
12+
<class name="edmtest::MissingDictionaryCUDAObject"/>
13+
<!--
14+
<class name="edm::Wrapper<edmtest::MissingDictionaryCUDAObject>" splitLevel="0"/>
15+
-->
416
</lcgdict>

HeterogeneousCore/CUDATest/test/BuildFile.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
</ifrelease>
1313

1414
<test name="testHeterogeneousCoreCUDATestWriteRead" command="testHeterogeneousCoreCUDATestWriteRead.sh"/>
15+
16+
<!--
17+
Test that the framework handles correctly the case of edm::Wrapper<T> where
18+
- T has a dictionary
19+
- edm::Wrapper<T> does not have a dictionary
20+
- the corresponding classes.h file includes CUDA headers
21+
-->
22+
<test name="testMissingDictionaryCUDA" command="testMissingDictionaryCUDA.sh"/>
1523
</iftool>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
3+
function die {
4+
echo -e "$1"
5+
echo "exit status $2"
6+
exit $2
7+
}
8+
9+
LOCAL_TEST_DIR=${SCRAM_TEST_PATH:-$CMSSW_BASE/src/HeterogeneousCore/CUDATest/test}
10+
11+
cmsRun ${LOCAL_TEST_DIR}/testMissingDictionaryCUDA_cfg.py >& testMissingDictionaryCUDA.log && die "The cmsRun test job succeeded unexpectedly" $?
12+
grep -q "An exception of category 'DictionaryNotFound' occurred" testMissingDictionaryCUDA.log || die "Cannot find the following string in the exception message:\nAn exception of category 'DictionaryNotFound' occurred" $?
13+
grep -q "edm::Wrapper<edmtest::MissingDictionaryCUDAObject>" testMissingDictionaryCUDA.log || die "Cannot find the following string in the exception message:\nedm::Wrapper<edmtest::MissingDictionaryCUDAObject>" $?
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
process = cms.Process("TEST")
4+
5+
process.source = cms.Source("EmptySource")
6+
process.maxEvents.input = 10
7+
8+
process.producer = cms.EDProducer("edmtest::MissingDictionaryCUDAProducer")
9+
10+
process.path = cms.Path(process.producer)

0 commit comments

Comments
 (0)