24#include <cuda_runtime.h>
29#if defined(OMPI_MPI_H) || defined(_MPI_H)
30#error CU-file includes mpi.h! This should not happen!
50 cudaDeviceProp deviceProp;
51 CUDA_CHECK(cudaGetDeviceProperties(&deviceProp, dev))
61 char buffer[256] = {
'\0'};
62 std::strncpy(buffer, prop.name, 256);
64 std::strncpy(name, buffer, 256);
68 cudaDeviceProp deviceProp;
69 CUDA_CHECK(cudaGetDeviceProperties(&deviceProp, dev))
74 cudaDeviceProp deviceProp;
75 CUDA_CHECK(cudaGetDeviceProperties(&deviceProp, dev))
82 deviceProp.totalGlobalMem,
83 deviceProp.multiProcessorCount};
105 err = cudaMalloc((
void **)&d,
sizeof(
int));
106 if (err != cudaSuccess) {
109 err = cudaMemcpy(d, &h,
sizeof(
int), cudaMemcpyHostToDevice);
110 if (err != cudaSuccess) {
115 err = cudaMemcpy(&h, d,
sizeof(
int), cudaMemcpyDeviceToHost);
117 if (err != cudaSuccess) {
130 if (incompatible or communication_failure) {
132 " is not capable of running ESPResSo.");
Wrapper for CUDA runtime exceptions.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static const int computeCapabilityMinMajor
EspressoGpuDevice cuda_get_device_props(const int dev)
Get properties of a CUDA device.
void cuda_check_device()
Check that a device is available, that its compute capability is sufficient for ESPResSo,...
bool cuda_check_gpu_compute_capability(int dev)
Check that a given GPU has compute capability.
void cuda_get_gpu_name(int dev, char *const name)
Get the name of a CUDA device.
bool cuda_test_device_access()
Test if communication to the CUDA device works.
static const int computeCapabilityMinMinor
int cuda_get_device()
Get the current CUDA device.
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_set_device(int dev)
Choose a device for future CUDA computations.
int cuda_get_n_gpus()
Get the number of CUDA devices.
void cuda_init()
Initializes the CUDA stream.
Struct to hold information relevant to ESPResSo about GPUs.
#define CUDA_CHECK(statement)
Convert CUDA error codes into runtime errors.