Add bureaucracy for openacc in autotools
This commit is contained in:
parent
249f1c0b51
commit
77e1aaabeb
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -18,6 +18,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
compiler:
|
compiler:
|
||||||
|
- gcc12
|
||||||
|
- gcc11
|
||||||
- gcc11
|
- gcc11
|
||||||
- gcc10
|
- gcc10
|
||||||
- gcc9
|
- gcc9
|
||||||
|
|||||||
10
configure.ac
10
configure.ac
@ -48,8 +48,9 @@ AM_CONDITIONAL([WITH_CLANG_CHECK], [test x${clang_check} = xYES])
|
|||||||
AC_ARG_ENABLE([cuda],
|
AC_ARG_ENABLE([cuda],
|
||||||
[AS_HELP_STRING([--enable-cuda],
|
[AS_HELP_STRING([--enable-cuda],
|
||||||
[Build with cuda])],
|
[Build with cuda])],
|
||||||
[WITH_CUDA=yes],
|
[WITH_CUDA=yes
|
||||||
[WITH_CUDA=no])
|
WITH_OPENACC=yes],
|
||||||
|
[WITH_CUDA=no])
|
||||||
AC_ARG_VAR([NVCC], [Path to the nvidia cuda compiler.])
|
AC_ARG_VAR([NVCC], [Path to the nvidia cuda compiler.])
|
||||||
AC_ARG_VAR([CUDA_LDFLAGS], [LDFLAGS to find libraries -lcuda, -lcudart, -lcublas.])
|
AC_ARG_VAR([CUDA_LDFLAGS], [LDFLAGS to find libraries -lcuda, -lcudart, -lcublas.])
|
||||||
AC_ARG_VAR([CUDA_CXXFLAGS], [CXXFLAGS to find the CUDA headers])
|
AC_ARG_VAR([CUDA_CXXFLAGS], [CXXFLAGS to find the CUDA headers])
|
||||||
@ -176,6 +177,11 @@ fi
|
|||||||
dnl CUDA NVIDIA -----------------------------------------------------------
|
dnl CUDA NVIDIA -----------------------------------------------------------
|
||||||
|
|
||||||
AM_CONDITIONAL([WITH_CUDA], [test x${WITH_CUDA} = xyes])
|
AM_CONDITIONAL([WITH_CUDA], [test x${WITH_CUDA} = xyes])
|
||||||
|
AM_CONDITIONAL([WITH_OPENACC], [test x${WITH_OPENACC} = xyes])
|
||||||
|
if test x${WITH_OPENACC} = xyes; then
|
||||||
|
ATRIP_OPENACC([CXXFLAGS="${CXXFLAGS} -fopenacc"],
|
||||||
|
[AC_MSG_ERROR([I can't use -fopenacc, aborting])])
|
||||||
|
fi
|
||||||
if test x${WITH_CUDA} = xyes; then
|
if test x${WITH_CUDA} = xyes; then
|
||||||
AC_MSG_RESULT([
|
AC_MSG_RESULT([
|
||||||
CUDA SUPPORT IS ENABLED
|
CUDA SUPPORT IS ENABLED
|
||||||
|
|||||||
53
etc/env/raven/cuda-openacc
vendored
Normal file
53
etc/env/raven/cuda-openacc
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
mods=(
|
||||||
|
cuda/11.6
|
||||||
|
gcc/12
|
||||||
|
openmpi
|
||||||
|
mkl/2020.4
|
||||||
|
autoconf/2.69
|
||||||
|
automake/1.15
|
||||||
|
libtool/2.4.6
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
module purge
|
||||||
|
module load ${mods[@]}
|
||||||
|
LIB_PATH="${CUDA_HOME}/lib64"
|
||||||
|
export CUDA_ROOT=${CUDA_HOME}
|
||||||
|
export CUDA_LDFLAGS="-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${LIB_PATH} -lcublas"
|
||||||
|
export CUDA_CXXFLAGS="-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="${MKL_HOME}/lib/intel64:${LD_LIBRARY_PATH}"
|
||||||
|
|
||||||
|
ls ${LIB_PATH}/libcublas.so
|
||||||
|
ls ${LIB_PATH}/libcudart.so
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
info
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
MKL_HOME = $MKL_HOME
|
||||||
|
BLAS_STATIC_PATH = $BLAS_STATIC_PATH
|
||||||
|
|
||||||
|
CUDA_ROOT = ${CUDA_HOME}
|
||||||
|
CUDA_LDFLAGS = "-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${LIB_PATH} -lcublas"
|
||||||
|
CUDA_CXXFLAGS = "-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Consider now runnng the following
|
||||||
|
|
||||||
|
../configure \\
|
||||||
|
--enable-cuda \\
|
||||||
|
--disable-slice \\
|
||||||
|
--with-blas="-L\$MKL_HOME/lib/intel64/ -lmkl_blacs_openmpi_lp64 -lmkl_rt" \\
|
||||||
|
CXX=mpicxx \\
|
||||||
|
MPICXX=mpicxx
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
70
etc/m4/atrip_openacc.m4
Normal file
70
etc/m4/atrip_openacc.m4
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# ATRIP_OPENACC([ACTION-SUCCESS], [ACTION-FAILURE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check whether the given the -fopenacc flag works with the current language's compiler
|
||||||
|
# or gives an error.
|
||||||
|
#
|
||||||
|
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||||
|
# success/failure.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2023 Alejandro Gallo <aamsgallo@gmail.com>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
AC_DEFUN([ATRIP_OPENACC],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([that the compiler works with the -fopenacc])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_ATRIP_OPENACC_SOURCE])],
|
||||||
|
[
|
||||||
|
$1
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
$2
|
||||||
|
AC_MSG_ERROR([no])
|
||||||
|
])
|
||||||
|
])dnl DEFUN
|
||||||
|
|
||||||
|
m4_define([_ATRIP_OPENACC_SOURCE], [[
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <openacc.h>
|
||||||
|
|
||||||
|
#define SIZE 10
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
float matrix[SIZE * SIZE];
|
||||||
|
float result[SIZE * SIZE];
|
||||||
|
|
||||||
|
// Initialize the matrix with random values
|
||||||
|
for (int i = 0; i < SIZE * SIZE; i++) {
|
||||||
|
matrix[i] = rand() / (float)RAND_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma acc data \
|
||||||
|
copy(matrix[0:SIZE * SIZE]) \
|
||||||
|
copyout(result[0:SIZE * SIZE])
|
||||||
|
{
|
||||||
|
// Calculate the matrix multiplication
|
||||||
|
#pragma acc parallel loop collapse(2)
|
||||||
|
for (int i = 0; i < SIZE; i++) {
|
||||||
|
for (int j = 0; j < SIZE; j++) {
|
||||||
|
float sum = 0.0f;
|
||||||
|
for (int k = 0; k < SIZE; k++) {
|
||||||
|
sum += matrix[i * SIZE + k] * matrix[j * SIZE + k];
|
||||||
|
}
|
||||||
|
result[i * SIZE + j] = sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
]])
|
||||||
@ -43,7 +43,7 @@
|
|||||||
# and this notice are preserved. This file is offered as-is, without any
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
# warranty.
|
# warranty.
|
||||||
|
|
||||||
#serial 14
|
#serial 15
|
||||||
|
|
||||||
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
||||||
dnl (serial version number 13).
|
dnl (serial version number 13).
|
||||||
@ -189,7 +189,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201103L
|
// MSVC always sets __cplusplus to 199711L in older versions; newer versions
|
||||||
|
// only set it correctly if /Zc:__cplusplus is specified as well as a
|
||||||
|
// /std:c++NN switch:
|
||||||
|
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
|
||||||
|
#elif __cplusplus < 201103L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++11 compiler"
|
#error "This is not a C++11 compiler"
|
||||||
|
|
||||||
@ -480,7 +484,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201402L
|
#elif __cplusplus < 201402L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++14 compiler"
|
#error "This is not a C++14 compiler"
|
||||||
|
|
||||||
@ -604,7 +608,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201703L
|
#elif __cplusplus < 201703L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++17 compiler"
|
#error "This is not a C++17 compiler"
|
||||||
|
|
||||||
@ -970,7 +974,7 @@ namespace cxx17
|
|||||||
|
|
||||||
} // namespace cxx17
|
} // namespace cxx17
|
||||||
|
|
||||||
#endif // __cplusplus < 201703L
|
#endif // __cplusplus < 201703L && !defined _MSC_VER
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@ -983,7 +987,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 202002L
|
#elif __cplusplus < 202002L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++20 compiler"
|
#error "This is not a C++20 compiler"
|
||||||
|
|
||||||
@ -1000,6 +1004,6 @@ namespace cxx20
|
|||||||
|
|
||||||
} // namespace cxx20
|
} // namespace cxx20
|
||||||
|
|
||||||
#endif // __cplusplus < 202002L
|
#endif // __cplusplus < 202002L && !defined _MSC_VER
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user