-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Reduce Alpaka event synchronization calls via EDMetadata #44841
Merged
cmsbuild
merged 3 commits into
cms-sw:master
from
makortel:alpakaReducedEventSynchronize
Apr 29, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7b30903
Avoid calling alpaka::wait() in produce() when no asynchronous work w…
makortel d18a254
Add a cache to record event completion to further reduce alpaka::wait…
makortel c237b97
Call alpaka::wait() in EDMetadata destructor only when its Queue has …
makortel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This update in the README actually holds (and is stronger) even without this PR, I just hadn't realized it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My brain hurts, but I trust you on this :-)