From: Bruno Turcksin Date: Mon, 22 Aug 2016 19:02:16 +0000 (-0400) Subject: Add tests for CUDAWrappers::Vector. X-Git-Tag: v8.5.0-rc1~695^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f4bc0b5c1f030d09b5dad8dcf9049bd612b7785;p=dealii.git Add tests for CUDAWrappers::Vector. --- diff --git a/source/lac/cuda_vector.cu b/source/lac/cuda_vector.cu index b954c3f7ab..caf7f6b44e 100644 --- a/source/lac/cuda_vector.cu +++ b/source/lac/cuda_vector.cu @@ -206,6 +206,13 @@ namespace LinearAlgebra blockIdx.x*(blockDim.x*CHUNK_SIZE); const typename Vector::size_type local_idx = threadIdx.x; + if (global_idx (result, result_buffer, local_idx, global_idx, N); } @@ -422,6 +429,11 @@ namespace LinearAlgebra res_buf[local_idx] += v1[idx]*v3[idx]; } } + + __syncthreads(); + + reduce> (res, res_buf, local_idx, + global_idx, N); } } diff --git a/tests/cuda/CMakeLists.txt b/tests/cuda/CMakeLists.txt new file mode 100644 index 0000000000..cc91456685 --- /dev/null +++ b/tests/cuda/CMakeLists.txt @@ -0,0 +1,6 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) +INCLUDE(../setup_testsubproject.cmake) +PROJECT(testsuite CXX) +IF(DEAL_II_WITH_CUDA) + DEAL_II_PICKUP_TESTS() +ENDIF() diff --git a/tests/cuda/cuda_vector_01.cc b/tests/cuda/cuda_vector_01.cc new file mode 100644 index 0000000000..8abae2c766 --- /dev/null +++ b/tests/cuda/cuda_vector_01.cc @@ -0,0 +1,112 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 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. +// +// --------------------------------------------------------------------- + + +// Check LinearAlgebra::CUDAWrappers::Vector assignement and import + +#include "../tests.h" +#include +#include +#include +#include +#include + +void test() +{ + const unsigned int size = 100; + LinearAlgebra::CUDAWrappers::Vector a; + LinearAlgebra::CUDAWrappers::Vector b(size); + LinearAlgebra::CUDAWrappers::Vector c(b); + + AssertThrow(a.size()==0, ExcMessage("Vector has the wrong size.")); + AssertThrow(b.size()==size, ExcMessage("Vector has the wrong size.")); + AssertThrow(c.size()==size, ExcMessage("Vector has the wrong size.")); + + a.reinit(size); + AssertThrow(a.size()==size, ExcMessage("Vector has the wrong size.")); + + + LinearAlgebra::ReadWriteVector read_write_1(size); + LinearAlgebra::ReadWriteVector read_write_2(size); + LinearAlgebra::ReadWriteVector read_write_3(size); + for (unsigned int i=0; i +#include +#include +#include +#include +#include + +// Check LinearAlgebra::CUDAWrappers::Vector add and sadd. + +void test() +{ + const unsigned int size = 100; + LinearAlgebra::CUDAWrappers::Vector a(size); + LinearAlgebra::CUDAWrappers::Vector b(size); + LinearAlgebra::CUDAWrappers::Vector c(size); + + LinearAlgebra::ReadWriteVector read_write_1(size); + LinearAlgebra::ReadWriteVector read_write_2(size); + LinearAlgebra::ReadWriteVector read_write_3(size); + + for (unsigned int i=0; i d(a); + a.add(2.,b,3.,d); + read_write_3.import(a, VectorOperation::insert); + for (unsigned int i=0; i