From: Timo Heister Date: Mon, 2 Jun 2025 02:35:41 +0000 (-0400) Subject: Kokkos: test Tensor on device X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F18535%2Fhead;p=dealii.git Kokkos: test Tensor on device --- diff --git a/tests/matrix_free_kokkos/tensor_01.cc b/tests/matrix_free_kokkos/tensor_01.cc new file mode 100644 index 0000000000..c527f39582 --- /dev/null +++ b/tests/matrix_free_kokkos/tensor_01.cc @@ -0,0 +1,67 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2019 - 2024 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + + +// check that Tensor works on device + +#include + +#include "deal.II/base/symmetric_tensor.h" +#include + +#include + +#include "../tests.h" + +DEAL_II_HOST_DEVICE +void +test_tensor() +{ + constexpr const int dim = 2; + + Tensor<2, dim> t1; + Tensor<2, dim> t2; + t1 = 0; + t2[0][1] = 1.0; + t1 += t2; + t1 *= 2.0; + Assert(t1.norm() == 2.0, ExcInternalError()); +} + +class Functor +{ +public: + DEAL_II_HOST_DEVICE void + operator()(const long n) const + { + test_tensor(); + } +}; + + + +int +main() +{ + initlog(); + + Kokkos::initialize(); + + Functor f; + Kokkos::parallel_for("test", 1, f); + + Kokkos::finalize(); + + return 0; +} diff --git a/tests/matrix_free_kokkos/tensor_01.output b/tests/matrix_free_kokkos/tensor_01.output new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/tests/matrix_free_kokkos/tensor_01.output @@ -0,0 +1 @@ +