[RAJA] Align the memory to 2MB pages

This commit is contained in:
Tom Deakin 2017-04-06 10:14:51 +01:00
parent 1eb75f034a
commit 1bd4adfe7b

View File

@ -10,6 +10,10 @@
using RAJA::forall; using RAJA::forall;
using RAJA::RangeSegment; using RAJA::RangeSegment;
#ifndef ALIGNMENT
#define ALIGNMENT (2*1024*1024) // 2MB
#endif
template <class T> template <class T>
RAJAStream<T>::RAJAStream(const unsigned int ARRAY_SIZE, const int device_index) RAJAStream<T>::RAJAStream(const unsigned int ARRAY_SIZE, const int device_index)
: array_size(ARRAY_SIZE) : array_size(ARRAY_SIZE)
@ -18,9 +22,9 @@ RAJAStream<T>::RAJAStream(const unsigned int ARRAY_SIZE, const int device_index)
index_set.push_back(seg); index_set.push_back(seg);
#ifdef RAJA_TARGET_CPU #ifdef RAJA_TARGET_CPU
d_a = new T[ARRAY_SIZE]; d_a = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
d_b = new T[ARRAY_SIZE]; d_b = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
d_c = new T[ARRAY_SIZE]; d_c = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
#else #else
cudaMallocManaged((void**)&d_a, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal); cudaMallocManaged((void**)&d_a, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal);
cudaMallocManaged((void**)&d_b, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal); cudaMallocManaged((void**)&d_b, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal);
@ -33,9 +37,9 @@ template <class T>
RAJAStream<T>::~RAJAStream() RAJAStream<T>::~RAJAStream()
{ {
#ifdef RAJA_TARGET_CPU #ifdef RAJA_TARGET_CPU
delete[] d_a; free(d_a);
delete[] d_b; free(d_b);
delete[] d_c; free(d_c);
#else #else
cudaFree(d_a); cudaFree(d_a);
cudaFree(d_b); cudaFree(d_b);