-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44841 from makortel/alpakaReducedEventSynchronize
Reduce Alpaka event synchronization calls via EDMetadata
- Loading branch information
Showing
12 changed files
with
173 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaGlobalProducerNoOutput.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESGetToken.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
|
||
namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
/** | ||
* This EDProducer only consumes a device EDProduct, and is intended | ||
* only for testing purposes. Do not use it as an example. | ||
*/ | ||
class TestAlpakaGlobalProducerNoOutput : public global::EDProducer<> { | ||
public: | ||
TestAlpakaGlobalProducerNoOutput(edm::ParameterSet const& config) | ||
: getToken_(consumes(config.getParameter<edm::InputTag>("source"))) {} | ||
|
||
void produce(edm::StreamID, device::Event& iEvent, device::EventSetup const& iSetup) const override { | ||
[[maybe_unused]] auto const& input = iEvent.get(getToken_); | ||
} | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.add("source", edm::InputTag{}); | ||
|
||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
private: | ||
const device::EDGetToken<portabletest::TestDeviceCollection> getToken_; | ||
}; | ||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
|
||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h" | ||
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducerNoOutput); |
62 changes: 62 additions & 0 deletions
62
HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaStreamSynchronizingProducerToDevice.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
|
||
#include "TestAlgo.h" | ||
|
||
namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
/** | ||
* This class demonstrates a stream EDProducer that | ||
* - produces a device EDProduct (that can get transferred to host automatically) | ||
* - synchronizes in a non-blocking way with the ExternalWork module | ||
* ability (via the SynchronizingEDProcucer base class) | ||
*/ | ||
class TestAlpakaStreamSynchronizingProducerToDevice : public stream::SynchronizingEDProducer<> { | ||
public: | ||
TestAlpakaStreamSynchronizingProducerToDevice(edm::ParameterSet const& iConfig) | ||
: putToken_{produces()}, | ||
size_{iConfig.getParameter<edm::ParameterSet>("size").getParameter<int32_t>( | ||
EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE))} {} | ||
|
||
void acquire(device::Event const& iEvent, device::EventSetup const& iSetup) override { | ||
deviceProduct_ = std::make_unique<portabletest::TestDeviceCollection>(size_, iEvent.queue()); | ||
|
||
// run the algorithm, potentially asynchronously | ||
algo_.fill(iEvent.queue(), *deviceProduct_); | ||
} | ||
|
||
void produce(device::Event& iEvent, device::EventSetup const& iSetup) override { | ||
iEvent.put(putToken_, std::move(deviceProduct_)); | ||
} | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
|
||
edm::ParameterSetDescription psetSize; | ||
psetSize.add<int32_t>("alpaka_serial_sync"); | ||
psetSize.add<int32_t>("alpaka_cuda_async"); | ||
psetSize.add<int32_t>("alpaka_rocm_async"); | ||
desc.add("size", psetSize); | ||
|
||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
private: | ||
const device::EDPutToken<portabletest::TestDeviceCollection> putToken_; | ||
const int32_t size_; | ||
|
||
// implementation of the algorithm | ||
TestAlgo algo_; | ||
|
||
std::unique_ptr<portabletest::TestDeviceCollection> deviceProduct_; | ||
}; | ||
|
||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
|
||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h" | ||
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaStreamSynchronizingProducerToDevice); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters