Skip to content

Commit 40efa59

Browse files
committed
Finished changing code but needs debugging since there are output errors
1 parent 5a390ef commit 40efa59

File tree

4 files changed

+142
-349
lines changed

4 files changed

+142
-349
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef __DIAG_RECIPROCAL__
2+
#define __DIAG_RECIPROCAL__
3+
4+
#include <CL/sycl.hpp>
5+
#include <sycl/ext/intel/fpga_extensions.hpp>
6+
7+
#include "mvdr_complex.hpp"
8+
9+
// SubmitDiagReciprocalKernel
10+
// Accept an upper-triangular R Matrix from QR Decomposition from StreamingQRD.
11+
// Compute the reciprocals of the diagonal and write them to an output pipe.
12+
13+
template <typename DiagReciprocalKernelName, // name to use for kernel
14+
size_t k_r_num_rows, // Number of rows in R Matrix
15+
typename RMatrixInPipe, // The R Matrix input
16+
typename RDiagRecipVectorOutPipe // 1 / values on diagonal of R Matrix input
17+
>
18+
event SubmitDiagReciprocalKernel(queue& q) {
19+
auto e = q.submit([&](handler& h) {
20+
h.single_task<DiagReciprocalKernelName>([=] {
21+
22+
//calculate total number of elements passed in for one processing iteration
23+
constexpr int elements = k_r_num_rows * (k_r_num_rows + 1) / 2;
24+
25+
while (1) {
26+
int row = 1;
27+
int col = 1;
28+
for (int i = 0; i < elements; i++) {
29+
ComplexType in = RMatrixInPipe::read();
30+
31+
if (row == col) {
32+
RDiagRecipVectorOutPipe::write(1/in.real());
33+
}
34+
35+
//calculate next element's row and col
36+
if (col == k_r_num_rows) {
37+
col = row + 1;
38+
row++;
39+
}
40+
else {
41+
col++;
42+
}
43+
}
44+
}
45+
46+
47+
}); // end of h.single_task
48+
}); // end of q.submit
49+
50+
return e;
51+
}
52+
53+
54+
#endif /* __DIAG_RECIPROCAL__ */

DirectProgramming/DPC++FPGA/ReferenceDesigns/mvdr_beamforming/src/MVDR.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include "ForwardSubstitution.hpp"
1717
#include "InputDemux.hpp"
1818
#include "SteeringVectorGenerator.hpp"
19-
#include "StreamingQRD.hpp"
19+
#include "StreamingQRDWrapper.hpp"
20+
#include "DiagReciprocal.hpp"
2021
#include "Transpose.hpp"
2122

2223
using namespace sycl;
@@ -27,6 +28,7 @@ enum class MVDRKernelNames {
2728
input_demux,
2829
transpose,
2930
streaming_qrd,
31+
diag_reciprocal,
3032
steering_vector_generator,
3133
forward_substitution,
3234
backward_substitution,
@@ -48,6 +50,8 @@ class Transpose;
4850
template <size_t k_instance_num>
4951
class StreamingQRD;
5052
template <size_t k_instance_num>
53+
class DiagReciprocal;
54+
template <size_t k_instance_num>
5155
class SteeringVectorGenerator;
5256
template <size_t k_instance_num>
5357
class ForwardSubstitution;
@@ -242,12 +246,13 @@ MVDREventArray SubmitMVDRKernels(
242246
((k_num_sensor_inputs * (k_num_sensor_inputs + 1)) / 2) * 2;
243247
using RMatrixPipes =
244248
fpga_tools::PipeArray<RMatrixPipesID<k_instance_num>, ComplexType,
245-
kRMatrixPipeMinDepth, 2>;
249+
kRMatrixPipeMinDepth, 3>;
246250
using RMatrixFSPipe = typename RMatrixPipes::template PipeAt<0>;
247251
using RMatrixBSPipe = typename RMatrixPipes::template PipeAt<1>;
252+
using RMatrixDRPipe = typename RMatrixPipes::template PipeAt<2>;
248253
using RMatrixDupPipe =
249254
fpga_tools::PipeDuplicator<RMatrixDupPipeID<k_instance_num>, ComplexType,
250-
RMatrixFSPipe, RMatrixBSPipe, RMatrixPipeOut>;
255+
RMatrixFSPipe, RMatrixBSPipe, RMatrixDRPipe, RMatrixPipeOut>;
251256
constexpr int kRDiagRecipVectorPipeMinDepth = k_num_sensor_inputs * 2;
252257
using RDiagRecipVectorPipes =
253258
fpga_tools::PipeArray<RDiagRecipVectorPipesID<k_instance_num>, float,
@@ -297,7 +302,7 @@ MVDREventArray SubmitMVDRKernels(
297302
// Q matrix pipe
298303
// Q matrix not used in MVDR design, so this is a 'null' pipe (a
299304
// PipeDuplicator with no output pipes connected)
300-
using QMatrixColumn = fpga_tools::NTuple<ComplexType, k_num_sensor_inputs>;
305+
using QMatrixColumn = fpga_tools::NTuple<ComplexType, k_num_complex_per_xrx_read>;
301306
using QMatrixPipe =
302307
fpga_tools::PipeDuplicator<QMatrixPipeID<k_instance_num>, QMatrixColumn>;
303308

@@ -359,8 +364,15 @@ MVDREventArray SubmitMVDRKernels(
359364
k_num_complex_per_xrx_read, // number of elements per pipe read
360365
TransposedTrainingDataPipe, // A matrix input
361366
QMatrixPipe, // Q output pipe (unused in MVDR)
362-
RMatrixDupPipe, // R output pipe
363-
RDiagRecipVectorDupPipe // 1 / the value of each diagonal entry of R
367+
RMatrixDupPipe // R output pipe
368+
>(q);
369+
370+
events[static_cast<int>(MVDRKernelNames::diag_reciprocal)] =
371+
SubmitDiagReciprocalKernel<
372+
DiagReciprocal<k_instance_num>, // Name to use for the Kernel
373+
k_num_sensor_inputs, // number of rows of the R matrix
374+
RMatrixDRPipe, // Input R pipe
375+
RDiagRecipVectorDupPipe // Output pipe for reciprocals
364376
>(q);
365377

366378
events[static_cast<int>(MVDRKernelNames::forward_substitution)] =

0 commit comments

Comments
 (0)