ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
GpuParticleData_cuda.cu File Reference

CUDA kernels to convert the particles AoS to a SoA on the device. More...

#include "config/config.hpp"
#include "GpuParticleData.hpp"
#include "ResourceCleanup.hpp"
#include "System.hpp"
#include "ParticleRange.hpp"
#include "errorhandling.hpp"
#include "cuda/init.hpp"
#include "cuda/utils.cuh"
#include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <cuda.h>
#include <cstddef>
#include <cstdio>
#include <memory>
#include <span>
+ Include dependency graph for GpuParticleData_cuda.cu:

Go to the source code of this file.

Classes

class  GpuParticleData::Storage
 Host and device containers for particle data. More...
 

Functions

template<class T >
T * raw_data_pointer (thrust::device_vector< T > &vec)
 
template<class SpanLike >
std::size_t byte_size (SpanLike const &v)
 
template<class T >
void resize_or_replace (thrust::device_vector< T > &vec, std::size_t n)
 Resize a thrust::device_vector.
 
template<typename T >
void free_device_vector (thrust::device_vector< T > &vec)
 
__global__ void split_kernel_r (GpuParticleData::GpuParticle *particles, float *r, std::size_t n)
 
__global__ void split_kernel_rq (GpuParticleData::GpuParticle *particles, float *r, float *q, std::size_t n)
 
__global__ void split_kernel_q (GpuParticleData::GpuParticle *particles, float *q, std::size_t n)
 
__global__ void split_kernel_dip (GpuParticleData::GpuParticle *particles, float *dip, std::size_t n)
 

Detailed Description

CUDA kernels to convert the particles AoS to a SoA on the device.

Definition in file GpuParticleData_cuda.cu.

Function Documentation

◆ byte_size()

template<class SpanLike >
std::size_t byte_size ( SpanLike const &  v)

◆ free_device_vector()

template<typename T >
void free_device_vector ( thrust::device_vector< T > &  vec)

Definition at line 84 of file GpuParticleData_cuda.cu.

◆ raw_data_pointer()

◆ resize_or_replace()

template<class T >
void resize_or_replace ( thrust::device_vector< T > &  vec,
std::size_t  n 
)

Resize a thrust::device_vector.

Due to a bug in thrust (https://github.com/thrust/thrust/issues/939), resizing or appending to default constructed containers causes undefined behavior by dereferencing a null-pointer for certain types. This function is used instead of the resize member function to side-step the problem. This is done by replacing the existing vector by a new one constructed with the desired size if resizing from capacity zero. Behaves as-if vec.resize(n) was called. This is fixed in Thrust 1.11, shipped in CUDA 11.3 (https://github.com/NVIDIA/thrust/commit/1c4f25d9).

Template Parameters
TType contained in the vector.
Parameters
vecVector to resize.
nDesired new size of the vector.

Definition at line 76 of file GpuParticleData_cuda.cu.

Referenced by GpuParticleData::Storage::copy_particles_to_device().

◆ split_kernel_dip()

__global__ void split_kernel_dip ( GpuParticleData::GpuParticle particles,
float *  dip,
std::size_t  n 
)

Definition at line 342 of file GpuParticleData_cuda.cu.

◆ split_kernel_q()

__global__ void split_kernel_q ( GpuParticleData::GpuParticle particles,
float *  q,
std::size_t  n 
)

Definition at line 329 of file GpuParticleData_cuda.cu.

◆ split_kernel_r()

__global__ void split_kernel_r ( GpuParticleData::GpuParticle particles,
float *  r,
std::size_t  n 
)

Definition at line 300 of file GpuParticleData_cuda.cu.

◆ split_kernel_rq()

__global__ void split_kernel_rq ( GpuParticleData::GpuParticle particles,
float *  r,
float *  q,
std::size_t  n 
)

Definition at line 315 of file GpuParticleData_cuda.cu.