Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add m4 check for openacc flags and fix for intel #305

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
QUAD_P: ${{ matrix.enable_quad_precision }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand Down
14 changes: 10 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ AM_CONDITIONAL([WITH_MPI_TESTS], [test x"$build_mpi" = x"yes" -a -z "$SKIP_MPI_T

#Build with OpenACC suport. Default is 'no'
AC_ARG_ENABLE([acc],
[AS_HELP_STRING([--enable-acc], [Build with OpenACC support. Defaults to 'no'])] )
AS_IF([test ${enable_acc:-no} = "yes"], [enable_acc=yes], [enable_acc=no])
AM_CONDITIONAL([ENABLE_ACC], [test $enable_acc = "yes"])
[AS_HELP_STRING([--enable-acc],
[Builds with OpenACC. This will result in a second executable for fregrid, fregrid_gpu.(default no)])])
AS_IF([test ${enable_acc:-no} = yes],
[enable_acc=yes],
[enable_acc=no])
# check compile flags
AS_IF([test ${enable_acc} = yes],
[GX_OPENACC_FLAGS()])
AM_CONDITIONAL([ENABLE_ACC], [test "$enable_acc" = "yes"])

AC_CHECK_FUNCS(gettid, [], [])

Expand Down Expand Up @@ -123,7 +129,7 @@ AC_CHECK_PROGS(PROVE, [prove])
AM_CONDITIONAL([WITH_CHECK_PROGS], [test -n "$PROVE" -a -n "$BATS"])

# Check if openacc.h exists
if test $enable_acc = yes ; then
if test "$enable_acc" = yes ; then
AC_CHECK_HEADERS([openacc.h], [], [AC_MSG_ERROR(["Cannot find OpenACC header file"])] )
AC_MSG_WARN(Currently only NVIDIA compilers are supported to compile with OpenACC in FRE-NCTOOLS)
fi
Expand Down
74 changes: 74 additions & 0 deletions m4/gx_openacc_flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ===========================================================================
#
# SYNOPSIS
#
# GX_OPENACC_FLAGS()
#
# DESCRIPTION
#
# Checks C compiler flags for openacc support.
#
# LICENSE
#
# Copyright (c) 2024 Ryan Mulhall
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.

# ----------------------------------------------------------------------
#
# Will set OPENACC_CFLAGS to openacc flags for a given compiler if accepted.
#
# Mainly for nvhpc, offloading with gcc is not currently supported,
# although the build will still work.
#
AC_DEFUN([GX_OPENACC_FLAGS],[
AC_CACHE_CHECK([whether C compiler accepts OpenACC flags], [gx_cv_openacc_flags],[

AC_LANG_ASSERT(C)
gx_cv_openacc_flags=unknown
gx_openacc_flags_CFLAGS_save=$CFLAGS

dnl check for base openacc flag
for ac_flag in '-acc' \
'-fopenacc'; do
AC_LINK_IFELSE([AC_LANG_SOURCE(
extern int acc_get_device_type();
int main(int argc, char** argv){
acc_get_device_type();
return 0;
})],
[gx_cv_openacc_flags="$gx_openacc_flags_CFLAGS_save ${ac_flag}"]; break)
done
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext

CFLAGS="$gx_openacc_flags_CFLAGS_save"

if test "x$gx_cv_openacc_flags" = xunknown; then
m4_default([$2],
[AC_MSG_ERROR([no])])
else
OPENACC_CFLAGS="${gx_cv_openacc_flags}"
AC_MSG_RESULT([yes])
fi
],
AC_SUBST([OPENACC_CFLAGS])
)])
3 changes: 2 additions & 1 deletion tools/fregrid_acc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ bin_PROGRAMS = fregrid_acc

AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils $(NETCDF_CFLAGS) \
-I$(top_srcdir)/tools/libfrencutils_acc \
-I$(top_srcdir)/tools/fregrid -acc
-I$(top_srcdir)/tools/fregrid \
$(OPENACC_CFLAGS)
LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS)

fregrid_acc_SOURCES = conserve_interp_acc.c \
Expand Down
2 changes: 1 addition & 1 deletion tools/libfrencutils_acc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#***********************************************************************
noinst_LIBRARIES = libfrencutils_acc.a

AM_CFLAGS = $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/libfrencutils -acc
AM_CFLAGS = $(NETCDF_CFLAGS) $(OPENACC_CFLAGS) -I$(top_srcdir)/tools/libfrencutils

libfrencutils_acc_a_SOURCES = create_xgrid_acc.c \
create_xgrid_acc.h
Expand Down
2 changes: 2 additions & 0 deletions tools/mppncscatter/mppncscatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

#define CHECK_NC_ERRSTAT(ierr) check_error(ierr,__FILE__,__LINE__)

void check_error(int ierr, const char* file, int line);

/*-------------------------------------------------------------------*/
void printsizetarray(size_t *a, int n) {
int i=0;
Expand Down