File: view-cxx.cc

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (41 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "flcl-cxx.hpp"
#include <Kokkos_Core.hpp>

using view_type = flcl::view_i32_2d_t;

extern "C" {

void c_init_view(view_type **v_x, int *val)
{
    using flcl::view_from_ndarray;

    view_type x = **v_x;
    int d_val = *val;
    Kokkos::parallel_for("initBuffer", x.extent(1), KOKKOS_LAMBDA(const size_t idy) {
        for (size_t idx = 0; idx < x.extent(0); idx++)
            x(idx, idy) = d_val + idx;
    });
    Kokkos::fence();

    return;
}

void c_print_view(view_type **v_x)
{
    using flcl::view_from_ndarray;

    view_type x = **v_x;

    Kokkos::parallel_for("printBuffer", 1, KOKKOS_LAMBDA(const size_t id) {
        for (size_t idx = 0; idx < x.extent(0); idx++)
        {
            for (size_t idy = 0; idy < x.extent(1); idy++)
                Kokkos::printf("%d ", x(idx, idy));
            Kokkos::printf("\n");
        }
    });
    Kokkos::fence();

    return;
}
}