ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
init.hpp File Reference
#include "config/config.hpp"
#include "utils.hpp"
#include <cstddef>
#include <vector>
+ Include dependency graph for init.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EspressoGpuDevice
 Struct to hold information relevant to ESPResSo about GPUs. More...
 

Functions

void cuda_init ()
 Initializes the CUDA stream.
 
int cuda_get_n_gpus ()
 Get the number of CUDA devices.
 
int cuda_check_gpu_compute_capability (int dev)
 Check that a given GPU has compute capability.
 
void cuda_get_gpu_name (int dev, char *name)
 Get the name of a CUDA device.
 
void cuda_set_device (int dev)
 Choose a device for future CUDA computations.
 
int cuda_get_device ()
 Get the current CUDA device.
 
int cuda_test_device_access ()
 Test if actual CUDA device works.
 
void cuda_check_device ()
 Check that a device is available, that its compute capability is sufficient for ESPResSo, and that data can be written to and read from it.
 
std::vector< EspressoGpuDevicecuda_gather_gpus ()
 Gather unique list of CUDA devices on all nodes.
 
EspressoGpuDevice cuda_get_device_props (int dev)
 Get properties of a CUDA device.
 
void cuda_on_program_start ()
 Called on program start.
 

Function Documentation

◆ cuda_check_device()

void cuda_check_device ( )

Check that a device is available, that its compute capability is sufficient for ESPResSo, and that data can be written to and read from it.

Otherwise, throw an exception.

Definition at line 130 of file init_cuda.cu.

References cuda_check_gpu_compute_capability(), cuda_get_device(), cuda_get_n_gpus(), cuda_test_device_access(), and ES_OK.

◆ cuda_check_gpu_compute_capability()

int cuda_check_gpu_compute_capability ( int  dev)

Check that a given GPU has compute capability.

The minimal compute capability required by ESPResSo is computeCapabilityMinMajor . computeCapabilityMinMinor .

Parameters
devCUDA device number
Returns
ES_OK if the GPU meets the requirements, else ES_ERROR.

Definition at line 50 of file init_cuda.cu.

References computeCapabilityMinMajor, computeCapabilityMinMinor, CUDA_CHECK, ES_ERROR, and ES_OK.

Referenced by cuda_check_device().

◆ cuda_gather_gpus()

std::vector< EspressoGpuDevice > cuda_gather_gpus ( )

Gather unique list of CUDA devices on all nodes.

Returns
vector of device properties.

Gather unique list of CUDA devices on all nodes.

It relies on MPI_Get_processor_name() to get a unique identifier of the physical node, as opposed to the logical rank of which there can be more than one per node.

Definition at line 52 of file init.cpp.

References communicator, cuda_get_device_props(), cuda_get_n_gpus(), invoke_skip_cuda_exceptions(), Communicator::size, and this_node.

Referenced by ScriptInterface::System::CudaInitHandle::do_call_method().

◆ cuda_get_device()

int cuda_get_device ( )

Get the current CUDA device.

Returns
the current device's number.

Definition at line 98 of file init_cuda.cu.

References CUDA_CHECK.

Referenced by allocBHmemCopy(), cuda_check_device(), and ScriptInterface::System::CudaInitHandle::CudaInitHandle().

◆ cuda_get_device_props()

EspressoGpuDevice cuda_get_device_props ( int  dev)

Get properties of a CUDA device.

Parameters
devCUDA device number

Definition at line 77 of file init_cuda.cu.

References CUDA_CHECK, and cuda_copy_gpu_name().

Referenced by allocBHmemCopy(), and cuda_gather_gpus().

◆ cuda_get_gpu_name()

void cuda_get_gpu_name ( int  dev,
char *  name 
)

Get the name of a CUDA device.

Parameters
[in]devthe CUDA device number to ask the name for
[out]namea buffer to write the name to, at least 256 characters

Definition at line 71 of file init_cuda.cu.

References CUDA_CHECK, and cuda_copy_gpu_name().

Referenced by ScriptInterface::System::CudaInitHandle::do_call_method().

◆ cuda_get_n_gpus()

int cuda_get_n_gpus ( )

Get the number of CUDA devices.

Returns
the number of GPUs.

Definition at line 44 of file init_cuda.cu.

References CUDA_CHECK, and deviceCount.

Referenced by cuda_check_device(), cuda_gather_gpus(), and ScriptInterface::System::CudaInitHandle::do_call_method().

◆ cuda_init()

void cuda_init ( )

Initializes the CUDA stream.

Definition at line 42 of file init_cuda.cu.

References CUDA_CHECK, and stream.

Referenced by cuda_on_program_start().

◆ cuda_on_program_start()

void cuda_on_program_start ( )

Called on program start.

Definition at line 115 of file init.cpp.

References communicator, cuda_init(), invoke_skip_cuda_exceptions(), and this_node.

Referenced by Communication::init().

◆ cuda_set_device()

void cuda_set_device ( int  dev)

Choose a device for future CUDA computations.

Parameters
devthe device to use

Definition at line 92 of file init_cuda.cu.

References CUDA_CHECK, cudaSetDevice, and stream.

Referenced by ScriptInterface::System::CudaInitHandle::CudaInitHandle().

◆ cuda_test_device_access()

int cuda_test_device_access ( )

Test if actual CUDA device works.

Returns
ES_OK on success, ES_ERROR else.

Definition at line 104 of file init_cuda.cu.

References ES_ERROR, ES_OK, and h.

Referenced by cuda_check_device().