Skip to content

Commit 5640599

Browse files
authored
Merge pull request #328 from mlee03/acc2gpu
convert fregrid_acc to fregrid_gpu
2 parents 7b34d65 + 9480f58 commit 5640599

30 files changed

+759
-759
lines changed

Makefile.am

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ if WITH_CHECK_PROGS
5656
SUBDIRS += t
5757
endif
5858

59-
if ENABLE_ACC
60-
SUBDIRS += tools/libfrencutils_acc
61-
SUBDIRS += tools/fregrid_acc
62-
SUBDIRS += t_acc
59+
if ENABLE_GPU
60+
SUBDIRS += tools/libfrencutils_gpu
61+
SUBDIRS += tools/fregrid_gpu
62+
SUBDIRS += t_gpu
6363
endif

configure.ac

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ AM_CONDITIONAL([WITH_MPI_TESTS], [test x"$build_mpi" = x"yes" -a -z "$SKIP_MPI_T
8989
AC_ARG_ENABLE([acc],
9090
[AS_HELP_STRING([--enable-acc],
9191
[Builds with OpenACC. This will result in a second executable for fregrid, fregrid_gpu.(default no)])])
92-
AS_IF([test ${enable_acc:-no} = yes],
93-
[enable_acc=yes],
94-
[enable_acc=no])
92+
AS_IF([test ${enable_gpu:-no} = yes],
93+
[enable_gpu=yes],
94+
[enable_gpu=no])
9595
# check compile flags
96-
AS_IF([test ${enable_acc} = yes],
96+
AS_IF([test ${enable_gpu} = yes],
9797
[GX_OPENACC_FLAGS()])
98-
AM_CONDITIONAL([ENABLE_ACC], [test "$enable_acc" = "yes"])
98+
AM_CONDITIONAL([ENABLE_GPU], [test "$enable_gpu" = "yes"])
9999

100100
AC_CHECK_FUNCS(gettid, [], [])
101101

@@ -135,7 +135,7 @@ else
135135
fi
136136

137137
# Check if openacc.h exists
138-
if test "$enable_acc" = yes ; then
138+
if test "$enable_gpu" = yes ; then
139139
AC_CHECK_HEADERS([openacc.h], [], [AC_MSG_ERROR(["Cannot find OpenACC header file"])] )
140140
AC_MSG_WARN(Currently only NVIDIA compilers are supported to compile with OpenACC in FRE-NCTOOLS)
141141
fi
@@ -206,11 +206,11 @@ AC_CONFIG_FILES([Makefile
206206
postprocessing/split_ncvars/Makefile
207207
postprocessing/timavg/Makefile
208208
tools/libfrencutils/Makefile
209-
tools/libfrencutils_acc/Makefile
209+
tools/libfrencutils_gpu/Makefile
210210
tools/check_mask/Makefile
211211
tools/cubic_utils/Makefile
212212
tools/fregrid/Makefile
213-
tools/fregrid_acc/Makefile
213+
tools/fregrid_gpu/Makefile
214214
tools/make_coupler_mosaic/Makefile
215215
tools/make_hgrid/Makefile
216216
tools/make_land_domain/Makefile
@@ -232,11 +232,11 @@ AC_CONFIG_FILES([Makefile
232232
tools/simple_hydrog/rmvpr/Makefile
233233
tools/simple_hydrog/libfmslite/Makefile
234234
t/Makefile
235-
t_acc/Makefile
236-
t_acc/test_read_remap_file/Makefile
237-
t_acc/test_get_grid_cell_struct/Makefile
238-
t_acc/test_get_upbound_nxcells_2dx2d/Makefile
239-
t_acc/test_get_interp_order1/Makefile
235+
t_gpu/Makefile
236+
t_gpu/test_read_remap_file/Makefile
237+
t_gpu/test_get_grid_cell_struct/Makefile
238+
t_gpu/test_get_upbound_nxcells_2dx2d/Makefile
239+
t_gpu/test_get_interp_order1/Makefile
240240
241241
])
242242

File renamed without changes.

t_acc/test_get_grid_cell_struct/Makefile.am renamed to t_gpu/test_get_grid_cell_struct/Makefile.am

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
check_PROGRAMS = test_get_grid_cell_struct
2121

2222
AM_CFLAGS = $(NETCDF_CFLAGS) \
23-
-I$(top_srcdir)/tools/fregrid_acc \
23+
-I$(top_srcdir)/tools/fregrid_gpu \
2424
-I$(top_srcdir)/tools/libfrencutils \
25-
-I$(top_srcdir)/tools/libfrencutils_acc -acc
25+
-I$(top_srcdir)/tools/libfrencutils_gpu -acc
2626

2727
LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) \
28-
$(top_builddir)/tools/fregrid_acc/interp_utils_acc.o \
28+
$(top_builddir)/tools/fregrid_gpu/interp_utils_gpu.o \
2929
$(top_builddir)/tools/libfrencutils/libfrencutils.a \
30-
$(top_builddir)/tools/libfrencutils_acc/libfrencutils_acc.a
30+
$(top_builddir)/tools/libfrencutils_gpu/libfrencutils_gpu.a
3131

3232
test_get_grid_cell_struct_SOURCES = test_get_grid_cell_struct.c
3333

t_acc/test_get_grid_cell_struct/test_get_grid_cell_struct.c renamed to t_gpu/test_get_grid_cell_struct/test_get_grid_cell_struct.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
* <http://www.gnu.org/licenses/>.
1919
**********************************************************************/
2020

21-
// This test tests the function test_get_grid_cell_struct used in fregrid_acc.
21+
// This test tests the function test_get_grid_cell_struct used in fregrid_gpu.
2222
// Properties of each grid cell in a smple made-up grid with no poles are computed
2323
// on the device. This test ensures that the data transfer between the host and device
2424
// and computations have executed on the device as expected.
2525

2626
#include <stdlib.h>
2727
#include <stdio.h>
2828
#include <math.h>
29-
#include "create_xgrid_utils_acc.h"
30-
#include "interp_utils_acc.h"
29+
#include "create_xgrid_utils_gpu.h"
30+
#include "interp_utils_gpu.h"
3131
#include "parameters.h"
32-
#include "globals_acc.h"
32+
#include "globals_gpu.h"
3333

3434
#define NLON 36 // 36 cells in lon direction (36+1 grid points in the lon direction for each lat point)
3535
#define NLAT 4 // 4 cells in lat direction ( 4+1 grid points in the lat direction for each lon point)
@@ -79,10 +79,10 @@ int main(){
7979
}
8080

8181
// copy grid to device
82-
copy_grid_to_device_acc((NLON+1)*(NLAT+1), grid.latc, grid.lonc);
82+
copy_grid_to_device_gpu((NLON+1)*(NLAT+1), grid.latc, grid.lonc);
8383

8484
// get grid_cells
85-
get_grid_cell_struct_acc( NLON, NLAT, &grid, &grid_cells);
85+
get_grid_cell_struct_gpu( NLON, NLAT, &grid, &grid_cells);
8686

8787
// get answers
8888
get_answers(grid.lonc, grid.latc, &answers);

t_acc/test_get_interp_order1/Makefile.am renamed to t_gpu/test_get_interp_order1/Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
check_PROGRAMS = test_get_interp_order1
2121

2222
AM_CFLAGS = $(NETCDF_CFLAGS) \
23-
-I$(top_srcdir)/tools/fregrid_acc \
23+
-I$(top_srcdir)/tools/fregrid_gpu \
2424
-I$(top_srcdir)/tools/libfrencutils \
25-
-I$(top_srcdir)/tools/libfrencutils_acc -acc
25+
-I$(top_srcdir)/tools/libfrencutils_gpu -acc
2626

2727
LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) \
28-
$(top_builddir)/tools/fregrid_acc/interp_utils_acc.o \
29-
$(top_builddir)/tools/fregrid_acc/conserve_interp_acc.o \
28+
$(top_builddir)/tools/fregrid_gpu/interp_utils_gpu.o \
29+
$(top_builddir)/tools/fregrid_gpu/conserve_interp_gpu.o \
3030
$(top_builddir)/tools/libfrencutils/libfrencutils.a \
31-
$(top_builddir)/tools/libfrencutils_acc/libfrencutils_acc.a
31+
$(top_builddir)/tools/libfrencutils_gpu/libfrencutils_gpu.a
3232

3333
test_get_interp_order1_SOURCES = test_get_interp_order1.c
3434

t_acc/test_get_interp_order1/test_get_interp_order1.c renamed to t_gpu/test_get_interp_order1/test_get_interp_order1.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
* <http://www.gnu.org/licenses/>.
1919
**********************************************************************/
2020

21-
// This test tests the function create_xgrid_2dx2d_order2_acc for a simple
21+
// This test tests the function create_xgrid_2dx2d_order2_gpu for a simple
2222
// case where the input grid is identical to the output grid. The exchange
2323
// grid is identical to the input/output grid. Only the parent indices corresponding
2424
// to each exchange cell are checked.
2525

2626
#include <stdlib.h>
2727
#include <stdio.h>
2828
#include <openacc.h>
29-
#include "globals_acc.h"
30-
#include "interp_utils_acc.h"
31-
#include "conserve_interp_acc.h"
32-
#include "create_xgrid_utils_acc.h"
33-
#include "create_xgrid_acc.h"
29+
#include "globals_gpu.h"
30+
#include "interp_utils_gpu.h"
31+
#include "conserve_interp_gpu.h"
32+
#include "create_xgrid_utils_gpu.h"
33+
#include "create_xgrid_gpu.h"
3434

3535
void generate_input_is_same_as_output_grids(Grid_config *input_grid, Grid_config *output_grid,
3636
Interp_per_input_tile *interp_answers);
@@ -152,30 +152,30 @@ int run_tests(Grid_config *input_grid, Grid_config *output_grid, Interp_per_inpu
152152
Grid_cells_struct_config output_grid_cells;
153153

154154
//copy grid to device
155-
copy_grid_to_device_acc(ngridpts_input, input_grid->latc, input_grid->lonc);
156-
copy_grid_to_device_acc(ngridpts_output, output_grid->latc, output_grid->lonc);
155+
copy_grid_to_device_gpu(ngridpts_input, input_grid->latc, input_grid->lonc);
156+
copy_grid_to_device_gpu(ngridpts_output, output_grid->latc, output_grid->lonc);
157157

158158
//get mask to skip input cells in creating interp
159-
get_input_grid_mask_acc(ncells_input, &input_grid_mask);
159+
get_input_grid_mask_gpu(ncells_input, &input_grid_mask);
160160

161161
//get output grid cell info
162-
get_grid_cell_struct_acc(nlon_output_cells, nlat_output_cells, output_grid, &output_grid_cells);
162+
get_grid_cell_struct_gpu(nlon_output_cells, nlat_output_cells, output_grid, &output_grid_cells);
163163

164164
//get bounding index
165-
get_bounding_indices_acc(nlon_output_cells, nlat_output_cells, nlon_input_cells, nlat_input_cells,
165+
get_bounding_indices_gpu(nlon_output_cells, nlat_output_cells, nlon_input_cells, nlat_input_cells,
166166
output_grid->latc, input_grid->latc, &jlat_overlap_starts, &jlat_overlap_ends);
167167

168168
//malloc and create arrays
169-
create_upbound_nxcells_arrays_on_device_acc(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
169+
create_upbound_nxcells_arrays_on_device_gpu(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
170170

171-
upbound_nxcells = get_upbound_nxcells_2dx2d_acc(input_grid->nxc, input_grid->nyc, output_grid->nxc, output_grid->nyc,
171+
upbound_nxcells = get_upbound_nxcells_2dx2d_gpu(input_grid->nxc, input_grid->nyc, output_grid->nxc, output_grid->nyc,
172172
jlat_overlap_starts, jlat_overlap_ends,
173173
input_grid->lonc, input_grid->latc,
174174
output_grid->lonc, output_grid->latc,
175175
input_grid_mask, &output_grid_cells,
176176
approx_nxcells_per_ij1, ij2_start, ij2_end);
177177

178-
nxcells = create_xgrid_2dx2d_order1_acc( nlon_input_cells, nlat_input_cells,
178+
nxcells = create_xgrid_2dx2d_order1_gpu( nlon_input_cells, nlat_input_cells,
179179
nlon_output_cells, nlat_output_cells,
180180
jlat_overlap_starts, jlat_overlap_ends,
181181
input_grid->lonc, input_grid->latc,
@@ -184,9 +184,9 @@ int run_tests(Grid_config *input_grid, Grid_config *output_grid, Interp_per_inpu
184184
approx_nxcells_per_ij1, ij2_start, ij2_end,
185185
interp);
186186

187-
free_grid_cell_struct_acc(ncells_output, &output_grid_cells);
188-
free_upbound_nxcells_arrays_acc(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
189-
free_input_grid_mask_acc(ncells_input, &input_grid_mask);
187+
free_grid_cell_struct_gpu(ncells_output, &output_grid_cells);
188+
free_upbound_nxcells_arrays_gpu(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
189+
free_input_grid_mask_gpu(ncells_input, &input_grid_mask);
190190

191191
return 0;
192192

t_acc/test_get_upbound_nxcells_2dx2d/Makefile.am renamed to t_gpu/test_get_upbound_nxcells_2dx2d/Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
check_PROGRAMS = test_get_upbound_nxcells_2dx2d
2121

2222
AM_CFLAGS = $(NETCDF_CFLAGS) \
23-
-I$(top_srcdir)/tools/fregrid_acc \
23+
-I$(top_srcdir)/tools/fregrid_gpu \
2424
-I$(top_srcdir)/tools/libfrencutils \
25-
-I$(top_srcdir)/tools/libfrencutils_acc -acc
25+
-I$(top_srcdir)/tools/libfrencutils_gpu -acc
2626

2727
LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) \
28-
$(top_builddir)/tools/fregrid_acc/conserve_interp_acc.o \
29-
$(top_builddir)/tools/fregrid_acc/interp_utils_acc.o \
28+
$(top_builddir)/tools/fregrid_gpu/conserve_interp_gpu.o \
29+
$(top_builddir)/tools/fregrid_gpu/interp_utils_gpu.o \
3030
$(top_builddir)/tools/libfrencutils/libfrencutils.a \
31-
$(top_builddir)/tools/libfrencutils_acc/libfrencutils_acc.a
31+
$(top_builddir)/tools/libfrencutils_gpu/libfrencutils_gpu.a
3232

3333
test_get_upbound_nxcells_2dx2d_SOURCES = test_get_upbound_nxcells_2dx2d.c
3434

t_acc/test_get_upbound_nxcells_2dx2d/test_get_upbound_nxcells_2dx2d.c renamed to t_gpu/test_get_upbound_nxcells_2dx2d/test_get_upbound_nxcells_2dx2d.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
#include <stdlib.h>
2929
#include <stdio.h>
3030
#include <openacc.h>
31-
#include "globals_acc.h"
32-
#include "conserve_interp_acc.h"
33-
#include "interp_utils_acc.h"
34-
#include "create_xgrid_utils_acc.h"
35-
#include "create_xgrid_acc.h"
31+
#include "globals_gpu.h"
32+
#include "conserve_interp_gpu.h"
33+
#include "interp_utils_gpu.h"
34+
#include "create_xgrid_utils_gpu.h"
35+
#include "create_xgrid_gpu.h"
3636

3737
typedef struct {
3838
int ncells_input;
@@ -322,33 +322,33 @@ int run_tests(Grid_config *input_grid, Grid_config *output_grid, Grid_cells_stru
322322
double *input_grid_mask;
323323

324324
//copy grid to device
325-
copy_grid_to_device_acc(ngridpts_input, input_grid->latc, input_grid->lonc);
326-
copy_grid_to_device_acc(ngridpts_output, output_grid->latc, output_grid->lonc);
325+
copy_grid_to_device_gpu(ngridpts_input, input_grid->latc, input_grid->lonc);
326+
copy_grid_to_device_gpu(ngridpts_output, output_grid->latc, output_grid->lonc);
327327

328328
//get mask to skip input cells in creating xgrid
329-
get_input_grid_mask_acc(ncells_input, &input_grid_mask);
329+
get_input_grid_mask_gpu(ncells_input, &input_grid_mask);
330330
if( ! acc_is_present(input_grid_mask, ncells_input*sizeof(double)) ) {
331331
printf("INPUT_GRID_MASK IS NOT ON DEVICE!"); exit(1);
332332
}
333333

334334
//get output grid cell info
335-
get_grid_cell_struct_acc(nlon_output_cells, nlat_output_cells, output_grid, output_grid_cells);
335+
get_grid_cell_struct_gpu(nlon_output_cells, nlat_output_cells, output_grid, output_grid_cells);
336336

337337
//get bounding indices
338-
get_bounding_indices_acc(nlon_output_cells, nlat_output_cells, nlon_input_cells, nlat_input_cells,
338+
get_bounding_indices_gpu(nlon_output_cells, nlat_output_cells, nlon_input_cells, nlat_input_cells,
339339
output_grid->latc, input_grid->latc, &jlat_overlap_starts, &jlat_overlap_ends);
340340
if(jlat_overlap_starts != 0) printf("SMETHING IS WRONG WITH JLAT_OVERLAP_STARTS %d\n", jlat_overlap_starts);
341341
if(jlat_overlap_ends != nlat_input_cells-1) // this is what was in the original.
342342
printf("SOMETHING IS WRONG WITH JLAT_OVERLAP_ENDS %d %d\n", jlat_overlap_ends, nlat_input_cells-1);
343343

344344
//malloc and create arrays
345-
create_upbound_nxcells_arrays_on_device_acc(ncells_input, &p_approx_nxcells_per_ij1, &p_ij2_start, &p_ij2_end);
345+
create_upbound_nxcells_arrays_on_device_gpu(ncells_input, &p_approx_nxcells_per_ij1, &p_ij2_start, &p_ij2_end);
346346

347347
// check to ensure all data have been transferred/created to device
348348
check_data_on_device(input_grid, output_grid, p_approx_nxcells_per_ij1, p_ij2_start, p_ij2_end,
349349
output_grid_cells);
350350

351-
*upbound_nxcells = get_upbound_nxcells_2dx2d_acc(input_grid->nxc, input_grid->nyc, output_grid->nxc, output_grid->nyc,
351+
*upbound_nxcells = get_upbound_nxcells_2dx2d_gpu(input_grid->nxc, input_grid->nyc, output_grid->nxc, output_grid->nyc,
352352
jlat_overlap_starts, jlat_overlap_ends,
353353
input_grid->lonc, input_grid->latc, output_grid->lonc, output_grid->latc,
354354
input_grid_mask, output_grid_cells,
@@ -358,7 +358,7 @@ int run_tests(Grid_config *input_grid, Grid_config *output_grid, Grid_cells_stru
358358
*ij2_start = p_ij2_start;
359359
*ij2_end = p_ij2_end;
360360

361-
free_input_grid_mask_acc(ncells_input, &input_grid_mask);
361+
free_input_grid_mask_gpu(ncells_input, &input_grid_mask);
362362

363363
return 0;
364364

@@ -372,8 +372,8 @@ void cleanup_test(Answers *answers, Grid_config *input_grid, Grid_config *output
372372
int ncells_output = output_grid->nxc * output_grid->nyc;
373373
int ncells_input = input_grid->nxc * input_grid->nyc;
374374

375-
free_grid_cell_struct_acc(ncells_output, output_grid_cells);
376-
free_upbound_nxcells_arrays_acc(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
375+
free_grid_cell_struct_gpu(ncells_output, output_grid_cells);
376+
free_upbound_nxcells_arrays_gpu(ncells_input, &approx_nxcells_per_ij1, &ij2_start, &ij2_end);
377377

378378
}
379379

t_acc/test_read_remap_file/Makefile.am renamed to t_gpu/test_read_remap_file/Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ check_PROGRAMS = test_read_remap_file
2121

2222
AM_CFLAGS = $(NETCDF_CFLAGS) \
2323
-I$(top_srcdir)/tools/libfrencutils \
24-
-I$(top_srcdir)/tools/libfrencutils_acc \
25-
-I$(top_srcdir)/tools/fregrid_acc -acc
24+
-I$(top_srcdir)/tools/libfrencutils_gpu \
25+
-I$(top_srcdir)/tools/fregrid_gpu -acc
2626

2727
LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) \
28-
$(top_builddir)/tools/fregrid_acc/conserve_interp_acc.o \
29-
$(top_builddir)/tools/fregrid_acc/interp_utils_acc.o \
28+
$(top_builddir)/tools/fregrid_gpu/conserve_interp_gpu.o \
29+
$(top_builddir)/tools/fregrid_gpu/interp_utils_gpu.o \
3030
$(top_builddir)/tools/libfrencutils/libfrencutils.a \
31-
$(top_builddir)/tools/libfrencutils_acc/libfrencutils_acc.a
31+
$(top_builddir)/tools/libfrencutils_gpu/libfrencutils_gpu.a
3232

3333
test_read_remap_file_SOURCES = test_read_remap_file.c
3434

0 commit comments

Comments
 (0)