Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
constrain_mixed_bc.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/jit.h>
44#include <device/opencl/check.h>
45
46#include "constrain_mixed_bc_kernel.cl.h"
47
48void opencl_constrain_mixed_bc_zero(void *mixed_msk, void *x, void *y,
49 void *z, int *constraint_n,
50 int *constraint_t1, int *constraint_t2,
51 void *n, void *t1, void *t2, int *m,
53 if (*m <= 0)
54 return;
55
56 cl_int err;
57
61
63 "constrain_mixed_bc_zero_kernel", &err);
65
66 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &mixed_msk));
67 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &x));
68 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &y));
69 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &z));
70 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(int), constraint_n));
71 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(int), constraint_t1));
72 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(int), constraint_t2));
73 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &n));
74 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &t1));
75 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &t2));
76 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(int), m));
77
78 const int nb = ((*m) + 256 - 1) / 256;
79 const size_t global_item_size = 256 * nb;
80 const size_t local_item_size = 256;
81
84 0, NULL, NULL));
86}
87
88void opencl_constrain_mixed_bc_set(void *mixed_msk, void *x, void *y,
89 void *z, int *constraint_n,
90 int *constraint_t1, int *constraint_t2,
91 void *n, void *t1, void *t2,
92 void *values_n, void *values_t1,
93 void *values_t2, int *m,
95 if (*m <= 0)
96 return;
97
98 cl_int err;
99
103
105 "constrain_mixed_bc_set_kernel", &err);
106 CL_CHECK(err);
107
108 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &mixed_msk));
109 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &x));
110 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &y));
111 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &z));
112 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(int), constraint_n));
113 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(int), constraint_t1));
114 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(int), constraint_t2));
115 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &n));
116 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &t1));
117 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &t2));
118 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(cl_mem), (void *) &values_n));
119 CL_CHECK(clSetKernelArg(kernel, 11, sizeof(cl_mem), (void *) &values_t1));
120 CL_CHECK(clSetKernelArg(kernel, 12, sizeof(cl_mem), (void *) &values_t2));
121 CL_CHECK(clSetKernelArg(kernel, 13, sizeof(int), m));
122
123 const int nb = ((*m) + 256 - 1) / 256;
124 const size_t global_item_size = 256 * nb;
125 const size_t local_item_size = 256;
126
129 0, NULL, NULL));
131}
132
134 void *z, int *constraint_n,
135 int *constraint_t1,
136 int *constraint_t2, void *n,
137 void *t1, void *t2, real *value_n,
139 int *m,
141 if (*m <= 0)
142 return;
143
144 cl_int err;
145
149
151 "constrain_mixed_bc_set_const_kernel",
152 &err);
153 CL_CHECK(err);
154
155 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &mixed_msk));
156 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &x));
157 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &y));
158 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &z));
159 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(int), constraint_n));
160 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(int), constraint_t1));
161 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(int), constraint_t2));
162 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &n));
163 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &t1));
164 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &t2));
165 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(real), value_n));
168 CL_CHECK(clSetKernelArg(kernel, 13, sizeof(int), m));
169
170 const int nb = ((*m) + 256 - 1) / 256;
171 const size_t global_item_size = 256 * nb;
172 const size_t local_item_size = 256;
173
176 0, NULL, NULL));
178}
void opencl_constrain_mixed_bc_set(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, void *values_n, void *values_t1, void *values_t2, int *m, cl_command_queue cmd_queue)
void opencl_constrain_mixed_bc_set_const(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, real *value_n, real *value_t1, real *value_t2, int *m, cl_command_queue cmd_queue)
void opencl_constrain_mixed_bc_zero(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, int *m, cl_command_queue cmd_queue)
__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
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 * constrain_mixed_bc_program