Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
init.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "config/config.hpp"
23
24#ifdef CUDA
25
26#include "utils.hpp"
27
28#include <cstddef>
29#include <vector>
30
31/** Struct to hold information relevant to ESPResSo
32 * about GPUs. Should contain only fixed-length plain
33 * old datatypes, as it is intended for MPI communication.
34 */
36 /** Local CUDA device id */
37 int id;
38 /** Local CUDA device name */
39 char name[256];
40 /** Node identification */
41 char proc_name[64];
42 /** MPI process identification */
43 int node;
44 /** Compute capability (major) */
46 /** Compute capability (minor) */
48 /** Total Memory */
49 std::size_t total_memory;
50 /** Number of cores */
52};
53
54/** Initializes the CUDA stream.
55 */
56void cuda_init();
57
58/** Get the number of CUDA devices.
59 *
60 * @return the number of GPUs.
61 */
62int cuda_get_n_gpus();
63
64/** Check that a given GPU has compute capability.
65 * The minimal compute capability required by ESPResSo is
66 * \ref computeCapabilityMinMajor . \ref computeCapabilityMinMinor .
67 *
68 * @param dev CUDA device number
69 * @return @c false if the GPU meets the requirements, else @c true.
70 */
72
73/** Get the name of a CUDA device.
74 *
75 * @param[in] dev the CUDA device number to ask the name for
76 * @param[out] name a buffer to write the name to, at least 256 characters
77 */
78void cuda_get_gpu_name(int dev, char *name);
79
80/** Choose a device for future CUDA computations.
81 *
82 * @param dev the device to use
83 */
84void cuda_set_device(int dev);
85
86/** Get the current CUDA device.
87 *
88 * @return the current device's number.
89 */
90int cuda_get_device();
91
92/** Test if communication to the CUDA device works.
93 * @return @c false on success, else @c true.
94 */
96
97/**
98 * Check that a device is available, that its compute capability
99 * is sufficient for ESPResSo, and that data can be written to
100 * and read from it. Otherwise, throw an exception.
101 */
102void cuda_check_device();
103
104/** Gather unique list of CUDA devices on all nodes.
105 * @return vector of device properties.
106 */
107std::vector<EspressoGpuDevice> cuda_gather_gpus();
108
109/** Get properties of a CUDA device
110 * @param dev CUDA device number
111 */
113
114/** @brief Called on program start. */
116
117#endif // CUDA
This file contains the defaults for ESPResSo.
std::vector< EspressoGpuDevice > cuda_gather_gpus()
Gather unique list of CUDA devices on all nodes.
Definition init.cpp:53
void cuda_on_program_start()
Called on program start.
Definition init.cpp:115
void cuda_check_device()
Check that a device is available, that its compute capability is sufficient for ESPResSo,...
Definition init_cuda.cu:113
bool cuda_check_gpu_compute_capability(int dev)
Check that a given GPU has compute capability.
Definition init_cuda.cu:50
bool cuda_test_device_access()
Test if communication to the CUDA device works.
Definition init_cuda.cu:101
EspressoGpuDevice cuda_get_device_props(int dev)
Get properties of a CUDA device.
Definition init_cuda.cu:74
int cuda_get_device()
Get the current CUDA device.
Definition init_cuda.cu:95
void cuda_set_device(int dev)
Choose a device for future CUDA computations.
Definition init_cuda.cu:89
void cuda_get_gpu_name(int dev, char *name)
Get the name of a CUDA device.
Definition init_cuda.cu:68
int cuda_get_n_gpus()
Get the number of CUDA devices.
Definition init_cuda.cu:44
void cuda_init()
Initializes the CUDA stream.
Definition init_cuda.cu:42
Struct to hold information relevant to ESPResSo about GPUs.
Definition init.hpp:35
char proc_name[64]
Node identification.
Definition init.hpp:41
std::size_t total_memory
Total Memory.
Definition init.hpp:49
int compute_capability_major
Compute capability (major)
Definition init.hpp:45
char name[256]
Local CUDA device name.
Definition init.hpp:39
int compute_capability_minor
Compute capability (minor)
Definition init.hpp:47
int node
MPI process identification.
Definition init.hpp:43
int n_cores
Number of cores.
Definition init.hpp:51
int id
Local CUDA device id.
Definition init.hpp:37