Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ale_kinematics.c
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, 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
42#include <device/opencl/check.h>
43#include <device/opencl/jit.h>
45
46#include "ale_kinematics_kernel.cl.h"
47
53typedef struct {
54 real cx, cy, cz;
55 real vtx, vty, vtz;
56 real vax, vay, vaz;
57 real px, py, pz;
58 real r11, r12, r13;
59 real r21, r22, r23;
60 real r31, r32, r33;
62
64void add_kinematics_to_mesh_velocity_opencl(void *wx, void *wy, void *wz,
65 void *x_ref, void *y_ref,
66 void *z_ref, void *phi,
67 void *x, void *y, void *z,
69 int n) {
70 cl_int err;
71
72 if (n < 1) return;
73
77 }
78
80 "ale_add_kinematics_kernel", &err);
82
83 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(int), (void *) &n));
84 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &wx));
85 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &wy));
86 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &wz));
87 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(cl_mem), (void *) &x_ref));
88 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(cl_mem), (void *) &y_ref));
89 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(cl_mem), (void *) &z_ref));
90 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &phi));
91 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &x));
92 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &y));
93 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(cl_mem), (void *) &z));
95 (void *) &kin_params));
96
97 const int nb = (n + 256 - 1) / 256;
98 const size_t global_item_size = 256 * nb;
99 const size_t local_item_size = 256;
100
103 &local_item_size, 0, NULL, NULL));
104
106}
107
109void compute_cheap_dist_opencl(void *d_d, void *x_d, void *y_d, void *z_d,
110 int lx, int ly, int lz, int nel,
111 int local_iters, void *nchange_d) {
112 cl_int err;
113
114 if (nel < 1) return;
115
119 }
120
122 "compute_cheap_dist_kernel", &err);
123 CL_CHECK(err);
124
125 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &d_d));
126 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &x_d));
127 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &y_d));
128 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &z_d));
129 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(int), (void *) &lx));
130 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(int), (void *) &ly));
131 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(int), (void *) &lz));
132 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(int), (void *) &nel));
133 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(int), (void *) &local_iters));
134 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &nchange_d));
135
136 const int nb = (nel + 256 - 1) / 256;
137 const size_t global_item_size = 256 * nb;
138 const size_t local_item_size = 256;
139
142 &local_item_size, 0, NULL, NULL));
143
145}
void add_kinematics_to_mesh_velocity_opencl(void *wx, void *wy, void *wz, void *x_ref, void *y_ref, void *z_ref, void *phi, void *x, void *y, void *z, kinematics_params_t kin_params, int n)
void compute_cheap_dist_opencl(void *d_d, void *x_d, void *y_d, void *z_d, int lx, int ly, int lz, int nel, int local_iters, void *nchange_d)
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
__global__ void const T *__restrict__ x
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ cz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ cx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ cy
double real
void opencl_kernel_jit(const char *kernel, cl_program *program)
Definition jit.c:50
#define CL_CHECK(err)
Definition check.h:12
void * ale_kinematics_program