diff --git a/HeterogeneousCore/SonicCore/interface/SonicClientAsync.h b/HeterogeneousCore/SonicCore/interface/SonicClientAsync.h index 1843ca08cbebd..cd8c03dba17aa 100644 --- a/HeterogeneousCore/SonicCore/interface/SonicClientAsync.h +++ b/HeterogeneousCore/SonicCore/interface/SonicClientAsync.h @@ -9,8 +9,6 @@ template class SonicClientAsync : public SonicClientBase, public SonicClientTypes { public: - virtual ~SonicClientAsync() {} - //main operation void dispatch(edm::WaitingTaskWithArenaHolder holder) override final { holder_ = std::move(holder); diff --git a/HeterogeneousCore/SonicCore/interface/SonicClientBase.h b/HeterogeneousCore/SonicCore/interface/SonicClientBase.h index 9a85ee03d3840..7ea3fe19afb24 100644 --- a/HeterogeneousCore/SonicCore/interface/SonicClientBase.h +++ b/HeterogeneousCore/SonicCore/interface/SonicClientBase.h @@ -14,6 +14,7 @@ class SonicClientBase { virtual ~SonicClientBase() = default; void setDebugName(const std::string& debugName) { debugName_ = debugName; } + const std::string& debugName() const { return debugName_; } //main operation virtual void dispatch(edm::WaitingTaskWithArenaHolder holder) = 0; @@ -25,11 +26,10 @@ class SonicClientBase { if (debugName_.empty()) return; t0_ = std::chrono::high_resolution_clock::now(); - setTime_ = true; } void finish(std::exception_ptr eptr = std::exception_ptr{}) { - if (setTime_) { + if (!debugName_.empty()) { auto t1 = std::chrono::high_resolution_clock::now(); edm::LogInfo(debugName_) << "Client time: " << std::chrono::duration_cast(t1 - t0_).count(); @@ -43,7 +43,6 @@ class SonicClientBase { //for logging/debugging std::string debugName_; std::chrono::time_point t0_; - bool setTime_ = false; }; #endif diff --git a/HeterogeneousCore/SonicCore/interface/SonicClientPseudoAsync.h b/HeterogeneousCore/SonicCore/interface/SonicClientPseudoAsync.h index 9b71181fcfa83..5ea20ed3ad30c 100644 --- a/HeterogeneousCore/SonicCore/interface/SonicClientPseudoAsync.h +++ b/HeterogeneousCore/SonicCore/interface/SonicClientPseudoAsync.h @@ -21,15 +21,15 @@ class SonicClientPseudoAsync : public SonicClientBase, public SonicClientTypes([this]() { waitForNext(); }); } //destructor - virtual ~SonicClientPseudoAsync() { - { - std::lock_guard guard(mutex_); - stop_ = true; - } + ~SonicClientPseudoAsync() override { + stop_ = true; cond_.notify_one(); if (thread_) { - thread_->join(); - thread_.reset(); + try { + thread_->join(); + thread_.reset(); + } catch (...) { + } } } //accessor @@ -46,7 +46,7 @@ class SonicClientPseudoAsync : public SonicClientBase, public SonicClientTypes class SonicClientSync : public SonicClientBase, public SonicClientTypes { public: - virtual ~SonicClientSync() {} - //main operation void dispatch(edm::WaitingTaskWithArenaHolder holder) override final { holder_ = std::move(holder); diff --git a/HeterogeneousCore/SonicCore/interface/SonicClientTypes.h b/HeterogeneousCore/SonicCore/interface/SonicClientTypes.h index 855aeae2bd59a..3056893c8fb29 100644 --- a/HeterogeneousCore/SonicCore/interface/SonicClientTypes.h +++ b/HeterogeneousCore/SonicCore/interface/SonicClientTypes.h @@ -1,8 +1,6 @@ #ifndef HeterogeneousCore_SonicCore_SonicClientTypes #define HeterogeneousCore_SonicCore_SonicClientTypes -#include "FWCore/ParameterSet/interface/ParameterSet.h" - //this base class exists to limit the impact of dependent scope in derived classes template class SonicClientTypes { diff --git a/HeterogeneousCore/SonicCore/interface/SonicEDProducer.h b/HeterogeneousCore/SonicCore/interface/SonicEDProducer.h index 110b1428751e4..0bc0689999ede 100644 --- a/HeterogeneousCore/SonicCore/interface/SonicEDProducer.h +++ b/HeterogeneousCore/SonicCore/interface/SonicEDProducer.h @@ -32,9 +32,9 @@ class SonicEDProducer : public edm::stream::EDProducer(t1 - t0).count(); + if (!client_.debugName().empty()) + edm::LogInfo(client_.debugName()) << "Load time: " + << std::chrono::duration_cast(t1 - t0).count(); client_.dispatch(holder); } virtual void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput) = 0; @@ -47,13 +47,9 @@ class SonicEDProducer : public edm::stream::EDProducer - - - - + diff --git a/HeterogeneousCore/SonicCore/test/SonicDummyProducer.cc b/HeterogeneousCore/SonicCore/test/SonicDummyProducer.cc index e9362d7b94d04..dc406c86c930b 100644 --- a/HeterogeneousCore/SonicCore/test/SonicDummyProducer.cc +++ b/HeterogeneousCore/SonicCore/test/SonicDummyProducer.cc @@ -6,7 +6,7 @@ #include -namespace edmtest { +namespace sonictest { template class SonicDummyProducer : public SonicEDProducer { public: @@ -15,50 +15,39 @@ namespace edmtest { using typename SonicEDProducer::Output; explicit SonicDummyProducer(edm::ParameterSet const& cfg) : SonicEDProducer(cfg), input_(cfg.getParameter("input")) { - this->template produces(); + //for debugging + this->setDebugName("SonicDummyProducer"); + putToken_ = this->template produces(); } void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput) override { iInput = input_; } void produce(edm::Event& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) override { - iEvent.put(std::make_unique(iOutput)); + iEvent.emplace(putToken_, iOutput); } - //to ensure distinct cfi names - specialized below - static std::string getCfiName(); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; Client::fillPSetDescription(desc); desc.add("input"); - descriptions.add(getCfiName(), desc); + //to ensure distinct cfi names + descriptions.addWithDefaultLabel(desc); } private: //members int input_; + edm::EDPutTokenT putToken_; }; typedef SonicDummyProducer SonicDummyProducerSync; typedef SonicDummyProducer SonicDummyProducerPseudoAsync; typedef SonicDummyProducer SonicDummyProducerAsync; +} // namespace sonictest - template <> - std::string SonicDummyProducerSync::getCfiName() { - return "SonicDummyProducerSync"; - } - template <> - std::string SonicDummyProducerPseudoAsync::getCfiName() { - return "SonicDummyProducerPseudoAsync"; - } - template <> - std::string SonicDummyProducerAsync::getCfiName() { - return "SonicDummyProducerAsync"; - } -} // namespace edmtest - -using edmtest::SonicDummyProducerSync; +using sonictest::SonicDummyProducerSync; DEFINE_FWK_MODULE(SonicDummyProducerSync); -using edmtest::SonicDummyProducerPseudoAsync; +using sonictest::SonicDummyProducerPseudoAsync; DEFINE_FWK_MODULE(SonicDummyProducerPseudoAsync); -using edmtest::SonicDummyProducerAsync; +using sonictest::SonicDummyProducerAsync; DEFINE_FWK_MODULE(SonicDummyProducerAsync); diff --git a/HeterogeneousCore/SonicCore/test/TestIntegration.cpp b/HeterogeneousCore/SonicCore/test/TestIntegration.cpp deleted file mode 100644 index b2991bd18ae57..0000000000000 --- a/HeterogeneousCore/SonicCore/test/TestIntegration.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "FWCore/Utilities/interface/TestHelper.h" - -RUNTEST() diff --git a/HeterogeneousCore/SonicCore/test/run_sonic_test.sh b/HeterogeneousCore/SonicCore/test/run_sonic_test.sh deleted file mode 100755 index f5ac4a880f38f..0000000000000 --- a/HeterogeneousCore/SonicCore/test/run_sonic_test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -function die { echo "$1": status $2 ; exit $2; } - -pushd ${LOCAL_TMP_DIR} - -TESTCFG=sonicTest_cfg.py -echo "cmsRun $TESTCFG" -cmsRun --parameter-set ${LOCAL_TEST_DIR}/${TESTCFG} || die "Failed in $TESTCFG" $? - -popd diff --git a/HeterogeneousCore/SonicCore/test/sonicTest_cfg.py b/HeterogeneousCore/SonicCore/test/sonicTest_cfg.py index 5dee21f7297f1..bd807088c0d83 100644 --- a/HeterogeneousCore/SonicCore/test/sonicTest_cfg.py +++ b/HeterogeneousCore/SonicCore/test/sonicTest_cfg.py @@ -4,12 +4,10 @@ process.source = cms.Source("EmptySource") -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1)) +process.maxEvents.input = 1 -process.options = cms.untracked.PSet( - numberOfThreads = cms.untracked.uint32(2), - numberOfStreams = cms.untracked.uint32(0) -) +process.options.numberOfThreads = 2 +process.options.numberOfStreams = 0 process.dummySync = cms.EDProducer("SonicDummyProducerSync", input = cms.int32(1),