Skip to content
Snippets Groups Projects

Particle Data Structure

Merged Slattery, Stuart requested to merge (removed):particle_api into master
2 files
+ 33
4
Compare changes
  • Side-by-side
  • Inline
Files
2
#ifndef CABANA_CUDAUVM_HPP
#define CABANA_CUDAUVM_HPP
#ifndef CABANA_CUDA_HPP
#define CABANA_CUDA_HPP
#if defined( __NVCC__ )
@@ -11,6 +11,35 @@
namespace Cabana
{
//---------------------------------------------------------------------------//
// Cuda tag.
struct Cuda {};
//---------------------------------------------------------------------------//
/*!
* \brief Memory policy for Cuda computations.
*/
template<>
struct MemoryPolicy<Cuda>
{
//! Allocate array of a number of objects of type T. This will only work
//! if T is of trivial type (trivially copyable and contiguous).
template<class T>
static
typename std::enable_if<std::is_trivial<T>::value,void>::type
allocate( T*& ptr, const std::size_t num_t )
{
cudaMalloc( (void**) &ptr, num_t * sizeof(T) );
}
//! Dellocate an array.
template<class T>
static void deallocate( T* ptr )
{
cudaFree( ptr );
}
};
//---------------------------------------------------------------------------//
// CudaUVM tag.
struct CudaUVM {};
@@ -46,4 +75,4 @@ struct MemoryPolicy<CudaUVM>
#endif // end defined( __NVCC__ )
#endif // end CABANA_CUDAUVM_HPP
#endif // end CABANA_CUDA_HPP
Loading