Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
local_interpolation.c
Go to the documentation of this file.
1/*
2 Copyright (c) 2022-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 "local_interpolation_kernel.cl.h"
51
56 void *pt_x, void* pt_y, void* pt_z,
57 void *x_hat, void *y_hat, void *z_hat,
58 void *resx, void *resy, void *resz,
59 int *lx, void *el_ids, int *n_pt, real *tol,
60 void *conv_pts) {
61 cl_int err;
65
66 size_t global_kstep[2];
67 size_t local_kstep[2];
68 local_kstep[0] = 1;
69 local_kstep[1] = 128;
70 global_kstep[0] = (*n_pt);
71 global_kstep[1] = 128;
72
73#define STR(X) #X
74#define CASE(LX) \
75 case LX: \
76 { \
77 cl_kernel kernel = \
78 clCreateKernel(find_rst_legendre_program, \
79 STR(find_rst_legendre_kernel_lx##LX), &err); \
80 CL_CHECK(err); \
81 \
82 CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &rst)); \
83 CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &pt_x)); \
84 CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &pt_y)); \
85 CL_CHECK(clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &pt_z)); \
86 CL_CHECK(clSetKernelArg(kernel, 4, sizeof(cl_mem), (void *) &x_hat)); \
87 CL_CHECK(clSetKernelArg(kernel, 5, sizeof(cl_mem), (void *) &y_hat)); \
88 CL_CHECK(clSetKernelArg(kernel, 6, sizeof(cl_mem), (void *) &z_hat)); \
89 CL_CHECK(clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &resx)); \
90 CL_CHECK(clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &resy)); \
91 CL_CHECK(clSetKernelArg(kernel, 9, sizeof(cl_mem), (void *) &resz)); \
92 CL_CHECK(clSetKernelArg(kernel, 10, sizeof(cl_mem), (void *) &el_ids)); \
93 CL_CHECK(clSetKernelArg(kernel, 11, sizeof(int), n_pt)); \
94 CL_CHECK(clSetKernelArg(kernel, 12, sizeof(real), tol)); \
95 CL_CHECK(clSetKernelArg(kernel, 13, sizeof(cl_mem), (void *) &conv_pts));\
96 \
97 CL_CHECK(clEnqueueNDRangeKernel((cl_command_queue) glb_cmd_queue, \
98 kernel, 2, NULL, global_kstep, \
99 local_kstep, 0, NULL, NULL)); \
100 \
101 } \
102 break
103
104 switch(*lx) {
105 CASE(2);
106 CASE(3);
107 CASE(4);
108 CASE(5);
109 CASE(6);
110 CASE(7);
111 CASE(8);
112 CASE(9);
113 CASE(10);
114 CASE(11);
115 CASE(12);
116 CASE(13);
117 CASE(14);
118 CASE(15);
119 CASE(16);
120 default:
121 {
122 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
123 exit(1);
124 }
125 }
126}
127
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
double real
void opencl_kernel_jit(const char *kernel, cl_program *program)
Definition jit.c:50
void opencl_find_rst_legendre(void *rst, void *pt_x, void *pt_y, void *pt_z, void *x_hat, void *y_hat, void *z_hat, void *resx, void *resy, void *resz, int *lx, void *el_ids, int *n_pt, real *tol, void *conv_pts)
#define CASE(LX)
void * find_rst_legendre_program