From ae8d629af33989a3b96c146f70c4c39d7b87bd27 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Sun, 28 Jan 2018 19:33:31 -0500 Subject: [PATCH] Fix a bug in a CUDA vector constructor The constructor did not set the values in the vector to zero --- include/deal.II/lac/cuda_vector.h | 1 - source/lac/cuda_vector.cu | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) 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); -- 2.39.5