File: reduction_select.hpp

package info (click to toggle)
gridtools 2.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,480 kB
  • sloc: cpp: 228,792; python: 17,561; javascript: 9,164; ansic: 4,101; sh: 850; makefile: 231; f90: 201
file content (84 lines) | stat: -rw-r--r-- 2,100 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * GridTools
 *
 * Copyright (c) 2014-2023, ETH Zurich
 * All rights reserved.
 *
 * Please, refer to the LICENSE file in the root directory.
 * SPDX-License-Identifier: BSD-3-Clause
 */
#pragma once

#include <type_traits>

#include <gridtools/meta.hpp>

// reduction backend
#if defined(GT_REDUCTION_NAIVE)
#ifndef GT_STENCIL_NAIVE
#define GT_STENCIL_NAIVE
#endif
#ifndef GT_STORAGE_CPU_KFIRST
#define GT_STORAGE_CPU_KFIRST
#endif
#ifndef GT_TIMER_DUMMY
#define GT_TIMER_DUMMY
#endif
#include <gridtools/reduction/naive.hpp>
namespace {
    using reduction_backend_t = gridtools::reduction::naive;
}
#elif defined(GT_REDUCTION_CPU)
#ifndef GT_STENCIL_CPU_IFIRST
#define GT_STENCIL_CPU_IFIRST
#endif
#ifndef GT_STORAGE_CPU_IFIRST
#define GT_STORAGE_CPU_IFIRST
#endif
#ifndef GT_TIMER_OMP
#define GT_TIMER_OMP
#endif
#include <gridtools/reduction/cpu.hpp>
namespace {
    using reduction_backend_t = gridtools::reduction::cpu;
}
#elif defined(GT_REDUCTION_GPU)
#ifndef GT_STENCIL_GPU
#define GT_STENCIL_GPU
#endif
#ifndef GT_STORAGE_GPU
#define GT_STORAGE_GPU
#endif
#ifndef GT_TIMER_CUDA
#define GT_TIMER_CUDA
#endif
#include <gridtools/reduction/gpu.hpp>
namespace {
    using reduction_backend_t = gridtools::reduction::gpu;
}
#endif

#include "stencil_select.hpp"
#include "storage_select.hpp"
#include "timer_select.hpp"

namespace gridtools {
    namespace reduction {
        struct naive;
        storage::cpu_kfirst backend_storage_traits(naive);
        timer_dummy backend_timer_impl(naive);
        inline char const *backend_name(naive const &) { return "naive"; }

        struct cpu;
        storage::cpu_ifirst backend_storage_traits(cpu);
        timer_omp backend_timer_impl(cpu);
        inline char const *backend_name(cpu const &) { return "cpu"; }

        namespace gpu_backend {
            struct gpu;
            storage::gpu backend_storage_traits(gpu);
            timer_cuda backend_timer_impl(gpu);
            inline char const *backend_name(gpu const &) { return "gpu"; }
        } // namespace gpu_backend
    }     // namespace reduction
} // namespace gridtools