[OpenMP] Align memory (2MB by default)
This commit is contained in:
parent
4f288ddc3d
commit
703eb945a2
@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include "OMPStream.h"
|
#include "OMPStream.h"
|
||||||
|
|
||||||
|
#ifndef ALIGNMENT
|
||||||
|
#define ALIGNMENT (2*1024*1024) // 2MB
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
OMPStream<T>::OMPStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int device)
|
OMPStream<T>::OMPStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int device)
|
||||||
{
|
{
|
||||||
@ -22,9 +26,9 @@ OMPStream<T>::OMPStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int dev
|
|||||||
{}
|
{}
|
||||||
#else
|
#else
|
||||||
// Allocate on the host
|
// Allocate on the host
|
||||||
this->a = (T*)malloc(sizeof(T)*array_size);
|
this->a = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
|
||||||
this->b = (T*)malloc(sizeof(T)*array_size);
|
this->b = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
|
||||||
this->c = (T*)malloc(sizeof(T)*array_size);
|
this->c = (T*)aligned_alloc(ALIGNMENT, sizeof(T)*array_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user