forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 6
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 cms-sw#46636 from AdrianoDee/copy_device_multi_fix…
…_tests Fix `CopyToDevice` for `PortableHostMultiCollection` and New Test
- Loading branch information
Showing
8 changed files
with
84 additions
and
5 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
60 changes: 60 additions & 0 deletions
60
HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerAMulti.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,60 @@ | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/ESGetToken.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h" | ||
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ModuleFactory.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/host.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h" | ||
#include "HeterogeneousCore/AlpakaTest/interface/AlpakaESTestRecords.h" | ||
#include "HeterogeneousCore/AlpakaTest/interface/AlpakaESTestSoA.h" | ||
#include "HeterogeneousCore/AlpakaTest/interface/ESTestData.h" | ||
#include "HeterogeneousCore/AlpakaTest/interface/alpaka/AlpakaESTestData.h" | ||
|
||
namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
/** | ||
* This class is the equivalent of TesAlpakaESProducerA.cc | ||
* for PortableHostMultiCollection. It consumes a standard | ||
* host ESProduct and converts the data into PortableHostMultiCollection, and | ||
* implicitly transfers the data product to device | ||
*/ | ||
class TestAlpakaESProducerAMulti : public ESProducer { | ||
public: | ||
TestAlpakaESProducerAMulti(edm::ParameterSet const& iConfig) : ESProducer(iConfig) { | ||
auto cc = setWhatProduced(this); | ||
token_ = cc.consumes(); | ||
} | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
std::optional<AlpakaESTestDataACMultiHost> produce(AlpakaESTestRecordA const& iRecord) { | ||
auto const& input = iRecord.get(token_); | ||
|
||
int const sizeA = 10; | ||
int const sizeC = 100; | ||
// TODO: pinned allocation? | ||
// TODO: cached allocation? | ||
AlpakaESTestDataACMultiHost product({{sizeA, sizeC}}, cms::alpakatools::host()); | ||
auto viewA = product.view< | ||
cms::alpakatest::AlpakaESTestSoAA>(); // this template is not really needed as this is fhe first layout | ||
auto viewC = product.view<cms::alpakatest::AlpakaESTestSoAC>(); | ||
|
||
for (int i = 0; i < sizeA; ++i) { | ||
viewA[i].z() = input.value() - i; | ||
} | ||
|
||
for (int i = 0; i < sizeC; ++i) { | ||
viewC[i].x() = input.value() + i; | ||
} | ||
|
||
return product; | ||
} | ||
|
||
private: | ||
edm::ESGetToken<cms::alpakatest::ESTestDataA, AlpakaESTestRecordA> token_; | ||
}; | ||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
|
||
DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(TestAlpakaESProducerAMulti); |
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