Skip to content
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

Functional changes as follow-up to 36176, related to SiPixelDigisCUDA SOA #36430

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions CUDADataFormats/SiPixelDigi/interface/SiPixelDigisCUDASOAView.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ class SiPixelDigisCUDASOAView {
uint32_t* rawIdArr_;

template <typename ReturnType, typename StoreType, typename LocationType>
ReturnType* getColumnAddress(LocationType column, StoreType& store, int maxFedWords) {
return reinterpret_cast<ReturnType*>(store.get() +
static_cast<int>(column) * roundFor128ByteAlignment(maxFedWords));
ReturnType* getColumnAddress(LocationType column, StoreType& store, int size) {
return reinterpret_cast<ReturnType*>(store.get() + static_cast<int>(column) * roundFor128ByteAlignment(size));
}

static int roundFor128ByteAlignment(int numFedWords) {
int mul = 128 / sizeof(uint16_t);
return ((numFedWords + mul - 1) / mul) * mul;
static int roundFor128ByteAlignment(int size) {
constexpr int mul = 128 / sizeof(uint16_t);
return ((size + mul - 1) / mul) * mul;
};
};

Expand Down
7 changes: 4 additions & 3 deletions CUDADataFormats/SiPixelDigi/src/SiPixelDigisCUDA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SiPixelDigisCUDA::SiPixelDigisCUDA(size_t maxFedWords, cudaStream_t stream)
: m_store(cms::cuda::make_device_unique<SiPixelDigisCUDA::StoreType[]>(
SiPixelDigisCUDASOAView::roundFor128ByteAlignment(maxFedWords) *
int(SiPixelDigisCUDASOAView::StorageLocation::kMAX),
static_cast<int>(SiPixelDigisCUDASOAView::StorageLocation::kMAX),
stream)),
m_view(m_store, maxFedWords, SiPixelDigisCUDASOAView::StorageLocation::kMAX) {
assert(maxFedWords != 0);
Expand All @@ -17,11 +17,12 @@ SiPixelDigisCUDA::SiPixelDigisCUDA(size_t maxFedWords, cudaStream_t stream)
cms::cuda::host::unique_ptr<SiPixelDigisCUDA::StoreType[]> SiPixelDigisCUDA::copyAllToHostAsync(
cudaStream_t stream) const {
auto ret = cms::cuda::make_host_unique<StoreType[]>(
m_view.roundFor128ByteAlignment(nDigis()) * int(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX), stream);
m_view.roundFor128ByteAlignment(nDigis()) * static_cast<int>(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX),
stream);
cudaCheck(cudaMemcpyAsync(ret.get(),
m_view.clus(),
m_view.roundFor128ByteAlignment(nDigis()) * sizeof(SiPixelDigisCUDA::StoreType) *
int(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX),
static_cast<int>(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX),
cudaMemcpyDeviceToHost,
stream));
return ret;
Expand Down