Alsvinn  0.5.3
The fast FVM simulator with UQ support
get_device_properties.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 #include "alsutils/config.hpp"
18 #ifdef ALSVINN_HAVE_CUDA
19  #include <cuda_runtime.h>
20 #endif
21 #include <boost/property_tree/ptree.hpp>
22 #include <boost/algorithm/string/join.hpp>
24 #include "alsutils/log.hpp"
25 namespace alsutils {
26 namespace cuda {
30 inline boost::property_tree::ptree getDeviceProperties() {
31 
32  boost::property_tree::ptree propertiesTree;
33  int currentDevice = -1;
34 #ifdef ALSVINN_HAVE_CUDA
35 
36  try {
37  CUDA_SAFE_CALL_SILENT(cudaGetDevice(&currentDevice));
38 
39 
40  cudaDeviceProp properties;
41  CUDA_SAFE_CALL_SILENT(cudaGetDeviceProperties(&properties, currentDevice));
42 
43  propertiesTree.add("name", properties.name);
44  propertiesTree.add("totalGlobalMem", properties.totalGlobalMem);
45  propertiesTree.add("sharedMemPerBlock", properties.sharedMemPerBlock);
46  propertiesTree.add("regsPerBlock", properties.regsPerBlock);
47  propertiesTree.add("warpSize", properties.warpSize);
48  propertiesTree.add("memPitch", properties.memPitch);
49  propertiesTree.add("maxThreadsPerBlock", properties.maxThreadsPerBlock);
50  propertiesTree.add("maxThreadsDim",
51  boost::algorithm::join(
52  std::vector<std::string>({std::to_string(properties.maxThreadsDim[0]),
53  std::to_string(properties.maxThreadsDim[1]),
54  std::to_string(properties.maxThreadsDim[2])}),
55  ", "));
56  propertiesTree.add("maxGridSize",
57  boost::algorithm::join(
58  std::vector<std::string>({std::to_string(properties.maxGridSize[0]),
59  std::to_string(properties.maxGridSize[1]),
60  std::to_string(properties.maxGridSize[2])}),
61  ", "));
62  propertiesTree.add("totalConstMem", properties.totalConstMem);
63  propertiesTree.add("major", properties.major);
64  propertiesTree.add("minor", properties.minor);
65  propertiesTree.add("clockRate", properties.clockRate);
66  propertiesTree.add("textureAlignment", properties.textureAlignment);
67  propertiesTree.add("deviceOverlap", properties.deviceOverlap);
68  propertiesTree.add("multiProcessorCount", properties.multiProcessorCount);
69  propertiesTree.add("kernelExecTimeoutEnabled",
70  properties.kernelExecTimeoutEnabled);
71  propertiesTree.add("integrated", properties.integrated);
72  propertiesTree.add("canMapHostMemory", properties.canMapHostMemory);
73  propertiesTree.add("computeMode", properties.computeMode);
74  propertiesTree.add("concurrentKernels", properties.concurrentKernels);
75  propertiesTree.add("ECCEnabled", properties.ECCEnabled);
76  propertiesTree.add("pciBusID", properties.pciBusID);
77  propertiesTree.add("pciDeviceID", properties.pciDeviceID);
78  propertiesTree.add("tccDriver", properties.tccDriver);
79 
80 
81 
82 
83  } catch (std::runtime_error& e) {
85  "(Ignore this if you are not running with CUDA). Failed getting CUDA GPU properties: "
86  <<
87  e.what());
88  }
89 
90 #endif
91 
92  return propertiesTree;
93 }
94 }
95 }
boost::property_tree::ptree getDeviceProperties()
Definition: get_device_properties.hpp:30
#define CUDA_SAFE_CALL_SILENT(x)
Does the same as CUDA_SAFE_CALL, but doesn&#39;t print an error message.
Definition: cuda_safe_call.hpp:31
Various utilities for mpi and cuda.
Definition: Factory.hpp:3
#define WARNING
Definition: log.hpp:30
#define ALSVINN_LOG(severity, message)
Definition: log.hpp:36