ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
init_cuda.cu File Reference
#include "init.hpp"
#include "utils.cuh"
#include <cuda.h>
#include <cuda_runtime.h>
#include <cstring>
#include <string>

Go to the source code of this file.

Functions

void cuda_init ()
 Initializes the CUDA stream.
 
int cuda_get_n_gpus ()
 Get the number of CUDA devices.
 
bool cuda_check_gpu_compute_capability (int dev)
 Check that a given GPU has compute capability.
 
static void cuda_copy_gpu_name (char *const name, cudaDeviceProp const &prop)
 Safely copy the device name and pad the string with null characters.
 
void cuda_get_gpu_name (int dev, char *const name)
 Get the name of a CUDA device.
 
EspressoGpuDevice cuda_get_device_props (const int dev)
 Get properties 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.
 
bool cuda_test_device_access ()
 Test if communication to the 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.
 

Variables

minimally required compute capability.
static const int computeCapabilityMinMajor = 3
 
static const int computeCapabilityMinMinor = 0
 

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 123 of file init_cuda.cu.

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

◆ cuda_check_gpu_compute_capability()

bool 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
false if the GPU meets the requirements, else true.

Definition at line 49 of file init_cuda.cu.

References computeCapabilityMinMajor, computeCapabilityMinMinor, and CUDA_CHECK.

Referenced by cuda_check_device().

◆ cuda_copy_gpu_name()

static void cuda_copy_gpu_name ( char *const  name,
cudaDeviceProp const &  prop 
)
static

Safely copy the device name and pad the string with null characters.

Definition at line 60 of file init_cuda.cu.

Referenced by cuda_get_device_props(), and cuda_get_gpu_name().

◆ cuda_get_device()

int cuda_get_device ( )

Get the current CUDA device.

Returns
the current device's number.

Definition at line 94 of file init_cuda.cu.

References CUDA_CHECK.

Referenced by 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 73 of file init_cuda.cu.

References CUDA_CHECK, and cuda_copy_gpu_name().

Referenced by 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 67 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 43 of file init_cuda.cu.

References CUDA_CHECK.

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 41 of file init_cuda.cu.

References CUDA_CHECK, and stream.

Referenced by cuda_on_program_start().

◆ cuda_set_device()

void cuda_set_device ( int  dev)

Choose a device for future CUDA computations.

Parameters
devthe device to use

Definition at line 88 of file init_cuda.cu.

References CUDA_CHECK, and stream.

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

◆ cuda_test_device_access()

bool cuda_test_device_access ( )

Test if communication to the CUDA device works.

Returns
false on success, else true.

Definition at line 100 of file init_cuda.cu.

Referenced by cuda_check_device().

Variable Documentation

◆ computeCapabilityMinMajor

const int computeCapabilityMinMajor = 3
static

Definition at line 37 of file init_cuda.cu.

Referenced by cuda_check_gpu_compute_capability().

◆ computeCapabilityMinMinor

const int computeCapabilityMinMinor = 0
static

Definition at line 38 of file init_cuda.cu.

Referenced by cuda_check_gpu_compute_capability().