Skip to content

Commit e279b7f

Browse files
author
Menno Veerman
committed
updating backward raytracer
1 parent 613390f commit e279b7f

File tree

12 files changed

+766
-406
lines changed

12 files changed

+766
-406
lines changed

include_rt/Raytracer_bw.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Raytracer_bw
2020

2121
void trace_rays(
2222
const Int photons_to_shoot,
23-
const int n_col_x, const int n_col_y, const int n_lay,
23+
const int n_col_x, const int n_col_y, const int nz, const int n_lay,
2424
const Float dx_grid, const Float dy_grid, const Float dz_grid,
2525
const Array_gpu<Float,1>& z_lev,
2626
const Optical_props_2str_rt& optical_props,
@@ -29,7 +29,7 @@ class Raytracer_bw
2929
const Float zenith_angle,
3030
const Float azimuth_angle,
3131
const Float tod_inc_direct,
32-
const Float tod_inc_diffuse.
32+
const Float tod_inc_diffuse,
3333
const Float toa_factor,
3434
const Float rayleigh,
3535
const Array_gpu<Float,2>& col_dry,
@@ -41,6 +41,7 @@ class Raytracer_bw
4141
const Int photons_to_shoot,
4242
const int ncol_x, const int ncol_y, const int nz, const int nlay,
4343
const Float dx_grid, const Float dy_grid, const Float dz_grid,
44+
const Array_gpu<Float,1>& z_lev,
4445
const Array_gpu<Float,2>& tau_gas,
4546
const Array_gpu<Float,2>& ssa_gas,
4647
const Array_gpu<Float,2>& asy_gas,
@@ -53,6 +54,11 @@ class Raytracer_bw
5354
const Array_gpu<Float,1>& cam_data,
5455
Array_gpu<Float,2>& flux_camera);
5556

57+
void add_camera(
58+
const int cam_nx, const int cam_ny,
59+
const Array_gpu<Float,2>& flux_camera,
60+
Array_gpu<Float,2>& radiance);
61+
5662
void add_xyz_camera(
5763
const int cam_nx, const int cam_ny,
5864
const Array_gpu<Float,1>& xyz_factor,

include_rt/gpt_combine_kernel_launcher_cuda_rt.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,35 @@
3131

3232
namespace gpt_combine_kernel_launcher_cuda_rt
3333
{
34-
34+
3535
void get_from_gpoint(const int ncol, const int igpt,
3636
Float* var_full, const Float* var_sub);
3737

3838
void add_from_gpoint(const int ncol, const int nlay,
3939
Float* var1_full, Float* var2_full, Float* var3_full, Float* var4_full, Float* var5_full,
4040
const Float* var1_sub, const Float* var2_sub, const Float* var3_sub, const Float* var4_sub, const Float* var5_sub);
41-
41+
4242
void add_from_gpoint(const int ncol, const int nlay,
4343
Float* var1_full, Float* var2_full, Float* var3_full, Float* var4_full,
4444
const Float* var1_sub, const Float* var2_sub, const Float* var3_sub, const Float* var4_sub);
45-
45+
4646
void add_from_gpoint(const int ncol, const int nlay,
4747
Float* var1_full, Float* var2_full,
4848
const Float* var1_sub, const Float* var2_sub);
49-
50-
49+
50+
void add_from_gpoint(const int ncol, const int nlay,
51+
Float* var1_full, const Float* var1_sub);
52+
5153
void add_from_gpoint(const int ncol, const int nlay,
5254
Float* var1_full, Float* var2_full, Float* var3_full,
5355
const Float* var1_sub, const Float* var2_sub, const Float* var3_sub);
5456

55-
57+
5658
void get_from_gpoint(const int ncol, const int nlay, const int igpt,
5759
Float* var1_full, Float* var2_full, Float* var3_full, Float* var4_full,
5860
const Float* var1_sub, const Float* var2_sub, const Float* var3_sub, const Float* var4_sub);
5961

60-
62+
6163
void get_from_gpoint(const int ncol, const int nlay, const int igpt,
6264
Float* var1_full, Float* var2_full, Float* var3_full,
6365
const Float* var1_sub, const Float* var2_sub, const Float* var3_sub);

include_rt/raytracer_kernels_bw.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
#ifdef RTE_RRTMGP_SINGLE_PRECISION
99
//using Float = float;
10-
constexpr int block_size= 512;
11-
constexpr int grid_size = 1024;
10+
constexpr int block_size= 256;
11+
constexpr int grid_size = 512;
1212
#else
1313
//using Float = double;
14-
constexpr int block_size = 512;
14+
constexpr int block_size = 256;
1515
constexpr int grid_size = 256;
1616
#endif
1717
using Int = unsigned long long;
18-
constexpr int ngrid_x = 20;
19-
constexpr int ngrid_y = 20;
20-
constexpr int ngrid_z = 35;
18+
constexpr int ngrid_x = 48;
19+
constexpr int ngrid_y = 48;
20+
constexpr int ngrid_z = 36;
2121
constexpr Float k_null_gas_min = Float(1.e-3);
2222

2323

@@ -45,16 +45,17 @@ void ray_tracer_kernel_bw(
4545
const Int photons_to_shoot,
4646
const Grid_knull* __restrict__ k_null_grid,
4747
Float* __restrict__ camera_count,
48+
Float* __restrict__ camera_diff,
4849
Float* __restrict__ camera_shot,
4950
int* __restrict__ counter,
5051
const int cam_nx, const int cam_ny, const Float* __restrict__ cam_data,
5152
const Optics_ext* __restrict__ k_ext, const Optics_scat* __restrict__ ssa_asy,
53+
const Optics_ext* __restrict__ k_ext_bg, const Optics_scat* __restrict__ ssa_asy_bg,
54+
const Float* __restrict__ z_lev_bg,
5255
const Float* __restrict__ surface_albedo,
5356
const Float mu,
54-
const Float bg_trans,
55-
const Float tod_frac_diffuse,
5657
const Float x_size, const Float y_size, const Float z_size,
5758
const Float dx_grid, const Float dy_grid, const Float dz_grid,
5859
const Float dir_x, const Float dir_y, const Float dir_z,
59-
const int itot, const int jtot, const int ktot);
60+
const int itot, const int jtot, const int ktot, const int nbg);
6061
#endif

include_test/Radiation_solver_bw.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ class Radiation_solver_shortwave
153153
const Array_gpu<Float,1>& grid_dims,
154154
Array_gpu<Float,2>& col_dry,
155155
const Array_gpu<Float,2>& sfc_alb_dir, const Array_gpu<Float,2>& sfc_alb_dif,
156-
const Array_gpu<Float,1>& tsi_scaling, const Array_gpu<Float,1>& mu0,
156+
const Array_gpu<Float,1>& tsi_scaling,
157+
const Array_gpu<Float,1>& mu0, const Array_gpu<Float,1>& azi,
157158
const Array_gpu<Float,2>& lwp, const Array_gpu<Float,2>& iwp,
158159
const Array_gpu<Float,2>& rel, const Array_gpu<Float,2>& rei,
159160
const Array_gpu<Float,1>& cam_data,
160161
Array_gpu<Float,3>& XYZ);
162+
#endif
161163

162164
#ifdef __CUDACC__
163165
void solve_gpu_bb(
@@ -171,7 +173,8 @@ class Radiation_solver_shortwave
171173
const Array_gpu<Float,1>& grid_dims,
172174
Array_gpu<Float,2>& col_dry,
173175
const Array_gpu<Float,2>& sfc_alb_dir, const Array_gpu<Float,2>& sfc_alb_dif,
174-
const Array_gpu<Float,1>& tsi_scaling, const Array_gpu<Float,1>& mu0,
176+
const Array_gpu<Float,1>& tsi_scaling,
177+
const Array_gpu<Float,1>& mu0, const Array_gpu<Float,1>& azi,
175178
const Array_gpu<Float,2>& lwp, const Array_gpu<Float,2>& iwp,
176179
const Array_gpu<Float,2>& rel, const Array_gpu<Float,2>& rei,
177180
const Array_gpu<Float,1>& cam_data,

src_cuda_rt/Raytracer.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace
123123

124124
__global__
125125
void count_to_flux_3d(
126-
const int ncol_x, const int ncol_y, const int nlay, const Float photons_per_col,
126+
const int ncol_x, const int ncol_y, const int nlay, const Float photons_per_col,
127127
const Float dz_grid, const Float toa_src,
128128
const Float* __restrict__ count_1, const Float* __restrict__ count_2,
129129
Float* __restrict__ flux_1, Float* __restrict__ flux_2)
@@ -266,7 +266,7 @@ void Raytracer::trace_rays(
266266
// number of photons per thread, this should a power of 2 and nonzero
267267
Float photons_per_thread_tmp = std::max(Float(1), static_cast<Float>(photons_total) / (grid_size * block_size));
268268
Int photons_per_thread = pow(Float(2.), std::floor(std::log2(Float(photons_per_thread_tmp))));
269-
269+
printf(" raytracing \n");
270270
ray_tracer_kernel<<<grid, block>>>(
271271
photons_per_thread,
272272
qrng_grid_x,

0 commit comments

Comments
 (0)