Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
coef.hip
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, The Neko Authors
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16
17 * Neither the name of the authors nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33*/
34
35#include <stdio.h>
36#include <hip/hip_runtime.h>
38#include <device/hip/check.h>
39#include "coef_kernel.h"
40
41extern "C" {
42
46 void hip_coef_generate_geo(void *G11, void *G12, void *G13,
47 void *G22, void *G23, void *G33,
48 void *drdx, void *drdy, void *drdz,
49 void *dsdx, void *dsdy, void *dsdz,
50 void *dtdx, void *dtdy, void *dtdz,
51 void *jacinv, void *w3, int *nel,
52 int *lx, int *gdim) {
53
54 const dim3 nthrds(1024, 1, 1);
55 const dim3 nblcks((*nel), 1, 1);
56
57#define GEO_CASE(LX) \
58 case LX: \
59 hipLaunchKernelGGL( \
60 HIP_KERNEL_NAME(coef_generate_geo_kernel<real, LX, 1024>), \
61 nblcks, nthrds, 0, (hipStream_t) glb_cmd_queue, \
62 (real *) G11, (real *) G12, (real *) G13, \
63 (real *) G22, (real *) G23, (real *) G33, \
64 (real *) drdx, (real *) drdy, (real *) drdz, \
65 (real *) dsdx, (real *) dsdy, (real *) dsdz, \
66 (real *) dtdx, (real *) dtdy, (real *) dtdz, \
67 (real *) jacinv, (real *) w3, *gdim); \
68 HIP_CHECK(hipGetLastError()); \
69 break
70
71 switch(*lx) {
72 GEO_CASE(2);
73 GEO_CASE(3);
74 GEO_CASE(4);
75 GEO_CASE(5);
76 GEO_CASE(6);
77 GEO_CASE(7);
78 GEO_CASE(8);
79 GEO_CASE(9);
80 GEO_CASE(10);
81 GEO_CASE(11);
82 GEO_CASE(12);
83 GEO_CASE(13);
84 GEO_CASE(14);
85 GEO_CASE(15);
86 GEO_CASE(16);
87 default:
88 {
89 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
90 exit(1);
91 }
92 }
93 }
94
98 void hip_coef_generate_dxyzdrst(void *drdx, void *drdy, void *drdz,
99 void *dsdx, void *dsdy, void *dsdz,
100 void *dtdx, void *dtdy, void *dtdz,
101 void *dxdr, void *dydr, void *dzdr,
102 void *dxds, void *dyds, void *dzds,
103 void *dxdt, void *dydt, void *dzdt,
104 void *dx, void *dy, void *dz,
105 void *x, void *y, void *z,
106 void *jacinv, void *jac,
107 int *lx, int *nel) {
108
109 const int n = (*nel) * (*lx) * (*lx) * (*lx);
110 const dim3 nthrds(1024, 1, 1);
111 const dim3 nblcks_dxyz((*nel), 1, 1);
112 const dim3 nblcks_drst((n + 1024 - 1)/ 1024, 1, 1);
113
114#define DXYZDRST_CASE(LX) \
115 case LX: \
116 hipLaunchKernelGGL( \
117 HIP_KERNEL_NAME(coef_generate_dxyz_kernel<real, LX, 1024>), \
118 nblcks_dxyz, nthrds, 0, (hipStream_t) glb_cmd_queue, \
119 (real *) dxdr, (real *) dydr, (real *) dzdr, \
120 (real *) dxds, (real *) dyds, (real *) dzds, \
121 (real *) dxdt, (real *) dydt, (real *) dzdt, \
122 (real *) dx, (real *) dy, (real *) dz, \
123 (real *) x, (real *) y, (real *) z); \
124 HIP_CHECK(hipGetLastError()); \
125 break
126
127 switch(*lx) {
128 DXYZDRST_CASE(2);
129 DXYZDRST_CASE(3);
130 DXYZDRST_CASE(4);
131 DXYZDRST_CASE(5);
132 DXYZDRST_CASE(6);
133 DXYZDRST_CASE(7);
134 DXYZDRST_CASE(8);
135 DXYZDRST_CASE(9);
136 DXYZDRST_CASE(10);
137 DXYZDRST_CASE(11);
138 DXYZDRST_CASE(12);
139 DXYZDRST_CASE(13);
140 DXYZDRST_CASE(14);
141 DXYZDRST_CASE(15);
142 DXYZDRST_CASE(16);
143 default:
144 {
145 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
146 exit(1);
147 }
148 }
149
151 nblcks_drst, nthrds, 0, (hipStream_t) glb_cmd_queue,
152 (real *) jac, (real *) jacinv,
153 (real *) drdx, (real *) drdy, (real *) drdz,
154 (real *) dsdx, (real *) dsdy, (real *) dsdz,
155 (real *) dtdx, (real *) dtdy, (real *) dtdz,
156 (real *) dxdr, (real *) dydr, (real *) dzdr,
157 (real *) dxds, (real *) dyds, (real *) dzds,
158 (real *) dxdt, (real *) dydt, (real *) dzdt, n);
160
161 }
162}
void hip_coef_generate_geo(void *G11, void *G12, void *G13, void *G22, void *G23, void *G33, void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *jacinv, void *w3, int *nel, int *lx, int *gdim)
Definition coef.hip:46
void hip_coef_generate_dxyzdrst(void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *dxdr, void *dydr, void *dzdr, void *dxds, void *dyds, void *dzds, void *dxdt, void *dydt, void *dzdt, void *dx, void *dy, void *dz, void *x, void *y, void *z, void *jacinv, void *jac, int *lx, int *nel)
Definition coef.hip:98
#define GEO_CASE(LX)
#define DXYZDRST_CASE(LX)
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ jacinv
__global__ void const T *__restrict__ x
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w3
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
double real
#define HIP_CHECK(err)
Definition check.h:8