Skip to content

Commit d2a851d

Browse files
Merge pull request #203 from alwinm/main-float32
Float 32 output, HDF5 overhaul, static_grav and other minor fixes. (copy for main)
2 parents cf898d5 + 03b3482 commit d2a851d

12 files changed

Lines changed: 578 additions & 570 deletions

File tree

builds/make.type.rot_proj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#-- Default hydro only build with rotated projection
2+
3+
DFLAGS += -DCUDA
4+
DFLAGS += -DMPI_CHOLLA
5+
DFLAGS += -DPRECISION=2
6+
DFLAGS += -DPPMC
7+
DFLAGS += -DHLLC
8+
9+
# Integrator
10+
DFLAGS += -DSIMPLE
11+
#DFLAGS += -DVL
12+
13+
# Apply a density and temperature floor
14+
DFLAGS += -DDENSITY_FLOOR
15+
DFLAGS += -DTEMPERATURE_FLOOR
16+
17+
# Solve the Gas Internal Energy usisng a Dual Energy Formalism
18+
#DFLAGS += -DDE
19+
20+
# Apply cooling on the GPU from precomputed tables
21+
#DFLAGS += -DCOOLING_GPU
22+
23+
# Measure the Timing of the different stages
24+
#DFLAGS += -DCPU_TIME
25+
26+
# Select output format
27+
# Can also add -DSLICES and -DPROJECTIONS
28+
OUTPUT ?= -DOUTPUT -DHDF5
29+
DFLAGS += $(OUTPUT)
30+
31+
DFLAGS += -DROTATED_PROJECTION

builds/make.type.static_grav

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#-- Default hydro only build with static_grav
2+
3+
DFLAGS += -DCUDA
4+
DFLAGS += -DMPI_CHOLLA
5+
DFLAGS += -DPRECISION=2
6+
DFLAGS += -DPPMC
7+
DFLAGS += -DHLLC
8+
9+
# Integrator
10+
DFLAGS += -DSIMPLE
11+
#DFLAGS += -DVL
12+
13+
# Apply a density and temperature floor
14+
DFLAGS += -DDENSITY_FLOOR
15+
DFLAGS += -DTEMPERATURE_FLOOR
16+
17+
# Solve the Gas Internal Energy usisng a Dual Energy Formalism
18+
#DFLAGS += -DDE
19+
20+
DFLAGS += -DSTATIC_GRAV
21+
22+
# Apply cooling on the GPU from precomputed tables
23+
#DFLAGS += -DCOOLING_GPU
24+
25+
# Measure the Timing of the different stages
26+
#DFLAGS += -DCPU_TIME
27+
28+
# Select output format
29+
# Can also add -DSLICES and -DPROJECTIONS
30+
OUTPUT ?= -DOUTPUT -DHDF5
31+
DFLAGS += $(OUTPUT)
32+

examples/3D/float32_sound_wave.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# Parameter File for sound wave test with float32 output
3+
#
4+
5+
################################################
6+
# number of grid cells in the x dimension
7+
nx=256
8+
# number of grid cells in the y dimension
9+
ny=256
10+
# number of grid cells in the z dimension
11+
nz=256
12+
# final output time
13+
tout=0.05
14+
# time interval for output
15+
outstep=0.05
16+
# name of initial conditions
17+
init=Sound_Wave
18+
# domain properties
19+
xmin=0.0
20+
ymin=0.0
21+
zmin=0.0
22+
xlen=4.0
23+
ylen=4.0
24+
zlen=4.0
25+
# type of boundary conditions
26+
xl_bcnd=1
27+
xu_bcnd=1
28+
yl_bcnd=1
29+
yu_bcnd=1
30+
zl_bcnd=1
31+
zu_bcnd=1
32+
# path to output directory
33+
outdir=./
34+
35+
# Enable float32 output
36+
# Enable float32 density field
37+
n_out_float32=1
38+
out_float32_density=1
39+
40+
# Uncomment this to enable momentum_x
41+
# out_float32_momentum_x=1
42+
43+
#################################################
44+
# Parameters for linear wave problems
45+
# initial density
46+
rho=1.0
47+
# velocity in the x direction
48+
vx=0
49+
# velocity in the y direction
50+
vy=0
51+
# velocity in the z direction
52+
vz=0
53+
# initial pressure
54+
P=0.6
55+
# amplitude of perturbing oscillations
56+
A=1e-4
57+
# value of gamma
58+
gamma=1.666666666666667
59+

src/global/global.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,30 @@ void parse_param(char *name,char *value, struct parameters *parms){
223223
parms->n_rotated_projection = atoi(value);
224224
else if (strcmp(name, "n_slice")==0)
225225
parms->n_slice = atoi(value);
226+
else if (strcmp(name, "n_out_float32")==0)
227+
parms->n_out_float32 = atoi(value);
228+
else if (strcmp(name, "out_float32_density")==0)
229+
parms->out_float32_density = atoi(value);
230+
else if (strcmp(name, "out_float32_momentum_x")==0)
231+
parms->out_float32_momentum_x = atoi(value);
232+
else if (strcmp(name, "out_float32_momentum_y")==0)
233+
parms->out_float32_momentum_y = atoi(value);
234+
else if (strcmp(name, "out_float32_momentum_z")==0)
235+
parms->out_float32_momentum_z = atoi(value);
236+
else if (strcmp(name, "out_float32_Energy")==0)
237+
parms->out_float32_Energy = atoi(value);
238+
#ifdef DE
239+
else if (strcmp(name, "out_float32_GasEnergy")==0)
240+
parms->out_float32_GasEnergy = atoi(value);
241+
#endif // DE
242+
#ifdef MHD
243+
else if (strcmp(name, "out_float32_magnetic_x")==0)
244+
parms->out_float32_magnetic_x = atoi(value);
245+
else if (strcmp(name, "out_float32_magnetic_y")==0)
246+
parms->out_float32_magnetic_y = atoi(value);
247+
else if (strcmp(name, "out_float32_magnetic_z")==0)
248+
parms->out_float32_magnetic_z = atoi(value);
249+
#endif // MHD
226250
else if (strcmp(name, "xmin")==0)
227251
parms->xmin = atof(value);
228252
else if (strcmp(name, "ymin")==0)
@@ -366,7 +390,7 @@ void parse_param(char *name,char *value, struct parameters *parms){
366390
#ifdef CHEMISTRY_GPU
367391
else if (strcmp(name, "UVB_rates_file")==0)
368392
strncpy (parms->UVB_rates_file, value, MAXLEN);
369-
#endif
393+
#endif
370394
#ifdef COOLING_GRACKLE
371395
else if (strcmp(name, "UVB_rates_file")==0)
372396
strncpy (parms->UVB_rates_file, value, MAXLEN);

src/global/global.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ struct parameters
204204
int n_projection;
205205
int n_rotated_projection;
206206
int n_slice;
207+
int n_out_float32=0;
208+
int out_float32_density=0;
209+
int out_float32_momentum_x=0;
210+
int out_float32_momentum_y=0;
211+
int out_float32_momentum_z=0;
212+
int out_float32_Energy=0;
213+
#ifdef DE
214+
int out_float32_GasEnergy=0;
215+
#endif
216+
#ifdef MHD
217+
int out_float32_magnetic_x=0;
218+
int out_float32_magnetic_y=0;
219+
int out_float32_magnetic_z=0;
220+
#endif
207221
Real xmin;
208222
Real ymin;
209223
Real zmin;

src/global/global_cuda.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
9292
}
9393
}
9494

95-
96-
97-
/*! \fn Real minof3(Real a, Real b, Real c)
98-
* \brief Returns the minimum of three floating point numbers. */
99-
__device__ inline Real minof3(Real a, Real b, Real c)
100-
{
101-
return fmin(a, fmin(b,c));
102-
}
103-
104-
105-
10695
/*! \fn int sgn_CUDA
10796
* \brief Mathematical sign function. Returns sign of x. */
10897
__device__ inline int sgn_CUDA(Real x)
@@ -111,11 +100,6 @@ __device__ inline int sgn_CUDA(Real x)
111100
else return 1;
112101
}
113102

114-
115-
__global__ void test_function();
116-
117-
118-
119103
#endif //GLOBAL_CUDA_H
120104

121105
#endif //CUDA

src/gravity/gravity_cuda.h

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
functions in hydro_cuda.cu. */
55
#ifdef CUDA
66

7+
#pragma once
8+
79
#include <stdio.h>
8-
#include <math.h>
9-
#include "../utils/gpu.hpp"
10-
#include "../global/global.h"
11-
#include "../global/global_cuda.h"
12-
#include "../gravity/gravity_cuda.h"
10+
#include <math.h> // provides sqrt log cos sin atan etc.
11+
#include "../global/global.h" // provides GN etc.
1312

1413
// Work around lack of pow(Real,int) in Hip Clang for Rocm 3.5
1514
static inline __device__ Real pow2(const Real x) { return x*x; }
1615

17-
__device__ void calc_g_1D(int xid, int x_off, int n_ghost, Real dx, Real xbound, Real *gx)
16+
inline __device__ void calc_g_1D(int xid, int x_off, int n_ghost, Real dx, Real xbound, Real *gx)
1817
{
1918
Real x_pos, r_disk, r_halo;
2019
x_pos = (x_off + xid - n_ghost + 0.5)*dx + xbound;
@@ -52,7 +51,7 @@ __device__ void calc_g_1D(int xid, int x_off, int n_ghost, Real dx, Real xbound,
5251
}
5352

5453

55-
__device__ void calc_g_2D(int xid, int yid, int x_off, int y_off, int n_ghost, Real dx, Real dy, Real xbound, Real ybound, Real *gx, Real *gy)
54+
inline __device__ void calc_g_2D(int xid, int yid, int x_off, int y_off, int n_ghost, Real dx, Real dy, Real xbound, Real ybound, Real *gx, Real *gy)
5655
{
5756
Real x_pos, y_pos, r, phi;
5857
// use the subgrid offset and global boundaries to calculate absolute positions on the grid
@@ -108,7 +107,7 @@ __device__ void calc_g_2D(int xid, int yid, int x_off, int y_off, int n_ghost, R
108107
}
109108

110109

111-
__device__ void calc_g_3D(int xid, int yid, int zid, int x_off, int y_off, int z_off, int n_ghost, Real dx, Real dy, Real dz, Real xbound, Real ybound, Real zbound, Real *gx, Real *gy, Real *gz)
110+
inline __device__ void calc_g_3D(int xid, int yid, int zid, int x_off, int y_off, int z_off, int n_ghost, Real dx, Real dy, Real dz, Real xbound, Real ybound, Real zbound, Real *gx, Real *gy, Real *gz)
112111
{
113112
Real x_pos, y_pos, z_pos, r_disk, r_halo;
114113
// use the subgrid offset and global boundaries to calculate absolute positions on the grid

src/hydro/hydro_cuda.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "../global/global.h"
1111
#include "../global/global_cuda.h"
1212
#include "../hydro/hydro_cuda.h"
13-
#include "../gravity/gravity_cuda.h"
13+
#include "../gravity/static_grav.h"
1414
#include "../utils/hydro_utilities.h"
1515
#include "../utils/cuda_utilities.h"
1616
#include "../utils/reduction_utilities.h"

0 commit comments

Comments
 (0)