Neko  0.9.0
A portable framework for high-order spectral element flow simulations
ax_helm_full.cu
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 <device/device_config.h>
39 #include <device/cuda/check.h>
40 #include "ax_helm_full_kernel.h"
41 
42 extern "C" {
43  #include <common/neko_log.h>
44 }
45 
46 extern "C" {
47 
51  void cuda_ax_helm_stress_vector(void *au, void *av, void *aw,
52  void *u, void *v, void *w,
53  void *dx, void *dy, void *dz,
54  void *dxt, void *dyt, void *dzt,
55  void *h1,
56  void *drdx, void *drdy, void *drdz,
57  void *dsdx, void *dsdy, void *dsdz,
58  void *dtdx, void *dtdy, void *dtdz,
59  void *jacinv, void *w3, int *nelv, int *lx) {
60 
61  const dim3 nthrds((*lx), (*lx), 1);
62  const dim3 nblcks((*nelv), 1, 1);
63  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
64 
65 #define CASE_VECTOR_KSTEP(LX) \
66  ax_helm_stress_kernel_vector_kstep<real, LX> \
67  <<<nblcks, nthrds, 0, stream>>> ((real *) au, (real *) av, (real *) aw, \
68  (real *) u, (real *) v, (real *) w, \
69  (real *) dx, (real *) dy, (real *) dz, (real *) h1,\
70  (real *) drdx, (real *) drdy, (real *) drdz, \
71  (real *) dsdx, (real *) dsdy, (real *) dsdz, \
72  (real *) dtdx, (real *) dtdy, (real *) dtdz, \
73  (real *) jacinv, (real *) w3); \
74  CUDA_CHECK(cudaGetLastError());
75 
76 #define CASE_VECTOR_KSTEP_PADDED(LX) \
77  ax_helm_stress_kernel_vector_kstep_padded<real, LX> \
78  <<<nblcks, nthrds, 0, stream>>> ((real *) au, (real *) av, (real *) aw, \
79  (real *) u, (real *) v, (real *) w, \
80  (real *) dx, (real *) dy, (real *) dz, (real *) h1,\
81  (real *) drdx, (real *) drdy, (real *) drdz, \
82  (real *) dsdx, (real *) dsdy, (real *) dsdz, \
83  (real *) dtdx, (real *) dtdy, (real *) dtdz, \
84  (real *) jacinv, (real *) w3); \
85  CUDA_CHECK(cudaGetLastError());
86 
87 #define CASE_VECTOR(LX) \
88  case LX: \
89  CASE_VECTOR_KSTEP(LX); \
90  break
91 
92 #define CASE_VECTOR_PADDED(LX) \
93  case LX: \
94  CASE_VECTOR_KSTEP_PADDED(LX); \
95  break
96 
97  switch(*lx) {
98  CASE_VECTOR(2);
99  CASE_VECTOR(3);
101  CASE_VECTOR(5);
102  CASE_VECTOR(6);
103  CASE_VECTOR(7);
105  CASE_VECTOR(9);
106  CASE_VECTOR(10);
107  CASE_VECTOR(11);
108  CASE_VECTOR(12);
109  CASE_VECTOR(13);
110  CASE_VECTOR(14);
111  CASE_VECTOR(15);
112  CASE_VECTOR_PADDED(16);
113  default:
114  {
115  fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
116  exit(1);
117  }
118  }
119  }
120 
124  void cuda_ax_helm_stress_vector_part2(void *au, void *av, void *aw,
125  void *u, void *v, void *w,
126  void *h2, void *B, int *n) {
127 
128  const dim3 nthrds(1024, 1, 1);
129  const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
130  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
131 
132  ax_helm_stress_kernel_vector_part2<real>
133  <<<nblcks, nthrds, 0, stream>>> ((real *) au, (real *) av, (real *) aw,
134  (real *) u, (real *) v, (real *) w,
135  (real *) h2, (real *) B, *n);
136  }
137 
138 }
#define CASE_VECTOR(LX)
void cuda_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)
Definition: ax_helm_full.cu:51
void cuda_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