Add support for Thrust managed memory

Closes #143
This commit is contained in:
Tom Deakin 2023-07-27 13:46:23 +01:00
parent d12af1075c
commit 6d11c72382
3 changed files with 18 additions and 1 deletions

View File

@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## Unreleased ## Unreleased
### Added ### Added
- Ability to build Kokkos and RAJA versions against existing packages. - Ability to build Kokkos and RAJA versions against existing packages.
- Thrust managed memory.
### Changed ### Changed
- RAJA CUDA CMake build issues resolved. - RAJA CUDA CMake build issues resolved.

View File

@ -8,7 +8,11 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#if defined(MANAGED)
#include <thrust/universal_vector.h>
#else
#include <thrust/device_vector.h> #include <thrust/device_vector.h>
#endif
#include "Stream.h" #include "Stream.h"
@ -21,9 +25,15 @@ class ThrustStream : public Stream<T>
// Size of arrays // Size of arrays
int array_size; int array_size;
#if defined(MANAGED)
thrust::universtal_vector<T> a;
thrust::universtal_vector<T> b;
thrust::universtal_vector<T> c;
#else
thrust::device_vector<T> a; thrust::device_vector<T> a;
thrust::device_vector<T> b; thrust::device_vector<T> b;
thrust::device_vector<T> c; thrust::device_vector<T> c;
#endif
public: public:
ThrustStream(const int, int); ThrustStream(const int, int);

View File

@ -18,6 +18,9 @@ register_flag_optional(BACKEND
" "
"CUDA") "CUDA")
register_flag_optional(MANAGED "Enabled managed memory mode."
"OFF")
register_flag_optional(CMAKE_CUDA_COMPILER register_flag_optional(CMAKE_CUDA_COMPILER
"[THRUST_IMPL==CUDA] Path to the CUDA nvcc compiler" "[THRUST_IMPL==CUDA] Path to the CUDA nvcc compiler"
"") "")
@ -34,6 +37,9 @@ register_flag_optional(CUDA_EXTRA_FLAGS
macro(setup) macro(setup)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
if (MANAGED)
register_definitions(MANAGED)
endif ()
if (${THRUST_IMPL} STREQUAL "CUDA") if (${THRUST_IMPL} STREQUAL "CUDA")