From 1bd4adfe7bad207deac51aae40f370dc4018953d Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Thu, 6 Apr 2017 10:14:51 +0100 Subject: [PATCH] [RAJA] Align the memory to 2MB pages --- RAJAStream.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/RAJAStream.cpp b/RAJAStream.cpp index 240f160..8d3f365 100644 --- a/RAJAStream.cpp +++ b/RAJAStream.cpp @@ -10,6 +10,10 @@ using RAJA::forall; using RAJA::RangeSegment; +#ifndef ALIGNMENT +#define ALIGNMENT (2*1024*1024) // 2MB +#endif + template RAJAStream::RAJAStream(const unsigned int ARRAY_SIZE, const int device_index) : array_size(ARRAY_SIZE) @@ -18,9 +22,9 @@ RAJAStream::RAJAStream(const unsigned int ARRAY_SIZE, const int device_index) index_set.push_back(seg); #ifdef RAJA_TARGET_CPU - d_a = new T[ARRAY_SIZE]; - d_b = new T[ARRAY_SIZE]; - d_c = new T[ARRAY_SIZE]; + d_a = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size); + d_b = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size); + d_c = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size); #else cudaMallocManaged((void**)&d_a, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal); cudaMallocManaged((void**)&d_b, sizeof(T)*ARRAY_SIZE, cudaMemAttachGlobal); @@ -33,9 +37,9 @@ template RAJAStream::~RAJAStream() { #ifdef RAJA_TARGET_CPU - delete[] d_a; - delete[] d_b; - delete[] d_c; + free(d_a); + free(d_b); + free(d_c); #else cudaFree(d_a); cudaFree(d_b);