Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_full.c
Go to the documentation of this file.
1/*
2 Copyright (c) 2025, 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#ifdef __APPLE__
36#include <OpenCL/cl.h>
37#else
38#include <CL/cl.h>
39#endif
40
41#include <stdlib.h>
42#include <stdio.h>
43#include <string.h>
45#include <device/opencl/jit.h>
47#include <device/opencl/check.h>
48#include <common/neko_log.h>
49
50#include "ax_helm_full_kernel.cl.h"
51
55void opencl_ax_helm_stress_vector(void *au, void *av, void *aw,
56 void *u, void *v, void *w,
57 void *dx, void *dy, void *dz,
58 void *dxt, void *dyt, void *dzt,
59 void *h1,
60 void *drdx, void *drdy, void *drdz,
61 void *dsdx, void *dsdy, void *dsdz,
62 void *dtdx, void *dtdy, void *dtdz,
63 void *jacinv, void *w3, int *nelv, int *lx) {
64 cl_int err;
65
69
70 size_t global_kstep[2];
71 size_t local_kstep[2];
72 local_kstep[0] = (*lx);
73 local_kstep[1] = (*lx);
74 global_kstep[0] = (*nelv) * (*lx);
75 global_kstep[1] = (*lx);
76
77#define STR(X) #X
78#define CASE(LX) \
79 case LX: \
80 { \
81 cl_kernel kernel = \
82 clCreateKernel(ax_helm_full_program, \
83 STR(ax_helm_stress_kernel_full_lx##LX), &err); \
84 CL_CHECK(err); \
85 \
86 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &au)); \
87 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &av)); \
88 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &aw)); \
89 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &u)); \
90 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(cl_mem), (void *) &v)); \
91 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(cl_mem), (void *) &w)); \
92 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(cl_mem), (void *) &dx)); \
93 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &dy)); \
94 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &dz)); \
95 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &h1)); \
96 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(cl_mem), (void *) &drdx)); \
97 CL_CHECK(clSetKernelArg(kernel, 11, sizeof(cl_mem), (void *) &drdy)); \
98 CL_CHECK(clSetKernelArg(kernel, 12, sizeof(cl_mem), (void *) &drdz)); \
99 CL_CHECK(clSetKernelArg(kernel, 13, sizeof(cl_mem), (void *) &dsdx)); \
100 CL_CHECK(clSetKernelArg(kernel, 14, sizeof(cl_mem), (void *) &dsdy)); \
101 CL_CHECK(clSetKernelArg(kernel, 15, sizeof(cl_mem), (void *) &dsdz)); \
102 CL_CHECK(clSetKernelArg(kernel, 16, sizeof(cl_mem), (void *) &dtdx)); \
103 CL_CHECK(clSetKernelArg(kernel, 17, sizeof(cl_mem), (void *) &dtdy)); \
104 CL_CHECK(clSetKernelArg(kernel, 18, sizeof(cl_mem), (void *) &dtdz)); \
105 CL_CHECK(clSetKernelArg(kernel, 19, sizeof(cl_mem), (void *) &jacinv)); \
106 CL_CHECK(clSetKernelArg(kernel, 20, sizeof(cl_mem), (void *) &w3)); \
107 \
108 CL_CHECK(clEnqueueNDRangeKernel((cl_command_queue) glb_cmd_queue, \
109 kernel, 2, NULL, global_kstep, \
110 local_kstep, 0, NULL, NULL)); \
111 \
112 } \
113 break
114
115 switch(*lx) {
116 CASE(2);
117 CASE(3);
118 CASE(4);
119 CASE(5);
120 CASE(6);
121 CASE(7);
122 CASE(8);
123 CASE(9);
124 CASE(10);
125 CASE(11);
126 CASE(12);
127 CASE(13);
128 CASE(14);
129 CASE(15);
130 CASE(16);
131 default:
132 {
133 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
134 exit(1);
135 }
136 }
137}
138
143 void *u, void *v, void *w,
144 void *h2, void *B, int *n) {
145
146 cl_int err;
147
151
153 "ax_helm_stress_kernel_vector_part2", &err);
154 CL_CHECK(err);
155
156 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &au));
157 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &av));
158 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &aw));
159 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &u));
160 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(cl_mem), (void *) &v));
161 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(cl_mem), (void *) &w));
162 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(cl_mem), (void *) &h2));
163 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &B));
164 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(int), n));
165
166 const int nb = ((*n) + 256 - 1) / 256;
167 const size_t global_item_size = 256 * nb;
168 const size_t local_item_size = 256;
169
170 CL_CHECK(clEnqueueNDRangeKernel(glb_cmd_queue, kernel, 1, NULL,
172 0, NULL, NULL));
173
174}
void opencl_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)
#define CASE(LX)
void opencl_ax_helm_stress_vector_part2(void *au, void *av, void *aw, void *u, void *v, void *w, void *h2, void *B, int *n)
__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
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dzt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dyt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dxt
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
void opencl_kernel_jit(const char *kernel, cl_program *program)
Definition jit.c:50
#define CL_CHECK(err)
Definition check.h:12
void * ax_helm_full_program