From: Bruno Turcksin Date: Fri, 16 Feb 2018 03:07:41 +0000 (-0500) Subject: Fix a bug in CUDAWrappers::Vector::reinit X-Git-Tag: v9.0.0-rc1~421^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5908%2Fhead;p=dealii.git Fix a bug in CUDAWrappers::Vector::reinit The second time that reinit was called the wrong number of elements was set to zero. --- diff --git a/source/lac/cuda_vector.cu b/source/lac/cuda_vector.cu index 9b9477afe8..c6164537e5 100644 --- a/source/lac/cuda_vector.cu +++ b/source/lac/cuda_vector.cu @@ -554,7 +554,7 @@ namespace LinearAlgebra if (omit_zeroing_entries == false) { cudaError_t error_code = cudaMemset(val, 0, - n_elements*sizeof(Number)); + n*sizeof(Number)); AssertCuda(error_code); } } diff --git a/tests/cuda/cuda_vector_03.cu b/tests/cuda/cuda_vector_03.cu new file mode 100644 index 0000000000..bd83012d52 --- /dev/null +++ b/tests/cuda/cuda_vector_03.cu @@ -0,0 +1,46 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#include "../tests.h" +#include +#include + +// Check that reinit correctly set all the entries of the vector to zero + +void test() +{ + const unsigned int size = 100; + LinearAlgebra::CUDAWrappers::Vector a(size); + LinearAlgebra::ReadWriteVector read_write(size); + for (unsigned int i=0; i