Skip to content

Commit 62b09c0

Browse files
makortelfwyzard
authored andcommitted
Implement changes from the CUDA framework review (cms-sw#429)
Rename the cudautils namespace to cms::cuda or cms::cudatest, and drop the CUDA prefix from the symbols defined there. Always record and query the CUDA event, to minimize need for error checking in CUDAScopedContextProduce destructor. Add comments to highlight the pieces in CachingDeviceAllocator that have been changed wrt. cub. Various other updates and clean up: - enable CUDA for compute capability 3.5. - clean up CUDAService, CUDA tests and plugins. - add CUDA existence protections to BuildFiles. - mark thread-safe static variables with CMS_THREAD_SAFE.
1 parent 41ef278 commit 62b09c0

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

CUDADataFormats/Common/interface/HeterogeneousSoA.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class HeterogeneousSoA {
1919
HeterogeneousSoA(HeterogeneousSoA &&) = default;
2020
HeterogeneousSoA &operator=(HeterogeneousSoA &&) = default;
2121

22-
explicit HeterogeneousSoA(cudautils::device::unique_ptr<T> &&p) : dm_ptr(std::move(p)) {}
23-
explicit HeterogeneousSoA(cudautils::host::unique_ptr<T> &&p) : hm_ptr(std::move(p)) {}
22+
explicit HeterogeneousSoA(cms::cuda::device::unique_ptr<T> &&p) : dm_ptr(std::move(p)) {}
23+
explicit HeterogeneousSoA(cms::cuda::host::unique_ptr<T> &&p) : hm_ptr(std::move(p)) {}
2424
explicit HeterogeneousSoA(std::unique_ptr<T> &&p) : std_ptr(std::move(p)) {}
2525

2626
auto const *get() const { return dm_ptr ? dm_ptr.get() : (hm_ptr ? hm_ptr.get() : std_ptr.get()); }
@@ -36,74 +36,74 @@ class HeterogeneousSoA {
3636
auto *operator-> () { return get(); }
3737

3838
// in reality valid only for GPU version...
39-
cudautils::host::unique_ptr<T> toHostAsync(cudaStream_t stream) const {
39+
cms::cuda::host::unique_ptr<T> toHostAsync(cudaStream_t stream) const {
4040
assert(dm_ptr);
41-
auto ret = cudautils::make_host_unique<T>(stream);
41+
auto ret = cms::cuda::make_host_unique<T>(stream);
4242
cudaCheck(cudaMemcpyAsync(ret.get(), dm_ptr.get(), sizeof(T), cudaMemcpyDefault, stream));
4343
return ret;
4444
}
4545

4646
private:
4747
// a union wan't do it, a variant will not be more efficienct
48-
cudautils::device::unique_ptr<T> dm_ptr; //!
49-
cudautils::host::unique_ptr<T> hm_ptr; //!
48+
cms::cuda::device::unique_ptr<T> dm_ptr; //!
49+
cms::cuda::host::unique_ptr<T> hm_ptr; //!
5050
std::unique_ptr<T> std_ptr; //!
5151
};
5252

5353
namespace cudaCompat {
5454

5555
struct GPUTraits {
5656
template <typename T>
57-
using unique_ptr = cudautils::device::unique_ptr<T>;
57+
using unique_ptr = cms::cuda::device::unique_ptr<T>;
5858

5959
template <typename T>
6060
static auto make_unique(cudaStream_t stream) {
61-
return cudautils::make_device_unique<T>(stream);
61+
return cms::cuda::make_device_unique<T>(stream);
6262
}
6363

6464
template <typename T>
6565
static auto make_unique(size_t size, cudaStream_t stream) {
66-
return cudautils::make_device_unique<T>(size, stream);
66+
return cms::cuda::make_device_unique<T>(size, stream);
6767
}
6868

6969
template <typename T>
7070
static auto make_host_unique(cudaStream_t stream) {
71-
return cudautils::make_host_unique<T>(stream);
71+
return cms::cuda::make_host_unique<T>(stream);
7272
}
7373

7474
template <typename T>
7575
static auto make_device_unique(cudaStream_t stream) {
76-
return cudautils::make_device_unique<T>(stream);
76+
return cms::cuda::make_device_unique<T>(stream);
7777
}
7878

7979
template <typename T>
8080
static auto make_device_unique(size_t size, cudaStream_t stream) {
81-
return cudautils::make_device_unique<T>(size, stream);
81+
return cms::cuda::make_device_unique<T>(size, stream);
8282
}
8383
};
8484

8585
struct HostTraits {
8686
template <typename T>
87-
using unique_ptr = cudautils::host::unique_ptr<T>;
87+
using unique_ptr = cms::cuda::host::unique_ptr<T>;
8888

8989
template <typename T>
9090
static auto make_unique(cudaStream_t stream) {
91-
return cudautils::make_host_unique<T>(stream);
91+
return cms::cuda::make_host_unique<T>(stream);
9292
}
9393

9494
template <typename T>
9595
static auto make_host_unique(cudaStream_t stream) {
96-
return cudautils::make_host_unique<T>(stream);
96+
return cms::cuda::make_host_unique<T>(stream);
9797
}
9898

9999
template <typename T>
100100
static auto make_device_unique(cudaStream_t stream) {
101-
return cudautils::make_device_unique<T>(stream);
101+
return cms::cuda::make_device_unique<T>(stream);
102102
}
103103

104104
template <typename T>
105105
static auto make_device_unique(size_t size, cudaStream_t stream) {
106-
return cudautils::make_device_unique<T>(size, stream);
106+
return cms::cuda::make_device_unique<T>(size, stream);
107107
}
108108
};
109109

@@ -158,7 +158,7 @@ class HeterogeneousSoAImpl {
158158

159159
T *get() { return m_ptr.get(); }
160160

161-
cudautils::host::unique_ptr<T> toHostAsync(cudaStream_t stream) const;
161+
cms::cuda::host::unique_ptr<T> toHostAsync(cudaStream_t stream) const;
162162

163163
private:
164164
unique_ptr<T> m_ptr; //!
@@ -171,8 +171,8 @@ HeterogeneousSoAImpl<T, Traits>::HeterogeneousSoAImpl(cudaStream_t stream) {
171171

172172
// in reality valid only for GPU version...
173173
template <typename T, typename Traits>
174-
cudautils::host::unique_ptr<T> HeterogeneousSoAImpl<T, Traits>::toHostAsync(cudaStream_t stream) const {
175-
auto ret = cudautils::make_host_unique<T>(stream);
174+
cms::cuda::host::unique_ptr<T> HeterogeneousSoAImpl<T, Traits>::toHostAsync(cudaStream_t stream) const {
175+
auto ret = cms::cuda::make_host_unique<T>(stream);
176176
cudaCheck(cudaMemcpyAsync(ret.get(), get(), sizeof(T), cudaMemcpyDefault, stream));
177177
return ret;
178178
}

CUDADataFormats/Common/interface/HostProduct.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class HostProduct {
1212
HostProduct(HostProduct&&) = default;
1313
HostProduct& operator=(HostProduct&&) = default;
1414

15-
explicit HostProduct(cudautils::host::unique_ptr<T>&& p) : hm_ptr(std::move(p)) {}
15+
explicit HostProduct(cms::cuda::host::unique_ptr<T>&& p) : hm_ptr(std::move(p)) {}
1616
explicit HostProduct(std::unique_ptr<T>&& p) : std_ptr(std::move(p)) {}
1717

1818
auto const* get() const { return hm_ptr ? hm_ptr.get() : std_ptr.get(); }
@@ -22,7 +22,7 @@ class HostProduct {
2222
auto const* operator-> () const { return get(); }
2323

2424
private:
25-
cudautils::host::unique_ptr<T> hm_ptr; //!
25+
cms::cuda::host::unique_ptr<T> hm_ptr; //!
2626
std::unique_ptr<T> std_ptr; //!
2727
};
2828

0 commit comments

Comments
 (0)