forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next prototype of the framework integration (#100)
Provide a mechanism for a chain of modules to share a resource, that can be e.g. CUDA device memory or a CUDA stream. Minimize data movements between the CPU and the device, and support multiple devices. Allow the same job configuration to be used on all hardware combinations. See HeterogeneousCore/CUDACore/README.md for a more detailed description and examples.
- Loading branch information
Showing
37 changed files
with
1,225 additions
and
223 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef CUDADataFormats_SiPixelCluster_classes_h | ||
#define CUDADataFormats_SiPixelCluster_classes_h | ||
|
||
#include "CUDADataFormats/Common/interface/CUDAProduct.h" | ||
#include "CUDADataFormats/SiPixelCluster/interface/SiPixelClustersCUDA.h" | ||
#include "DataFormats/Common/interface/Wrapper.h" | ||
|
||
#endif |
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,4 @@ | ||
<lcgdict> | ||
<class name="CUDAProduct<SiPixelClustersCUDA>" persistent="false"/> | ||
<class name="edm::Wrapper<CUDAProduct<SiPixelClustersCUDA>>" persistent="false"/> | ||
</lcgdict> |
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
40 changes: 40 additions & 0 deletions
40
CUDADataFormats/SiPixelDigi/interface/SiPixelDigiErrorsCUDA.h
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,40 @@ | ||
#ifndef CUDADataFormats_SiPixelDigi_interface_SiPixelDigiErrorsCUDA_h | ||
#define CUDADataFormats_SiPixelDigi_interface_SiPixelDigiErrorsCUDA_h | ||
|
||
#include "DataFormats/SiPixelDigi/interface/PixelErrors.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/GPUSimpleVector.h" | ||
|
||
#include <cuda/api_wrappers.h> | ||
|
||
class SiPixelDigiErrorsCUDA { | ||
public: | ||
SiPixelDigiErrorsCUDA() = default; | ||
explicit SiPixelDigiErrorsCUDA(size_t maxFedWords, PixelFormatterErrors errors, cuda::stream_t<>& stream); | ||
~SiPixelDigiErrorsCUDA() = default; | ||
|
||
SiPixelDigiErrorsCUDA(const SiPixelDigiErrorsCUDA&) = delete; | ||
SiPixelDigiErrorsCUDA& operator=(const SiPixelDigiErrorsCUDA&) = delete; | ||
SiPixelDigiErrorsCUDA(SiPixelDigiErrorsCUDA&&) = default; | ||
SiPixelDigiErrorsCUDA& operator=(SiPixelDigiErrorsCUDA&&) = default; | ||
|
||
const PixelFormatterErrors& formatterErrors() const { return formatterErrors_h; } | ||
|
||
GPU::SimpleVector<PixelErrorCompact> *error() { return error_d.get(); } | ||
GPU::SimpleVector<PixelErrorCompact> const *error() const { return error_d.get(); } | ||
GPU::SimpleVector<PixelErrorCompact> const *c_error() const { return error_d.get(); } | ||
|
||
using HostDataError = std::pair<GPU::SimpleVector<PixelErrorCompact>, cudautils::host::unique_ptr<PixelErrorCompact[]>>; | ||
HostDataError dataErrorToHostAsync(cuda::stream_t<>& stream) const; | ||
|
||
void copyErrorToHostAsync(cuda::stream_t<>& stream); | ||
|
||
private: | ||
cudautils::device::unique_ptr<PixelErrorCompact[]> data_d; | ||
cudautils::device::unique_ptr<GPU::SimpleVector<PixelErrorCompact>> error_d; | ||
cudautils::host::unique_ptr<GPU::SimpleVector<PixelErrorCompact>> error_h; | ||
PixelFormatterErrors formatterErrors_h; | ||
}; | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "CUDADataFormats/SiPixelDigi/interface/SiPixelDigiErrorsCUDA.h" | ||
|
||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "HeterogeneousCore/CUDAServices/interface/CUDAService.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/memsetAsync.h" | ||
|
||
SiPixelDigiErrorsCUDA::SiPixelDigiErrorsCUDA(size_t maxFedWords, PixelFormatterErrors errors, cuda::stream_t<>& stream): | ||
formatterErrors_h(std::move(errors)) | ||
{ | ||
edm::Service<CUDAService> cs; | ||
|
||
error_d = cs->make_device_unique<GPU::SimpleVector<PixelErrorCompact>>(stream); | ||
data_d = cs->make_device_unique<PixelErrorCompact[]>(maxFedWords, stream); | ||
|
||
cudautils::memsetAsync(data_d, 0x00, maxFedWords, stream); | ||
|
||
error_h = cs->make_host_unique<GPU::SimpleVector<PixelErrorCompact>>(stream); | ||
GPU::make_SimpleVector(error_h.get(), maxFedWords, data_d.get()); | ||
assert(error_h->size() == 0); | ||
assert(error_h->capacity() == static_cast<int>(maxFedWords)); | ||
|
||
cudautils::copyAsync(error_d, error_h, stream); | ||
} | ||
|
||
void SiPixelDigiErrorsCUDA::copyErrorToHostAsync(cuda::stream_t<>& stream) { | ||
cudautils::copyAsync(error_h, error_d, stream); | ||
} | ||
|
||
SiPixelDigiErrorsCUDA::HostDataError SiPixelDigiErrorsCUDA::dataErrorToHostAsync(cuda::stream_t<>& stream) const { | ||
edm::Service<CUDAService> cs; | ||
// On one hand size() could be sufficient. On the other hand, if | ||
// someone copies the SimpleVector<>, (s)he might expect the data | ||
// buffer to actually have space for capacity() elements. | ||
auto data = cs->make_host_unique<PixelErrorCompact[]>(error_h->capacity(), stream); | ||
|
||
// but transfer only the required amount | ||
if(error_h->size() > 0) { | ||
cudautils::copyAsync(data, data_d, error_h->size(), stream); | ||
} | ||
auto err = *error_h; | ||
err.set_data(data.get()); | ||
return HostDataError(std::move(err), std::move(data)); | ||
} |
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
Oops, something went wrong.