Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-24 00:02:22

0001 #ifndef HeterogeneousCore_AlpakaCore_interface_alpaka_EDMetadataAcquireSentry_h
0002 #define HeterogeneousCore_AlpakaCore_interface_alpaka_EDMetadataAcquireSentry_h
0003 
0004 #include "FWCore/Concurrency/interface/WaitingTaskWithArenaHolder.h"
0005 #include "FWCore/Utilities/interface/StreamID.h"
0006 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDMetadata.h"
0007 
0008 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0009   namespace detail {
0010     /**
0011      * Helper class to be used in acquire()
0012      *
0013      * TODO: not really a sentry as it doesn't do anything special in its destructor. Better name?
0014      */
0015     class EDMetadataAcquireSentry {
0016     public:
0017       // TODO: WaitingTaskWithArenaHolder not really needed for host synchronous case
0018       // Constructor overload to be called from acquire()
0019       EDMetadataAcquireSentry(edm::StreamID stream, edm::WaitingTaskWithArenaHolder holder);
0020 
0021       // Constructor overload to be called from registerTransformAsync()
0022       EDMetadataAcquireSentry(Device const& device, edm::WaitingTaskWithArenaHolder holder);
0023 
0024       EDMetadataAcquireSentry(EDMetadataAcquireSentry const&) = delete;
0025       EDMetadataAcquireSentry& operator=(EDMetadataAcquireSentry const&) = delete;
0026       EDMetadataAcquireSentry(EDMetadataAcquireSentry&&) = delete;
0027       EDMetadataAcquireSentry& operator=(EDMetadataAcquireSentry&&) = delete;
0028 
0029       std::shared_ptr<EDMetadata> metadata() { return metadata_; }
0030 
0031 #ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
0032       // all synchronous backends
0033       std::shared_ptr<EDMetadata> finish() { return std::move(metadata_); }
0034 #else
0035       // all asynchronous backends
0036       std::shared_ptr<EDMetadata> finish();
0037 #endif
0038 
0039     private:
0040       std::shared_ptr<EDMetadata> metadata_;
0041 
0042       edm::WaitingTaskWithArenaHolder waitingTaskHolder_;
0043     };
0044   }  // namespace detail
0045 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0046 
0047 #endif