Skip to content

Commit

Permalink
static cast, change parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
czangela committed Dec 9, 2021
1 parent e832c49 commit 6c70f12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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) {
static int roundFor128ByteAlignment(int size) {
int mul = 128 / sizeof(uint16_t);
return ((numFedWords + mul - 1) / mul) * mul;
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

0 comments on commit 6c70f12

Please sign in to comment.