|
| 1 | +/* |
| 2 | + * Copyright (C) 2019-2022, Xilinx, Inc. |
| 3 | + * Copyright (C) 2022-2023, Advanced Micro Devices, Inc. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#ifndef __KERNEL_APODIZATION_H__ |
| 19 | +#define __KERNEL_APODIZATION_H__ |
| 20 | + |
| 21 | +#include <adf.h> |
| 22 | +#include <kernels.hpp> |
| 23 | + |
| 24 | +namespace us { |
| 25 | +namespace L1 { |
| 26 | + |
| 27 | +// declare param |
| 28 | +template <class T> |
| 29 | +struct para_Apodization { |
| 30 | + int iter_line; |
| 31 | + int iter_element; |
| 32 | + int iter_seg; |
| 33 | + int num_line; |
| 34 | + int num_element; |
| 35 | + int num_seg; |
| 36 | + int num_dep_seg; // = num_depth / num_seg = 512 |
| 37 | + T f_num; |
| 38 | + T tileVApo_x; |
| 39 | + T tileVApo_z; |
| 40 | + T ref_point_x; |
| 41 | + T ref_point_z; |
| 42 | + void print() { |
| 43 | + printf("apo: <%d/%d lines, %d/%d elements, %d/%d segments>\n", iter_line, num_line, iter_element, num_element, |
| 44 | + iter_seg, num_seg); |
| 45 | + } |
| 46 | + void update() { |
| 47 | + if (iter_seg != num_seg - 1) |
| 48 | + iter_seg++; |
| 49 | + else { |
| 50 | + iter_seg = 0; |
| 51 | + if (iter_element != num_element - 1) |
| 52 | + iter_element++; |
| 53 | + else { |
| 54 | + iter_element = 0; |
| 55 | + iter_line++; |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +//---------------------------------------------------- |
| 62 | +// brief |
| 63 | +// apodization_preprocess |
| 64 | +//---1.top function to switch between vector and scaler version |
| 65 | +//---2.top function to test top graph connection only, no calculation |
| 66 | +// apodization_main_precess |
| 67 | +//---3.top function to switch between vector and scaler version |
| 68 | +//---4.top function to test top graph connection only, no calculation |
| 69 | +//---------------------------------------------------- |
| 70 | + |
| 71 | +template <typename T, int LEN_OUT, int LEN_IN, int VECDIM, int APODI_PRE_LEN32b_PARA> |
| 72 | +void kfun_apodization_pre(adf::output_buffer<T, adf::extents<LEN_OUT> >& __restrict p_invD_out, |
| 73 | + adf::input_buffer<T, adf::extents<LEN_IN> >& __restrict p_points_x_in, |
| 74 | + adf::input_buffer<T, adf::extents<LEN_IN> >& __restrict p_points_z_in, |
| 75 | + const int (¶_const)[APODI_PRE_LEN32b_PARA]); |
| 76 | + |
| 77 | +template <typename T, int LEN_OUT, int LEN_IN, int VECDIM, int APODI_PRE_LEN32b_PARA> |
| 78 | +void kfun_apodization_pre_shell(adf::output_buffer<T, adf::extents<LEN_OUT> >& __restrict p_invD_out, |
| 79 | + adf::input_buffer<T, adf::extents<LEN_IN> >& __restrict p_points_x_in, |
| 80 | + adf::input_buffer<T, adf::extents<LEN_IN> >& __restrict p_points_z_in, |
| 81 | + const int (¶_const)[APODI_PRE_LEN32b_PARA]); |
| 82 | + |
| 83 | +template <typename T, int LEN_OUT, int LEN_IN_F, int LEN_IN_D, int VECDIM, int APODI_PRE_LEN32b_PARA> |
| 84 | +void __attribute__((noinline)) |
| 85 | +kfun_apodization_main(adf::output_buffer<T, adf::extents<LEN_OUT> >& __restrict p_apodization_out, |
| 86 | + adf::input_buffer<T, adf::extents<LEN_IN_F> >& __restrict p_focal_in, |
| 87 | + adf::input_buffer<T, adf::extents<LEN_IN_D> >& __restrict p_invD_in, |
| 88 | + const int (¶_const)[APODI_PRE_LEN32b_PARA]); |
| 89 | + |
| 90 | +template <typename T, int LEN_OUT, int LEN_IN_F, int LEN_IN_D, int VECDIM, int APODI_PRE_LEN32b_PARA> |
| 91 | +void kfun_apodization_main_shell( |
| 92 | + // output_stream<T>* p_apodization_out, |
| 93 | + adf::output_buffer<T, adf::extents<LEN_OUT> >& __restrict p_apodization_out, |
| 94 | + adf::input_buffer<T, adf::extents<LEN_IN_F> >& __restrict p_focal_in, |
| 95 | + adf::input_buffer<T, adf::extents<LEN_IN_D> >& __restrict p_invD_in, |
| 96 | + const int (¶_const)[APODI_PRE_LEN32b_PARA]); |
| 97 | + |
| 98 | +} // namespace L1 |
| 99 | +} // namespace us |
| 100 | + |
| 101 | +#endif //__KERNEL_APODIZATION_H__ |
0 commit comments