-
Notifications
You must be signed in to change notification settings - Fork 35
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
[cudadev] Macro based SoA (followup of #PR211) #287
base: master
Are you sure you want to change the base?
Changes from 39 commits
bc4392b
de1f3ed
d8db9e9
7e01562
d72582a
e8a7735
2918050
c815fe2
3718459
be3fb71
aaadfb4
7cf639e
851d711
6122c36
ca7840e
3a7b692
c38be20
a4d1b46
16ae05f
8107f13
e3fdaea
4805e5e
cbac317
8bcecbe
4dc5308
b50d5a9
988e8db
cf212d2
9911404
a8bf1ff
7b24d99
3986550
c004580
a2fad0a
87d084a
5a2d472
f89caec
9ad2ba7
a2643bf
24926af
f1e7f05
bb0d028
c7a5f59
4f08179
218f925
2be25c5
3abe4d5
8b50bc3
352eee9
54d0e3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,54 @@ | |
#include "CUDACore/device_unique_ptr.h" | ||
#include "CUDACore/host_unique_ptr.h" | ||
#include "CUDACore/cudaCompat.h" | ||
#include "DataFormats/SoALayout.h" | ||
#include "DataFormats/SoAView.h" | ||
|
||
#include <cuda_runtime.h> | ||
|
||
class SiPixelClustersCUDA { | ||
public: | ||
SiPixelClustersCUDA() = default; | ||
GENERATE_SOA_LAYOUT(DeviceLayoutTemplate, | ||
SOA_COLUMN(uint32_t, moduleStart), // index of the first pixel of each module | ||
SOA_COLUMN(uint32_t, clusInModule), // number of clusters found in each module | ||
SOA_COLUMN(uint32_t, moduleId), // module id of each module | ||
|
||
// originally from rechits | ||
SOA_COLUMN(uint32_t, clusModuleStart) // index of the first cluster of each module | ||
) | ||
|
||
// We use all defaults for the template parameters. | ||
using DeviceLayout = DeviceLayoutTemplate<>; | ||
|
||
GENERATE_SOA_VIEW(DeviceViewTemplate, | ||
SOA_VIEW_LAYOUT_LIST(SOA_VIEW_LAYOUT(DeviceLayout, deviceLayout)), | ||
SOA_VIEW_VALUE_LIST( | ||
SOA_VIEW_VALUE(deviceLayout, moduleStart), // index of the first pixel of each module | ||
SOA_VIEW_VALUE(deviceLayout, clusInModule), // number of clusters found in each module | ||
SOA_VIEW_VALUE(deviceLayout, moduleId), // module id of each module | ||
|
||
// originally from rechits | ||
SOA_VIEW_VALUE(deviceLayout, clusModuleStart) // index of the first cluster of each module | ||
) | ||
) | ||
|
||
using DeviceView = DeviceViewTemplate<>; | ||
|
||
GENERATE_SOA_CONST_VIEW(DeviceConstViewTemplate, | ||
SOA_VIEW_LAYOUT_LIST(SOA_VIEW_LAYOUT(DeviceView, deviceView)), | ||
SOA_VIEW_VALUE_LIST( | ||
SOA_VIEW_VALUE(deviceView, moduleStart), // index of the first pixel of each module | ||
SOA_VIEW_VALUE(deviceView, clusInModule), // number of clusters found in each module | ||
SOA_VIEW_VALUE(deviceView, moduleId), // module id of each module | ||
|
||
// originally from rechits | ||
SOA_VIEW_VALUE(deviceView, clusModuleStart) // index of the first cluster of each module | ||
) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this "derived" from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "idea" was that the class has its mutable view internally for initialization, and then down grades it to a const view for usage by the user in member function That makes the name of the |
||
|
||
using DeviceConstView = DeviceConstViewTemplate<>; | ||
|
||
explicit SiPixelClustersCUDA(); | ||
explicit SiPixelClustersCUDA(size_t maxModules, cudaStream_t stream); | ||
~SiPixelClustersCUDA() = default; | ||
|
||
|
@@ -22,41 +64,23 @@ class SiPixelClustersCUDA { | |
|
||
uint32_t nClusters() const { return nClusters_h; } | ||
|
||
uint32_t *moduleStart() { return moduleStart_d.get(); } | ||
uint32_t *clusInModule() { return clusInModule_d.get(); } | ||
uint32_t *moduleId() { return moduleId_d.get(); } | ||
uint32_t *clusModuleStart() { return clusModuleStart_d.get(); } | ||
uint32_t *moduleStart() { return deviceView_.moduleStart(); } | ||
uint32_t *clusInModule() { return deviceView_.clusInModule(); } | ||
uint32_t *moduleId() { return deviceView_.moduleId(); } | ||
uint32_t *clusModuleStart() { return deviceView_.clusModuleStart(); } | ||
|
||
uint32_t const *moduleStart() const { return moduleStart_d.get(); } | ||
uint32_t const *clusInModule() const { return clusInModule_d.get(); } | ||
uint32_t const *moduleId() const { return moduleId_d.get(); } | ||
uint32_t const *clusModuleStart() const { return clusModuleStart_d.get(); } | ||
uint32_t const *moduleStart() const { return deviceView_.moduleStart(); } | ||
uint32_t const *clusInModule() const { return deviceView_.clusInModule(); } | ||
uint32_t const *moduleId() const { return deviceView_.moduleId(); } | ||
uint32_t const *clusModuleStart() const { return deviceView_.clusModuleStart(); } | ||
|
||
class DeviceConstView { | ||
public: | ||
__device__ __forceinline__ uint32_t moduleStart(int i) const { return __ldg(moduleStart_ + i); } | ||
__device__ __forceinline__ uint32_t clusInModule(int i) const { return __ldg(clusInModule_ + i); } | ||
__device__ __forceinline__ uint32_t moduleId(int i) const { return __ldg(moduleId_ + i); } | ||
__device__ __forceinline__ uint32_t clusModuleStart(int i) const { return __ldg(clusModuleStart_ + i); } | ||
|
||
uint32_t const *moduleStart_; | ||
uint32_t const *clusInModule_; | ||
uint32_t const *moduleId_; | ||
uint32_t const *clusModuleStart_; | ||
}; | ||
|
||
DeviceConstView *view() const { return view_d.get(); } | ||
DeviceConstView view() const { return DeviceConstView(deviceView_); } | ||
|
||
private: | ||
cms::cuda::device::unique_ptr<uint32_t[]> moduleStart_d; // index of the first pixel of each module | ||
cms::cuda::device::unique_ptr<uint32_t[]> clusInModule_d; // number of clusters found in each module | ||
cms::cuda::device::unique_ptr<uint32_t[]> moduleId_d; // module id of each module | ||
|
||
// originally from rechits | ||
cms::cuda::device::unique_ptr<uint32_t[]> clusModuleStart_d; // index of the first cluster of each module | ||
|
||
cms::cuda::device::unique_ptr<DeviceConstView> view_d; // "me" pointer | ||
|
||
cms::cuda::device::unique_ptr<std::byte[]> data_d; // Single SoA storage | ||
DeviceLayout deviceLayout_; | ||
DeviceView deviceView_; | ||
|
||
uint32_t nClusters_h = 0; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be simplified using
GENERATE_SOA_LAYOUT_VIEW_AND_CONST_VIEW
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this code predates the introduction of this utility macro.