Commit c6ea4646 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix the usage of posix_memalign

posix_memalign does not support alignments which are not multiple
of sizeof(void*). Usual memalign supported that.
parent 44144174
......@@ -151,13 +151,16 @@ QVector<Tile> generateTiles(int size,
const int vecSize = 1;
#endif
const size_t pixelAlignment = qMax(size_t(vecSize * 4), sizeof(void*));
const size_t maskAlignment = qMax(size_t(vecSize), sizeof(void*));
for (int i = 0; i < size; i++) {
void *ptr = NULL;
posix_memalign(&ptr, vecSize * 4, numPixels * 4 + srcAlignmentShift);
posix_memalign(&ptr, pixelAlignment, numPixels * 4 + srcAlignmentShift);
tiles[i].src = (quint8*)ptr + srcAlignmentShift;
posix_memalign(&ptr, vecSize * 4, numPixels * 4 + dstAlignmentShift);
posix_memalign(&ptr, pixelAlignment, numPixels * 4 + dstAlignmentShift);
tiles[i].dst = (quint8*)ptr + dstAlignmentShift;
posix_memalign(&ptr, vecSize, numPixels);
posix_memalign(&ptr, maskAlignment, numPixels);
tiles[i].mask = (quint8*)ptr;
generateDataLine(1, numPixels, tiles[i].src, tiles[i].dst, tiles[i].mask, srcAlphaRange, dstAlphaRange);
}
......@@ -573,16 +576,21 @@ void KisCompositionBenchmark::benchmarkMemcpy()
freeTiles(tiles, 0, 0);
}
void KisCompositionBenchmark::benchmarkUintFloat()
{
#ifdef HAVE_VC
const int vecSize = Vc::float_v::Size;
const size_t uint8VecAlignment = qMax(vecSize * sizeof(quint8), sizeof(void*));
const size_t uint32VecAlignment = qMax(vecSize * sizeof(quint32), sizeof(void*));
const size_t floatVecAlignment = qMax(vecSize * sizeof(float), sizeof(void*));
#endif
void KisCompositionBenchmark::benchmarkUintFloat()
{
#ifdef HAVE_VC
const int dataSize = 4096;
void *ptr = NULL;
posix_memalign(&ptr, vecSize, dataSize);
posix_memalign(&ptr, uint8VecAlignment, dataSize);
quint8 *iData = (quint8*)ptr;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, floatVecAlignment, dataSize * sizeof(float));
float *fData = (float*)ptr;
QBENCHMARK {
......@@ -602,13 +610,11 @@ void KisCompositionBenchmark::benchmarkUintFloat()
void KisCompositionBenchmark::benchmarkUintIntFloat()
{
#ifdef HAVE_VC
const int vecSize = Vc::float_v::Size;
const int dataSize = 4096;
void *ptr = NULL;
posix_memalign(&ptr, vecSize, dataSize);
posix_memalign(&ptr, uint8VecAlignment, dataSize);
quint8 *iData = (quint8*)ptr;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, floatVecAlignment, dataSize * sizeof(float));
float *fData = (float*)ptr;
QBENCHMARK {
......@@ -628,13 +634,11 @@ void KisCompositionBenchmark::benchmarkUintIntFloat()
void KisCompositionBenchmark::benchmarkFloatUint()
{
#ifdef HAVE_VC
const int vecSize = Vc::float_v::Size;
const int dataSize = 4096;
void *ptr = NULL;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, uint32VecAlignment, dataSize * sizeof(quint32));
quint32 *iData = (quint32*)ptr;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, floatVecAlignment, dataSize * sizeof(float));
float *fData = (float*)ptr;
QBENCHMARK {
......@@ -654,13 +658,11 @@ void KisCompositionBenchmark::benchmarkFloatUint()
void KisCompositionBenchmark::benchmarkFloatIntUint()
{
#ifdef HAVE_VC
const int vecSize = Vc::float_v::Size;
const int dataSize = 4096;
void *ptr = NULL;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, uint32VecAlignment, dataSize * sizeof(quint32));
quint32 *iData = (quint32*)ptr;
posix_memalign(&ptr, vecSize * 4, dataSize * 4);
posix_memalign(&ptr, floatVecAlignment, dataSize * sizeof(float));
float *fData = (float*)ptr;
QBENCHMARK {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment