Skip to content

Commit f9e4e0f

Browse files
committed
Integrate the comments from the upstream PRs (cms-sw#442)
Clean up the Patatrack code base following the comments received during the integration into the upstream release. Currently tracks the changes introduced due to - cms-sw#29109: Patatrack integration - trivial changes (1/N) - cms-sw#29110: Patatrack integration - common tools (2/N) List of changes: * Remove unused files * Fix compilation warnings * Fix AtomicPairCounter unit test * Rename the cudaCompat namespace to cms::cudacompat * Remove extra semicolon * Move SimpleVector and VecArray to the cms::cuda namespace * Add missing dependency * Move HistoContainer, AtomicPairCounter, prefixScan and radixSort to the cms::cuda namespace * Remove rule exception for HeterogeneousCore * Fix code rule violations: - replace using namespace cms::cuda in test/OneToManyAssoc_t.h . - add an exception for cudaCompat.h: cudaCompat relies on defining equivalent symbols to the CUDA intrinsics in the cms::cudacompat namespace, and pulling them in the global namespace when compiling device code without CUDA. * Protect the headers to compile only with a CUDA compiler
1 parent 62b09c0 commit f9e4e0f

File tree

1 file changed

+93
-91
lines changed

1 file changed

+93
-91
lines changed

CUDADataFormats/Common/interface/HeterogeneousSoA.h

Lines changed: 93 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -50,94 +50,96 @@ class HeterogeneousSoA {
5050
std::unique_ptr<T> std_ptr; //!
5151
};
5252

53-
namespace cudaCompat {
54-
55-
struct GPUTraits {
56-
template <typename T>
57-
using unique_ptr = cms::cuda::device::unique_ptr<T>;
58-
59-
template <typename T>
60-
static auto make_unique(cudaStream_t stream) {
61-
return cms::cuda::make_device_unique<T>(stream);
62-
}
63-
64-
template <typename T>
65-
static auto make_unique(size_t size, cudaStream_t stream) {
66-
return cms::cuda::make_device_unique<T>(size, stream);
67-
}
68-
69-
template <typename T>
70-
static auto make_host_unique(cudaStream_t stream) {
71-
return cms::cuda::make_host_unique<T>(stream);
72-
}
73-
74-
template <typename T>
75-
static auto make_device_unique(cudaStream_t stream) {
76-
return cms::cuda::make_device_unique<T>(stream);
77-
}
78-
79-
template <typename T>
80-
static auto make_device_unique(size_t size, cudaStream_t stream) {
81-
return cms::cuda::make_device_unique<T>(size, stream);
82-
}
83-
};
84-
85-
struct HostTraits {
86-
template <typename T>
87-
using unique_ptr = cms::cuda::host::unique_ptr<T>;
88-
89-
template <typename T>
90-
static auto make_unique(cudaStream_t stream) {
91-
return cms::cuda::make_host_unique<T>(stream);
92-
}
93-
94-
template <typename T>
95-
static auto make_host_unique(cudaStream_t stream) {
96-
return cms::cuda::make_host_unique<T>(stream);
97-
}
98-
99-
template <typename T>
100-
static auto make_device_unique(cudaStream_t stream) {
101-
return cms::cuda::make_device_unique<T>(stream);
102-
}
103-
104-
template <typename T>
105-
static auto make_device_unique(size_t size, cudaStream_t stream) {
106-
return cms::cuda::make_device_unique<T>(size, stream);
107-
}
108-
};
109-
110-
struct CPUTraits {
111-
template <typename T>
112-
using unique_ptr = std::unique_ptr<T>;
113-
114-
template <typename T>
115-
static auto make_unique(cudaStream_t) {
116-
return std::make_unique<T>();
117-
}
118-
119-
template <typename T>
120-
static auto make_unique(size_t size, cudaStream_t) {
121-
return std::make_unique<T>(size);
122-
}
123-
124-
template <typename T>
125-
static auto make_host_unique(cudaStream_t) {
126-
return std::make_unique<T>();
127-
}
128-
129-
template <typename T>
130-
static auto make_device_unique(cudaStream_t) {
131-
return std::make_unique<T>();
132-
}
133-
134-
template <typename T>
135-
static auto make_device_unique(size_t size, cudaStream_t) {
136-
return std::make_unique<T>(size);
137-
}
138-
};
139-
140-
} // namespace cudaCompat
53+
namespace cms {
54+
namespace cudacompat {
55+
56+
struct GPUTraits {
57+
template <typename T>
58+
using unique_ptr = cms::cuda::device::unique_ptr<T>;
59+
60+
template <typename T>
61+
static auto make_unique(cudaStream_t stream) {
62+
return cms::cuda::make_device_unique<T>(stream);
63+
}
64+
65+
template <typename T>
66+
static auto make_unique(size_t size, cudaStream_t stream) {
67+
return cms::cuda::make_device_unique<T>(size, stream);
68+
}
69+
70+
template <typename T>
71+
static auto make_host_unique(cudaStream_t stream) {
72+
return cms::cuda::make_host_unique<T>(stream);
73+
}
74+
75+
template <typename T>
76+
static auto make_device_unique(cudaStream_t stream) {
77+
return cms::cuda::make_device_unique<T>(stream);
78+
}
79+
80+
template <typename T>
81+
static auto make_device_unique(size_t size, cudaStream_t stream) {
82+
return cms::cuda::make_device_unique<T>(size, stream);
83+
}
84+
};
85+
86+
struct HostTraits {
87+
template <typename T>
88+
using unique_ptr = cms::cuda::host::unique_ptr<T>;
89+
90+
template <typename T>
91+
static auto make_unique(cudaStream_t stream) {
92+
return cms::cuda::make_host_unique<T>(stream);
93+
}
94+
95+
template <typename T>
96+
static auto make_host_unique(cudaStream_t stream) {
97+
return cms::cuda::make_host_unique<T>(stream);
98+
}
99+
100+
template <typename T>
101+
static auto make_device_unique(cudaStream_t stream) {
102+
return cms::cuda::make_device_unique<T>(stream);
103+
}
104+
105+
template <typename T>
106+
static auto make_device_unique(size_t size, cudaStream_t stream) {
107+
return cms::cuda::make_device_unique<T>(size, stream);
108+
}
109+
};
110+
111+
struct CPUTraits {
112+
template <typename T>
113+
using unique_ptr = std::unique_ptr<T>;
114+
115+
template <typename T>
116+
static auto make_unique(cudaStream_t) {
117+
return std::make_unique<T>();
118+
}
119+
120+
template <typename T>
121+
static auto make_unique(size_t size, cudaStream_t) {
122+
return std::make_unique<T>(size);
123+
}
124+
125+
template <typename T>
126+
static auto make_host_unique(cudaStream_t) {
127+
return std::make_unique<T>();
128+
}
129+
130+
template <typename T>
131+
static auto make_device_unique(cudaStream_t) {
132+
return std::make_unique<T>();
133+
}
134+
135+
template <typename T>
136+
static auto make_device_unique(size_t size, cudaStream_t) {
137+
return std::make_unique<T>(size);
138+
}
139+
};
140+
141+
} // namespace cudacompat
142+
} // namespace cms
141143

142144
// a heterogeneous unique pointer (of a different sort) ...
143145
template <typename T, typename Traits>
@@ -178,10 +180,10 @@ cms::cuda::host::unique_ptr<T> HeterogeneousSoAImpl<T, Traits>::toHostAsync(cuda
178180
}
179181

180182
template <typename T>
181-
using HeterogeneousSoAGPU = HeterogeneousSoAImpl<T, cudaCompat::GPUTraits>;
183+
using HeterogeneousSoAGPU = HeterogeneousSoAImpl<T, cms::cudacompat::GPUTraits>;
182184
template <typename T>
183-
using HeterogeneousSoACPU = HeterogeneousSoAImpl<T, cudaCompat::CPUTraits>;
185+
using HeterogeneousSoACPU = HeterogeneousSoAImpl<T, cms::cudacompat::CPUTraits>;
184186
template <typename T>
185-
using HeterogeneousSoAHost = HeterogeneousSoAImpl<T, cudaCompat::HostTraits>;
187+
using HeterogeneousSoAHost = HeterogeneousSoAImpl<T, cms::cudacompat::HostTraits>;
186188

187189
#endif

0 commit comments

Comments
 (0)