diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a263df9c5..82aa97abb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,9 +54,10 @@ jobs: os: ubuntu-22.04 CC: icx CXX: icpx - FC: ifx CXXFLAGS: -Wno-uninitialized + FC: ifx OCCA_COVERAGE: 0 + OCCA_FORTRAN_ENABLED: 1 useCMake: true useoneAPI: true @@ -114,9 +115,9 @@ jobs: -DCMAKE_C_COMPILER=${CC} \ -DCMAKE_CXX_COMPILER=${CXX} \ -DCMAKE_Fortran_COMPILER=${FC} \ - -DENABLE_TESTS=ON \ - -DENABLE_EXAMPLES=ON \ - -DENABLE_FORTRAN=ON + -DOCCA_ENABLE_TESTS=ON \ + -DOCCA_ENABLE_EXAMPLES=ON \ + -DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED} - name: CMake configure if: ${{ matrix.useCMake && matrix.useoneAPI}} @@ -125,16 +126,15 @@ jobs: OCCA_CXX: ${{ matrix.CXX }} run: | source /opt/intel/oneapi/setvars.sh - export SYCL_ROOT=/opt/intel/oneapi/compiler/latest cmake -S . -B build \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_C_COMPILER=${CC} \ -DCMAKE_CXX_COMPILER=${CXX} \ -DCMAKE_Fortran_COMPILER=${FC} \ - -DENABLE_TESTS=ON \ - -DENABLE_EXAMPLES=ON \ - -DENABLE_FORTRAN=ON + -DOCCA_ENABLE_TESTS=ON \ + -DOCCA_ENABLE_EXAMPLES=ON \ + -DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED} - name: CMake build if: ${{ matrix.useCMake && !matrix.useoneAPI}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0415f6168..77dc8d9b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,18 +27,18 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -option(ENABLE_OPENMP "Build with OpenMP if available" ON) -option(ENABLE_CUDA "Build with CUDA if available" ON) -option(ENABLE_OPENCL "Build with OpenCL if available" ON) -option(ENABLE_HIP "Build with HIP if available" ON) -option(ENABLE_METAL "Build with Metal if available" ON) -option(ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON) - -option(ENABLE_TESTS "Build tests" OFF) -option(ENABLE_EXAMPLES "Build simple examples" OFF) -option(ENABLE_FORTRAN "Enable Fortran interface" OFF) - -if(ENABLE_FORTRAN) +option(OCCA_ENABLE_OPENMP "Build with OpenMP if available" ON) +option(OCCA_ENABLE_CUDA "Build with CUDA if available" ON) +option(OCCA_ENABLE_OPENCL "Build with OpenCL if available" ON) +option(OCCA_ENABLE_HIP "Build with HIP if available" ON) +option(OCCA_ENABLE_METAL "Build with Metal if available" ON) +option(OCCA_ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON) + +option(OCCA_ENABLE_TESTS "Build tests" OFF) +option(OCCA_ENABLE_EXAMPLES "Build simple examples" OFF) +option(OCCA_ENABLE_FORTRAN "Enable Fortran interface" OFF) + +if(OCCA_ENABLE_FORTRAN) enable_language(Fortran) endif() @@ -80,11 +80,11 @@ message("-- System : ${CMAKE_SYSTEM}") message("-- Build type : ${CMAKE_BUILD_TYPE}") message("-- C flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") message("-- CXX flags : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") -if(ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) message("-- F90 flags : ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") endif() -if(ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) set(CMAKE_Fortran_MODULE_DIRECTORY ${OCCA_BUILD_DIR}/mod) endif() #======================================= @@ -116,7 +116,7 @@ target_compile_definitions(libocca PRIVATE -DUSE_CMAKE) #======================================= #---[ OpenMP ]-------------------------- -if(ENABLE_OPENMP) +if(OCCA_ENABLE_OPENMP) find_package(OpenMP) if(OPENMP_CXX_FOUND) @@ -128,14 +128,14 @@ if(ENABLE_OPENMP) # Use the provided imported target OpenMP::OpenMP_CXX, # (which wraps the CXX_INCLUDE_DIRS and CXX_LIBRARIES,) to make our package relocatable target_link_libraries(libocca PRIVATE OpenMP::OpenMP_CXX) - else(OPENMP_CXX_FOUND) + else() set(OCCA_OPENMP_ENABLED 0) - endif(OPENMP_CXX_FOUND) -endif(ENABLE_OPENMP) + endif() +endif() #======================================= #---[ CUDA ]---------------------------- -if(ENABLE_CUDA) +if(OCCA_ENABLE_CUDA) find_package(CUDAToolkit) if(CUDAToolkit_FOUND) @@ -146,15 +146,14 @@ if(ENABLE_CUDA) # Use the provided imported target CUDA::cuda_driver, to make our package relocatable target_link_libraries(libocca PRIVATE CUDA::cuda_driver) - - else (CUDAToolkit_FOUND) + else() set(OCCA_CUDA_ENABLED 0) - endif(CUDAToolkit_FOUND) -endif(ENABLE_CUDA) + endif() +endif() #======================================= #---[ OpenCL ]-------------------------- -if(ENABLE_OPENCL) +if(OCCA_ENABLE_OPENCL) find_package(OpenCLWrapper) if(OpenCL_FOUND) @@ -166,14 +165,14 @@ if(ENABLE_OPENCL) # Use the provided imported target OpenCL::OpenCL, # (which wraps the _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable target_link_libraries(libocca PRIVATE OpenCL::OpenCL) - else (OpenCL_FOUND) + else() set(OCCA_OPENCL_ENABLED 0) - endif(OpenCL_FOUND) -endif(ENABLE_OPENCL) + endif() +endif() #======================================= #---[ SYCL/DPCPP ]----------------------- -if(ENABLE_DPCPP) +if(OCCA_ENABLE_DPCPP) find_package(DPCPP) if(DPCPP_FOUND) @@ -189,11 +188,11 @@ if(ENABLE_DPCPP) else() set(OCCA_DPCPP_ENABLED 0) endif() -endif(ENABLE_DPCPP) +endif() #======================================= #---[ HIP ]----------------------------- -if(ENABLE_HIP) +if(OCCA_ENABLE_HIP) find_package(HIP) if(HIP_FOUND) @@ -210,11 +209,11 @@ if(ENABLE_HIP) else (HIP_FOUND) set(OCCA_HIP_ENABLED 0) endif(HIP_FOUND) -endif(ENABLE_HIP) +endif() #======================================= #---[ Metal ]--------------------------- -if(ENABLE_METAL AND APPLE) +if(OCCA_ENABLE_METAL AND APPLE) find_package(METAL) if(METAL_FOUND) @@ -257,7 +256,7 @@ file( GLOB_RECURSE OCCA_SRC_cpp RELATIVE ${OCCA_SOURCE_DIR} "src/*.cpp") -if(ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) file(GLOB_RECURSE OCCA_SRC_f90 RELATIVE ${OCCA_SOURCE_DIR} "src/*.f90") @@ -287,14 +286,14 @@ target_sources(libocca PRIVATE ${OCCA_SRC}) install(TARGETS libocca EXPORT occaExport DESTINATION lib) install(DIRECTORY include/ DESTINATION include) -if(ENABLE_TESTS) +if(OCCA_ENABLE_TESTS) include(CTest) add_subdirectory(tests) -endif(ENABLE_TESTS) +endif() -if(ENABLE_EXAMPLES) +if(OCCA_ENABLE_EXAMPLES) add_subdirectory(examples) -endif(ENABLE_EXAMPLES) +endif() add_subdirectory(bin) diff --git a/INSTALL.md b/INSTALL.md index 34755dfa8..9a90ae62f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -25,7 +25,7 @@ OCCA uses the [CMake] build system. For convenience, the shell script `configure Example ```shell -$ CC=clang CXX=clang++ ENABLE_OPENMP="OFF" ./configure-cmake.sh +$ CC=clang CXX=clang++ OCCA_ENABLE_OPENMP="OFF" ./configure-cmake.sh ``` | Build Parameter | Description | Default | @@ -37,15 +37,15 @@ $ CC=clang CXX=clang++ ENABLE_OPENMP="OFF" ./configure-cmake.sh | CXXFLAGS | C++ compiler flags | *empty* | | CC | C11 compiler| `gcc` | | CFLAGS | C compiler flags | *empty* | -| ENABLE_CUDA | Enable use of the CUDA backend | `ON`| -| ENABLE_HIP | Enable use of the HIP backend | `ON`| -| ENABLE_DPCPP | Enable use of the DPC++ backend | `ON`| -| ENABLE_OPENCL | Enable use of the OpenCL backend | `ON`| -| ENABLE_OPENMP | Enable use of the OpenMP backend | `ON`| -| ENABLE_METAL | Enable use of the Metal backend | `ON`| -| ENABLE_TESTS | Build OCCA's test harness | `ON` | -| ENABLE_EXAMPLES | Build OCCA examples | `ON` | -| ENABLE_FORTRAN | Build the Fortran language bindings | `OFF`| +| OCCA_ENABLE_CUDA | Enable use of the CUDA backend | `ON`| +| OCCA_ENABLE_HIP | Enable use of the HIP backend | `ON`| +| OCCA_ENABLE_DPCPP | Enable use of the DPC++ backend | `ON`| +| OCCA_ENABLE_OPENCL | Enable use of the OpenCL backend | `ON`| +| OCCA_ENABLE_OPENMP | Enable use of the OpenMP backend | `ON`| +| OCCA_ENABLE_METAL | Enable use of the Metal backend | `ON`| +| OCCA_ENABLE_TESTS | Build OCCA's test harness | `ON` | +| OCCA_ENABLE_EXAMPLES | Build OCCA examples | `ON` | +| OCCA_ENABLE_FORTRAN | Build the Fortran language bindings | `OFF`| | FC | Fortran 90 compiler | `gfortran` | | FFLAGS | Fortran compiler flags | *empty* | diff --git a/README.md b/README.md index c66ffe05c..82bddcc09 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ For convenience, the shell script `configure-cmake.sh` has been provided to driv The following demonstrates a typical sequence of shell commands to build, test, and install occa: ```shell -$ ./configure.sh +$ ./configure-cmake.sh $ cmake --build build --parallel $ ctest --test-dir build --output-on-failure $ cmake --install build --prefix install diff --git a/cmake/SetCompilerFlags.cmake b/cmake/SetCompilerFlags.cmake index be10b91a5..affad91af 100644 --- a/cmake/SetCompilerFlags.cmake +++ b/cmake/SetCompilerFlags.cmake @@ -61,7 +61,7 @@ set(CMAKE_C_FLAGS "${SUPPORTED_WARN_C_FLAGS} ${CMAKE_C_FLAGS}") set_optional_c_flag(SUPPORTED_WERROR_C_FLAGS "-Werror") set(CMAKE_C_FLAGS_DEBUG "${SUPPORTED_WERROR_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") -if (ENABLE_FORTRAN) +if (OCCA_ENABLE_FORTRAN) include(CheckFortranCompilerFlag) function(set_optional_fortran_flag var) diff --git a/configure-cmake.sh b/configure-cmake.sh index 41562fb06..3d26e19ca 100755 --- a/configure-cmake.sh +++ b/configure-cmake.sh @@ -3,6 +3,9 @@ #CC= #CXX= #FC= +#CFLAGS= +#CXXFLAGS +#FFLAGS= # Default build parameters : ${BUILD_DIR:=`pwd`/build} @@ -13,15 +16,15 @@ : ${CXX:="g++"} : ${FC:="gfortran"} -: ${ENABLE_DPCPP:="ON"} -: ${ENABLE_OPENCL:="ON"} -: ${ENABLE_CUDA:="ON"} -: ${ENABLE_HIP="ON"} -: ${ENABLE_OPENMP="ON"} -: ${ENABLE_METAL="ON"} -: ${ENABLE_FORTRAN="OFF"} -: ${ENABLE_TESTS="ON"} -: ${ENABLE_EXAMPLES="ON"} +: ${OCCA_ENABLE_DPCPP:="ON"} +: ${OCCA_ENABLE_OPENCL:="ON"} +: ${OCCA_ENABLE_CUDA:="ON"} +: ${OCCA_ENABLE_HIP="ON"} +: ${OCCA_ENABLE_OPENMP="ON"} +: ${OCCA_ENABLE_METAL="ON"} +: ${OCCA_ENABLE_FORTRAN="OFF"} +: ${OCCA_ENABLE_TESTS="ON"} +: ${OCCA_ENABLE_EXAMPLES="ON"} cmake -S . -B ${BUILD_DIR} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ @@ -32,12 +35,12 @@ cmake -S . -B ${BUILD_DIR} \ -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ -DCMAKE_C_FLAGS="${CFLAGS}" \ -DCMAKE_Fortran_FLAGS="${FFLAGS}" \ - -DENABLE_OPENMP=${ENABLE_OPENMP} \ - -DENABLE_OPENCL=${ENABLE_OPENCL} \ - -DENABLE_DPCPP=${ENABLE_DPCPP} \ - -DENABLE_CUDA=${ENABLE_CUDA} \ - -DENABLE_HIP=${ENABLE_HIP} \ - -DENABLE_METAL=${ENABLE_METAL} \ - -DENABLE_FORTRAN=${ENABLE_FORTRAN} \ - -DENABLE_TESTS=${ENABLE_TESTS} \ - -DENABLE_EXAMPLES=${ENABLE_EXAMPLES} + -DOCCA_ENABLE_OPENMP=${OCCA_ENABLE_OPENMP} \ + -DOCCA_ENABLE_OPENCL=${OCCA_ENABLE_OPENCL} \ + -DOCCA_ENABLE_DPCPP=${OCCA_ENABLE_DPCPP} \ + -DOCCA_ENABLE_CUDA=${OCCA_ENABLE_CUDA} \ + -DOCCA_ENABLE_HIP=${OCCA_ENABLE_HIP} \ + -DOCCA_ENABLE_METAL=${OCCA_ENABLE_METAL} \ + -DOCCA_ENABLE_FORTRAN=${OCCA_ENABLE_FORTRAN} \ + -DOCCA_ENABLE_TESTS=${OCCA_ENABLE_TESTS} \ + -DOCCA_ENABLE_EXAMPLES=${OCCA_ENABLE_EXAMPLES} diff --git a/configure-sycl-nv-cmake.sh b/configure-sycl-nv-cmake.sh index 231b5b72a..ea773ae81 100755 --- a/configure-sycl-nv-cmake.sh +++ b/configure-sycl-nv-cmake.sh @@ -20,15 +20,15 @@ CXX=clang++ : ${CXX:="g++"} : ${FC:="gfortran"} -: ${ENABLE_DPCPP:="ON"} -: ${ENABLE_OPENCL:="OFF"} -: ${ENABLE_CUDA:="ON"} -: ${ENABLE_HIP="OFF"} -: ${ENABLE_OPENMP="OFF"} -: ${ENABLE_METAL="OFF"} -: ${ENABLE_FORTRAN="OFF"} -: ${ENABLE_TESTS="ON"} -: ${ENABLE_EXAMPLES="ON"} +: ${OCCA_ENABLE_DPCPP:="ON"} +: ${OCCA_ENABLE_OPENCL:="OFF"} +: ${OCCA_ENABLE_CUDA:="ON"} +: ${OCCA_ENABLE_HIP="OFF"} +: ${OCCA_ENABLE_OPENMP="OFF"} +: ${OCCA_ENABLE_METAL="OFF"} +: ${OCCA_ENABLE_FORTRAN="OFF"} +: ${OCCA_ENABLE_TESTS="ON"} +: ${OCCA_ENABLE_EXAMPLES="ON"} cmake -S . -B ${BUILD_DIR} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ @@ -39,12 +39,12 @@ cmake -S . -B ${BUILD_DIR} \ -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ -DCMAKE_C_FLAGS="${CFLAGS}" \ -DCMAKE_Fortran_FLAGS="${FFLAGS}" \ - -DENABLE_OPENMP=${ENABLE_OPENMP} \ - -DENABLE_OPENCL=${ENABLE_OPENCL} \ - -DENABLE_DPCPP=${ENABLE_DPCPP} \ - -DENABLE_CUDA=${ENABLE_CUDA} \ - -DENABLE_HIP=${ENABLE_HIP} \ - -DENABLE_METAL=${ENABLE_METAL} \ - -DENABLE_FORTRAN=${ENABLE_FORTRAN} \ - -DENABLE_TESTS=${ENABLE_TESTS} \ - -DENABLE_EXAMPLES=${ENABLE_EXAMPLES} + -DOCCA_ENABLE_OPENMP=${OCCA_ENABLE_OPENMP} \ + -DOCCA_ENABLE_OPENCL=${OCCA_ENABLE_OPENCL} \ + -DOCCA_ENABLE_DPCPP=${OCCA_ENABLE_DPCPP} \ + -DOCCA_ENABLE_CUDA=${OCCA_ENABLE_CUDA} \ + -DOCCA_ENABLE_HIP=${OCCA_ENABLE_HIP} \ + -DOCCA_ENABLE_METAL=${OCCA_ENABLE_METAL} \ + -DOCCA_ENABLE_FORTRAN=${OCCA_ENABLE_FORTRAN} \ + -DOCCA_ENABLE_TESTS=${OCCA_ENABLE_TESTS} \ + -DOCCA_ENABLE_EXAMPLES=${OCCA_ENABLE_EXAMPLES} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ca92e4793..945ed46bf 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -35,7 +35,7 @@ macro(compile_c_example target file) target_link_libraries(examples_c_${target} libocca) target_include_directories(examples_c_${target} PRIVATE $) - if (ENABLE_TESTS) + if (OCCA_ENABLE_TESTS) add_test_with_modes(examples_c_${target}) endif() endmacro() @@ -45,7 +45,7 @@ macro(compile_cpp_example target file) target_link_libraries(examples_cpp_${target} libocca) target_include_directories(examples_cpp_${target} PRIVATE $) - if (ENABLE_TESTS) + if (OCCA_ENABLE_TESTS) add_test_without_mode(examples_cpp_${target}) endif() endmacro() @@ -55,7 +55,7 @@ macro(compile_cpp_example_with_modes target file) target_link_libraries(examples_cpp_${target} libocca) target_include_directories(examples_cpp_${target} PRIVATE $) - if (ENABLE_TESTS) + if (OCCA_ENABLE_TESTS) add_test_with_modes(examples_cpp_${target}) endif() endmacro() @@ -63,11 +63,11 @@ endmacro() add_subdirectory(c) add_subdirectory(cpp) -if (ENABLE_FORTRAN) +if (OCCA_ENABLE_FORTRAN) macro(compile_fortran_example_with_modes target file) add_executable(examples_fortran_${target} ${file}) target_link_libraries(examples_fortran_${target} libocca) - if (ENABLE_TESTS) + if (OCCA_ENABLE_TESTS) add_test_with_modes(examples_fortran_${target}) endif() endmacro() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7ee6a5822..6f8b8ffdc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,7 +39,7 @@ file( GLOB_RECURSE occa_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") -if (ENABLE_FORTRAN) +if (OCCA_ENABLE_FORTRAN) file( GLOB_RECURSE occa_fortran_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.f90")