Neko  0.9.99
A portable framework for high-order spectral element flow simulations
ax_helm_full.hip
Go to the documentation of this file.
1 /*
2  Copyright (c) 2024, 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 <string.h>
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <hip/hip_runtime.h>
39 #include <device/device_config.h>
40 #include <device/hip/check.h>
41 #include "ax_helm_full_kernel.h"
42 
43 extern "C" {
44  #include <common/neko_log.h>
45 }
46 
47 extern "C" {
48 
52  void hip_ax_helm_stress_vector(void *au, void *av, void *aw,
53  void *u, void *v, void *w,
54  void *dx, void *dy, void *dz,
55  void *dxt, void *dyt, void *dzt,
56  void *h1,
57  void *drdx, void *drdy, void *drdz,
58  void *dsdx, void *dsdy, void *dsdz,
59  void *dtdx, void *dtdy, void *dtdz,
60  void *jacinv, void *w3, int *nelv, int *lx) {
61 
62  const dim3 nthrds((*lx), (*lx), 1);
63  const dim3 nblcks((*nelv), 1, 1);
64 
65 #define CASE_VECTOR_KSTEP(LX) \
66  hipLaunchKernelGGL( HIP_KERNEL_NAME( ax_helm_stress_kernel_vector_kstep<real, LX> ), \
67  nblcks, nthrds, 0, \
68  (hipStream_t) glb_cmd_queue, \
69  (real *) au, (real *) av, (real *) aw, \
70  (real *) u, (real *) v, (real *) w, \
71  (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
72  (real *) drdx, (real *) drdy, (real *) drdz, \
73  (real *) dsdx, (real *) dsdy, (real *) dsdz, \
74  (real *) dtdx, (real *) dtdy, (real *) dtdz, \
75  (real *) jacinv, (real *) w3); \
76  HIP_CHECK(hipGetLastError());
77 
78 #define CASE_VECTOR_KSTEP_PADDED(LX) \
79  hipLaunchKernelGGL( HIP_KERNEL_NAME( ax_helm_stress_kernel_vector_kstep_padded<real, LX> ), \
80  nblcks, nthrds, 0, \
81  (hipStream_t) glb_cmd_queue, \
82  (real *) au, (real *) av, (real *) aw, \
83  (real *) u, (real *) v, (real *) w, \
84  (real *) dx, (real *) dy, (real *) dz, (real *) h1, \
85  (real *) drdx, (real *) drdy, (real *) drdz, \
86  (real *) dsdx, (real *) dsdy, (real *) dsdz, \
87  (real *) dtdx, (real *) dtdy, (real *) dtdz, \
88  (real *) jacinv, (real *) w3); \
89  HIP_CHECK(hipGetLastError());
90 
91 #define CASE_VECTOR(LX) \
92  case LX: \
93  CASE_VECTOR_KSTEP(LX); \
94  break
95 
96 #define CASE_VECTOR_PADDED(LX) \
97  case LX: \
98  CASE_VECTOR_KSTEP_PADDED(LX); \
99  break
100 
101  switch(*lx) {
102  CASE_VECTOR(2);
103  CASE_VECTOR(3);
105  CASE_VECTOR(5);
106  CASE_VECTOR(6);
107  CASE_VECTOR(7);
109  CASE_VECTOR(9);
110  CASE_VECTOR(10);
111  CASE_VECTOR(11);
112  CASE_VECTOR(12);
113  CASE_VECTOR(13);
114  CASE_VECTOR(14);
115  CASE_VECTOR(15);
116  CASE_VECTOR_PADDED(16);
117  default:
118  {
119  fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
120  exit(1);
121  }
122  }
123  }
124 
128  void hip_ax_helm_stress_vector_part2(void *au, void *av, void *aw,
129  void *u, void *v, void *w,
130  void *h2, void *B, int *n) {
131 
132  const dim3 nthrds(1024, 1, 1);
133  const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
134  const hipStream_t stream = (hipStream_t) glb_cmd_queue;
135 
136  hipLaunchKernelGGL( HIP_KERNEL_NAME( ax_helm_stress_kernel_vector_part2<real> ),
137  nblcks, nthrds, 0, stream,
138  (real *) au, (real *) av, (real *) aw,
139  (real *) u, (real *) v, (real *) w,
140  (real *) h2, (real *) B, *n);
141  }
142 
143 }
#define CASE_VECTOR(LX)
void hip_ax_helm_stress_vector(void *au, void *av, void *aw, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *dxt, void *dyt, void *dzt, void *h1, void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *jacinv, void *w3, int *nelv, int *lx)
void hip_ax_helm_stress_vector_part2(void *au, void *av, void *aw, void *u, void *v, void *w, void *h2, void *B, int *n)
#define CASE_VECTOR_PADDED(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__ aw
__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__ w
__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__ u
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void T *__restrict__ av
__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__ v
__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__ const T *__restrict__ const T *__restrict__ h1
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w3
Definition: cdtp_kernel.h:113
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dzt
Definition: cdtp_kernel.h:112
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dyt
Definition: cdtp_kernel.h:111
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dxt
Definition: cdtp_kernel.h:110
double real
Definition: device_config.h:12
void * glb_cmd_queue