From 9111c71fd67cc4097da83173dfd05926ec1415f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 7 Feb 2014 12:03:29 +0100 Subject: [PATCH 1/2] fix initilization of cudaPitchedPtr - fix wrong initialization of xsize from cudaPitchedPtr# - size must be given in byte not number of elements --- .../memory/buffers/DeviceBufferIntern.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp index 88d96c2455..ae27044496 100644 --- a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp +++ b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp @@ -112,7 +112,7 @@ namespace PMacc } if (DIM == DIM2) { - CUDA_CHECK(cudaMemset2D(data.ptr, data.pitch, 0, data.xsize * sizeof (TYPE), data.ysize)); + CUDA_CHECK(cudaMemset2D(data.ptr, data.pitch, 0, data.xsize , data.ysize)); } if (DIM == DIM3) { @@ -249,20 +249,20 @@ namespace PMacc __startOperation(ITask::TASK_CUDA); data.ptr = NULL; data.pitch = 1; - data.xsize = this->data_space[0]; + data.xsize = this->data_space[0]* sizeof (TYPE); data.ysize = 1; if (DIM == DIM1) { - log("Create device 1D data: %1% MiB") % ( this->data_space[0] * sizeof (TYPE) / 1024 / 1024 ); - CUDA_CHECK(cudaMallocPitch(&data.ptr, &data.pitch, this->data_space[0] * sizeof (TYPE), 1)); + log("Create device 1D data: %1% MiB") % ( data.xsize / 1024 / 1024 ); + CUDA_CHECK(cudaMallocPitch(&data.ptr, &data.pitch, data.xsize , 1)); } if (DIM == DIM2) { - data.xsize = this->data_space[0]; + data.xsize = this->data_space[0]* sizeof (TYPE); data.ysize = this->data_space[1]; - log("Create device 2D data: %1% MiB") % ( data.xsize * data.ysize * sizeof (TYPE) / 1024 / 1024 ); - CUDA_CHECK(cudaMallocPitch(&data.ptr, &data.pitch, data.xsize * sizeof (TYPE), data.ysize)); + log("Create device 2D data: %1% MiB") % ( data.xsize * data.ysize / 1024 / 1024 ); + CUDA_CHECK(cudaMallocPitch(&data.ptr, &data.pitch, data.xsize , data.ysize)); } if (DIM == DIM3) @@ -286,7 +286,7 @@ namespace PMacc __startOperation(ITask::TASK_CUDA); data.ptr = NULL; data.pitch = 1; - data.xsize = this->data_space[0]; + data.xsize = this->data_space[0]* sizeof (TYPE); data.ysize = 1; log("Create device fake data: %1% MiB") % ( this->data_space.productOfComponents() * sizeof (TYPE) / 1024 / 1024 ); From d7346352ea68dc0d601180534ea59d4ec979d1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Mon, 10 Feb 2014 13:35:37 +0100 Subject: [PATCH 2/2] delete double assign of cudaPitchedPtr component --- src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp index ae27044496..75744dbb2b 100644 --- a/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp +++ b/src/libPMacc/include/memory/buffers/DeviceBufferIntern.hpp @@ -259,7 +259,6 @@ namespace PMacc } if (DIM == DIM2) { - data.xsize = this->data_space[0]* sizeof (TYPE); data.ysize = this->data_space[1]; log("Create device 2D data: %1% MiB") % ( data.xsize * data.ysize / 1024 / 1024 ); CUDA_CHECK(cudaMallocPitch(&data.ptr, &data.pitch, data.xsize , data.ysize));