@@ -64,10 +64,7 @@ namespace alpaka
6464 using IDeviceQueue = uniform_cuda_hip::detail::QueueUniformCudaHipRtImpl<TApi>;
6565
6666 protected:
67- DevUniformCudaHipRt ()
68- : m_QueueRegistry{std::make_shared<alpaka::detail::QueueRegistry<IDeviceQueue>>()}
69- , m_deviceProperties{std::make_shared<alpaka::DeviceProperties>()}
70- , m_mutex(std::make_shared<std::mutex>())
67+ DevUniformCudaHipRt () : m_QueueRegistry{std::make_shared<alpaka::detail::QueueRegistry<IDeviceQueue>>()}
7168 {
7269 }
7370
@@ -109,16 +106,12 @@ namespace alpaka
109106 DevUniformCudaHipRt (int iDevice)
110107 : m_iDevice(iDevice)
111108 , m_QueueRegistry(std::make_shared<alpaka::detail::QueueRegistry<IDeviceQueue>>())
112- , m_deviceProperties(std::make_shared<alpaka::DeviceProperties>())
113- , m_mutex(std::make_shared<std::mutex>())
114109 {
115110 }
116111
117112 int m_iDevice;
118113
119114 std::shared_ptr<alpaka::detail::QueueRegistry<IDeviceQueue>> m_QueueRegistry;
120- std::shared_ptr<alpaka::DeviceProperties> m_deviceProperties;
121- std::shared_ptr<std::mutex> m_mutex;
122115 };
123116
124117 namespace trait
@@ -130,18 +123,18 @@ namespace alpaka
130123 ALPAKA_FN_HOST static auto getName (DevUniformCudaHipRt<TApi> const & dev) -> std::string
131124 {
132125 {
133- std::lock_guard<std::mutex> lock (* dev.m_mutex );
134- if (!dev.m_deviceProperties -> name .has_value ())
126+ std::lock_guard<std::mutex> lock (dev.m_QueueRegistry -> mutex () );
127+ if (!dev.m_QueueRegistry -> deviceProperties (). name .has_value ())
135128 {
136129 // There is cuda/hip-DeviceGetAttribute as faster alternative to cuda/hip-GetDeviceProperties
137130 // to get a single device property but it has no option to get the name
138131 typename TApi::DeviceProp_t devProp;
139132 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (TApi::getDeviceProperties (&devProp, dev.getNativeHandle ()));
140- dev.m_deviceProperties -> name = std::string (devProp.name );
133+ dev.m_QueueRegistry -> deviceProperties (). name = std::string (devProp.name );
141134 }
142135 }
143136
144- return dev.m_deviceProperties -> name .value ();
137+ return dev.m_QueueRegistry -> deviceProperties (). name .value ();
145138 }
146139 };
147140
@@ -152,8 +145,8 @@ namespace alpaka
152145 ALPAKA_FN_HOST static auto getMemBytes (DevUniformCudaHipRt<TApi> const & dev) -> std::size_t
153146 {
154147 {
155- std::lock_guard<std::mutex> lock (* dev.m_mutex );
156- if (!dev.m_deviceProperties -> freeGlobalMem .has_value ())
148+ std::lock_guard<std::mutex> lock (dev.m_QueueRegistry -> mutex () );
149+ if (!dev.m_QueueRegistry -> deviceProperties (). totalGlobalMem .has_value ())
157150 {
158151 // Set the current device to wait for.
159152 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (TApi::setDevice (dev.getNativeHandle ()));
@@ -163,12 +156,11 @@ namespace alpaka
163156
164157 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (TApi::memGetInfo (&freeInternal, &totalInternal));
165158
166- dev.m_deviceProperties ->totalGlobalMem = totalInternal;
167- dev.m_deviceProperties ->freeGlobalMem = freeInternal;
159+ dev.m_QueueRegistry ->deviceProperties ().totalGlobalMem = totalInternal;
168160 }
169161 }
170162
171- return dev.m_deviceProperties -> totalGlobalMem .value ();
163+ return dev.m_QueueRegistry -> deviceProperties (). totalGlobalMem .value ();
172164 }
173165 };
174166
@@ -178,24 +170,23 @@ namespace alpaka
178170 {
179171 ALPAKA_FN_HOST static auto getFreeMemBytes (DevUniformCudaHipRt<TApi> const & dev) -> std::size_t
180172 {
173+ std::size_t freeInternal (0u );
181174 {
182- std::lock_guard<std::mutex> lock (* dev.m_mutex );
183- if (!dev.m_deviceProperties -> totalGlobalMem .has_value ())
175+ std::lock_guard<std::mutex> lock (dev.m_QueueRegistry -> mutex () );
176+ if (!dev.m_QueueRegistry -> deviceProperties (). totalGlobalMem .has_value ())
184177 {
185178 // Set the current device to wait for.
186179 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (TApi::setDevice (dev.getNativeHandle ()));
187180
188- std::size_t freeInternal (0u );
189181 std::size_t totalInternal (0u );
190182
191183 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (TApi::memGetInfo (&freeInternal, &totalInternal));
192184
193- dev.m_deviceProperties ->totalGlobalMem = totalInternal;
194- dev.m_deviceProperties ->freeGlobalMem = freeInternal;
185+ dev.m_QueueRegistry ->deviceProperties ().totalGlobalMem = totalInternal;
195186 }
196187 }
197188
198- return dev. m_deviceProperties -> freeGlobalMem . value () ;
189+ return freeInternal ;
199190 }
200191 };
201192
@@ -206,14 +197,14 @@ namespace alpaka
206197 ALPAKA_FN_HOST static auto getWarpSizes (DevUniformCudaHipRt<TApi> const & dev) -> std::vector<std::size_t>
207198 {
208199 {
209- std::lock_guard<std::mutex> lock (* dev.m_mutex );
210- if (!dev.m_deviceProperties -> warpSizes .has_value ())
200+ std::lock_guard<std::mutex> lock (dev.m_QueueRegistry -> mutex () );
201+ if (!dev.m_QueueRegistry -> deviceProperties (). warpSizes .has_value ())
211202 {
212- dev.m_deviceProperties -> warpSizes = std::vector<std::size_t >{
203+ dev.m_QueueRegistry -> deviceProperties (). warpSizes = std::vector<std::size_t >{
213204 GetPreferredWarpSize<DevUniformCudaHipRt<TApi>>::getPreferredWarpSize (dev)};
214205 }
215206 }
216- return dev.m_deviceProperties -> warpSizes .value ();
207+ return dev.m_QueueRegistry -> deviceProperties (). warpSizes .value ();
217208 }
218209 };
219210
@@ -224,18 +215,18 @@ namespace alpaka
224215 ALPAKA_FN_HOST static auto getPreferredWarpSize (DevUniformCudaHipRt<TApi> const & dev) -> std::size_t
225216 {
226217 {
227- std::lock_guard<std::mutex> lock (* dev.m_mutex );
228- if (!dev.m_deviceProperties -> preferredWarpSize .has_value ())
218+ std::lock_guard<std::mutex> lock (dev.m_QueueRegistry -> mutex () );
219+ if (!dev.m_QueueRegistry -> deviceProperties (). preferredWarpSize .has_value ())
229220 {
230221 int warpSize = 0 ;
231222
232223 ALPAKA_UNIFORM_CUDA_HIP_RT_CHECK (
233224 TApi::deviceGetAttribute (&warpSize, TApi::deviceAttributeWarpSize, dev.getNativeHandle ()));
234- dev.m_deviceProperties -> preferredWarpSize = static_cast <std::size_t >(warpSize);
225+ dev.m_QueueRegistry -> deviceProperties (). preferredWarpSize = static_cast <std::size_t >(warpSize);
235226 }
236227 }
237228
238- return dev.m_deviceProperties -> preferredWarpSize .value ();
229+ return dev.m_QueueRegistry -> deviceProperties (). preferredWarpSize .value ();
239230 }
240231 };
241232
0 commit comments