This repository was archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path0001-migration-to-oneAPI.patch
11833 lines (11761 loc) · 437 KB
/
0001-migration-to-oneAPI.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 2c2496a1763f8fba1a428b1b237641dbba198df5 Mon Sep 17 00:00:00 2001
From: wangyon1 <[email protected]>
Date: Tue, 2 Feb 2021 15:08:51 +0800
Subject: [PATCH 1/4] migration to oneAPI
---
.../Beamformer/HilbertFirEnvelope.dp.cpp | 132 +++
.../SupraLib/Beamformer/HilbertFirEnvelope.h | 44 +
.../SupraLib/Beamformer/LogCompressor.dp.cpp | 90 ++
.../src/SupraLib/Beamformer/LogCompressor.h | 32 +
.../SupraLib/Beamformer/RxBeamformerCommon.h | 62 +
.../Beamformer/RxBeamformerCommon.h.yaml | 72 ++
.../Beamformer/RxBeamformerCuda.dp.cpp | 559 +++++++++
.../SupraLib/Beamformer/RxBeamformerCuda.h | 81 ++
.../Beamformer/RxBeamformerParameters.h | 109 ++
.../RxSampleBeamformerDelayAndStdDev.h | 245 ++++
.../RxSampleBeamformerDelayAndStdDev.h.yaml | 46 +
.../RxSampleBeamformerDelayAndSum.h | 186 +++
.../RxSampleBeamformerDelayAndSum.h.yaml | 30 +
.../Beamformer/RxSampleBeamformerTestSignal.h | 137 +++
.../RxSampleBeamformerTestSignal.h.yaml | 30 +
.../SupraLib/Beamformer/ScanConverter.dp.cpp | 931 +++++++++++++++
.../src/SupraLib/Beamformer/ScanConverter.h | 68 ++
oneapi/src/SupraLib/Beamformer/USRawData.h | 84 ++
oneapi/src/SupraLib/Beamformer/USTransducer.h | 125 ++
.../src/SupraLib/Beamformer/WindowFunction.h | 150 +++
.../SupraLib/Beamformer/WindowFunction.h.yaml | 160 +++
oneapi/src/SupraLib/Container.h | 329 +++++
oneapi/src/SupraLib/Container.h.yaml | 779 ++++++++++++
.../src/SupraLib/ContainerFactory.cpp.dp.cpp | 290 +++++
oneapi/src/SupraLib/ContainerFactory.h | 79 ++
oneapi/src/SupraLib/ContainerFactory.h.yaml | 22 +
oneapi/src/SupraLib/RecordObject.h | 62 +
oneapi/src/SupraLib/USImage.h | 133 +++
oneapi/src/SupraLib/USImageProperties.h | 208 ++++
oneapi/src/SupraLib/utilities/DataType.h | 90 ++
oneapi/src/SupraLib/utilities/DataType.h.yaml | 30 +
.../src/SupraLib/utilities/FirFilterFactory.h | 238 ++++
.../utilities/FirFilterFactory.h.yaml | 56 +
oneapi/src/SupraLib/utilities/Logging.h | 330 ++++++
oneapi/src/SupraLib/utilities/cudaUtility.h | 168 +++
.../src/SupraLib/utilities/cudaUtility.h.yaml | 311 +++++
oneapi/src/SupraLib/utilities/utility.h | 216 ++++
oneapi/src/SupraLib/utilities/utility.h.yaml | 22 +
oneapi/src/SupraLib/vec.h | 412 +++++++
oneapi/src/SupraLib/vec.h.yaml | 1056 +++++++++++++++++
.../Beamformer/HilbertFirEnvelope.dp.cpp | 132 +++
src/SupraLib/Beamformer/LogCompressor.dp.cpp | 90 ++
src/SupraLib/Beamformer/RxBeamformerCommon.h | 20 +-
.../Beamformer/RxBeamformerCuda.dp.cpp | 627 ++++++++++
.../RxSampleBeamformerDelayAndStdDev.h | 10 +-
.../RxSampleBeamformerDelayAndSum.h | 6 +-
.../Beamformer/RxSampleBeamformerTestSignal.h | 6 +-
src/SupraLib/Beamformer/ScanConverter.dp.cpp | 937 +++++++++++++++
src/SupraLib/Beamformer/WindowFunction.h | 36 +-
src/SupraLib/Container.h | 120 +-
src/SupraLib/ContainerFactory.cpp.dp.cpp | 290 +++++
src/SupraLib/ContainerFactory.h | 4 +-
src/SupraLib/utilities/DataType.h | 6 +-
src/SupraLib/utilities/FirFilterFactory.h | 11 +-
src/SupraLib/utilities/cudaUtility.h | 54 +-
src/SupraLib/utilities/utility.h | 2 +
src/SupraLib/vec.h | 168 ++-
57 files changed, 10526 insertions(+), 197 deletions(-)
create mode 100644 oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.dp.cpp
create mode 100644 oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.h
create mode 100644 oneapi/src/SupraLib/Beamformer/LogCompressor.dp.cpp
create mode 100644 oneapi/src/SupraLib/Beamformer/LogCompressor.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h.yaml
create mode 100644 oneapi/src/SupraLib/Beamformer/RxBeamformerCuda.dp.cpp
create mode 100644 oneapi/src/SupraLib/Beamformer/RxBeamformerCuda.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxBeamformerParameters.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerDelayAndStdDev.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerDelayAndStdDev.h.yaml
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerDelayAndSum.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerDelayAndSum.h.yaml
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerTestSignal.h
create mode 100644 oneapi/src/SupraLib/Beamformer/RxSampleBeamformerTestSignal.h.yaml
create mode 100644 oneapi/src/SupraLib/Beamformer/ScanConverter.dp.cpp
create mode 100644 oneapi/src/SupraLib/Beamformer/ScanConverter.h
create mode 100644 oneapi/src/SupraLib/Beamformer/USRawData.h
create mode 100644 oneapi/src/SupraLib/Beamformer/USTransducer.h
create mode 100644 oneapi/src/SupraLib/Beamformer/WindowFunction.h
create mode 100644 oneapi/src/SupraLib/Beamformer/WindowFunction.h.yaml
create mode 100644 oneapi/src/SupraLib/Container.h
create mode 100644 oneapi/src/SupraLib/Container.h.yaml
create mode 100644 oneapi/src/SupraLib/ContainerFactory.cpp.dp.cpp
create mode 100644 oneapi/src/SupraLib/ContainerFactory.h
create mode 100644 oneapi/src/SupraLib/ContainerFactory.h.yaml
create mode 100644 oneapi/src/SupraLib/RecordObject.h
create mode 100644 oneapi/src/SupraLib/USImage.h
create mode 100644 oneapi/src/SupraLib/USImageProperties.h
create mode 100644 oneapi/src/SupraLib/utilities/DataType.h
create mode 100644 oneapi/src/SupraLib/utilities/DataType.h.yaml
create mode 100644 oneapi/src/SupraLib/utilities/FirFilterFactory.h
create mode 100644 oneapi/src/SupraLib/utilities/FirFilterFactory.h.yaml
create mode 100644 oneapi/src/SupraLib/utilities/Logging.h
create mode 100644 oneapi/src/SupraLib/utilities/cudaUtility.h
create mode 100644 oneapi/src/SupraLib/utilities/cudaUtility.h.yaml
create mode 100644 oneapi/src/SupraLib/utilities/utility.h
create mode 100644 oneapi/src/SupraLib/utilities/utility.h.yaml
create mode 100644 oneapi/src/SupraLib/vec.h
create mode 100644 oneapi/src/SupraLib/vec.h.yaml
create mode 100644 src/SupraLib/Beamformer/HilbertFirEnvelope.dp.cpp
create mode 100644 src/SupraLib/Beamformer/LogCompressor.dp.cpp
create mode 100644 src/SupraLib/Beamformer/RxBeamformerCuda.dp.cpp
create mode 100644 src/SupraLib/Beamformer/ScanConverter.dp.cpp
create mode 100644 src/SupraLib/ContainerFactory.cpp.dp.cpp
diff --git a/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.dp.cpp b/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.dp.cpp
new file mode 100644
index 0000000..f2823f9
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.dp.cpp
@@ -0,0 +1,132 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2019, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+
+#include <CL/sycl.hpp>
+#include <dpct/dpct.hpp>
+#include "HilbertFirEnvelope.h"
+#include <utilities/utility.h>
+#include <utilities/FirFilterFactory.h>
+
+#include <dpct/dpl_utils.hpp>
+#include <oneapi/dpl/execution>
+#include <oneapi/dpl/algorithm>
+
+#include <algorithm>
+
+using namespace std;
+
+namespace supra
+{
+ template <typename InputType, typename OutputType>
+ void kernelFilterDemodulation(
+ const InputType* __restrict__ signal,
+ const HilbertFirEnvelope::WorkType * __restrict__ filter,
+ OutputType * __restrict__ out,
+ const int numSamples,
+ const int numScanlines,
+ const int filterLength,
+ sycl::nd_item<3> item_ct1) {
+ int scanlineIdx = item_ct1.get_local_range().get(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2);
+ int sampleIdx = item_ct1.get_local_range().get(1) * item_ct1.get_group(1) + item_ct1.get_local_id(1);
+
+ if (scanlineIdx < numScanlines && sampleIdx < numSamples)
+ {
+ HilbertFirEnvelope::WorkType accumulator = 0;
+
+ int startPoint = sampleIdx - filterLength / 2;
+ int endPoint = sampleIdx + filterLength / 2;
+ int currentFilterElement = 0;
+ for (int currentSample = startPoint;
+ currentSample <= endPoint;
+ currentSample++, currentFilterElement++)
+ {
+ if (currentSample >= 0 && currentSample < numSamples)
+ {
+ HilbertFirEnvelope::WorkType sample = static_cast<HilbertFirEnvelope::WorkType>(signal[scanlineIdx + currentSample*numScanlines]);
+ HilbertFirEnvelope::WorkType filterElement = filter[currentFilterElement];
+ accumulator += sample*filterElement;
+ }
+ }
+
+ HilbertFirEnvelope::WorkType signalValue = static_cast<HilbertFirEnvelope::WorkType>(signal[scanlineIdx + sampleIdx*numScanlines]);
+ out[ scanlineIdx + sampleIdx * numScanlines ] = sycl::sqrt(squ(signalValue) + squ(accumulator));
+ }
+
+ }
+
+ HilbertFirEnvelope::HilbertFirEnvelope(size_t filterLength)
+ : m_filterLength(filterLength)
+ , m_hilbertFilter(nullptr)
+ {
+ prepareFilter();
+ }
+
+ HilbertFirEnvelope::~HilbertFirEnvelope()
+ {
+ }
+
+ void HilbertFirEnvelope::prepareFilter()
+ {
+ m_hilbertFilter = FirFilterFactory::createFilter<float>(
+ m_filterLength,
+ FirFilterFactory::FilterTypeHilbertTransformer,
+ FirFilterFactory::FilterWindowHamming);
+ m_hilbertFilter = make_shared<Container<float> >(LocationGpu, *m_hilbertFilter);
+ }
+
+ template<typename InputType, typename OutputType>
+ shared_ptr<Container<OutputType> > HilbertFirEnvelope::demodulate(
+ const shared_ptr<const Container<InputType>>& inImageData,
+ int numScanlines, int numSamples)
+ {
+ auto pEnv = make_shared<Container<OutputType> >(LocationGpu, inImageData->getStream(), numScanlines*numSamples);
+ sycl::range<3> blockSizeFilter(1, 8, 16);
+ sycl::range<3> gridSizeFilter(1, static_cast<unsigned int>((numSamples + blockSizeFilter[ 1 ] - 1) / blockSizeFilter[ 1 ]),
+ static_cast<unsigned int>((numScanlines + blockSizeFilter[ 2 ] - 1) / blockSizeFilter[ 2 ]));
+
+ /*
+ DPCT1049:27: The workgroup size passed to the SYCL kernel may exceed the limit. To get the device limit, query info::device::max_work_group_size. Adjust the workgroup size if needed.
+ */
+ inImageData->getStream()->submit([ & ](sycl::handler& cgh) {
+ auto inImageData_get_ct0 = inImageData->get();
+ auto m_hilbertFilter_get_ct1 = m_hilbertFilter->get();
+ auto pEnv_get_ct2 = pEnv->get();
+ auto m_filterLength_ct5 = ( int )m_filterLength;
+
+ cgh.parallel_for(sycl::nd_range<3>(gridSizeFilter * blockSizeFilter, blockSizeFilter), [ = ](sycl::nd_item<3> item_ct1) {
+ kernelFilterDemodulation(inImageData_get_ct0, m_hilbertFilter_get_ct1, pEnv_get_ct2, numSamples, numScanlines, m_filterLength_ct5, item_ct1);
+ });
+ });
+ /*
+ DPCT1010:26: SYCL uses exceptions to report errors and does not use the error codes. The call was replaced with 0. You need to rewrite this code.
+ */
+ cudaSafeCall(0);
+
+ return pEnv;
+ }
+
+ template
+ shared_ptr<Container<int16_t> > HilbertFirEnvelope::demodulate<int16_t, int16_t>(
+ const shared_ptr<const Container<int16_t> >& inImageData,
+ int numScanlines, int numSamples);
+ template
+ shared_ptr<Container<int16_t> > HilbertFirEnvelope::demodulate<float, int16_t>(
+ const shared_ptr<const Container<float> >& inImageData,
+ int numScanlines, int numSamples);
+ template
+ shared_ptr<Container<float> > HilbertFirEnvelope::demodulate<int16_t, float>(
+ const shared_ptr<const Container<int16_t> >& inImageData,
+ int numScanlines, int numSamples);
+ template
+ shared_ptr<Container<float> > HilbertFirEnvelope::demodulate<float, float>(
+ const shared_ptr<const Container<float> >& inImageData,
+ int numScanlines, int numSamples);
+}
\ No newline at end of file
diff --git a/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.h b/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.h
new file mode 100644
index 0000000..b76d74e
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/HilbertFirEnvelope.h
@@ -0,0 +1,44 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2019, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+
+#ifndef __HILBERTFIRENVELOPE_H__
+#define __HILBERTFIRENVELOPE_H__
+
+#include "Container.h"
+
+#include <memory>
+
+namespace supra
+{
+ class HilbertFirEnvelope
+ {
+ public:
+ typedef float WorkType;
+
+ HilbertFirEnvelope(size_t filterLength);
+ ~HilbertFirEnvelope();
+
+ template<typename InputType, typename OutputType>
+ std::shared_ptr<Container<OutputType> >
+ demodulate(
+ const std::shared_ptr<const Container<InputType> >& inImageData,
+ int numScanlines, int numSamples);
+
+ private:
+ void prepareFilter();
+
+ size_t m_filterLength;
+
+ std::shared_ptr<Container<WorkType> > m_hilbertFilter;
+ };
+}
+
+#endif //!__HILBERTFIRENVELOPE_H__
diff --git a/oneapi/src/SupraLib/Beamformer/LogCompressor.dp.cpp b/oneapi/src/SupraLib/Beamformer/LogCompressor.dp.cpp
new file mode 100644
index 0000000..7389daf
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/LogCompressor.dp.cpp
@@ -0,0 +1,90 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2016, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+
+#include <CL/sycl.hpp>
+#include <dpct/dpct.hpp>
+#include "LogCompressor.h"
+
+#include <dpct/dpl_utils.hpp>
+#include <oneapi/dpl/execution>
+#include <oneapi/dpl/algorithm>
+#include <cmath>
+
+using namespace std;
+
+namespace supra
+{
+ template <typename In, typename Out, typename WorkType>
+ /*
+ DPCT1044:29: thrust::unary_function was removed because std::unary_function has been deprecated in C++11. You may need to remove references to typedefs from thrust::unary_function in the class
+ definition.
+ */
+ struct thrustLogcompress {
+ WorkType _inScale;
+ WorkType _scaleOverDenominator;
+
+ // Thrust functor that computes
+ // signal = log10(1 + a*signal)./log10(1 + a)
+ // of the downscaled (_inMax) input signal
+ thrustLogcompress(double dynamicRange, In inMax, Out outMax, double scale)
+ : _inScale(static_cast<WorkType>(dynamicRange / inMax))
+ , _scaleOverDenominator(static_cast<WorkType>(scale * outMax / log10(dynamicRange + 1)))
+ {};
+
+ Out operator()(const In& a) const
+ {
+ WorkType val = log10(abs(static_cast<WorkType>(a))*_inScale + (WorkType)1) * _scaleOverDenominator;
+ return clampCast<Out>(val);
+ }
+ };
+
+ template <typename InputType, typename OutputType>
+ shared_ptr<Container<OutputType> > LogCompressor::compress(const shared_ptr<const Container<InputType>>& inImageData, vec3s size, double dynamicRange, double scale, double inMax)
+ {
+ size_t width = size.x;
+ size_t height = size.y;
+ size_t depth = size.z;
+
+ auto pComprGpu = make_shared<Container<OutputType> >(LocationGpu, inImageData->getStream(), width*height*depth);
+
+ OutputType outMax;
+ if (std::is_integral<OutputType>::value)
+ {
+ outMax = std::numeric_limits<OutputType>::max();
+ }
+ else if (std::is_floating_point<OutputType>::value)
+ {
+ outMax = static_cast<OutputType>(255.0);
+ }
+
+ thrustLogcompress<InputType, OutputType, WorkType> c(sycl::pow<double>(10, (dynamicRange / 20)), static_cast<InputType>(inMax), outMax, scale);
+ std::transform(thrust::cuda::par.on(inImageData->getStream()), inImageData->get(), inImageData->get() + (width * height * depth), pComprGpu->get(), c);
+ /*
+ DPCT1010:28: SYCL uses exceptions to report errors and does not use the error codes. The call was replaced with 0. You need to rewrite this code.
+ */
+ cudaSafeCall(0);
+
+ return pComprGpu;
+ }
+
+ template
+ shared_ptr<Container<uint8_t> > LogCompressor::compress<int16_t, uint8_t>(const shared_ptr<const Container<int16_t> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ template
+ shared_ptr<Container<uint8_t> > LogCompressor::compress<float, uint8_t>(const shared_ptr<const Container<float> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ template
+ shared_ptr<Container<uint8_t> > LogCompressor::compress<uint8_t, uint8_t>(const shared_ptr<const Container<uint8_t> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ template
+ shared_ptr<Container<float> > LogCompressor::compress<int16_t, float>(const shared_ptr<const Container<int16_t> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ template
+ shared_ptr<Container<float> > LogCompressor::compress<float, float>(const shared_ptr<const Container<float> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ template
+ shared_ptr<Container<float> > LogCompressor::compress<uint8_t, float>(const shared_ptr<const Container<uint8_t> >& inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+}
\ No newline at end of file
diff --git a/oneapi/src/SupraLib/Beamformer/LogCompressor.h b/oneapi/src/SupraLib/Beamformer/LogCompressor.h
new file mode 100644
index 0000000..fe9481e
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/LogCompressor.h
@@ -0,0 +1,32 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2016, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+
+#ifndef __LOGCOMPRESSOR_H__
+#define __LOGCOMPRESSOR_H__
+
+#include "USImage.h"
+
+#include <memory>
+
+namespace supra
+{
+ class LogCompressor
+ {
+ public:
+ typedef float WorkType;
+
+ template<typename InputType, typename OutputType>
+ std::shared_ptr<Container<OutputType> >
+ compress(const std::shared_ptr<const Container<InputType> > & inImageData, vec3s size, double dynamicRange, double scale, double inMax);
+ };
+}
+
+#endif //!__LOGCOMPRESSOR_H__
diff --git a/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h b/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h
new file mode 100644
index 0000000..1527995
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h
@@ -0,0 +1,62 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2016, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+
+#ifndef __RXBEAMFORMERCOMMON_H__
+#define __RXBEAMFORMERCOMMON_H__
+
+#include <CL/sycl.hpp>
+#include <dpct/dpct.hpp>
+#include "WindowFunction.h"
+
+//TODO ALL ELEMENT/SCANLINE Y positons are actually Z! Change all variable names accordingly
+namespace supra
+{
+
+ template <typename T>
+ inline T computeAperture_D(T F, T z)
+ {
+ return z / (2 * F);
+ }
+
+ template <typename T>
+ inline T computeDelayDTSPACE_D(T dirX, T dirY, T dirZ, T x_element, T x, T z)
+ {
+ return sqrt((x_element - (x + dirX*z))*
+ (x_element - (x + dirX*z)) +
+ (dirY*z)*(dirY*z)) + z;
+ }
+
+ template <typename T>
+ inline T computeDelayDTSPACE3D_D(T dirX, T dirY, T dirZ, T x_element, T z_element, T x, T z, T d)
+ {
+ return sqrt(
+ squ(x_element - (x + dirX*d)) +
+ squ(z_element - (z + dirZ*d)) +
+ squ(dirY*d)) + d;
+ }
+
+ // distance has to be normalized to [-1, 1] (inclusive)
+ inline WindowFunctionGpu::ElementType
+ computeWindow3D(const WindowFunctionGpu& windowFunction, const vec2f& distance)
+ {
+ return sycl::sqrt(windowFunction.get(distance.x) * windowFunction.get(distance.y));
+ }
+
+
+ // distance has to be normalized to [-1, 1] (inclusive)
+ inline WindowFunctionGpu::ElementType
+ computeWindow3DShared(const WindowFunctionGpu& windowFunction, const WindowFunctionGpu::ElementType * __restrict__ sharedData, const vec2f& distance)
+ {
+ return sycl::sqrt(windowFunction.getShared(sharedData, distance.x) * windowFunction.getShared(sharedData, distance.y));
+ }
+}
+
+#endif //!__RXBEAMFORMERCOMMON_H__
\ No newline at end of file
diff --git a/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h.yaml b/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h.yaml
new file mode 100644
index 0000000..90d29af
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h.yaml
@@ -0,0 +1,72 @@
+---
+MainSourceFile: '/home/wangyon1/projects/supra-projects/golden/supra/oneapi/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+Replacements:
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 549
+ Length: 0
+ ReplacementText: '#include <CL/sycl.hpp>
+#include <dpct/dpct.hpp>
+'
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 714
+ Length: 11
+ ReplacementText: ''
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 815
+ Length: 11
+ ReplacementText: ''
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 1036
+ Length: 11
+ ReplacementText: ''
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 1316
+ Length: 11
+ ReplacementText: ''
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 1462
+ Length: 72
+ ReplacementText: 'sycl::sqrt(windowFunction.get(distance.x)*
+ windowFunction.get(distance.y))'
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 1599
+ Length: 11
+ ReplacementText: ''
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+ - FilePath: '/home/wangyon1/projects/supra-projects/golden/supra/src/SupraLib/Beamformer/RxBeamformerCommon.h'
+ Offset: 1815
+ Length: 108
+ ReplacementText: 'sycl::sqrt(windowFunction.getShared(sharedData, distance.x)*
+ windowFunction.getShared(sharedData, distance.y))'
+ ConstantFlag: ''
+ ConstantOffset: 0
+ InitStr: ''
+ NewHostVarName: ''
+...
diff --git a/oneapi/src/SupraLib/Beamformer/RxBeamformerCuda.dp.cpp b/oneapi/src/SupraLib/Beamformer/RxBeamformerCuda.dp.cpp
new file mode 100644
index 0000000..0973fad
--- /dev/null
+++ b/oneapi/src/SupraLib/Beamformer/RxBeamformerCuda.dp.cpp
@@ -0,0 +1,559 @@
+// ================================================================================================
+//
+// If not explicitly stated: Copyright (C) 2016, all rights reserved,
+// Rüdiger Göbl
+// Email [email protected]
+// Chair for Computer Aided Medical Procedures
+// Technische Universität München
+// Boltzmannstr. 3, 85748 Garching b. München, Germany
+//
+// ================================================================================================
+#include <CL/sycl.hpp>
+#include <dpct/dpct.hpp>
+#include "RxBeamformerCuda.h"
+#include "USImage.h"
+#include "USRawData.h"
+#include "RxSampleBeamformerDelayAndSum.h"
+#include "RxSampleBeamformerDelayAndStdDev.h"
+#include "RxSampleBeamformerTestSignal.h"
+#include "RxBeamformerCommon.h"
+#include "utilities/cudaUtility.h"
+
+//TODO ALL ELEMENT/SCANLINE Y positons are actually Z! Change all variable names accordingly
+namespace supra
+{
+ RxBeamformerCuda::RxBeamformerCuda(const RxBeamformerParameters & parameters)
+ : m_windowFunction(nullptr)
+ {
+ dpct::device_ext& dev_ct1 = dpct::get_current_device();
+ sycl::queue& q_ct1 = dev_ct1.default_queue();
+ m_lastSeenDt = 0;
+ m_numRxScanlines = parameters.getNumRxScanlines();
+ m_rxScanlineLayout = parameters.getRxScanlineLayout();
+
+ m_is3D = (m_rxScanlineLayout.x > 1 && m_rxScanlineLayout.y > 1);
+ m_speedOfSoundMMperS = parameters.getSpeedOfSoundMMperS();
+ m_rxNumDepths = parameters.getRxNumDepths();
+
+ // create and fill new buffers
+ m_pRxDepths = std::unique_ptr<Container<LocationType>>(new Container<LocationType>(LocationGpu, &q_ct1, parameters.getRxDepths()));
+
+ m_pRxScanlines = std::unique_ptr<Container<ScanlineRxParameters3D>>(new Container<ScanlineRxParameters3D>(LocationGpu, &q_ct1, parameters.getRxScanlines()));
+
+ m_pRxElementXs = std::unique_ptr<Container<LocationType>>(new Container<LocationType>(LocationGpu, &q_ct1, parameters.getRxElementXs()));
+ m_pRxElementYs = std::unique_ptr<Container<LocationType>>(new Container<LocationType>(LocationGpu, &q_ct1, parameters.getRxElementYs()));
+ }
+
+ RxBeamformerCuda::~RxBeamformerCuda()
+ {
+ }
+
+ void RxBeamformerCuda::convertToDtSpace(double dt, double speedOfSoundMMperS, size_t numTransducerElements) const
+ {
+ if (m_lastSeenDt != dt || m_speedOfSoundMMperS != speedOfSoundMMperS)
+ {
+ double oldFactor = 1;
+ double oldFactorTime = 1;
+ if (m_lastSeenDt != 0 && m_speedOfSoundMMperS != 0)
+ {
+ oldFactor = 1 / (m_speedOfSoundMMperS * m_lastSeenDt);
+ oldFactorTime = 1 / m_lastSeenDt;
+ }
+
+ double factor = 1 / oldFactor / (speedOfSoundMMperS * dt);
+ double factorTime = 1 / oldFactorTime / dt;
+
+ m_pRxScanlines = std::unique_ptr<Container<ScanlineRxParameters3D> >(new Container<ScanlineRxParameters3D>(LocationHost, *m_pRxScanlines));
+ for (size_t i = 0; i < m_numRxScanlines; i++)
+ {
+ ScanlineRxParameters3D p = m_pRxScanlines->get()[i];
+ p.position = p.position*factor;
+ for (size_t k = 0; k < std::extent<decltype(p.txWeights)>::value; k++)
+ {
+ p.txParameters[k].initialDelay *= factorTime;
+ }
+ p.maxElementDistance = p.maxElementDistance*factor;
+ m_pRxScanlines->get()[i] = p;
+ }
+ m_pRxScanlines = std::unique_ptr<Container<ScanlineRxParameters3D> >(new Container<ScanlineRxParameters3D>(LocationGpu, *m_pRxScanlines));
+
+ m_pRxDepths = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationHost, *m_pRxDepths));
+ for (size_t i = 0; i < m_rxNumDepths; i++)
+ {
+ m_pRxDepths->get()[i] = static_cast<LocationType>(m_pRxDepths->get()[i] * factor);
+ }
+ m_pRxDepths = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationGpu, *m_pRxDepths));
+
+ m_pRxElementXs = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationHost, *m_pRxElementXs));
+ m_pRxElementYs = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationHost, *m_pRxElementYs));
+ for (size_t i = 0; i < numTransducerElements; i++)
+ {
+ m_pRxElementXs->get()[i] = static_cast<LocationType>(m_pRxElementXs->get()[i] * factor);
+ m_pRxElementYs->get()[i] = static_cast<LocationType>(m_pRxElementYs->get()[i] * factor);
+ }
+ m_pRxElementXs = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationGpu, *m_pRxElementXs));
+ m_pRxElementYs = std::unique_ptr<Container<LocationType> >(new Container<LocationType>(LocationGpu, *m_pRxElementYs));
+
+ m_lastSeenDt = dt;
+ m_speedOfSoundMMperS = speedOfSoundMMperS;
+ }
+ }
+
+ template <class SampleBeamformer, bool interpolateRFlines, bool interpolateBetweenTransmits, unsigned int maxNumElements, unsigned int maxNumFunctionElements, typename RFType, typename ResultType, typename LocationType>
+
+ void rxBeamformingDTSPACE3DKernel(
+ uint32_t numTransducerElements,
+ vec2T<uint32_t> elementLayout,
+ uint32_t numReceivedChannels,
+ uint32_t numTimesteps,
+ const RFType* __restrict__ RF,
+ uint32_t numTxScanlines,
+ uint32_t numRxScanlines,
+ const ScanlineRxParameters3D* __restrict__ scanlinesDT,
+ uint32_t numDs,
+ const LocationType* __restrict__ dsDT,
+ const LocationType* __restrict__ x_elemsDT,
+ const LocationType* __restrict__ z_elemsDT,
+ LocationType speedOfSound,
+ LocationType dt,
+ uint32_t additionalOffset,
+ LocationType F,
+ const WindowFunctionGpu windowFunction,
+ ResultType* __restrict__ s,
+ sycl::nd_item<3> item_ct1,
+ LocationType *x_elemsDTsh,
+ LocationType *z_elemsDTsh,
+ WindowFunction::ElementType *functionShared)
+ {
+
+ //fetch element positions to shared memory
+ for (int threadId = (item_ct1.get_local_id(1) * item_ct1.get_local_range().get(2)) + item_ct1.get_local_id(2); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ threadId < maxNumElements && threadId < numTransducerElements;
+ threadId += item_ct1.get_local_range().get(2) * item_ct1.get_local_range().get(1)) //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ {
+ x_elemsDTsh[threadId] = x_elemsDT[threadId];
+ z_elemsDTsh[threadId] = z_elemsDT[threadId];
+ }
+ for (int threadId = (item_ct1.get_local_id(1) * item_ct1.get_local_range().get(2)) + item_ct1.get_local_id(2); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ threadId < maxNumFunctionElements && threadId < windowFunction.numElements();
+ threadId += item_ct1.get_local_range().get(2) * item_ct1.get_local_range().get(1)) //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ {
+ functionShared[threadId] = windowFunction.getDirect(threadId);
+ }
+ item_ct1.barrier(); //@suppress("Function cannot be resolved")
+
+ int r = item_ct1.get_local_range().get(1) * item_ct1.get_group(1) + item_ct1.get_local_id(1); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ int scanlineIdx = item_ct1.get_local_range().get(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+
+ if (r < numDs && scanlineIdx < numRxScanlines)
+ {
+ LocationType d = dsDT[r];
+ //TODO should this also depend on the angle?
+ LocationType aDT = squ(computeAperture_D(F, d*dt*speedOfSound) / speedOfSound / dt);
+ ScanlineRxParameters3D scanline = scanlinesDT[scanlineIdx];
+
+ LocationType scanline_x = scanline.position.x;
+ LocationType scanline_z = scanline.position.z;
+ LocationType dirX = scanline.direction.x;
+ LocationType dirY = scanline.direction.y;
+ LocationType dirZ = scanline.direction.z;
+ vec2f maxElementDistance = static_cast<vec2f>(scanline.maxElementDistance);
+ vec2f invMaxElementDistance = vec2f{ 1.0f, 1.0f } / min(vec2f{ sqrt(aDT), sqrt(aDT) }, maxElementDistance);
+
+ float sInterp = 0.0f;
+
+ int highestWeightIndex;
+ if (!interpolateBetweenTransmits)
+ {
+ highestWeightIndex = 0;
+ float highestWeight = scanline.txWeights[0];
+ for (int k = 1; k < std::extent<decltype(scanline.txWeights)>::value; k++)
+ {
+ if (scanline.txWeights[k] > highestWeight)
+ {
+ highestWeight = scanline.txWeights[k];
+ highestWeightIndex = k;
+ }
+ }
+ }
+
+ // now iterate over all four txScanlines to interpolate beamformed scanlines from those transmits
+ for (int k = (interpolateBetweenTransmits ? 0 : highestWeightIndex);
+ (interpolateBetweenTransmits && k < std::extent<decltype(scanline.txWeights)>::value) ||
+ (!interpolateBetweenTransmits && k == highestWeightIndex);
+ k++)
+ {
+ if (scanline.txWeights[k] > 0.0)
+ {
+ ScanlineRxParameters3D::TransmitParameters txParams = scanline.txParameters[k];
+ uint32_t txScanlineIdx = txParams.txScanlineIdx;
+ if (txScanlineIdx >= numTxScanlines)
+ {
+ //ERROR!
+ return;
+ }
+ float sLocal = 0.0f;
+
+ sLocal = SampleBeamformer::template sampleBeamform3D<interpolateRFlines, RFType, float, LocationType>(
+ txParams, RF, elementLayout, numReceivedChannels, numTimesteps,
+ x_elemsDTsh, z_elemsDTsh, scanline_x, scanline_z, dirX, dirY, dirZ,
+ aDT, d, invMaxElementDistance, speedOfSound, dt, additionalOffset, &windowFunction, functionShared);
+
+ if (interpolateBetweenTransmits)
+ {
+ sInterp += static_cast<float>(scanline.txWeights[k])* sLocal;
+ }
+ else
+ {
+ sInterp += sLocal;
+ }
+ }
+ }
+ s[scanlineIdx + r * numRxScanlines] = clampCast<ResultType>(sInterp);
+ }
+ }
+
+ template <class SampleBeamformer, bool interpolateRFlines, bool interpolateBetweenTransmits, typename RFType, typename ResultType, typename LocationType>
+
+ void rxBeamformingDTSPACEKernel(
+ size_t numTransducerElements,
+ size_t numReceivedChannels,
+ size_t numTimesteps,
+ const RFType* __restrict__ RF,
+ size_t numTxScanlines,
+ size_t numRxScanlines,
+ const ScanlineRxParameters3D* __restrict__ scanlinesDT,
+ size_t numDs,
+ const LocationType* __restrict__ dsDT,
+ const LocationType* __restrict__ x_elemsDT,
+ LocationType speedOfSound,
+ LocationType dt,
+ uint32_t additionalOffset,
+ LocationType F,
+ const WindowFunctionGpu windowFunction,
+ ResultType* __restrict__ s,
+ sycl::nd_item<3> item_ct1)
+ {
+ int r = item_ct1.get_local_range().get(1) * item_ct1.get_group(1) + item_ct1.get_local_id(1); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ int scanlineIdx = item_ct1.get_local_range().get(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2); //@suppress("Symbol is not resolved") @suppress("Field cannot be resolved")
+ if (r < numDs && scanlineIdx < numRxScanlines)
+ {
+ LocationType d = dsDT[r];
+ //TODO should this also depend on the angle?
+ LocationType aDT = computeAperture_D(F, d*dt*speedOfSound) / speedOfSound / dt;
+ ScanlineRxParameters3D scanline = scanlinesDT[scanlineIdx];
+ LocationType scanline_x = scanline.position.x;
+ LocationType dirX = scanline.direction.x;
+ LocationType dirY = scanline.direction.y;
+ LocationType dirZ = scanline.direction.z;
+ LocationType maxElementDistance = static_cast<LocationType>(scanline.maxElementDistance.x);
+ LocationType invMaxElementDistance = 1 / std::min(aDT, maxElementDistance);
+
+ float sInterp = 0.0f;
+
+ int highestWeightIndex;
+ if (!interpolateBetweenTransmits)
+ {
+ highestWeightIndex = 0;
+ float highestWeight = scanline.txWeights[0];
+ for (int k = 1; k < std::extent<decltype(scanline.txWeights)>::value; k++)
+ {
+ if (scanline.txWeights[k] > highestWeight)
+ {
+ highestWeight = scanline.txWeights[k];
+ highestWeightIndex = k;
+ }
+ }
+ }
+
+ // now iterate over all four txScanlines to interpolate beamformed scanlines from those transmits
+ for (int k = (interpolateBetweenTransmits ? 0 : highestWeightIndex);
+ (interpolateBetweenTransmits && k < std::extent<decltype(scanline.txWeights)>::value) ||
+ (!interpolateBetweenTransmits && k == highestWeightIndex);
+ k++)
+ {
+ if (scanline.txWeights[k] > 0.0)
+ {
+ ScanlineRxParameters3D::TransmitParameters txParams = scanline.txParameters[k];
+ uint32_t txScanlineIdx = txParams.txScanlineIdx;
+ if (txScanlineIdx >= numTxScanlines)
+ {
+ //ERROR!
+ return;
+ }
+
+ float sLocal = 0.0f;
+ sLocal = SampleBeamformer::template sampleBeamform2D<interpolateRFlines, RFType, float, LocationType>(
+ txParams, RF, numTransducerElements, numReceivedChannels, numTimesteps,
+ x_elemsDT, scanline_x, dirX, dirY, dirZ,
+ aDT, d, invMaxElementDistance, speedOfSound, dt, additionalOffset, &windowFunction);
+
+ if (interpolateBetweenTransmits)
+ {
+ sInterp += static_cast<float>(scanline.txWeights[k])* sLocal;
+ }
+ else
+ {
+ sInterp += sLocal;
+ }
+ }
+ }
+ s[scanlineIdx + r * numRxScanlines] = clampCast<ResultType>(sInterp);
+ }
+ }
+
+ template <class SampleBeamformer, unsigned int maxWindowFunctionNumel, typename RFType, typename ResultType, typename LocationType>
+ void rxBeamformingDTspaceCuda3D(bool interpolateRFlines, bool interpolateBetweenTransmits, size_t numTransducerElements, vec2s elementLayout, size_t numReceivedChannels, size_t numTimesteps,
+ const RFType* RF, size_t numTxScanlines, size_t numRxScanlines, const ScanlineRxParameters3D* scanlines, size_t numZs, const LocationType* zs,
+ const LocationType* x_elems, const LocationType* y_elems, LocationType speedOfSound, LocationType dt, uint32_t additionalOffset, LocationType F,
+ const WindowFunctionGpu windowFunction, sycl::queue* stream, ResultType* s)
+ {
+ sycl::range<3> blockSize(1, 256, 1);
+ sycl::range<3> gridSize(1, static_cast<unsigned int>((numZs + blockSize[ 1 ] - 1) / blockSize[ 1 ]), static_cast<unsigned int>((numRxScanlines + blockSize[ 2 ] - 1) / blockSize[ 2 ]));
+
+ if (interpolateRFlines)
+ {
+ if (interpolateBetweenTransmits)
+ {
+ rxBeamformingDTSPACE3DKernel<SampleBeamformer, true, true, 1024, maxWindowFunctionNumel> << <gridSize, blockSize, 0, stream>> > (
+ (uint32_t)numTransducerElements, static_cast<vec2T<uint32_t>>(elementLayout),
+ (uint32_t)numReceivedChannels, (uint32_t)numTimesteps, RF,
+ (uint32_t)numTxScanlines, (uint32_t)numRxScanlines, scanlines,
+ (uint32_t)numZs, zs, x_elems, y_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ else {
+ rxBeamformingDTSPACE3DKernel<SampleBeamformer, true, false, 1024, maxWindowFunctionNumel> << <gridSize, blockSize, 0, stream>> > (
+ (uint32_t)numTransducerElements, static_cast<vec2T<uint32_t>>(elementLayout),
+ (uint32_t)numReceivedChannels, (uint32_t)numTimesteps, RF,
+ (uint32_t)numTxScanlines, (uint32_t)numRxScanlines, scanlines,
+ (uint32_t)numZs, zs, x_elems, y_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ }
+ else {
+ if (interpolateBetweenTransmits)
+ {
+ rxBeamformingDTSPACE3DKernel<SampleBeamformer, false, true, 1024, maxWindowFunctionNumel> << <gridSize, blockSize, 0, stream>> > (
+ (uint32_t)numTransducerElements, static_cast<vec2T<uint32_t>>(elementLayout),
+ (uint32_t)numReceivedChannels, (uint32_t)numTimesteps, RF,
+ (uint32_t)numTxScanlines, (uint32_t)numRxScanlines, scanlines,
+ (uint32_t)numZs, zs, x_elems, y_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ else {
+ rxBeamformingDTSPACE3DKernel<SampleBeamformer, false, false, 1024, maxWindowFunctionNumel> << <gridSize, blockSize, 0, stream>> > (
+ (uint32_t)numTransducerElements, static_cast<vec2T<uint32_t>>(elementLayout),
+ (uint32_t)numReceivedChannels, (uint32_t)numTimesteps, RF,
+ (uint32_t)numTxScanlines, (uint32_t)numRxScanlines, scanlines,
+ (uint32_t)numZs, zs, x_elems, y_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ }
+ /*
+ DPCT1010:30: SYCL uses exceptions to report errors and does not use the error codes. The call was replaced with 0. You need to rewrite this code.
+ */
+ cudaSafeCall(0);
+ }
+
+ template <class SampleBeamformer, typename RFType, typename ResultType, typename LocationType>
+ void rxBeamformingDTspaceCuda(bool interpolateRFlines, bool interpolateBetweenTransmits, size_t numTransducerElements, size_t numReceivedChannels, size_t numTimesteps, const RFType* RF,
+ size_t numTxScanlines, size_t numRxScanlines, const ScanlineRxParameters3D* scanlines, size_t numZs, const LocationType* zs, const LocationType* x_elems,
+ LocationType speedOfSound, LocationType dt, uint32_t additionalOffset, LocationType F, const WindowFunctionGpu windowFunction, sycl::queue* stream, ResultType* s)
+ {
+ sycl::range<3> blockSize(1, 256, 1);
+ sycl::range<3> gridSize(1, static_cast<unsigned int>((numZs + blockSize[ 1 ] - 1) / blockSize[ 1 ]), static_cast<unsigned int>((numRxScanlines + blockSize[ 2 ] - 1) / blockSize[ 2 ]));
+ if (interpolateRFlines)
+ {
+ if (interpolateBetweenTransmits)
+ {
+ rxBeamformingDTSPACEKernel<SampleBeamformer, true, true> << <gridSize, blockSize, 0, stream>> > (
+ numTransducerElements, numReceivedChannels, numTimesteps, RF,
+ numTxScanlines, numRxScanlines, scanlines,
+ numZs, zs, x_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ else {
+ rxBeamformingDTSPACEKernel<SampleBeamformer, true, false> << <gridSize, blockSize, 0, stream>> > (
+ numTransducerElements, numReceivedChannels, numTimesteps, RF,
+ numTxScanlines, numRxScanlines, scanlines,
+ numZs, zs, x_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ }
+ else {
+ if (interpolateBetweenTransmits)
+ {
+ rxBeamformingDTSPACEKernel<SampleBeamformer, false, true> << <gridSize, blockSize, 0, stream>> > (
+ numTransducerElements, numReceivedChannels, numTimesteps, RF,
+ numTxScanlines, numRxScanlines, scanlines,
+ numZs, zs, x_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ else {
+ rxBeamformingDTSPACEKernel<SampleBeamformer, false, false> <<<gridSize, blockSize, 0, stream>>> (
+ numTransducerElements, numReceivedChannels, numTimesteps, RF,
+ numTxScanlines, numRxScanlines, scanlines,
+ numZs, zs, x_elems, speedOfSound, dt, additionalOffset, F, windowFunction, s);
+ }
+ }
+ /*
+ DPCT1010:31: SYCL uses exceptions to report errors and does not use the error codes. The call was replaced with 0. You need to rewrite this code.
+ */
+ cudaSafeCall(0);
+ }
+
+ template <typename ChannelDataType, typename ImageDataType>
+ shared_ptr<USImage> RxBeamformerCuda::performRxBeamforming(
+ RxBeamformerCuda::RxSampleBeamformer sampleBeamformer,
+ shared_ptr<const USRawData> rawData,
+ double fNumber,
+ double speedOfSoundMMperS,
+ WindowType windowType,
+ WindowFunction::ElementType windowParameter,
+ bool interpolateBetweenTransmits,
+ int32_t additionalOffset) const
+ {
+ //Ensure the raw-data are on the gpu
+ auto gRawData = rawData->getData<ChannelDataType>();
+ if (!gRawData->isGPU() && !gRawData->isBoth())
+ {