forked from stanfordhpccenter/HTR-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometeo_rhs.cu
1005 lines (891 loc) · 48.9 KB
/
prometeo_rhs.cu
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
// Copyright (c) "2019, by Stanford University
// Developer: Mario Di Renzo
// Affiliation: Center for Turbulence Research, Stanford University
// URL: https://ctr.stanford.edu
// Citation: Di Renzo, M., Lin, F., and Urzay, J. (2020).
// HTR solver: An open-source exascale-oriented task-based
// multi-GPU high-order code for hypersonic aerothermodynamics.
// Computer Physics Communications 255, 107262"
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "prometeo_rhs.hpp"
#include "prometeo_rhs.inl"
#include "cuda_utils.hpp"
// Load thrust
#include <thrust/device_ptr.h>
#include <thrust/partition.h>
#include <thrust/execution_policy.h>
// Define a constant memory that will hold the Mixture struct
__device__ __constant__ Mix mix;
//-----------------------------------------------------------------------------
// COMMON KERNELS
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void UpdateRHSUsingFlux_kernel(const DeferredBuffer<VecNEq, 3> Flux,
const AccessorRO<double, 3> m,
const AccessorRW<VecNEq, 3> Conserved_t,
const Rect<3> Divg_bounds,
const Rect<3> Fluid_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z,
const coord_t size)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + Divg_bounds.lo.x,
y + Divg_bounds.lo.y,
z + Divg_bounds.lo.z);
const Point<3> pm1 = warpPeriodic<dir, Minus>(Fluid_bounds, p, size, -1);
#pragma unroll
for (int i=0; i<nEq; i++)
Conserved_t[p][i] += m[p]*(Flux[p][i] - Flux[pm1][i]);
}
}
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingHybridEulerFluxTask
//-----------------------------------------------------------------------------
template<direction dir>
struct is_KGPoint {
is_KGPoint(const AccessorRO< bool, 3> shockSensor_,
const AccessorRO< int, 3> nType_,
const Rect<3> bounds_,
const coord_t size_) :
shockSensor(shockSensor_),
nType(nType_),
bounds(bounds_),
size(size_) {};
__device__
bool operator()(const Point<3> p) {
const Point<3> pM1 = warpPeriodic<dir, Minus>(bounds, p, size, offM1(nType[p]));
const Point<3> pP1 = warpPeriodic<dir, Plus >(bounds, p, size, offP1(nType[p]));
return (shockSensor[pM1] &&
shockSensor[p ] &&
shockSensor[pP1]);
}
private:
const AccessorRO< bool, 3> shockSensor;
const AccessorRO< int, 3> nType;
const Rect<3> bounds;
const coord_t size;
};
__global__
void storePoints_kernel(const DeferredBuffer<Point<3>, 1> Points,
const Rect<3> bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z,
const coord_t first)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z))
Points[Point<1>(first + x + y*size_x + z*size_x*size_y)] =
Point<3>(x + bounds.lo.x,
y + bounds.lo.y,
z + bounds.lo.z);
}
template<direction dir>
__global__
void KGFluxReconstruction_kernel(const DeferredBuffer<VecNEq, 3> Flux,
const DeferredBuffer<Point<3>, 1> Points,
const AccessorRO<VecNEq, 3> Conserved,
const AccessorRO<double, 3> rho,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<double, 3> pressure,
const AccessorRO< int, 3> nType,
const Rect<3> Fluid_bounds,
const coord_t offset,
const coord_t size)
{
const coord_t tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < offset) {
const Point<3> p = Points[tid];
UpdateUsingEulerFluxUtils<dir>::KGFluxReconstruction(
Flux[p].v,
Conserved, rho, MassFracs,
velocity, pressure,
p, nType[p], size, Fluid_bounds);
}
}
template<direction dir>
__global__
void TENOFluxReconstruction_kernel(const DeferredBuffer<VecNEq, 3> Flux,
const DeferredBuffer<Point<3>, 1> Points,
const AccessorRO<VecNEq, 3> Conserved,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<double, 3> pressure,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> temperature,
const AccessorRO< int, 3> nType,
const Rect<3> Fluid_bounds,
const coord_t offset,
const coord_t volume,
const coord_t size)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x + offset;
if (tid < volume) {
const Point<3> p = Points[tid];
UpdateUsingEulerFluxUtils<dir>::TENOFluxReconstruction(Flux[p].v,
Conserved, SoS, rho, velocity,
pressure, MassFracs, temperature,
p, nType[p], mix, size, Fluid_bounds);
}
}
template<direction dir>
__host__
void UpdateUsingHybridEulerFluxTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 7);
assert(futures.size() == 0);
// Accessors for variables in the Flux stencil
const AccessorRO<VecNEq, 3> acc_Conserved(regions[0], FID_Conserved);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<VecNSp, 3> acc_MassFracs(regions[0], FID_MassFracs);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
// Accessors for shock sensor
const AccessorRO< bool, 3> acc_shockSensor(regions[1], FID_shockSensor);
// Accessors for quantities needed for the Roe averages
const AccessorRO<double, 3> acc_temperature(regions[2], FID_temperature);
// Accessors for node types
const AccessorRO< int, 3> acc_nType(regions[3], FID_nType);
// Accessors for metrics
const AccessorRO<double, 3> acc_m_e(regions[4], FID_m_e);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[5], FID_Conserved_t);
// Extract execution domains
Rect<3> r_ModCells = runtime->get_index_space_domain(ctx, args.ModCells.get_index_space());
Rect<3> Fluid_bounds = args.Fluid_bounds;
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Store the Flux domain and the linear size of Fluid
Domain FluxDomain = runtime->get_index_space_domain(ctx, args.FluxGhost.get_index_space());
const coord_t size = getSize<dir>(Fluid_bounds);
const int threads_per_block = 256;
// Extract lists of points where we are going to deploy the KG or TENO reconstruction
// Points for KG reconstruction are in PointsList[0, offset)
// Points for TENO reconstruction are in PointsList[offset, FluxDomainVolume)
cudaStream_t default_stream;
cudaStreamCreate(&default_stream);
const coord_t FluxDomainVolume = FluxDomain.get_volume();
DeferredBuffer<Point<3>, 1> PointsList(Rect<1>(0, FluxDomainVolume), Memory::GPU_FB_MEM);
coord_t first = 0;
for (RectInDomainIterator<3> Rit(FluxDomain); Rit(); Rit++) {
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, *Rit);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(*Rit) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(*Rit) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(*Rit) + (TPB_3d.z - 1)) / TPB_3d.z);
storePoints_kernel<<<num_blocks_3d, TPB_3d, 0, default_stream>>>(PointsList, (*Rit),
getSize<Xdir>(*Rit), getSize<Ydir>(*Rit), getSize<Zdir>(*Rit),
first);
first += getSize<Xdir>(*Rit)*getSize<Ydir>(*Rit)*getSize<Zdir>(*Rit);
}
assert(first == FluxDomainVolume);
// Partition the PointsList vector based on the shock sensor
thrust::device_ptr<Point<3>> PointsList_vec(PointsList.ptr(Point<1>(0)));
const coord_t offset = thrust::stable_partition(thrust::cuda::par.on(default_stream),
PointsList_vec, PointsList_vec + FluxDomainVolume,
is_KGPoint<dir>(acc_shockSensor, acc_nType, Fluid_bounds, size))
- PointsList_vec;
// Record an event on the KG stream
cudaEvent_t ListDone;
cudaEventCreate(&ListDone);
cudaEventRecord(ListDone, default_stream);
// Store all diffusion fluxes in a deferred buffer
DeferredBuffer<VecNEq, 3> Flux(Memory::GPU_FB_MEM, FluxDomain);
// Launch the kernel to reconstruct the fluxes using KG (after the node list is built)
cudaStream_t KGstream;
cudaStreamCreateWithFlags(&KGstream, cudaStreamNonBlocking);
cudaStreamWaitEvent(KGstream, ListDone, 0);
if (offset > 0) {
const int num_blocks = (offset + (threads_per_block-1)) / threads_per_block;
KGFluxReconstruction_kernel<dir><<<num_blocks, threads_per_block, 0, KGstream>>>(
Flux, PointsList,
acc_Conserved, acc_rho, acc_MassFracs,
acc_velocity, acc_pressure, acc_nType,
Fluid_bounds, offset, size);
}
// Record an event on the KG stream
cudaEvent_t KGend;
cudaEventCreate(&KGend);
cudaEventRecord(KGend, KGstream);
// Launch the kernel to reconstruct the fluxes using TENO (after the node list is built)
cudaStream_t TENOstream;
cudaStreamCreateWithFlags(&TENOstream, cudaStreamNonBlocking);
cudaStreamWaitEvent(TENOstream, ListDone, 0);
if (FluxDomainVolume - offset > 0) {
const int num_blocks = ((FluxDomainVolume - offset) + (threads_per_block-1)) / threads_per_block;
TENOFluxReconstruction_kernel<dir><<<num_blocks, threads_per_block, 0, TENOstream>>>(
Flux, PointsList,
acc_Conserved, acc_SoS, acc_rho,
acc_velocity, acc_pressure, acc_MassFracs, acc_temperature, acc_nType,
Fluid_bounds, offset, FluxDomainVolume, size);
}
// Record an event on the TENO stream
cudaEvent_t TENOend;
cudaEventCreate(&TENOend);
cudaEventRecord(TENOend, TENOstream);
// Ensure that reconstruction kernels are done and cleanup the reconstruction streams
cudaStreamWaitEvent(default_stream, KGend, 0);
cudaStreamWaitEvent(default_stream, TENOend, 0);
cudaEventDestroy(ListDone);
cudaEventDestroy( KGend);
cudaEventDestroy( TENOend);
cudaStreamDestroy( KGstream);
cudaStreamDestroy(TENOstream);
// Launch the kernel to update the RHS using the fluxes on each point of the FluxDomain
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, r_ModCells);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_ModCells) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_ModCells) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_ModCells) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateRHSUsingFlux_kernel<dir><<<num_blocks_3d, TPB_3d, 0, default_stream>>>(
Flux, acc_m_e, acc_Conserved_t,
r_ModCells, Fluid_bounds,
getSize<Xdir>(r_ModCells), getSize<Ydir>(r_ModCells), getSize<Zdir>(r_ModCells), size);
// Cleanup default stream
cudaStreamDestroy(default_stream);
}
// Force the compiler to instanciate these functions
template void UpdateUsingHybridEulerFluxTask<Xdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingHybridEulerFluxTask<Ydir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingHybridEulerFluxTask<Zdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingTENOAEulerFluxTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void TENOAFluxReconstruction_kernel(const DeferredBuffer<VecNEq, 3> Flux,
const AccessorRO<VecNEq, 3> Conserved,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<double, 3> pressure,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> temperature,
const AccessorRO< int, 3> nType,
const Rect<3> Flux_bounds,
const Rect<3> Fluid_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z,
const coord_t size)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + Flux_bounds.lo.x,
y + Flux_bounds.lo.y,
z + Flux_bounds.lo.z);
UpdateUsingEulerFluxUtils<dir>::TENOAFluxReconstruction(Flux[p].v,
Conserved, SoS, rho, velocity,
pressure, MassFracs, temperature,
p, nType[p], mix, size, Fluid_bounds);
}
}
template<direction dir>
__host__
void UpdateUsingTENOAEulerFluxTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 6);
assert(futures.size() == 0);
// Accessors for variables in the Flux stencil
const AccessorRO<VecNEq, 3> acc_Conserved(regions[0], FID_Conserved);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
// Accessors for quantities needed for the Roe averages
const AccessorRO<double, 3> acc_temperature(regions[1], FID_temperature);
const AccessorRO<VecNSp, 3> acc_MassFracs (regions[1], FID_MassFracs);
// Accessors for node types
const AccessorRO< int, 3> acc_nType(regions[2], FID_nType);
// Accessors for metrics
const AccessorRO<double, 3> acc_m_e(regions[3], FID_m_e);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[4], FID_Conserved_t);
// Extract execution domains
Rect<3> r_ModCells = runtime->get_index_space_domain(ctx, args.ModCells.get_index_space());
Rect<3> Fluid_bounds = args.Fluid_bounds;
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Store the Flux domain and the linear size of Fluid
Domain FluxDomain = runtime->get_index_space_domain(ctx, args.FluxGhost.get_index_space());
const coord_t size = getSize<dir>(Fluid_bounds);
// Store all Euler fluxes in a deferred buffer
DeferredBuffer<VecNEq, 3> Flux(Memory::GPU_FB_MEM, FluxDomain);
const int threads_per_block = 256;
// Launch the kernel to compute the fluxes on each point of the FluxDomain
for (RectInDomainIterator<3> Rit(FluxDomain); Rit(); Rit++) {
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, *Rit);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(*Rit) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(*Rit) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(*Rit) + (TPB_3d.z - 1)) / TPB_3d.z);
TENOAFluxReconstruction_kernel<dir><<<num_blocks_3d, TPB_3d>>>(Flux,
acc_Conserved, acc_SoS, acc_rho, acc_velocity,
acc_pressure, acc_MassFracs, acc_temperature, acc_nType,
(*Rit), Fluid_bounds,
getSize<Xdir>(*Rit), getSize<Ydir>(*Rit), getSize<Zdir>(*Rit), size);
}
// Launch the kernel to update the RHS using the fluxes on each point of the FluxDomain
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, r_ModCells);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_ModCells) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_ModCells) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_ModCells) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateRHSUsingFlux_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
Flux, acc_m_e, acc_Conserved_t,
r_ModCells, Fluid_bounds,
getSize<Xdir>(r_ModCells), getSize<Ydir>(r_ModCells), getSize<Zdir>(r_ModCells), size);
}
// Force the compiler to instanciate these functions
template void UpdateUsingTENOAEulerFluxTask<Xdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingTENOAEulerFluxTask<Ydir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingTENOAEulerFluxTask<Zdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingDiffusionFluxTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void ComputeDiffusionFlux_kernel(const DeferredBuffer<VecNEq, 3> Flux,
const AccessorRO< int, 3> nType,
const AccessorRO<double, 3> metric,
const AccessorRO<double, 3> rho,
const AccessorRO<double, 3> mu,
const AccessorRO<double, 3> lam,
const AccessorRO<VecNSp, 3> Di,
const AccessorRO<double, 3> temperature,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<VecNSp, 3> Xi,
const AccessorRO<VecNEq, 3> rhoYi,
const AccessorRO< Vec3, 3> vGrad1,
const AccessorRO< Vec3, 3> vGrad2,
const Rect<3> Flux_bounds,
const Rect<3> Fluid_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z,
const coord_t size)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + Flux_bounds.lo.x,
y + Flux_bounds.lo.y,
z + Flux_bounds.lo.z);
UpdateUsingDiffusionFluxTask<dir>::GetDiffusionFlux(
Flux[p].v, nType[p], metric[p], mix,
rho, mu, lam, Di,
temperature, velocity, Xi,
rhoYi, vGrad1, vGrad2,
p, size, Fluid_bounds);
}
}
template<direction dir>
__host__
void UpdateUsingDiffusionFluxTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 5);
assert(futures.size() == 0);
// Accessors for DiffGhost region
const AccessorRO<VecNEq, 3> acc_Conserved (regions[0], FID_Conserved);
const AccessorRO<double, 3> acc_temperature(regions[0], FID_temperature);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO<VecNSp, 3> acc_MolarFracs (regions[0], FID_MolarFracs);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<double, 3> acc_mu (regions[0], FID_mu);
const AccessorRO<double, 3> acc_lam (regions[0], FID_lam);
const AccessorRO<VecNSp, 3> acc_Di (regions[0], FID_Di);
const AccessorRO< Vec3, 3> acc_vGrad1 (regions[0], FID_vGrad1);
const AccessorRO< Vec3, 3> acc_vGrad2 (regions[0], FID_vGrad2);
// Accessors for DivgGhost region
const AccessorRO< int, 3> acc_nType (regions[1], FID_nType);
const AccessorRO<double, 3> acc_m_s (regions[1], FID_m_s);
// Accessors for metrics
const AccessorRO<double, 3> acc_m_d (regions[2], FID_m_d);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[3], FID_Conserved_t);
// Extract execution domains
Rect<3> r_ModCells = runtime->get_index_space_domain(ctx, args.ModCells.get_index_space());
Rect<3> Fluid_bounds = args.Fluid_bounds;
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Store the Flux domain and the linear size of Fluid
Domain FluxDomain = runtime->get_index_space_domain(ctx, args.FluxGhost.get_index_space());
const coord_t size = getSize<dir>(Fluid_bounds);
// Store all diffusion fluxes in a deferred buffer
DeferredBuffer<VecNEq, 3> Flux(Memory::GPU_FB_MEM, FluxDomain);
// Launch the kernel to compute the fluxes on each point of the FluxDomain
const int threads_per_block = 256;
for (RectInDomainIterator<3> Rit(FluxDomain); Rit(); Rit++) {
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, *Rit);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(*Rit) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(*Rit) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(*Rit) + (TPB_3d.z - 1)) / TPB_3d.z);
ComputeDiffusionFlux_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
Flux, acc_nType, acc_m_s,
acc_rho, acc_mu, acc_lam, acc_Di,
acc_temperature, acc_velocity, acc_MolarFracs,
acc_Conserved, acc_vGrad1, acc_vGrad2,
(*Rit), Fluid_bounds,
getSize<Xdir>(*Rit), getSize<Ydir>(*Rit), getSize<Zdir>(*Rit), size);
}
// Launch the kernel to update the RHS using the fluxes on each point of the FluxDomain
const dim3 TPB_3d = splitThreadsPerBlock<dir>(threads_per_block, r_ModCells);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_ModCells) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_ModCells) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_ModCells) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateRHSUsingFlux_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
Flux, acc_m_d, acc_Conserved_t,
r_ModCells, Fluid_bounds,
getSize<Xdir>(r_ModCells), getSize<Ydir>(r_ModCells), getSize<Zdir>(r_ModCells), size);
}
template void UpdateUsingDiffusionFluxTask<Xdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingDiffusionFluxTask<Ydir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingDiffusionFluxTask<Zdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingFluxNSCBCInflowMinusSideTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void UpdateUsingFluxNSCBCInflowMinusSideTask_kernel(
const AccessorRW<VecNEq, 3> Conserved_t,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> pressure,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO<double, 3> temperature,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO< Vec3, 3> vGrad,
const AccessorRO< Vec3, 3> dudt,
const AccessorRO<double, 3> dTdt,
const AccessorRO< int, 3> nType,
const AccessorRO<double, 3> m_d,
const Rect<3> BC_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + BC_bounds.lo.x,
y + BC_bounds.lo.y,
z + BC_bounds.lo.z);
UpdateUsingFluxNSCBCInflowMinusSideTask<dir>::addLODIfluxes(
Conserved_t[p].v,
MassFracs, pressure,
SoS[p], rho[p], temperature[p],
velocity[p].v, vGrad[p].v, dudt[p].v, dTdt[p],
p, nType[p], m_d[p], mix);
}
}
template<direction dir>
__host__
void UpdateUsingFluxNSCBCInflowMinusSideTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 2);
assert(futures.size() == 0);
// Accessors for Input data
const AccessorRO< int, 3> acc_nType (regions[0], FID_nType);
const AccessorRO<double, 3> acc_m_d (regions[0], FID_m_d);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<VecNSp, 3> acc_MassFracs (regions[0], FID_MassFracs);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
const AccessorRO<double, 3> acc_temperature(regions[0], FID_temperature);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO< Vec3, 3> acc_vGrad (regions[0], FID_vGrad);
const AccessorRO< Vec3, 3> acc_dudt (regions[0], FID_dudtBoundary);
const AccessorRO<double, 3> acc_dTdt (regions[0], FID_dTdtBoundary);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[1], FID_Conserved_t);
// Extract BC domain
Rect<3> r_BC = runtime->get_index_space_domain(ctx,
runtime->get_logical_subregion_by_color(args.Fluid_BC, 0).get_index_space());
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Launch the kernel to update the RHS NSCBC nodes
const int threads_per_block = 256;
const dim3 TPB_3d = splitThreadsPerBlock<Xdir>(threads_per_block, r_BC);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_BC) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_BC) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_BC) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateUsingFluxNSCBCInflowMinusSideTask_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
acc_Conserved_t,
acc_MassFracs, acc_pressure, acc_SoS, acc_rho,
acc_temperature, acc_velocity, acc_vGrad, acc_dudt, acc_dTdt,
acc_nType, acc_m_d,
r_BC,
getSize<Xdir>(r_BC), getSize<Ydir>(r_BC), getSize<Zdir>(r_BC));
}
template void UpdateUsingFluxNSCBCInflowMinusSideTask<Xdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingFluxNSCBCInflowPlusSideTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void UpdateUsingFluxNSCBCInflowPlusSideTask_kernel(
const AccessorRW<VecNEq, 3> Conserved_t,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> pressure,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO<double, 3> temperature,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO< Vec3, 3> vGrad,
const AccessorRO< Vec3, 3> dudt,
const AccessorRO<double, 3> dTdt,
const AccessorRO< int, 3> nType,
const AccessorRO<double, 3> m_d,
const Rect<3> BC_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + BC_bounds.lo.x,
y + BC_bounds.lo.y,
z + BC_bounds.lo.z);
UpdateUsingFluxNSCBCInflowMinusSideTask<dir>::addLODIfluxes(
Conserved_t[p].v,
MassFracs, pressure,
SoS[p], rho[p], temperature[p],
velocity[p].v, vGrad[p].v, dudt[p].v, dTdt[p],
p, nType[p], m_d[p], mix);
}
}
template<direction dir>
__host__
void UpdateUsingFluxNSCBCInflowPlusSideTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 2);
assert(futures.size() == 0);
// Accessors for Input data
const AccessorRO< int, 3> acc_nType (regions[0], FID_nType);
const AccessorRO<double, 3> acc_m_d (regions[0], FID_m_d);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<VecNSp, 3> acc_MassFracs (regions[0], FID_MassFracs);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
const AccessorRO<double, 3> acc_temperature(regions[0], FID_temperature);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO< Vec3, 3> acc_vGrad (regions[0], FID_vGrad);
const AccessorRO< Vec3, 3> acc_dudt (regions[0], FID_dudtBoundary);
const AccessorRO<double, 3> acc_dTdt (regions[0], FID_dTdtBoundary);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[1], FID_Conserved_t);
// Extract BC domain
Rect<3> r_BC = runtime->get_index_space_domain(ctx,
runtime->get_logical_subregion_by_color(args.Fluid_BC, 0).get_index_space());
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Launch the kernel to update the RHS NSCBC nodes
const int threads_per_block = 256;
const dim3 TPB_3d = splitThreadsPerBlock<Xdir>(threads_per_block, r_BC);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_BC) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_BC) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_BC) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateUsingFluxNSCBCInflowMinusSideTask_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
acc_Conserved_t,
acc_MassFracs, acc_pressure, acc_SoS, acc_rho,
acc_temperature, acc_velocity, acc_vGrad, acc_dudt, acc_dTdt,
acc_nType, acc_m_d,
r_BC,
getSize<Xdir>(r_BC), getSize<Ydir>(r_BC), getSize<Zdir>(r_BC));
}
template void UpdateUsingFluxNSCBCInflowPlusSideTask<Ydir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingFluxNSCBCOutflowMinusSideTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void UpdateUsingFluxNSCBCOutflowMinusSideTask_kernel(
const AccessorRW<VecNEq, 3> Conserved_t,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> pressure,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO<double, 3> mu,
const AccessorRO<double, 3> temperature,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<VecNEq, 3> Conserved,
const AccessorRO< Vec3, 3> vGradN,
const AccessorRO< Vec3, 3> vGradT1,
const AccessorRO< Vec3, 3> vGradT2,
const AccessorRO< int, 3> nType,
const AccessorRO<double, 3> m_d,
const double MaxMach,
const double LengthScale,
const double PInf,
const Rect<3> BC_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + BC_bounds.lo.x,
y + BC_bounds.lo.y,
z + BC_bounds.lo.z);
UpdateUsingFluxNSCBCOutflowMinusSideTask<dir>::addLODIfluxes(
Conserved_t[p].v,
MassFracs, rho, mu, pressure,
velocity, vGradN, vGradT1, vGradT2,
SoS[p], temperature[p], Conserved[p].v,
p, nType[p], m_d[p],
MaxMach, LengthScale, PInf, mix);
}
}
template<direction dir>
__host__
void UpdateUsingFluxNSCBCOutflowMinusSideTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 2);
assert(futures.size() == 1);
// Accessors for Input data
const AccessorRO< int, 3> acc_nType (regions[0], FID_nType);
const AccessorRO<double, 3> acc_m_d (regions[0], FID_m_d);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<double, 3> acc_mu (regions[0], FID_mu);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<VecNSp, 3> acc_MassFracs (regions[0], FID_MassFracs);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
const AccessorRO<double, 3> acc_temperature(regions[0], FID_temperature);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO<VecNEq, 3> acc_Conserved (regions[0], FID_Conserved);
const AccessorRO< Vec3, 3> acc_vGradN (regions[0], FID_vGradN);
const AccessorRO< Vec3, 3> acc_vGradT1 (regions[0], FID_vGradT1);
const AccessorRO< Vec3, 3> acc_vGradT2 (regions[0], FID_vGradT2);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[1], FID_Conserved_t);
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Wait for the maximum Mach number
const double MaxMach = futures[0].get_result<double>();
// Extract BC domain
Rect<3> r_BC = runtime->get_index_space_domain(ctx,
runtime->get_logical_subregion_by_color(args.Fluid_BC, 0).get_index_space());
// Launch the kernel to update the RHS NSCBC nodes
const int threads_per_block = 256;
const dim3 TPB_3d = splitThreadsPerBlock<Xdir>(threads_per_block, r_BC);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_BC) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_BC) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_BC) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateUsingFluxNSCBCOutflowMinusSideTask_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
acc_Conserved_t,
acc_MassFracs, acc_pressure, acc_SoS, acc_rho, acc_mu,
acc_temperature, acc_velocity, acc_Conserved,
acc_vGradN, acc_vGradT1, acc_vGradT2,
acc_nType, acc_m_d,
MaxMach, args.LengthScale, args.PInf, r_BC,
getSize<Xdir>(r_BC), getSize<Ydir>(r_BC), getSize<Zdir>(r_BC));
}
template void UpdateUsingFluxNSCBCOutflowMinusSideTask<Ydir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
//-----------------------------------------------------------------------------
// KERNELS FOR UpdateUsingFluxNSCBCOutflowPlusSideTask
//-----------------------------------------------------------------------------
template<direction dir>
__global__
void UpdateUsingFluxNSCBCOutflowPlusSideTask_kernel(
const AccessorRW<VecNEq, 3> Conserved_t,
const AccessorRO<VecNSp, 3> MassFracs,
const AccessorRO<double, 3> pressure,
const AccessorRO<double, 3> SoS,
const AccessorRO<double, 3> rho,
const AccessorRO<double, 3> mu,
const AccessorRO<double, 3> temperature,
const AccessorRO< Vec3, 3> velocity,
const AccessorRO<VecNEq, 3> Conserved,
const AccessorRO< Vec3, 3> vGradN,
const AccessorRO< Vec3, 3> vGradT1,
const AccessorRO< Vec3, 3> vGradT2,
const AccessorRO< int, 3> nType,
const AccessorRO<double, 3> m_d,
const double MaxMach,
const double LengthScale,
const double PInf,
const Rect<3> BC_bounds,
const coord_t size_x,
const coord_t size_y,
const coord_t size_z)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
if ((x < size_x) && (y < size_y) && (z < size_z)) {
const Point<3> p = Point<3>(x + BC_bounds.lo.x,
y + BC_bounds.lo.y,
z + BC_bounds.lo.z);
UpdateUsingFluxNSCBCOutflowPlusSideTask<dir>::addLODIfluxes(
Conserved_t[p].v,
MassFracs, rho, mu, pressure,
velocity, vGradN, vGradT1, vGradT2,
SoS[p], temperature[p], Conserved[p].v,
p, nType[p], m_d[p],
MaxMach, LengthScale, PInf, mix);
}
}
template<direction dir>
__host__
void UpdateUsingFluxNSCBCOutflowPlusSideTask<dir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime)
{
assert(regions.size() == 2);
assert(futures.size() == 1);
// Accessors for Input data
const AccessorRO< int, 3> acc_nType (regions[0], FID_nType);
const AccessorRO<double, 3> acc_m_d (regions[0], FID_m_d);
const AccessorRO<double, 3> acc_rho (regions[0], FID_rho);
const AccessorRO<double, 3> acc_mu (regions[0], FID_mu);
const AccessorRO<double, 3> acc_SoS (regions[0], FID_SoS);
const AccessorRO<VecNSp, 3> acc_MassFracs (regions[0], FID_MassFracs);
const AccessorRO<double, 3> acc_pressure (regions[0], FID_pressure);
const AccessorRO<double, 3> acc_temperature(regions[0], FID_temperature);
const AccessorRO< Vec3, 3> acc_velocity (regions[0], FID_velocity);
const AccessorRO<VecNEq, 3> acc_Conserved (regions[0], FID_Conserved);
const AccessorRO< Vec3, 3> acc_vGradN (regions[0], FID_vGradN);
const AccessorRO< Vec3, 3> acc_vGradT1 (regions[0], FID_vGradT1);
const AccessorRO< Vec3, 3> acc_vGradT2 (regions[0], FID_vGradT2);
// Accessors for RHS
const AccessorRW<VecNEq, 3> acc_Conserved_t(regions[1], FID_Conserved_t);
// Copy the mixture to the device
cudaMemcpyToSymbolAsync(mix, &(args.mix), sizeof(Mix));
// Wait for the maximum Mach number
const double MaxMach = futures[0].get_result<double>();
// Extract BC domain
Rect<3> r_BC = runtime->get_index_space_domain(ctx,
runtime->get_logical_subregion_by_color(args.Fluid_BC, 0).get_index_space());
// Launch the kernel to update the RHS NSCBC nodes
const int threads_per_block = 256;
const dim3 TPB_3d = splitThreadsPerBlock<Xdir>(threads_per_block, r_BC);
const dim3 num_blocks_3d = dim3((getSize<Xdir>(r_BC) + (TPB_3d.x - 1)) / TPB_3d.x,
(getSize<Ydir>(r_BC) + (TPB_3d.y - 1)) / TPB_3d.y,
(getSize<Zdir>(r_BC) + (TPB_3d.z - 1)) / TPB_3d.z);
UpdateUsingFluxNSCBCOutflowPlusSideTask_kernel<dir><<<num_blocks_3d, TPB_3d>>>(
acc_Conserved_t,
acc_MassFracs, acc_pressure, acc_SoS, acc_rho, acc_mu,
acc_temperature, acc_velocity, acc_Conserved,
acc_vGradN, acc_vGradT1, acc_vGradT2,
acc_nType, acc_m_d,
MaxMach, args.LengthScale, args.PInf, r_BC,
getSize<Xdir>(r_BC), getSize<Ydir>(r_BC), getSize<Zdir>(r_BC));
}
template void UpdateUsingFluxNSCBCOutflowPlusSideTask<Xdir>::gpu_base_impl(
const Args &args,
const std::vector<PhysicalRegion> ®ions,
const std::vector<Future> &futures,
Context ctx, Runtime *runtime);
template void UpdateUsingFluxNSCBCOutflowPlusSideTask<Ydir>::gpu_base_impl(