| 1 |
//@HEADER |
| 2 |
// ************************************************************************ |
| 3 |
// |
| 4 |
// Kokkos v. 4.0 |
| 5 |
// Copyright (2022) National Technology & Engineering |
| 6 |
// Solutions of Sandia, LLC (NTESS). |
| 7 |
// |
| 8 |
// Under the terms of Contract DE-NA0003525 with NTESS, |
| 9 |
// the U.S. Government retains certain rights in this software. |
| 10 |
// |
| 11 |
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
// See https://kokkos.org/LICENSE for license information. |
| 13 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 14 |
// |
| 15 |
//@HEADER |
| 16 |
|
| 17 |
// Created by David Poliakoff and Amy Powell on 6/15/2021 |
| 18 |
|
| 19 |
#ifndef KOKKOSKERNELS_KOKKOSBLAS_GEMV_TEST_RPS_HPP |
| 20 |
#define KOKKOSKERNELS_KOKKOSBLAS_GEMV_TEST_RPS_HPP |
| 21 |
|
| 22 |
#include <Kokkos_Core.hpp> |
| 23 |
#include "blas/KokkosBlas1_dot.hpp" |
| 24 |
#include <Kokkos_Random.hpp> |
| 25 |
|
| 26 |
// These headers are required for RPS perf test implementation |
| 27 |
// |
| 28 |
#ifdef KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE |
| 29 |
#include <PerfTestUtilities.hpp> |
| 30 |
|
| 31 |
test_list construct_gemv_kernel_base(const rajaperf::RunParams& run_params); |
| 32 |
|
| 33 |
#endif // KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE |
| 34 |
|
| 35 |
template <class ExecSpace, class Layout> |
| 36 |
struct testData_gemv { |
| 37 |
// type aliases for Kokkos data structures |
| 38 |
|
| 39 |
using Scalar = double; |
| 40 |
using MemSpace = typename ExecSpace::memory_space; |
| 41 |
using Device = Kokkos::Device<ExecSpace, MemSpace>; |
| 42 |
|
| 43 |
// These are fields in the struct |
| 44 |
// m is vector length |
| 45 |
int m = 100000; |
| 46 |
// n is the number of columns |
| 47 |
int n = 100000; |
| 48 |
int repeat = 1; |
| 49 |
bool layoutLeft = true; |
| 50 |
|
| 51 |
// Create 2D view, "A", w/ Device as the ExecSpace; this is the input matrix, |
| 52 |
// as a 2-D Kokkos::View |
| 53 |
Kokkos::View<Scalar**, Layout, Device> A; |
| 54 |
|
| 55 |
// Create 1D view, "x", w/ Device as the ExecSpace; input vector, as a 1-D |
| 56 |
// Kokkos::View |
| 57 |
Kokkos::View<Scalar*, Device> x; |
| 58 |
|
| 59 |
// Create 1D view, "y", w/ Device as the ExecSpace; input/output vector, as a |
| 60 |
// 1-D Kokkos::View |
| 61 |
Kokkos::View<Scalar*, Device> y; |
| 62 |
|
| 63 |
// A function with no return type whose name is the name of the class is a |
| 64 |
// constructor or a destructor; |
| 65 |
// Constructor -- create function: |
| 66 |
testData_gemv(int m_in, int n_in, int repeat_in) : m(m_in), n(n_in), repeat(repeat_in) { |
| 67 |
A = Kokkos::View<Scalar**, Layout, Device>(Kokkos::ViewAllocateWithoutInitializing("A"), m, n); |
| 68 |
x = Kokkos::View<Scalar*, Device>(Kokkos::ViewAllocateWithoutInitializing("x"), n); |
| 69 |
y = Kokkos::View<Scalar*, Device>(Kokkos::ViewAllocateWithoutInitializing("y"), m); |
| 70 |
|
| 71 |
Kokkos::Random_XorShift64_Pool<ExecSpace> pool(123); |
| 72 |
|
| 73 |
// Fill input matrices A and x with 10 random values from pool |
| 74 |
Kokkos::fill_random(A, pool, 10.0); |
| 75 |
Kokkos::fill_random(x, pool, 10.0); |
| 76 |
} |
| 77 |
}; |
| 78 |
|
| 79 |
template <typename ExecSpace, typename Layout> |
| 80 |
testData_gemv<ExecSpace, Layout> setup_test(int m, int n, int repeat, bool layoutLeft); |
| 81 |
|
| 82 |
#endif // KOKKOSKERNELS_KOKKOSBLAS_GEMV_TEST_RPS_HPP |