Skip to content

Commit 03b3482

Browse files
committed
static_grav renamed/fixed, light side fixes
1 parent f68e794 commit 03b3482

7 files changed

Lines changed: 86 additions & 51 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+

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"

src/io/io.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,11 @@ void Grid3D::Write_Rotated_Projection_HDF5(hid_t file_id)
18201820
int nx_dset = R.nx;
18211821
int nz_dset = R.nz;
18221822

1823+
if (R.nx * R.nz == 0) {
1824+
chprintf("WARNING: compiled with -DROTATED_PROJECTION but input parameters nxr or nzr = 0\n");
1825+
return;
1826+
}
1827+
18231828
// set the projected dataset size for this process to capture
18241829
// this piece of the simulation volume
18251830
// min and max values were set in the header write
@@ -1920,15 +1925,17 @@ void Grid3D::Write_Rotated_Projection_HDF5(hid_t file_id)
19201925
// Free the dataspace id
19211926
status = H5Sclose(dataspace_xzr_id);
19221927

1928+
//free the data
1929+
free(dataset_buffer_dxzr);
1930+
free(dataset_buffer_Txzr);
1931+
free(dataset_buffer_vxxzr);
1932+
free(dataset_buffer_vyxzr);
1933+
free(dataset_buffer_vzxzr);
1934+
19231935
}
1924-
else printf("Rotated projection write only implemented for 3D data.\n");
1925-
1926-
//free the data
1927-
free(dataset_buffer_dxzr);
1928-
free(dataset_buffer_Txzr);
1929-
free(dataset_buffer_vxxzr);
1930-
free(dataset_buffer_vyxzr);
1931-
free(dataset_buffer_vzxzr);
1936+
else chprintf("Rotated projection write only implemented for 3D data.\n");
1937+
1938+
19321939

19331940
}
19341941
#endif //HDF5

0 commit comments

Comments
 (0)