From: Bruno Turcksin Date: Mon, 29 Jan 2018 00:33:31 +0000 (-0500) Subject: Fix a bug in a CUDA vector constructor X-Git-Tag: v9.0.0-rc1~498^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae8d629af33989a3b96c146f70c4c39d7b87bd27;p=dealii.git Fix a bug in a CUDA vector constructor The constructor did not set the values in the vector to zero --- diff --git a/include/deal.II/lac/cuda_vector.h b/include/deal.II/lac/cuda_vector.h index aa407fff13..488138ccfb 100644 --- a/include/deal.II/lac/cuda_vector.h +++ b/include/deal.II/lac/cuda_vector.h @@ -27,7 +27,6 @@ DEAL_II_NAMESPACE_OPEN class CommunicationPatternBase; -class IndexSet; template class ReadWriteVector; namespace LinearAlgebra diff --git a/source/lac/cuda_vector.cu b/source/lac/cuda_vector.cu index 41501d8968..36b2be442b 100644 --- a/source/lac/cuda_vector.cu +++ b/source/lac/cuda_vector.cu @@ -503,11 +503,10 @@ namespace LinearAlgebra template Vector::Vector(const size_type n) : - n_elements(n) + val(nullptr), + n_elements(0) { - // Allocate the memory - cudaError_t error_code = cudaMalloc(&val, n_elements*sizeof(Number)); - AssertCuda(error_code); + reinit(n, false); } @@ -542,7 +541,7 @@ namespace LinearAlgebra } else { - if (n_elements != n) + if ((n_elements != n) && (val != nullptr)) { cudaError_t error_code = cudaFree(val); AssertCuda(error_code);