diff --git a/.cmake_format.json b/.cmake_format.json new file mode 100644 index 000000000..8b34e84ef --- /dev/null +++ b/.cmake_format.json @@ -0,0 +1,311 @@ +{ + "_help_parse": "Options affecting listfile parsing", + "parse": { + "_help_additional_commands": [ + "Specify structure for custom cmake functions" + ], + "additional_commands": { + "foo": { + "flags": [ + "BAR", + "BAZ" + ], + "kwargs": { + "HEADERS": "*", + "SOURCES": "*", + "DEPENDS": "*" + } + } + }, + "_help_override_spec": [ + "Override configurations per-command where available" + ], + "override_spec": {}, + "_help_vartags": [ + "Specify variable tags." + ], + "vartags": [], + "_help_proptags": [ + "Specify property tags." + ], + "proptags": [] + }, + "_help_format": "Options affecting formatting.", + "format": { + "_help_disable": [ + "Disable formatting entirely, making cmake-format a no-op" + ], + "disable": false, + "_help_line_width": [ + "How wide to allow formatted cmake files" + ], + "line_width": 80, + "_help_tab_size": [ + "How many spaces to tab for indent" + ], + "tab_size": 2, + "_help_use_tabchars": [ + "If true, lines are indented using tab characters (utf-8", + "0x09) instead of space characters (utf-8 0x20).", + "In cases where the layout would require a fractional tab", + "character, the behavior of the fractional indentation is", + "governed by " + ], + "use_tabchars": false, + "_help_fractional_tab_policy": [ + "If is True, then the value of this variable", + "indicates how fractional indentions are handled during", + "whitespace replacement. If set to 'use-space', fractional", + "indentation is left as spaces (utf-8 0x20). If set to", + "`round-up` fractional indentation is replaced with a single", + "tab character (utf-8 0x09) effectively shifting the column", + "to the next tabstop" + ], + "fractional_tab_policy": "use-space", + "_help_max_subgroups_hwrap": [ + "If an argument group contains more than this many sub-groups", + "(parg or kwarg groups) then force it to a vertical layout." + ], + "max_subgroups_hwrap": 2, + "_help_max_pargs_hwrap": [ + "If a positional argument group contains more than this many", + "arguments, then force it to a vertical layout." + ], + "max_pargs_hwrap": 6, + "_help_max_rows_cmdline": [ + "If a cmdline positional group consumes more than this many", + "lines without nesting, then invalidate the layout (and nest)" + ], + "max_rows_cmdline": 2, + "_help_separate_ctrl_name_with_space": [ + "If true, separate flow control names from their parentheses", + "with a space" + ], + "separate_ctrl_name_with_space": false, + "_help_separate_fn_name_with_space": [ + "If true, separate function names from parentheses with a", + "space" + ], + "separate_fn_name_with_space": false, + "_help_dangle_parens": [ + "If a statement is wrapped to more than one line, than dangle", + "the closing parenthesis on its own line." + ], + "dangle_parens": false, + "_help_dangle_align": [ + "If the trailing parenthesis must be 'dangled' on its on", + "line, then align it to this reference: `prefix`: the start", + "of the statement, `prefix-indent`: the start of the", + "statement, plus one indentation level, `child`: align to", + "the column of the arguments" + ], + "dangle_align": "prefix", + "_help_min_prefix_chars": [ + "If the statement spelling length (including space and", + "parenthesis) is smaller than this amount, then force reject", + "nested layouts." + ], + "min_prefix_chars": 4, + "_help_max_prefix_chars": [ + "If the statement spelling length (including space and", + "parenthesis) is larger than the tab width by more than this", + "amount, then force reject un-nested layouts." + ], + "max_prefix_chars": 10, + "_help_max_lines_hwrap": [ + "If a candidate layout is wrapped horizontally but it exceeds", + "this many lines, then reject the layout." + ], + "max_lines_hwrap": 2, + "_help_line_ending": [ + "What style line endings to use in the output." + ], + "line_ending": "unix", + "_help_command_case": [ + "Format command names consistently as 'lower' or 'upper' case" + ], + "command_case": "canonical", + "_help_keyword_case": [ + "Format keywords consistently as 'lower' or 'upper' case" + ], + "keyword_case": "unchanged", + "_help_always_wrap": [ + "A list of command names which should always be wrapped" + ], + "always_wrap": [], + "_help_enable_sort": [ + "If true, the argument lists which are known to be sortable", + "will be sorted lexicographicall" + ], + "enable_sort": true, + "_help_autosort": [ + "If true, the parsers may infer whether or not an argument", + "list is sortable (without annotation)." + ], + "autosort": false, + "_help_require_valid_layout": [ + "By default, if cmake-format cannot successfully fit", + "everything into the desired linewidth it will apply the", + "last, most agressive attempt that it made. If this flag is", + "True, however, cmake-format will print error, exit with non-", + "zero status code, and write-out nothing" + ], + "require_valid_layout": false, + "_help_layout_passes": [ + "A dictionary mapping layout nodes to a list of wrap", + "decisions. See the documentation for more information." + ], + "layout_passes": {} + }, + "_help_markup": "Options affecting comment reflow and formatting.", + "markup": { + "_help_bullet_char": [ + "What character to use for bulleted lists" + ], + "bullet_char": "*", + "_help_enum_char": [ + "What character to use as punctuation after numerals in an", + "enumerated list" + ], + "enum_char": ".", + "_help_first_comment_is_literal": [ + "If comment markup is enabled, don't reflow the first comment", + "block in each listfile. Use this to preserve formatting of", + "your copyright/license statements." + ], + "first_comment_is_literal": false, + "_help_literal_comment_pattern": [ + "If comment markup is enabled, don't reflow any comment block", + "which matches this (regex) pattern. Default is `None`", + "(disabled)." + ], + "literal_comment_pattern": null, + "_help_fence_pattern": [ + "Regular expression to match preformat fences in comments", + "default= ``r'^\\s*([`~]{3}[`~]*)(.*)$'``" + ], + "fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$", + "_help_ruler_pattern": [ + "Regular expression to match rulers in comments default=", + "``r'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'``" + ], + "ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$", + "_help_explicit_trailing_pattern": [ + "If a comment line matches starts with this pattern then it", + "is explicitly a trailing comment for the preceeding", + "argument. Default is '#<'" + ], + "explicit_trailing_pattern": "#<", + "_help_hashruler_min_length": [ + "If a comment line starts with at least this many consecutive", + "hash characters, then don't lstrip() them off. This allows", + "for lazy hash rulers where the first hash char is not", + "separated by space" + ], + "hashruler_min_length": 10, + "_help_canonicalize_hashrulers": [ + "If true, then insert a space between the first hash char and", + "remaining hash chars in a hash ruler, and normalize its", + "length to fill the column" + ], + "canonicalize_hashrulers": true, + "_help_enable_markup": [ + "enable comment markup parsing and reflow" + ], + "enable_markup": true + }, + "_help_lint": "Options affecting the linter", + "lint": { + "_help_disabled_codes": [ + "a list of lint codes to disable" + ], + "disabled_codes": [], + "_help_function_pattern": [ + "regular expression pattern describing valid function names" + ], + "function_pattern": "[0-9a-z_]+", + "_help_macro_pattern": [ + "regular expression pattern describing valid macro names" + ], + "macro_pattern": "[0-9A-Z_]+", + "_help_global_var_pattern": [ + "regular expression pattern describing valid names for", + "variables with global (cache) scope" + ], + "global_var_pattern": "[A-Z][0-9A-Z_]+", + "_help_internal_var_pattern": [ + "regular expression pattern describing valid names for", + "variables with global scope (but internal semantic)" + ], + "internal_var_pattern": "_[A-Z][0-9A-Z_]+", + "_help_local_var_pattern": [ + "regular expression pattern describing valid names for", + "variables with local scope" + ], + "local_var_pattern": "[a-z][a-z0-9_]+", + "_help_private_var_pattern": [ + "regular expression pattern describing valid names for", + "privatedirectory variables" + ], + "private_var_pattern": "_[0-9a-z_]+", + "_help_public_var_pattern": [ + "regular expression pattern describing valid names for public", + "directory variables" + ], + "public_var_pattern": "[A-Z][0-9A-Z_]+", + "_help_argument_var_pattern": [ + "regular expression pattern describing valid names for", + "function/macro arguments and loop variables." + ], + "argument_var_pattern": "[a-z][a-z0-9_]+", + "_help_keyword_pattern": [ + "regular expression pattern describing valid names for", + "keywords used in functions or macros" + ], + "keyword_pattern": "[A-Z][0-9A-Z_]+", + "_help_max_conditionals_custom_parser": [ + "In the heuristic for C0201, how many conditionals to match", + "within a loop in before considering the loop a parser." + ], + "max_conditionals_custom_parser": 2, + "_help_min_statement_spacing": [ + "Require at least this many newlines between statements" + ], + "min_statement_spacing": 1, + "_help_max_statement_spacing": [ + "Require no more than this many newlines between statements" + ], + "max_statement_spacing": 2, + "max_returns": 6, + "max_branches": 12, + "max_arguments": 5, + "max_localvars": 15, + "max_statements": 50 + }, + "_help_encode": "Options affecting file encoding", + "encode": { + "_help_emit_byteorder_mark": [ + "If true, emit the unicode byte-order mark (BOM) at the start", + "of the file" + ], + "emit_byteorder_mark": false, + "_help_input_encoding": [ + "Specify the encoding of the input file. Defaults to utf-8" + ], + "input_encoding": "utf-8", + "_help_output_encoding": [ + "Specify the encoding of the output file. Defaults to utf-8.", + "Note that cmake only claims to support utf-8 so be careful", + "when using anything else" + ], + "output_encoding": "utf-8" + }, + "_help_misc": "Miscellaneous configurations options.", + "misc": { + "_help_per_command": [ + "A dictionary containing any per-command configuration", + "overrides. Currently only `command_case` is supported." + ], + "per_command": {} + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29f41e713..1d8d1e6cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,6 @@ on: description: 'Run the build with tmate debugging enabled' required: false default: true - jobs: run: strategy: diff --git a/.github/workflows/cff-validator.yml b/.github/workflows/cff-validator.yml index 0963d66e2..2c20b88c3 100644 --- a/.github/workflows/cff-validator.yml +++ b/.github/workflows/cff-validator.yml @@ -3,6 +3,9 @@ on: push: paths: - CITATION.cff + pull_request: + paths: + - CITATION.cff jobs: validate-citation-cff: name: Validate CITATION.cff diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..a7de4e310 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,30 @@ +# Based on https://dev.to/10xlearner/formatting-cmake-4dle +name: Check formatting + +on: + push: + branches: [development, main] + paths-ignore: + - 'README.md' + - 'INSTALL.md' + - 'docs/**' + pull_request: + branches: [development, main] + paths-ignore: + - 'README.md' + - 'INSTALL.md' + - 'docs/**' +jobs: + cmake-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install cmake-format + run: | + python -m pip install --upgrade pip + pip install cmake_format + - name: Run cmake-format + run: | + find . \( -name '*.cmake' -o -name 'CMakeLists.txt' \) -exec cmake-format -i {} \; + - name: Check format + run: git diff --exit-code diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e247f3d0..2dddc7ff1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,52 @@ -cmake_minimum_required (VERSION 3.21 FATAL_ERROR) +cmake_minimum_required(VERSION 3.21 FATAL_ERROR) -#---[ CMake Config ]-------------------- +# ---[ CMake Config ]-------------------- set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# See here: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling -set(CMAKE_SKIP_BUILD_RPATH FALSE) -set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) - -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) -set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +# See here: +# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") message(STATUS "Using CMake version ${CMAKE_VERSION}") cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0056 NEW) -#======================================= - -#---[ Build Config ]-------------------- -project(OCCA - VERSION 2.0.0 - DESCRIPTION "JIT Compilation for Multiple Architectures: C++, OpenMP, CUDA, HIP, OpenCL, Metal" +# ======================================= + +# ---[ Build Config ]-------------------- +project( + OCCA + VERSION 2.0.0 + DESCRIPTION + "JIT Compilation for Multiple Architectures: C++, OpenMP, CUDA, HIP, OpenCL, Metal" HOMEPAGE_URL "https://github.com/libocca/occa" - LANGUAGES C CXX -) + LANGUAGES C CXX) if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Build type" FORCE) endif() -# CMake will decay to a previous C++ standard if a compiler does not support C++17 -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +# CMake will decay to a previous C++ standard if a compiler does not support +# C++17 +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -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_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) +option(OCCA_ENABLE_TESTS "Build tests" OFF) +option(OCCA_ENABLE_EXAMPLES "Build simple examples" OFF) +option(OCCA_ENABLE_FORTRAN "Enable Fortran interface" OFF) option(OCCA_CLANG_BASED_TRANSPILER "Build with occa-transpiler dependecy" OFF) if(OCCA_ENABLE_FORTRAN) @@ -50,7 +54,7 @@ if(OCCA_ENABLE_FORTRAN) endif() option(ENABLE_SHARABLE_DEVICE "Enable sharable device by multiple threads" OFF) -if (ENABLE_SHARABLE_DEVICE) +if(ENABLE_SHARABLE_DEVICE) set(OCCA_THREAD_SHARABLE_ENABLED 1) message("-- OCCA sharable by multi-threads : Enabled") else() @@ -58,12 +62,12 @@ else() endif() set(OCCA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(OCCA_BUILD_DIR ${CMAKE_BINARY_DIR}) +set(OCCA_BUILD_DIR ${CMAKE_BINARY_DIR}) include(CodeGen) set(OCCA_USING_VS OFF) -set(OCCA_UNSAFE OFF) +set(OCCA_UNSAFE OFF) # Test Apple first because UNIX==true for Apple and Linux. if(APPLE) @@ -79,10 +83,15 @@ include(SetCompilerFlags) string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER) 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}}") +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(OCCA_ENABLE_FORTRAN) - message("-- F90 flags : ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") + message( + "-- F90 flags : ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" + ) endif() if(OCCA_ENABLE_FORTRAN) @@ -90,40 +99,32 @@ if(OCCA_ENABLE_FORTRAN) endif() set(namespace "${PROJECT_NAME}::") -#======================================= +# ======================================= -#---[ libocca.so ]---------------------- +# ---[ libocca.so ]---------------------- add_library(libocca SHARED) add_library(${namespace}libocca ALIAS libocca) -target_include_directories(libocca - PUBLIC - $ - $ - $ - $ -) +target_include_directories( + libocca + PUBLIC $ + $ + $ + $) # Without this, CMake will create liblibocca.so -set_target_properties(libocca - PROPERTIES - OUTPUT_NAME - occa - LIBRARY_OUTPUT_DIRECTORY - ${OCCA_BUILD_DIR}/lib -) +set_target_properties( + libocca PROPERTIES OUTPUT_NAME occa LIBRARY_OUTPUT_DIRECTORY + ${OCCA_BUILD_DIR}/lib) # Find needed and requested packages find_package(Threads REQUIRED) -# Use the provided imported target Threads::Threads, to make our package relocatable -target_link_libraries(libocca - PRIVATE - Threads::Threads - ${CMAKE_DL_LIBS} -) -#======================================= +# Use the provided imported target Threads::Threads, to make our package +# relocatable +target_link_libraries(libocca PRIVATE Threads::Threads ${CMAKE_DL_LIBS}) +# ======================================= -#---[ OpenMP ]-------------------------- +# ---[ OpenMP ]-------------------------- if(OCCA_ENABLE_OPENMP) find_package(OpenMP) @@ -133,16 +134,16 @@ if(OCCA_ENABLE_OPENMP) message("-- OpenMP include dirs: ${OpenMP_CXX_INCLUDE_DIRS}") message("-- OpenMP libraries: ${OpenMP_CXX_LIBRARIES}") - # Use the provided imported target OpenMP::OpenMP_CXX, - # (which wraps the CXX_INCLUDE_DIRS and CXX_LIBRARIES,) to make our package relocatable + # 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() set(OCCA_OPENMP_ENABLED 0) endif() endif() -#======================================= +# ======================================= -#---[ CUDA ]---------------------------- +# ---[ CUDA ]---------------------------- if(OCCA_ENABLE_CUDA) find_package(CUDAToolkit) @@ -152,15 +153,16 @@ if(OCCA_ENABLE_CUDA) message("-- CUDA include dirs: ${CUDAToolkit_INCLUDE_DIRS}") message("-- CUDA driver library: ${CUDAToolkit_LIBRARY_DIR}") - # Use the provided imported target CUDA::cuda_driver, to make our package relocatable + # Use the provided imported target CUDA::cuda_driver, to make our package + # relocatable target_link_libraries(libocca PRIVATE CUDA::cuda_driver) else() set(OCCA_CUDA_ENABLED 0) endif() endif() -#======================================= +# ======================================= -#---[ OpenCL ]-------------------------- +# ---[ OpenCL ]-------------------------- if(OCCA_ENABLE_OPENCL) find_package(OpenCLWrapper) @@ -170,16 +172,16 @@ if(OCCA_ENABLE_OPENCL) message("-- OpenCL include dirs: ${OpenCL_INCLUDE_DIRS}") message("-- OpenCL libraries: ${OpenCL_LIBRARIES}") - # Use the provided imported target OpenCL::OpenCL, - # (which wraps the _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable + # 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() set(OCCA_OPENCL_ENABLED 0) endif() endif() -#======================================= +# ======================================= -#---[ SYCL/DPCPP ]----------------------- +# ---[ SYCL/DPCPP ]----------------------- if(OCCA_ENABLE_DPCPP) find_package(DPCPP) @@ -190,16 +192,16 @@ if(OCCA_ENABLE_DPCPP) message("-- DPCPP include dirs: ${DPCPP_INCLUDE_DIRS}") message("-- DPCPP libraries: ${DPCPP_LIBRARIES}") - # Use our wrapper imported target OCCA::depends::DPCPP, - # (which wraps the _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable + # Use our wrapper imported target OCCA::depends::DPCPP, (which wraps the + # _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable target_link_libraries(libocca PRIVATE OCCA::depends::DPCPP) else() set(OCCA_DPCPP_ENABLED 0) endif() endif() -#======================================= +# ======================================= -#---[ HIP ]----------------------------- +# ---[ HIP ]----------------------------- if(OCCA_ENABLE_HIP) find_package(HIP) @@ -211,16 +213,17 @@ if(OCCA_ENABLE_HIP) message("-- HIP include dirs: ${HIP_INCLUDE_DIRS}") message("-- HIP libraries: ${HIP_LIBRARIES}") - # Use our wrapper imported target OCCA::depends::HIP, - # (which wraps the _COMPILE_DEFINITIONS, _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable + # Use our wrapper imported target OCCA::depends::HIP, (which wraps the + # _COMPILE_DEFINITIONS, _INCLUDE_DIRS and _LIBRARIES,) to make our package + # relocatable target_link_libraries(libocca PRIVATE OCCA::depends::HIP) - else (HIP_FOUND) + else(HIP_FOUND) set(OCCA_HIP_ENABLED 0) endif(HIP_FOUND) endif() -#======================================= +# ======================================= -#---[ Metal ]--------------------------- +# ---[ Metal ]--------------------------- if(OCCA_ENABLE_METAL AND APPLE) find_package(METAL) @@ -231,54 +234,64 @@ if(OCCA_ENABLE_METAL AND APPLE) message("-- METAL core services: ${CORE_SERVICES}") message("-- METAL app kit: ${APP_KIT}") - # Use our wrapper imported target OCCA::depends::METAL, - # (which wraps the three libraries variables,) to make our package relocatable + # Use our wrapper imported target OCCA::depends::METAL, (which wraps the + # three libraries variables,) to make our package relocatable target_link_libraries(libocca PRIVATE OCCA::depends::METAL) else() set(OCCA_METAL_ENABLED 0) endif() endif() -#======================================= +# ======================================= -#---[ Clang Transpiler ]--------------------------- +# ---[ Clang Transpiler ]--------------------------- # INFO: order is important, deps should not apply compiler flags -if (OCCA_CLANG_BASED_TRANSPILER) +if(OCCA_CLANG_BASED_TRANSPILER) find_package(oklt REQUIRED) target_link_libraries(libocca PRIVATE occa::occa-transpiler) - target_compile_definitions(libocca PRIVATE -DBUILD_WITH_CLANG_BASED_TRANSPILER) + target_compile_definitions(libocca + PRIVATE -DBUILD_WITH_CLANG_BASED_TRANSPILER) endif() include(CheckRequiredCompilerFeatures) - + if(NOT OCCA_IS_TOP_LEVEL) # OCCA is being built as a subdirectory in another project - set(OCCA_OPENMP_ENABLED ${OCCA_OPENMP_ENABLED} PARENT_SCOPE) - set(OCCA_CUDA_ENABLED ${OCCA_CUDA_ENABLED} PARENT_SCOPE) - set(OCCA_HIP_ENABLED ${OCCA_HIP_ENABLED} PARENT_SCOPE) - set(OCCA_DPCPP_ENABLED ${OCCA_DPCPP_ENABLED} PARENT_SCOPE) - set(OCCA_OPENCL_ENABLED ${OCCA_OPENCL_ENABLED} PARENT_SCOPE) - set(OCCA_METAL_ENABLED ${OCCA_METAL_ENABLED} PARENT_SCOPE) + set(OCCA_OPENMP_ENABLED + ${OCCA_OPENMP_ENABLED} + PARENT_SCOPE) + set(OCCA_CUDA_ENABLED + ${OCCA_CUDA_ENABLED} + PARENT_SCOPE) + set(OCCA_HIP_ENABLED + ${OCCA_HIP_ENABLED} + PARENT_SCOPE) + set(OCCA_DPCPP_ENABLED + ${OCCA_DPCPP_ENABLED} + PARENT_SCOPE) + set(OCCA_OPENCL_ENABLED + ${OCCA_OPENCL_ENABLED} + PARENT_SCOPE) + set(OCCA_METAL_ENABLED + ${OCCA_METAL_ENABLED} + PARENT_SCOPE) endif() # Generate CompiledDefines from libraries we found -configure_file( - scripts/build/compiledDefinesTemplate.hpp.in - ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp) +configure_file(scripts/build/compiledDefinesTemplate.hpp.in + ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp) -install( - FILES ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp - DESTINATION include/occa/defines) +install(FILES ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp + DESTINATION include/occa/defines) if(OCCA_ENABLE_FORTRAN) - install(CODE - "file(GLOB public-modules ${CMAKE_Fortran_MODULE_DIRECTORY}/*.mod)\n + install( + CODE "file(GLOB public-modules ${CMAKE_Fortran_MODULE_DIRECTORY}/*.mod)\n file(INSTALL DESTINATION ${CMAKE_INSTALL_PREFIX}/include TYPE FILE FILES \${public-modules})") - set_target_properties(libocca PROPERTIES - LINKER_LANGUAGE C) + set_target_properties(libocca PROPERTIES LINKER_LANGUAGE C) endif() add_subdirectory(src) @@ -291,35 +304,25 @@ if(OCCA_ENABLE_TESTS) add_subdirectory(tests) endif() -if (OCCA_ENABLE_FORTRAN) - install(TARGETS - libocca - c_api - fortran_api - EXPORT - occaExport - DESTINATION - lib - ) +if(OCCA_ENABLE_FORTRAN) + install( + TARGETS libocca c_api fortran_api + EXPORT occaExport + DESTINATION lib) else() - install(TARGETS - libocca - c_api - EXPORT - occaExport - DESTINATION - lib - ) + install( + TARGETS libocca c_api + EXPORT occaExport + DESTINATION lib) endif() install(DIRECTORY include/ DESTINATION include) # Create a package config and associated files. include(ExportAndPackageConfig) -install(CODE - "configure_file( +install( + CODE "configure_file( ${OCCA_SOURCE_DIR}/modulefiles/occa ${CMAKE_INSTALL_PREFIX}/modulefiles/occa @ONLY - )" -) + )") diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index ea0b1137a..a9db25ea0 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -2,7 +2,10 @@ add_executable(occa occa.cpp) add_executable(${namespace}occa ALIAS occa) target_link_libraries(occa libocca) -target_include_directories(occa PRIVATE - $) +target_include_directories(occa + PRIVATE $) -install(TARGETS occa EXPORT occaExport DESTINATION bin) +install( + TARGETS occa + EXPORT occaExport + DESTINATION bin) diff --git a/cmake/CheckRequiredCompilerFeatures.cmake b/cmake/CheckRequiredCompilerFeatures.cmake index 20f1df2e4..a1378935b 100644 --- a/cmake/CheckRequiredCompilerFeatures.cmake +++ b/cmake/CheckRequiredCompilerFeatures.cmake @@ -1,6 +1,7 @@ include(CheckCXXCompilerFlag) -check_cxx_source_compiles(" +check_cxx_source_compiles( + " #include namespace fs = std::filesystem; @@ -8,15 +9,18 @@ namespace fs = std::filesystem; int main(int argc, char *argv[]) { return 0; } -" HAS_FILE_SYSTEM) +" + HAS_FILE_SYSTEM) -if (NOT HAS_FILE_SYSTEM) +if(NOT HAS_FILE_SYSTEM) message(FATAL_ERROR "CXX compiler doesn't have std::filesystem support !") endif() -if (OCCA_DPCPP_ENABLED) +if(OCCA_DPCPP_ENABLED) check_cxx_compiler_flag("-fsycl" IS_SYCL_SUPPORTED) - if (NOT IS_SYCL_SUPPORTED) - message(FATAL_ERROR "DPCPP is enabled but the compiler doesn't support \"-fsycl\" flag!") + if(NOT IS_SYCL_SUPPORTED) + message( + FATAL_ERROR + "DPCPP is enabled but the compiler doesn't support \"-fsycl\" flag!") endif() endif() diff --git a/cmake/CodeGen.cmake b/cmake/CodeGen.cmake index f59cb5ab1..b2d0c585c 100644 --- a/cmake/CodeGen.cmake +++ b/cmake/CodeGen.cmake @@ -1,36 +1,73 @@ -## Generated codes for handling kernel arguments -# Configure default/pre-generated files -# Check if those files need to be re-generated -option(KEEP_DEFAULT_MAX_NUM_INLINE_KERNEL_ARGS "Skip code generations for the given maximum number of arguments on inline kernels, use default instead" OFF) +# Generated codes for handling kernel arguments Configure default/pre-generated +# files Check if those files need to be re-generated +option( + KEEP_DEFAULT_MAX_NUM_INLINE_KERNEL_ARGS + "Skip code generations for the given maximum number of arguments on inline kernels, use default instead" + OFF) set(MAX_NUM_KERNEL_ARGS_DEFAULT "128") -set(MAX_NUM_KERNEL_ARGS ${MAX_NUM_KERNEL_ARGS_DEFAULT} CACHE STRING "The maximum number of allowed kernel arguments") -set(OCCA_MAX_ARGS ${MAX_NUM_KERNEL_ARGS_DEFAULT} CACHE STRING "The maximum number of allowed kernel arguments stored to use, do not change this value directly, update MAX_NUM_KERNEL_ARGS instead") -if (NOT ${MAX_NUM_KERNEL_ARGS} EQUAL ${OCCA_MAX_ARGS}) +set(MAX_NUM_KERNEL_ARGS + ${MAX_NUM_KERNEL_ARGS_DEFAULT} + CACHE STRING "The maximum number of allowed kernel arguments") +set(OCCA_MAX_ARGS + ${MAX_NUM_KERNEL_ARGS_DEFAULT} + CACHE + STRING + "The maximum number of allowed kernel arguments stored to use, do not change this value directly, update MAX_NUM_KERNEL_ARGS instead" +) +if(NOT ${MAX_NUM_KERNEL_ARGS} EQUAL ${OCCA_MAX_ARGS}) execute_process(COMMAND python --version OUTPUT_VARIABLE python_version) string(REGEX MATCH "[0-9.]\+" python_version ${python_version}) - if ("${python_version}" VERSION_LESS "3.7.2") - message(WARNING "-- Failed to set the maximum number of kernel arguments to ${MAX_NUM_KERNEL_ARGS}, required minimum python version 3.7.2. The default value ${MAX_NUM_KERNEL_ARGS_DEFAULT} will be used.") + if("${python_version}" VERSION_LESS "3.7.2") + message( + WARNING + "-- Failed to set the maximum number of kernel arguments to ${MAX_NUM_KERNEL_ARGS}, required minimum python version 3.7.2. The default value ${MAX_NUM_KERNEL_ARGS_DEFAULT} will be used." + ) else() - message("-- Codegen for the maximum number of kernel arguments : ${MAX_NUM_KERNEL_ARGS}") - if (KEEP_DEFAULT_MAX_NUM_INLINE_KERNEL_ARGS AND ${MAX_NUM_KERNEL_ARGS} GREATER ${MAX_NUM_KERNEL_ARGS_DEFAULT}) - execute_process(COMMAND ${CMAKE_COMMAND} -E env OCCA_DIR=${OCCA_BUILD_DIR} python ${OCCA_SOURCE_DIR}/scripts/codegen/setup_kernel_operators.py -N ${MAX_NUM_KERNEL_ARGS} --skipInline) + message( + "-- Codegen for the maximum number of kernel arguments : ${MAX_NUM_KERNEL_ARGS}" + ) + if(KEEP_DEFAULT_MAX_NUM_INLINE_KERNEL_ARGS + AND ${MAX_NUM_KERNEL_ARGS} GREATER ${MAX_NUM_KERNEL_ARGS_DEFAULT}) + execute_process( + COMMAND + ${CMAKE_COMMAND} -E env OCCA_DIR=${OCCA_BUILD_DIR} python + ${OCCA_SOURCE_DIR}/scripts/codegen/setup_kernel_operators.py -N + ${MAX_NUM_KERNEL_ARGS} --skipInline) else() - execute_process(COMMAND ${CMAKE_COMMAND} -E env OCCA_DIR=${OCCA_BUILD_DIR} python ${OCCA_SOURCE_DIR}/scripts/codegen/setup_kernel_operators.py -N ${MAX_NUM_KERNEL_ARGS}) + execute_process( + COMMAND + ${CMAKE_COMMAND} -E env OCCA_DIR=${OCCA_BUILD_DIR} python + ${OCCA_SOURCE_DIR}/scripts/codegen/setup_kernel_operators.py -N + ${MAX_NUM_KERNEL_ARGS}) endif() - set(OCCA_MAX_ARGS ${MAX_NUM_KERNEL_ARGS} CACHE STRING "The maximum number of allowed kernel arguments stored to use, do not change this value directly, update MAX_NUM_KERNEL_ARGS instead" FORCE) + set(OCCA_MAX_ARGS + ${MAX_NUM_KERNEL_ARGS} + CACHE + STRING + "The maximum number of allowed kernel arguments stored to use, do not change this value directly, update MAX_NUM_KERNEL_ARGS instead" + FORCE) endif() else() - if (${OCCA_MAX_ARGS} EQUAL ${MAX_NUM_KERNEL_ARGS_DEFAULT}) - configure_file(${OCCA_SOURCE_DIR}/scripts/codegen/kernelOperators.hpp_codegen.in ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.hpp_codegen COPYONLY) - configure_file(${OCCA_SOURCE_DIR}/scripts/codegen/kernelOperators.cpp_codegen.in ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.cpp_codegen COPYONLY) - configure_file(${OCCA_SOURCE_DIR}/scripts/codegen/runFunction.cpp_codegen.in ${OCCA_BUILD_DIR}/include/codegen/runFunction.cpp_codegen COPYONLY) - configure_file(${OCCA_SOURCE_DIR}/scripts/codegen/macros.hpp_codegen.in ${OCCA_BUILD_DIR}/include/codegen/macros.hpp_codegen COPYONLY) + if(${OCCA_MAX_ARGS} EQUAL ${MAX_NUM_KERNEL_ARGS_DEFAULT}) + configure_file( + ${OCCA_SOURCE_DIR}/scripts/codegen/kernelOperators.hpp_codegen.in + ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.hpp_codegen COPYONLY) + configure_file( + ${OCCA_SOURCE_DIR}/scripts/codegen/kernelOperators.cpp_codegen.in + ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.cpp_codegen COPYONLY) + configure_file( + ${OCCA_SOURCE_DIR}/scripts/codegen/runFunction.cpp_codegen.in + ${OCCA_BUILD_DIR}/include/codegen/runFunction.cpp_codegen COPYONLY) + configure_file( + ${OCCA_SOURCE_DIR}/scripts/codegen/macros.hpp_codegen.in + ${OCCA_BUILD_DIR}/include/codegen/macros.hpp_codegen COPYONLY) endif() endif() # Set installtion of files required in header -install(FILES ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.cpp_codegen - ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.hpp_codegen - ${OCCA_BUILD_DIR}/include/codegen/macros.hpp_codegen - ${OCCA_BUILD_DIR}/include/codegen/runFunction.cpp_codegen +install( + FILES ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.cpp_codegen + ${OCCA_BUILD_DIR}/include/codegen/kernelOperators.hpp_codegen + ${OCCA_BUILD_DIR}/include/codegen/macros.hpp_codegen + ${OCCA_BUILD_DIR}/include/codegen/runFunction.cpp_codegen DESTINATION include/codegen) diff --git a/cmake/ExportAndPackageConfig.cmake b/cmake/ExportAndPackageConfig.cmake index 9c05df959..56c24b334 100644 --- a/cmake/ExportAndPackageConfig.cmake +++ b/cmake/ExportAndPackageConfig.cmake @@ -1,24 +1,26 @@ -# Create -# occaTargets.cmake, that defines IMPORTED targets for all targets associated with occaExport -# occaConfig.cmake, used by find_package(occa), will use occaTargets.cmake to create the IMPORTED targets -# occaConfigVersion.cmake, the version file associated with occaConfig.cmake +# Create occaTargets.cmake, that defines IMPORTED targets for all targets +# associated with occaExport occaConfig.cmake, used by find_package(occa), will +# use occaTargets.cmake to create the IMPORTED targets occaConfigVersion.cmake, +# the version file associated with occaConfig.cmake -# Install in subdirectory lib/cmake/PACKAGENAME, which is where cmake expects package config files +# Install in subdirectory lib/cmake/PACKAGENAME, which is where cmake expects +# package config files set(PackageConfigInstallLocation lib/cmake/OCCA) -# Set the exportPackageDependencies variable, for use in configuring occaConfig.cmake.in -# Do this for all our dependencies. In theory, could skip some if they are -# e.g. static or header libraries only AND we are only building shared libraries or executables AND -# we link PRIVATE, however the first condition is not easily checked. -set (exportPackageDependencies "") +# Set the exportPackageDependencies variable, for use in configuring +# occaConfig.cmake.in Do this for all our dependencies. In theory, could skip +# some if they are e.g. static or header libraries only AND we are only building +# shared libraries or executables AND we link PRIVATE, however the first +# condition is not easily checked. +set(exportPackageDependencies "") string(APPEND exportPackageDependencies "find_dependency(Threads)\n") -if (OCCA_OPENMP_ENABLED) +if(OCCA_OPENMP_ENABLED) string(APPEND exportPackageDependencies "find_dependency(OpenMP)\n") endif() -if (OCCA_CUDA_ENABLED) +if(OCCA_CUDA_ENABLED) string(APPEND exportPackageDependencies "find_dependency(CUDAToolkit)\n") endif() -if (OCCA_OPENCL_ENABLED) +if(OCCA_OPENCL_ENABLED) string(APPEND exportPackageDependencies "find_dependency(OpenCLWrapper)\n") endif() if(OCCA_DPCPP_ENABLED) @@ -32,52 +34,58 @@ if(OCCA_METAL_ENABLED) endif() # List of what targets are exported, for use in configuring occaConfig.cmake.in -# Explicit list because unfortunately no easy way to retrieve it through cmake, even though they all are part of the EXPORT occaExport +# Explicit list because unfortunately no easy way to retrieve it through cmake, +# even though they all are part of the EXPORT occaExport set(exportTargets "") -string(APPEND exportTargets "# ${namespace}libocca Target to link to for using occa\n") -string(APPEND exportTargets "# ${namespace}occa The occa executable, e.g. can be called to get information on supported backends\n") +string(APPEND exportTargets + "# ${namespace}libocca Target to link to for using occa\n") +string( + APPEND + exportTargets + "# ${namespace}occa The occa executable, e.g. can be called to get information on supported backends\n" +) include(CMakePackageConfigHelpers) # Create the PackageConfig file, based on the template configure_package_config_file( "${CMAKE_CURRENT_LIST_DIR}/OCCAConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfig.cmake" - INSTALL_DESTINATION ${PackageConfigInstallLocation} # Only used as relative reference during in this function, does not determine actual install location - NO_CHECK_REQUIRED_COMPONENTS_MACRO # As long as components are not used, don't need it - ) + INSTALL_DESTINATION + ${PackageConfigInstallLocation} # Only used as relative reference during in + # this function, does not determine actual + # install location + NO_CHECK_REQUIRED_COMPONENTS_MACRO # As long as components are not used, don't + # need it +) -# Create the Version file -# Take the version string from occa.hpp -# Improvement possible: Put in occa.hpp, instead of read from. Requires that also non-cmake workflow supports that. +# Create the Version file Take the version string from occa.hpp Improvement +# possible: Put in occa.hpp, instead of read from. Requires that also non-cmake +# workflow supports that. file(READ "${OCCA_SOURCE_DIR}/include/occa/defines/occa.hpp" occadefs) string(REGEX MATCH "#define OCCA_VERSION_STR +\"([.0-9]*)\"" _ ${occadefs}) set(OCCA_VERSION_STR ${CMAKE_MATCH_1}) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfigVersion.cmake" VERSION "${OCCA_VERSION_STR}" - COMPATIBILITY AnyNewerVersion -) + COMPATIBILITY AnyNewerVersion) -# Install the exported-targets file -# Will be used by the PackageConfig to generate the imported targets +# Install the exported-targets file Will be used by the PackageConfig to +# generate the imported targets install( EXPORT occaExport NAMESPACE ${namespace} FILE OCCATargets.cmake - DESTINATION ${PackageConfigInstallLocation} -) + DESTINATION ${PackageConfigInstallLocation}) -# Install the Config and Version files, and any files they need -# Note that find_package is case-sensitive w.r.t. the name of the package as part of the name of these files -# find_package(occa) will only match occaConfig.cmake, NOT OccaConfig.cmake +# Install the Config and Version files, and any files they need Note that +# find_package is case-sensitive w.r.t. the name of the package as part of the +# name of these files find_package(occa) will only match occaConfig.cmake, NOT +# OccaConfig.cmake install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfigVersion.cmake" - "${CMAKE_CURRENT_LIST_DIR}/FindDPCPP.cmake" - "${CMAKE_CURRENT_LIST_DIR}/FindHIP.cmake" - "${CMAKE_CURRENT_LIST_DIR}/FindMETAL.cmake" - "${CMAKE_CURRENT_LIST_DIR}/FindOpenCLWrapper.cmake" - DESTINATION - ${PackageConfigInstallLocation} -) + FILES "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/OCCAConfigVersion.cmake" + "${CMAKE_CURRENT_LIST_DIR}/FindDPCPP.cmake" + "${CMAKE_CURRENT_LIST_DIR}/FindHIP.cmake" + "${CMAKE_CURRENT_LIST_DIR}/FindMETAL.cmake" + "${CMAKE_CURRENT_LIST_DIR}/FindOpenCLWrapper.cmake" + DESTINATION ${PackageConfigInstallLocation}) diff --git a/cmake/FindDPCPP.cmake b/cmake/FindDPCPP.cmake index 38e4c3ca8..4df0b292e 100644 --- a/cmake/FindDPCPP.cmake +++ b/cmake/FindDPCPP.cmake @@ -1,13 +1,13 @@ -############################################################################### -# FIND module for DPCPP components -# This Find module is also distributed alongside the occa package config file! -############################################################################### +# ############################################################################## +# FIND module for DPCPP components This Find module is also distributed +# alongside the occa package config file! +# ############################################################################## message(CHECK_START "Looking for DPC++") unset(missingDpcppComponents) find_package(IntelSYCL QUIET) -if (IntelSYCL_FOUND) +if(IntelSYCL_FOUND) set(DPCPP_FOUND TRUE) set(DPCPP_FLAGS "${SYCL_FLAGS}") set(DPCPP_INCLUDE_DIRS "${SYCL_INCLUDE_DIR};${SYCL_INCLUDE_SYCL_DIR}") @@ -19,59 +19,37 @@ else() find_path( DPCPP_INCLUDE_DIRS - NAMES - sycl/sycl.hpp - PATHS - ENV SYCL_ROOT - ${SYCL_ROOT} - ENV CMPLR_ROOT - ${cxx_root_dir} - PATH_SUFFIXES - include - include/sycl - include/CL - include/sycl/CL - ) + NAMES sycl/sycl.hpp + PATHS ENV SYCL_ROOT ${SYCL_ROOT} ENV CMPLR_ROOT ${cxx_root_dir} + PATH_SUFFIXES include include/sycl include/CL include/sycl/CL) set(DPCPP_INCLUDE_DIRS "${DPCPP_INCLUDE_DIRS};${DPCPP_INCLUDE_DIRS}/sycl") find_library( DPCPP_LIBRARIES - NAMES - sycl libsycl - PATHS - ENV SYCL_ROOT - ${SYCL_ROOT} - ENV CMPLR_ROOT - ${cxx_root_dir} - PATH_SUFFIXES - lib - ) + NAMES sycl libsycl + PATHS ENV SYCL_ROOT ${SYCL_ROOT} ENV CMPLR_ROOT ${cxx_root_dir} + PATH_SUFFIXES lib) set(DPCPP_FLAGS -fsycl) endif() -if (NOT SYCL_FLAGS) +if(NOT SYCL_FLAGS) set(DPCPP_FLAGS SYCL_FLAGS) endif() # TODO: Check if the backend compiler supports DPCPP_FLAGS include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - DPCPP - REQUIRED_VARS - DPCPP_INCLUDE_DIRS - DPCPP_LIBRARIES - DPCPP_FLAGS -) + DPCPP REQUIRED_VARS DPCPP_INCLUDE_DIRS DPCPP_LIBRARIES DPCPP_FLAGS) -if (DPCPP_FOUND AND NOT TARGET OCCA::depends::DPCPP) - # Create our wrapper imported target - # Put it in the OCCA namespace to make it clear that we created it. +if(DPCPP_FOUND AND NOT TARGET OCCA::depends::DPCPP) + # Create our wrapper imported target Put it in the OCCA namespace to make it + # clear that we created it. add_library(OCCA::depends::DPCPP INTERFACE IMPORTED) separate_arguments(DPCPP_FLAGS UNIX_COMMAND "${DPCPP_FLAGS}") target_compile_options(OCCA::depends::DPCPP INTERFACE ${DPCPP_FLAGS}) - set_target_properties(OCCA::depends::DPCPP PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${DPCPP_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${DPCPP_LIBRARIES}" - ) + set_target_properties( + OCCA::depends::DPCPP + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${DPCPP_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${DPCPP_LIBRARIES}") endif() diff --git a/cmake/FindHIP.cmake b/cmake/FindHIP.cmake index 99ad26c32..b1c55e853 100644 --- a/cmake/FindHIP.cmake +++ b/cmake/FindHIP.cmake @@ -1,38 +1,38 @@ -############################################################################### -# FIND: HIP and associated helper binaries -# This Find module is also distributed alongside the occa package config file! -############################################################################### +# ############################################################################## +# FIND: HIP and associated helper binaries This Find module is also distributed +# alongside the occa package config file! +# ############################################################################## # HIP is supported on Linux only -if(UNIX AND NOT APPLE AND NOT CYGWIN) +if(UNIX + AND NOT APPLE + AND NOT CYGWIN) # Search for HIP installation if(NOT HIP_ROOT_DIR) # Search in user specified path first find_path( HIP_ROOT_DIR NAMES hipconfig - PATHS - ENV ROCM_PATH - ENV HIP_PATH + PATHS ENV ROCM_PATH ENV HIP_PATH PATH_SUFFIXES bin DOC "HIP installed location" - NO_DEFAULT_PATH - ) + NO_DEFAULT_PATH) # Now search in default path find_path( HIP_ROOT_DIR NAMES hipconfig - PATHS - /opt/rocm + PATHS /opt/rocm PATH_SUFFIXES bin - DOC "HIP installed location" - ) + DOC "HIP installed location") # Check if we found HIP installation if(HIP_ROOT_DIR) # If so, fix the path - string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" HIP_ROOT_DIR ${HIP_ROOT_DIR}) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" HIP_ROOT_DIR + ${HIP_ROOT_DIR}) # And push it back to the cache - set(HIP_ROOT_DIR ${HIP_ROOT_DIR} CACHE PATH "HIP installed location" FORCE) + set(HIP_ROOT_DIR + ${HIP_ROOT_DIR} + CACHE PATH "HIP installed location" FORCE) endif() endif() @@ -40,14 +40,9 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) find_program( HIP_HIPCONFIG_EXECUTABLE NAMES hipconfig - PATHS - "${HIP_ROOT_DIR}" - ENV ROCM_PATH - ENV HIP_PATH - /opt/rocm + PATHS "${HIP_ROOT_DIR}" ENV ROCM_PATH ENV HIP_PATH /opt/rocm PATH_SUFFIXES bin - NO_DEFAULT_PATH - ) + NO_DEFAULT_PATH) if(NOT HIP_HIPCONFIG_EXECUTABLE) # Now search in default paths find_program(HIP_HIPCONFIG_EXECUTABLE hipconfig) @@ -60,13 +55,15 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --version OUTPUT_VARIABLE _hip_version ERROR_VARIABLE _hip_error - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if(NOT _hip_error) - set(HIP_VERSION ${_hip_version} CACHE STRING "Version of HIP as computed from hipcc") + set(HIP_VERSION + ${_hip_version} + CACHE STRING "Version of HIP as computed from hipcc") else() - set(HIP_VERSION "0.0.0" CACHE STRING "Version of HIP as computed by FindHIP()") + set(HIP_VERSION + "0.0.0" + CACHE STRING "Version of HIP as computed by FindHIP()") endif() mark_as_advanced(HIP_VERSION) endif() @@ -83,9 +80,10 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) execute_process( COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform OUTPUT_VARIABLE _hip_platform - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set(HIP_PLATFORM ${_hip_platform} CACHE STRING "HIP platform as computed by hipconfig") + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(HIP_PLATFORM + ${_hip_platform} + CACHE STRING "HIP platform as computed by hipconfig") mark_as_advanced(HIP_PLATFORM) endif() @@ -94,9 +92,10 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) execute_process( COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --compiler OUTPUT_VARIABLE _hip_compiler - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - set(HIP_COMPILER ${_hip_compiler} CACHE STRING "HIP compiler as computed by hipconfig") + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(HIP_COMPILER + ${_hip_compiler} + CACHE STRING "HIP compiler as computed by hipconfig") mark_as_advanced(HIP_COMPILER) endif() @@ -111,15 +110,14 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) elseif(${HIP_PLATFORM} STREQUAL "nvidia") find_package(CUDA) - #find the shared library, rather than the static that find_package returns + # find the shared library, rather than the static that find_package + # returns find_library( CUDART_LIB NAMES cudart - PATHS - ${CUDA_TOOLKIT_ROOT_DIR} + PATHS ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES lib64 lib - DOC "CUDA RT lib location" - ) + DOC "CUDA RT lib location") set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include;${CUDA_INCLUDE_DIRS}") set(HIP_LIBRARIES "${CUDART_LIB};cuda") @@ -134,8 +132,8 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - HIP - REQUIRED_VARS + HIP + REQUIRED_VARS HIP_ROOT_DIR HIP_INCLUDE_DIRS HIP_LIBRARIES @@ -143,16 +141,15 @@ find_package_handle_standard_args( HIP_HIPCONFIG_EXECUTABLE HIP_PLATFORM HIP_COMPILER - VERSION_VAR HIP_VERSION - ) + VERSION_VAR HIP_VERSION) if(HIP_FOUND AND NOT TARGET OCCA::depends::HIP) - # Create our wrapper imported target - # Put it in the OCCA namespace to make it clear that we created it. + # Create our wrapper imported target Put it in the OCCA namespace to make it + # clear that we created it. add_library(OCCA::depends::HIP INTERFACE IMPORTED) - set_target_properties(OCCA::depends::HIP PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "${HIP_RUNTIME_DEFINE}" - INTERFACE_INCLUDE_DIRECTORIES "${HIP_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${HIP_LIBRARIES}" - ) + set_target_properties( + OCCA::depends::HIP + PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${HIP_RUNTIME_DEFINE}" + INTERFACE_INCLUDE_DIRECTORIES "${HIP_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${HIP_LIBRARIES}") endif() diff --git a/cmake/FindMETAL.cmake b/cmake/FindMETAL.cmake index e1251246e..bc78c6a62 100644 --- a/cmake/FindMETAL.cmake +++ b/cmake/FindMETAL.cmake @@ -1,24 +1,20 @@ -############################################################################### -# FIND module for METAL components -# This Find module is also distributed alongside the occa package config file! -############################################################################### +# ############################################################################## +# FIND module for METAL components This Find module is also distributed +# alongside the occa package config file! +# ############################################################################## find_library(METAL_LIBRARY Metal) find_library(CORE_SERVICES CoreServices) find_library(APP_KIT AppKit) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - METAL - REQUIRED_VARS - METAL_LIBRARY - CORE_SERVICES - APP_KIT - ) +find_package_handle_standard_args(METAL REQUIRED_VARS METAL_LIBRARY + CORE_SERVICES APP_KIT) if(METAL_FOUND AND NOT TARGET OCCA::depends::METAL) - # Create our wrapper imported target - # Put it in the OCCA namespace to make it clear that we created it. + # Create our wrapper imported target Put it in the OCCA namespace to make it + # clear that we created it. add_library(OCCA::depends::METAL INTERFACE IMPORTED) - target_link_libraries(OCCA::depends::METAL INTERFACE ${METAL_LIBRARY} ${CORE_SERVICES} ${APP_KIT}) + target_link_libraries(OCCA::depends::METAL + INTERFACE ${METAL_LIBRARY} ${CORE_SERVICES} ${APP_KIT}) endif() diff --git a/cmake/FindOpenCLWrapper.cmake b/cmake/FindOpenCLWrapper.cmake index 1d7f6c2ec..206f2a722 100644 --- a/cmake/FindOpenCLWrapper.cmake +++ b/cmake/FindOpenCLWrapper.cmake @@ -1,51 +1,51 @@ -############################################################################### -# FIND module wrapper around finding OpenCL -# This Find module is also distributed alongside the occa package config file! -############################################################################### +# ############################################################################## +# FIND module wrapper around finding OpenCL This Find module is also distributed +# alongside the occa package config file! +# ############################################################################## # Try finding OpenCL. The user should set OpenCL_ROOT if needed. find_package(OpenCL QUIET) if(NOT OpenCL_FOUND) # Otherwise, look for the headers and library in standard locations - find_path(OpenCL_INCLUDE_DIR + find_path( + OpenCL_INCLUDE_DIR NAMES CL/cl.h OpenCL/cl.h - PATHS - ENV CUDA_PATH - ENV CUDAToolkit_ROOT - ENV ROCM_PATH - ENV NVHPC_ROOT - ENV SYCL_ROOT - /usr/local/cuda - /opt/rocm/ - /opt/rocm/opencl - /opt/intel/oneapi/compiler/latest/linux - PATH_SUFFIXES - include - include/sycl - ) + PATHS ENV + CUDA_PATH + ENV + CUDAToolkit_ROOT + ENV + ROCM_PATH + ENV + NVHPC_ROOT + ENV + SYCL_ROOT + /usr/local/cuda + /opt/rocm/ + /opt/rocm/opencl + /opt/intel/oneapi/compiler/latest/linux + PATH_SUFFIXES include include/sycl) - find_library(OpenCL_LIBRARY + find_library( + OpenCL_LIBRARY NAMES OpenCL libOpenCL - PATHS - ENV CUDA_PATH - ENV CUDAToolkit_ROOT - ENV ROCM_PATH - ENV NVHPC_ROOT - ENV SYCL_ROOT - /usr/local/cuda - /opt/rocm/ - /opt/rocm/opencl - /opt/intel/oneapi/compiler/latest/linux - PATH_SUFFIXES - lib - lib64 - ) + PATHS ENV + CUDA_PATH + ENV + CUDAToolkit_ROOT + ENV + ROCM_PATH + ENV + NVHPC_ROOT + ENV + SYCL_ROOT + /usr/local/cuda + /opt/rocm/ + /opt/rocm/opencl + /opt/intel/oneapi/compiler/latest/linux + PATH_SUFFIXES lib lib64) endif() find_package(OpenCL) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - OpenCLWrapper - REQUIRED_VARS - OpenCL_FOUND - ) +find_package_handle_standard_args(OpenCLWrapper REQUIRED_VARS OpenCL_FOUND) diff --git a/cmake/SetCompilerFlags.cmake b/cmake/SetCompilerFlags.cmake index 74d58604b..fdf77c826 100644 --- a/cmake/SetCompilerFlags.cmake +++ b/cmake/SetCompilerFlags.cmake @@ -4,34 +4,44 @@ function(set_optional_cxx_flag var) foreach(flag ${ARGN}) string(MAKE_C_IDENTIFIER "Allowed_CXX_Flag${flag}" check_var) check_cxx_compiler_flag("${flag}" ${check_var}) - if (${${check_var}}) + if(${${check_var}}) set(${var} "${${var}} ${flag}") endif() endforeach() - set(${var} "${${var}}" PARENT_SCOPE) + set(${var} + "${${var}}" + PARENT_SCOPE) endfunction(set_optional_cxx_flag) # Enable warnings set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wall -Wextra") -set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wunused-function -Wunused-variable") -set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wwrite-strings -Wfloat-equal" "-Wcast-align -Wlogical-op" "-Wshadow") -# set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wstrict-prototypes -Wmissing-prototypes" "-Wundef") -# Disable warnings +set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS + "-Wunused-function -Wunused-variable") +set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wwrite-strings -Wfloat-equal" + "-Wcast-align -Wlogical-op" "-Wshadow") +# set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wstrict-prototypes +# -Wmissing-prototypes" "-Wundef") Disable warnings set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-Wno-unused-parameter") -set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "-diag-disable 11074 -diag-disable 11076") # Intel: Disable warnings about inline limits reached -set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "--display_error_number") # Show PGI error numbers - -if (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") - # Workaround for - # CMakeFiles/tools-trie.dir/trie.cpp.o: in function `occa::trie, std::allocator > >::getLongest(char const*, int) const': - # occa/include/occa/tools/trie.tpp:238:(.text+0x5cdc): relocation truncated to fit: R_X86_64_PC32 against `.rodata' +# Intel: Disable warnings about inline limits reached +set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS + "-diag-disable 11074 -diag-disable 11076") +# Show PGI error numbers +set_optional_cxx_flag(SUPPORTED_WARN_CXX_FLAGS "--display_error_number") + +if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") + # Workaround for CMakeFiles/tools-trie.dir/trie.cpp.o: in function + # `occa::trie, + # std::allocator > >::getLongest(char const*, int) const': + # occa/include/occa/tools/trie.tpp:238:(.text+0x5cdc): relocation truncated to + # fit: R_X86_64_PC32 against `.rodata' set(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG") endif() set(CMAKE_CXX_FLAGS "${SUPPORTED_WARN_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") set_optional_cxx_flag(SUPPORTED_WERROR_CXX_FLAGS "-Werror") -set(CMAKE_CXX_FLAGS_DEBUG "${SUPPORTED_WERROR_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") +set(CMAKE_CXX_FLAGS_DEBUG + "${SUPPORTED_WERROR_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") include(CheckCCompilerFlag) @@ -39,61 +49,74 @@ function(set_optional_c_flag var) foreach(flag ${ARGN}) string(MAKE_C_IDENTIFIER "Allowed_C_Flag${flag}" check_var) check_c_compiler_flag("${flag}" ${check_var}) - if (${${check_var}}) + if(${${check_var}}) set(${var} "${${var}} ${flag}") endif() endforeach() - set(${var} "${${var}}" PARENT_SCOPE) + set(${var} + "${${var}}" + PARENT_SCOPE) endfunction(set_optional_c_flag) # Enable warnings set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wall -Wextra") -set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wunused-function -Wunused-variable") -set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wwrite-strings -Wfloat-equal" "-Wcast-align -Wlogical-op" "-Wshadow") -# set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wstrict-prototypes -Wmissing-prototypes" "-Wundef") -# Disble warnings +set_optional_c_flag(SUPPORTED_WARN_C_FLAGS + "-Wunused-function -Wunused-variable") +set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wwrite-strings -Wfloat-equal" + "-Wcast-align -Wlogical-op" "-Wshadow") +# set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wstrict-prototypes +# -Wmissing-prototypes" "-Wundef") Disble warnings set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-Wno-c++11-long-long") -set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "-diag-disable 11074 -diag-disable 11076") # Disable warnings about inline limits reached -set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "--display_error_number") # Show PGI error numbers +# Disable warnings about inline limits reached +set_optional_c_flag(SUPPORTED_WARN_C_FLAGS + "-diag-disable 11074 -diag-disable 11076") +# Show PGI error numbers +set_optional_c_flag(SUPPORTED_WARN_C_FLAGS "--display_error_number") 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 (OCCA_ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) include(CheckFortranCompilerFlag) function(set_optional_fortran_flag var) foreach(flag ${ARGN}) string(MAKE_C_IDENTIFIER "Allowed_Fortran_Flag${flag}" check_var) - check_fortran_compiler_flag("${flag}" ${check_var}) - if (${${check_var}}) + CHECK_Fortran_COMPILER_FLAG("${flag}" ${check_var}) + if(${${check_var}}) set(${var} "${${var}} ${flag}") endif() endforeach() - set(${var} "${${var}}" PARENT_SCOPE) + set(${var} + "${${var}}" + PARENT_SCOPE) endfunction(set_optional_fortran_flag) # Enable warnings set_optional_fortran_flag(SUPPORTED_WARN_Fortran_FLAGS "-Wall -Wextra") set_optional_fortran_flag(SUPPORTED_WARN_Fortran_FLAGS "-warn all") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${SUPPORTED_WARN_Fortran_FLAGS}") + set(CMAKE_Fortran_FLAGS + "${CMAKE_Fortran_FLAGS} ${SUPPORTED_WARN_Fortran_FLAGS}") set_optional_fortran_flag(SUPPORTED_WERROR_Fortran_FLAGS "-Werror") set_optional_fortran_flag(SUPPORTED_WERROR_Fortran_FLAGS "-warn errors") - set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${SUPPORTED_WERROR_Fortran_FLAGS}") + set(CMAKE_Fortran_FLAGS_DEBUG + "${CMAKE_Fortran_FLAGS_DEBUG} ${SUPPORTED_WERROR_Fortran_FLAGS}") - set_optional_fortran_flag(SUPPORTED_WNO_INTEGER_DIVISION_Fortran_FLAGS "-Wno-integer-division") + set_optional_fortran_flag(SUPPORTED_WNO_INTEGER_DIVISION_Fortran_FLAGS + "-Wno-integer-division") # Fix for: # https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-2025-warning-5472/td-p/1643667 - if (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + if(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpscomp logicals") endif() endif() -check_cxx_compiler_flag("-fno-strict-aliasing" COMPILER_SUPPORTS_NO_STRICT_ALIASING) +check_cxx_compiler_flag("-fno-strict-aliasing" + COMPILER_SUPPORTS_NO_STRICT_ALIASING) if(COMPILER_SUPPORTS_NO_STRICT_ALIASING) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5d5aa2bd6..b28e37ca9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,75 +1,77 @@ -cmake_minimum_required (VERSION 3.21 FATAL_ERROR) -project(OCCAExamples +cmake_minimum_required(VERSION 3.21 FATAL_ERROR) +project( + OCCAExamples VERSION 2.0.0 - DESCRIPTION "OCCA Examples" + DESCRIPTION "OCCA Examples" HOMEPAGE_URL "https://github.com/libocca/occa" LANGUAGES C CXX) -if (NOT TARGET OCCA::libocca) +if(NOT TARGET OCCA::libocca) find_package(OCCA REQUIRED) endif() macro(add_test_with_mode exe mode device) add_test(NAME ${exe}-${mode} COMMAND ./${exe} --verbose --device "${device}") - set_property(TEST ${exe}-${mode} APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) + set_property( + TEST ${exe}-${mode} + APPEND + PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) endmacro() macro(add_test_with_modes exe) add_test_with_mode(${exe} serial "{\"mode\": \"Serial\"}") - if (OCCA_CUDA_ENABLED) + if(OCCA_CUDA_ENABLED) add_test_with_mode(${exe} cuda "{\"mode\": \"CUDA\", \"device_id\": 0}") endif() - if (OCCA_HIP_ENABLED) + if(OCCA_HIP_ENABLED) add_test_with_mode(${exe} hip "{\"mode\": \"HIP\", \"device_id\": 0}") endif() - if (OCCA_METAL_ENABLED) + if(OCCA_METAL_ENABLED) add_test_with_mode(${exe} metal "{\"mode\": \"Metal\", \"device_id\": 0}") endif() - if (OCCA_OPENCL_ENABLED) - add_test_with_mode(${exe} opencl "{\"mode\": \"OpenCL\", \"platform_id\": 0, \"device_id\": 0}") + if(OCCA_OPENCL_ENABLED) + add_test_with_mode( + ${exe} opencl + "{\"mode\": \"OpenCL\", \"platform_id\": 0, \"device_id\": 0}") endif() - if (OCCA_DPCPP_ENABLED) - add_test_with_mode(${exe} dpcpp "{\"mode\": \"dpcpp\", \"platform_id\": 0, \"device_id\": 0}") + if(OCCA_DPCPP_ENABLED) + add_test_with_mode( + ${exe} dpcpp + "{\"mode\": \"dpcpp\", \"platform_id\": 0, \"device_id\": 0}") endif() - if (OCCA_OPENMP_ENABLED) + if(OCCA_OPENMP_ENABLED) add_test_with_mode(${exe} openmp "{\"mode\": \"OpenMP\"}") endif() endmacro() macro(add_test_without_mode exe) add_test(NAME ${exe} COMMAND ${exe} --verbose) - set_property(TEST ${exe} APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) + set_property( + TEST ${exe} + APPEND + PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) endmacro() macro(compile_example target file mode) add_executable(${target} ${file}) - target_link_libraries(${target} - PRIVATE - OCCA::c_api - OCCA::libocca - ) - if (OCCA_ENABLE_FORTRAN) - target_link_libraries(${target} - PRIVATE - OCCA::fortran_api - ) + target_link_libraries(${target} PRIVATE OCCA::c_api OCCA::libocca) + if(OCCA_ENABLE_FORTRAN) + target_link_libraries(${target} PRIVATE OCCA::fortran_api) endif() target_include_directories(${target} - PRIVATE - $ - ) + PRIVATE $) file(RELATIVE_PATH install_dir ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR}) file(GLOB_RECURSE OKLS "${CMAKE_CURRENT_LIST_DIR}/*.okl") install(TARGETS ${target} DESTINATION ${install_dir}) install(FILES ${OKLS} DESTINATION ${install_dir}) - if (NOT OCCA_ENABLE_TESTS) + if(NOT OCCA_ENABLE_TESTS) return() endif() - if (${mode}) + if(${mode}) add_test_with_modes(${target}) else() add_test_without_mode(${target}) @@ -78,10 +80,7 @@ endmacro() macro(compile_c_example target file) compile_example(examples_c_${target} ${file} TRUE) - target_link_libraries(examples_c_${target} - PRIVATE - OCCA::c_api - ) + target_link_libraries(examples_c_${target} PRIVATE OCCA::c_api) endmacro() macro(compile_cpp_example target file) @@ -98,6 +97,6 @@ endmacro() add_subdirectory(c) add_subdirectory(cpp) -if (OCCA_ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) add_subdirectory(fortran) endif() diff --git a/examples/c/01_add_vectors/CMakeLists.txt b/examples/c/01_add_vectors/CMakeLists.txt index 2f561a5cb..81abb70c6 100644 --- a/examples/c/01_add_vectors/CMakeLists.txt +++ b/examples/c/01_add_vectors/CMakeLists.txt @@ -1,4 +1,7 @@ compile_c_example(add_vector main.c) -add_custom_target(c_example_add_vectors_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + c_example_add_vectors_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_c_add_vector c_example_add_vectors_okl) diff --git a/examples/c/02_background_device/CMakeLists.txt b/examples/c/02_background_device/CMakeLists.txt index eef133459..588baef7d 100644 --- a/examples/c/02_background_device/CMakeLists.txt +++ b/examples/c/02_background_device/CMakeLists.txt @@ -1,4 +1,7 @@ compile_c_example(background_device main.c) -add_custom_target(c_example_background_devices_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + c_example_background_devices_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_c_background_device c_example_background_devices_okl) diff --git a/examples/c/04_reduction/CMakeLists.txt b/examples/c/04_reduction/CMakeLists.txt index 4909bc1d6..dd4b33de7 100644 --- a/examples/c/04_reduction/CMakeLists.txt +++ b/examples/c/04_reduction/CMakeLists.txt @@ -1,4 +1,7 @@ compile_c_example(reduction main.c) -add_custom_target(c_example_reduction_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl reduction.okl) +add_custom_target( + c_example_reduction_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl + reduction.okl) add_dependencies(examples_c_reduction c_example_reduction_okl) diff --git a/examples/cpp/01_add_vectors/CMakeLists.txt b/examples/cpp/01_add_vectors/CMakeLists.txt index 252d8023f..d09f77e9f 100644 --- a/examples/cpp/01_add_vectors/CMakeLists.txt +++ b/examples/cpp/01_add_vectors/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example_with_modes(add_vectors main.cpp) -add_custom_target(cpp_example_add_vectors_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + cpp_example_add_vectors_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_add_vectors cpp_example_add_vectors_okl) diff --git a/examples/cpp/05_custom_types/CMakeLists.txt b/examples/cpp/05_custom_types/CMakeLists.txt index 678c62483..261dc5935 100644 --- a/examples/cpp/05_custom_types/CMakeLists.txt +++ b/examples/cpp/05_custom_types/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example_with_modes(custom_types main.cpp) -add_custom_target(cpp_example_custom_types_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + cpp_example_custom_types_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_custom_types cpp_example_custom_types_okl) diff --git a/examples/cpp/06_shared_memory/CMakeLists.txt b/examples/cpp/06_shared_memory/CMakeLists.txt index a022f9220..1d0079269 100644 --- a/examples/cpp/06_shared_memory/CMakeLists.txt +++ b/examples/cpp/06_shared_memory/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example_with_modes(shared_memory main.cpp) -add_custom_target(cpp_example_shared_memory_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl reduction.okl) +add_custom_target( + cpp_example_shared_memory_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl + reduction.okl) add_dependencies(examples_cpp_shared_memory cpp_example_shared_memory_okl) diff --git a/examples/cpp/07_streams/CMakeLists.txt b/examples/cpp/07_streams/CMakeLists.txt index 132397160..143050b3b 100644 --- a/examples/cpp/07_streams/CMakeLists.txt +++ b/examples/cpp/07_streams/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example_with_modes(streams main.cpp) -add_custom_target(cpp_example_streams_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + cpp_example_streams_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_streams cpp_example_streams_okl) diff --git a/examples/cpp/09_native_cpp_kernels/CMakeLists.txt b/examples/cpp/09_native_cpp_kernels/CMakeLists.txt index 871682d09..db9ade3db 100644 --- a/examples/cpp/09_native_cpp_kernels/CMakeLists.txt +++ b/examples/cpp/09_native_cpp_kernels/CMakeLists.txt @@ -1,4 +1,8 @@ compile_cpp_example(native_cpp_kernels main.cpp) -add_custom_target(cpp_example_native_cpp_kernels_cpp ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cpp addVectors.cpp) -add_dependencies(examples_cpp_native_cpp_kernels cpp_example_native_cpp_kernels_cpp) +add_custom_target( + cpp_example_native_cpp_kernels_cpp ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cpp + addVectors.cpp) +add_dependencies(examples_cpp_native_cpp_kernels + cpp_example_native_cpp_kernels_cpp) diff --git a/examples/cpp/10_native_c_kernels/CMakeLists.txt b/examples/cpp/10_native_c_kernels/CMakeLists.txt index be247e905..949448768 100644 --- a/examples/cpp/10_native_c_kernels/CMakeLists.txt +++ b/examples/cpp/10_native_c_kernels/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example(native_c_kernels main.cpp) -add_custom_target(cpp_example_native_c_kernels_c ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.c addVectors.c) +add_custom_target( + cpp_example_native_c_kernels_c ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.c + addVectors.c) add_dependencies(examples_cpp_native_c_kernels cpp_example_native_c_kernels_c) diff --git a/examples/cpp/11_native_cuda_kernels/CMakeLists.txt b/examples/cpp/11_native_cuda_kernels/CMakeLists.txt index d0a5be83a..5b2d2bfbd 100644 --- a/examples/cpp/11_native_cuda_kernels/CMakeLists.txt +++ b/examples/cpp/11_native_cuda_kernels/CMakeLists.txt @@ -1,6 +1,10 @@ -if (WITH_CUDA) +if(WITH_CUDA) compile_cpp_example(native_cuda_kernels main.cpp) - add_custom_target(cpp_example_native_cuda_kernels_cu ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cu addVectors.cu) - add_dependencies(examples_cpp_native_cuda_kernels cpp_example_native_cuda_kernels_cu) + add_custom_target( + cpp_example_native_cuda_kernels_cu ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cu + addVectors.cu) + add_dependencies(examples_cpp_native_cuda_kernels + cpp_example_native_cuda_kernels_cu) endif() diff --git a/examples/cpp/12_native_opencl_kernels/CMakeLists.txt b/examples/cpp/12_native_opencl_kernels/CMakeLists.txt index e880fb7ae..241914bf1 100644 --- a/examples/cpp/12_native_opencl_kernels/CMakeLists.txt +++ b/examples/cpp/12_native_opencl_kernels/CMakeLists.txt @@ -1,6 +1,10 @@ -if (WITH_OPENCL) +if(WITH_OPENCL) compile_cpp_example(native_opencl_kernels main.cpp) - add_custom_target(cpp_example_native_opencl_kernels_cl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cl addVectors.cl) - add_dependencies(examples_cpp_native_opencl_kernels cpp_example_native_opencl_kernels_cl) + add_custom_target( + cpp_example_native_opencl_kernels_cl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cl + addVectors.cl) + add_dependencies(examples_cpp_native_opencl_kernels + cpp_example_native_opencl_kernels_cl) endif() diff --git a/examples/cpp/13_openmp_interop/CMakeLists.txt b/examples/cpp/13_openmp_interop/CMakeLists.txt index 149f0b332..1415504c4 100644 --- a/examples/cpp/13_openmp_interop/CMakeLists.txt +++ b/examples/cpp/13_openmp_interop/CMakeLists.txt @@ -1,6 +1,9 @@ -if (WITH_OPENMP) +if(WITH_OPENMP) compile_cpp_example(openmp_interop main.cpp) - add_custom_target(cpp_example_openmp_interop_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) + add_custom_target( + cpp_example_openmp_interop_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_openmp_interop cpp_example_openmp_interop_okl) -endif (WITH_OPENMP) +endif(WITH_OPENMP) diff --git a/examples/cpp/14_cuda_interop/CMakeLists.txt b/examples/cpp/14_cuda_interop/CMakeLists.txt index 58b529fcc..2062f396b 100644 --- a/examples/cpp/14_cuda_interop/CMakeLists.txt +++ b/examples/cpp/14_cuda_interop/CMakeLists.txt @@ -1,6 +1,9 @@ -if (WITH_CUDA) +if(WITH_CUDA) compile_cpp_example(cuda_interop main.cpp) - add_custom_target(cpp_example_cuda_interop_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) + add_custom_target( + cpp_example_cuda_interop_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_cuda_interop cpp_example_cuda_interop_okl) endif() diff --git a/examples/cpp/17_memory_pool/CMakeLists.txt b/examples/cpp/17_memory_pool/CMakeLists.txt index 1a6e5c668..5aeba0c52 100644 --- a/examples/cpp/17_memory_pool/CMakeLists.txt +++ b/examples/cpp/17_memory_pool/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example(memory_pool main.cpp) -add_custom_target(cpp_example_memory_pool_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + cpp_example_memory_pool_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_memory_pool cpp_example_memory_pool_okl) diff --git a/examples/cpp/18_nonblocking_streams/CMakeLists.txt b/examples/cpp/18_nonblocking_streams/CMakeLists.txt index 376de5be6..b2f7e1137 100644 --- a/examples/cpp/18_nonblocking_streams/CMakeLists.txt +++ b/examples/cpp/18_nonblocking_streams/CMakeLists.txt @@ -1,4 +1,8 @@ compile_cpp_example_with_modes(nonblocking_streams main.cpp) -add_custom_target(cpp_example_nonblocking_streams_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/powerOfPi.okl powerOfPi.okl) -add_dependencies(examples_cpp_nonblocking_streams cpp_example_nonblocking_streams_okl) +add_custom_target( + cpp_example_nonblocking_streams_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/powerOfPi.okl + powerOfPi.okl) +add_dependencies(examples_cpp_nonblocking_streams + cpp_example_nonblocking_streams_okl) diff --git a/examples/cpp/19_stream_tags/CMakeLists.txt b/examples/cpp/19_stream_tags/CMakeLists.txt index 8b73428d4..2bafb32b9 100755 --- a/examples/cpp/19_stream_tags/CMakeLists.txt +++ b/examples/cpp/19_stream_tags/CMakeLists.txt @@ -1,4 +1,7 @@ compile_cpp_example_with_modes(stream_tags main.cpp) -add_custom_target(cpp_example_stream_tags_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/powerOfPi2.okl powerOfPi2.okl) +add_custom_target( + cpp_example_stream_tags_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/powerOfPi2.okl + powerOfPi2.okl) add_dependencies(examples_cpp_stream_tags cpp_example_stream_tags_okl) diff --git a/examples/cpp/20_native_dpcpp_kernel/CMakeLists.txt b/examples/cpp/20_native_dpcpp_kernel/CMakeLists.txt index 5f67a2aa2..cd84cada9 100644 --- a/examples/cpp/20_native_dpcpp_kernel/CMakeLists.txt +++ b/examples/cpp/20_native_dpcpp_kernel/CMakeLists.txt @@ -1,6 +1,10 @@ -if (OCCA_DPCPP_ENABLED) +if(OCCA_DPCPP_ENABLED) compile_cpp_example(native_dpcpp_kernel main.cpp) - add_custom_target(cpp_example_native_dpcpp_kernel ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cpp addVectors.cpp) - add_dependencies(examples_cpp_native_dpcpp_kernel cpp_example_native_dpcpp_kernel) + add_custom_target( + cpp_example_native_dpcpp_kernel ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.cpp + addVectors.cpp) + add_dependencies(examples_cpp_native_dpcpp_kernel + cpp_example_native_dpcpp_kernel) endif() diff --git a/examples/cpp/30_device_function/CMakeLists.txt b/examples/cpp/30_device_function/CMakeLists.txt index a27e79bba..3c2b3145d 100644 --- a/examples/cpp/30_device_function/CMakeLists.txt +++ b/examples/cpp/30_device_function/CMakeLists.txt @@ -1,5 +1,8 @@ set(EXAMPLE_NAME "device_function") compile_cpp_example_with_modes(${EXAMPLE_NAME} main.cpp) -add_custom_target(cpp_example_${EXAMPLE_NAME}_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + cpp_example_${EXAMPLE_NAME}_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_cpp_${EXAMPLE_NAME} cpp_example_${EXAMPLE_NAME}_okl) diff --git a/examples/cpp/31_oklt_v3_moving_avg/CMakeLists.txt b/examples/cpp/31_oklt_v3_moving_avg/CMakeLists.txt index 847101f33..fde0d08b0 100644 --- a/examples/cpp/31_oklt_v3_moving_avg/CMakeLists.txt +++ b/examples/cpp/31_oklt_v3_moving_avg/CMakeLists.txt @@ -1,9 +1,14 @@ compile_cpp_example_with_modes(oklt_v3_moving_avg main.cpp) -add_custom_target(cpp_example_oklt_v3_moving_avg_cpy ALL - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/constants.h constants.h - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/movingAverage.okl movingAverage.okl) -add_dependencies(examples_cpp_oklt_v3_moving_avg cpp_example_oklt_v3_moving_avg_cpy) -target_sources(examples_cpp_oklt_v3_moving_avg +add_custom_target( + cpp_example_oklt_v3_moving_avg_cpy ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/constants.h + constants.h + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/movingAverage.okl movingAverage.okl) +add_dependencies(examples_cpp_oklt_v3_moving_avg + cpp_example_oklt_v3_moving_avg_cpy) +target_sources( + examples_cpp_oklt_v3_moving_avg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/movingAverage.okl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/constants.h) diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 7cd44774a..69f065b55 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -12,14 +12,13 @@ add_subdirectory(12_native_opencl_kernels) add_subdirectory(13_openmp_interop) add_subdirectory(14_cuda_interop) add_subdirectory(17_memory_pool) -# Don't force-compile OpenGL examples -# add_subdirectory(16_finite_difference) +# Don't force-compile OpenGL examples add_subdirectory(16_finite_difference) # add_subdirectory(17_mandelbulb) add_subdirectory(18_nonblocking_streams) add_subdirectory(19_stream_tags) add_subdirectory(20_native_dpcpp_kernel) add_subdirectory(30_device_function) -if (NOT OCCA_CLANG_BASED_TRANSPILER) +if(NOT OCCA_CLANG_BASED_TRANSPILER) add_subdirectory(31_oklt_v3_moving_avg) endif() diff --git a/examples/fortran/01_add_vectors/CMakeLists.txt b/examples/fortran/01_add_vectors/CMakeLists.txt index c0d280685..caa52186f 100644 --- a/examples/fortran/01_add_vectors/CMakeLists.txt +++ b/examples/fortran/01_add_vectors/CMakeLists.txt @@ -1,4 +1,8 @@ compile_fortran_example_with_modes(01_add_vectors main.f90) -add_custom_target(fortran_example_01_addVectors_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) -add_dependencies(examples_fortran_01_add_vectors fortran_example_01_addVectors_okl) +add_custom_target( + fortran_example_01_addVectors_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) +add_dependencies(examples_fortran_01_add_vectors + fortran_example_01_addVectors_okl) diff --git a/examples/fortran/03_static_compilation/CMakeLists.txt b/examples/fortran/03_static_compilation/CMakeLists.txt index 85d23498a..f609adc33 100644 --- a/examples/fortran/03_static_compilation/CMakeLists.txt +++ b/examples/fortran/03_static_compilation/CMakeLists.txt @@ -1,4 +1,8 @@ compile_fortran_example_with_modes(03_static_compilation main.f90) -add_custom_target(fortran_example_03_addVectors_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) -add_dependencies(examples_fortran_03_static_compilation fortran_example_03_addVectors_okl) +add_custom_target( + fortran_example_03_addVectors_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) +add_dependencies(examples_fortran_03_static_compilation + fortran_example_03_addVectors_okl) diff --git a/examples/fortran/04_reduction/CMakeLists.txt b/examples/fortran/04_reduction/CMakeLists.txt index 2935cbcc7..e83dff077 100644 --- a/examples/fortran/04_reduction/CMakeLists.txt +++ b/examples/fortran/04_reduction/CMakeLists.txt @@ -1,6 +1,11 @@ compile_fortran_example_with_modes(04_reduction main.f90) -set_source_files_properties(main.f90 PROPERTIES COMPILE_FLAGS "${SUPPORTED_WNO_INTEGER_DIVISION_Fortran_FLAGS}") +set_source_files_properties( + main.f90 PROPERTIES COMPILE_FLAGS + "${SUPPORTED_WNO_INTEGER_DIVISION_Fortran_FLAGS}") -add_custom_target(fortran_example_04_reduction_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl reduction.okl) +add_custom_target( + fortran_example_04_reduction_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/reduction.okl + reduction.okl) add_dependencies(examples_fortran_04_reduction fortran_example_04_reduction_okl) diff --git a/examples/fortran/09_streams/CMakeLists.txt b/examples/fortran/09_streams/CMakeLists.txt index 2ff79f62d..734a17058 100644 --- a/examples/fortran/09_streams/CMakeLists.txt +++ b/examples/fortran/09_streams/CMakeLists.txt @@ -1,4 +1,7 @@ compile_fortran_example_with_modes(09_streams main.f90) -add_custom_target(fortran_example_09_addVectors_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl addVectors.okl) +add_custom_target( + fortran_example_09_addVectors_okl ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/addVectors.okl + addVectors.okl) add_dependencies(examples_fortran_09_streams fortran_example_09_addVectors_okl) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c821e0412..034d18db4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(c) add_subdirectory(core) add_subdirectory(dtype) add_subdirectory(experimental) -if (OCCA_ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) add_subdirectory(fortran) endif() add_subdirectory(functional) diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 039788c83..09e005bb7 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -1,21 +1,17 @@ add_library(c_api SHARED) add_library(${namespace}c_api ALIAS c_api) -target_sources(c_api - PRIVATE - base.cpp - device.cpp - dtype.cpp - io.cpp - json.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - scope.cpp - stream.cpp -) +target_sources( + c_api + PRIVATE base.cpp + device.cpp + dtype.cpp + io.cpp + json.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + scope.cpp + stream.cpp) add_subdirectory(experimental) -target_link_libraries(c_api - PRIVATE - libocca -) +target_link_libraries(c_api PRIVATE libocca) diff --git a/src/c/experimental/CMakeLists.txt b/src/c/experimental/CMakeLists.txt index a5be31687..d1be291d8 100644 --- a/src/c/experimental/CMakeLists.txt +++ b/src/c/experimental/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(c_api - PRIVATE - kernelBuilder.cpp -) +target_sources(c_api PRIVATE kernelBuilder.cpp) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ee0f81c99..6fe419009 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,11 +1,10 @@ -target_sources(libocca - PRIVATE - base.cpp - device.cpp - kernelArg.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - stream.cpp - streamTag.cpp -) +target_sources( + libocca + PRIVATE base.cpp + device.cpp + kernelArg.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + stream.cpp + streamTag.cpp) diff --git a/src/dtype/CMakeLists.txt b/src/dtype/CMakeLists.txt index e86b03e8e..eb6d6737d 100644 --- a/src/dtype/CMakeLists.txt +++ b/src/dtype/CMakeLists.txt @@ -1,5 +1 @@ -target_sources(libocca - PRIVATE - builtins.cpp - dtype.cpp -) +target_sources(libocca PRIVATE builtins.cpp dtype.cpp) diff --git a/src/experimental/CMakeLists.txt b/src/experimental/CMakeLists.txt index 2912d6a2c..33545099a 100644 --- a/src/experimental/CMakeLists.txt +++ b/src/experimental/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(libocca - PRIVATE - kernelBuilder.cpp -) +target_sources(libocca PRIVATE kernelBuilder.cpp) diff --git a/src/fortran/CMakeLists.txt b/src/fortran/CMakeLists.txt index 923586169..ebf83d371 100644 --- a/src/fortran/CMakeLists.txt +++ b/src/fortran/CMakeLists.txt @@ -1,25 +1,20 @@ add_library(fortran_api SHARED) add_library(${namespace}fortran_api ALIAS fortran_api) -target_sources(fortran_api - PRIVATE - fc_string_m.f90 - occa_base_m.f90 - occa_device_m.f90 - occa_dtype_m.f90 - occa_json_m.f90 - occa_kernelBuilder_m.f90 - occa_kernel_m.f90 - occa_memory_m.f90 - occa_m.f90 - occa_scope_m.f90 - occa_stream_m.f90 - occa_typedefs_m.f90 - occa_types_m.f90 - kernel_fortran_interface.cpp -) +target_sources( + fortran_api + PRIVATE fc_string_m.f90 + occa_base_m.f90 + occa_device_m.f90 + occa_dtype_m.f90 + occa_json_m.f90 + occa_kernelBuilder_m.f90 + occa_kernel_m.f90 + occa_memory_m.f90 + occa_m.f90 + occa_scope_m.f90 + occa_stream_m.f90 + occa_typedefs_m.f90 + occa_types_m.f90 + kernel_fortran_interface.cpp) -target_link_libraries(fortran_api - PRIVATE - c_api - libocca -) +target_link_libraries(fortran_api PRIVATE c_api libocca) diff --git a/src/functional/CMakeLists.txt b/src/functional/CMakeLists.txt index 2ecbd8975..5e1273804 100644 --- a/src/functional/CMakeLists.txt +++ b/src/functional/CMakeLists.txt @@ -1,8 +1,2 @@ -target_sources(libocca - PRIVATE - baseFunction.cpp - functionDefinition.cpp - range.cpp - scope.cpp - utils.cpp -) +target_sources(libocca PRIVATE baseFunction.cpp functionDefinition.cpp + range.cpp scope.cpp utils.cpp) diff --git a/src/loops/CMakeLists.txt b/src/loops/CMakeLists.txt index 09be6b665..62c1fa84b 100644 --- a/src/loops/CMakeLists.txt +++ b/src/loops/CMakeLists.txt @@ -1,13 +1,7 @@ -target_sources(libocca - PRIVATE - forLoop.cpp - iteration.cpp - typelessForLoop.cpp -) +target_sources(libocca PRIVATE forLoop.cpp iteration.cpp typelessForLoop.cpp) -target_include_directories(libocca - PRIVATE - $ - $ - $ -) +target_include_directories( + libocca + PRIVATE $ + $ + $) diff --git a/src/occa/CMakeLists.txt b/src/occa/CMakeLists.txt index 3ddc328d8..105d974ca 100644 --- a/src/occa/CMakeLists.txt +++ b/src/occa/CMakeLists.txt @@ -1,2 +1 @@ add_subdirectory(internal) - diff --git a/src/occa/internal/CMakeLists.txt b/src/occa/internal/CMakeLists.txt index 047a72320..3f17c9f91 100644 --- a/src/occa/internal/CMakeLists.txt +++ b/src/occa/internal/CMakeLists.txt @@ -1,7 +1,4 @@ -target_sources(libocca - PRIVATE - modes.cpp -) +target_sources(libocca PRIVATE modes.cpp) add_subdirectory(api) add_subdirectory(bin) @@ -10,5 +7,5 @@ add_subdirectory(core) add_subdirectory(functional) add_subdirectory(io) add_subdirectory(lang) -add_subdirectory(modes ) +add_subdirectory(modes) add_subdirectory(utils) diff --git a/src/occa/internal/api/CMakeLists.txt b/src/occa/internal/api/CMakeLists.txt index fdc4471fb..db47b51cd 100644 --- a/src/occa/internal/api/CMakeLists.txt +++ b/src/occa/internal/api/CMakeLists.txt @@ -1,8 +1,5 @@ -if (OCCA_METAL_ENABLED) - target_sources(libocca - PRIVATE - metal.mm - ) +if(OCCA_METAL_ENABLED) + target_sources(libocca PRIVATE metal.mm) endif() add_subdirectory(metal) diff --git a/src/occa/internal/api/metal/CMakeLists.txt b/src/occa/internal/api/metal/CMakeLists.txt index decd1b534..5b8976679 100644 --- a/src/occa/internal/api/metal/CMakeLists.txt +++ b/src/occa/internal/api/metal/CMakeLists.txt @@ -1,15 +1,6 @@ -if (OCCA_METAL_ENABLED) - target_sources(libocca - PRIVATE - buffer.mm - commandQueue.mm - device.mm - event.mm - function.mm - ) +if(OCCA_METAL_ENABLED) + target_sources(libocca PRIVATE buffer.mm commandQueue.mm device.mm event.mm + function.mm) endif() -target_sources(libocca - PRIVATE - polyfill.cpp -) +target_sources(libocca PRIVATE polyfill.cpp) diff --git a/src/occa/internal/bin/CMakeLists.txt b/src/occa/internal/bin/CMakeLists.txt index f66aac99b..ac594abc5 100644 --- a/src/occa/internal/bin/CMakeLists.txt +++ b/src/occa/internal/bin/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(libocca - PRIVATE - occa.cpp -) +target_sources(libocca PRIVATE occa.cpp) diff --git a/src/occa/internal/c/CMakeLists.txt b/src/occa/internal/c/CMakeLists.txt index df8a07345..13ce06431 100644 --- a/src/occa/internal/c/CMakeLists.txt +++ b/src/occa/internal/c/CMakeLists.txt @@ -1,5 +1 @@ -target_sources(libocca - PRIVATE - cli.cpp - types.cpp -) +target_sources(libocca PRIVATE cli.cpp types.cpp) diff --git a/src/occa/internal/core/CMakeLists.txt b/src/occa/internal/core/CMakeLists.txt index 0f2e0beb7..ddba691d0 100644 --- a/src/occa/internal/core/CMakeLists.txt +++ b/src/occa/internal/core/CMakeLists.txt @@ -1,12 +1,11 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - launchedDevice.cpp - launchedKernel.cpp - memory.cpp - memoryPool.cpp - stream.cpp - streamTag.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + launchedDevice.cpp + launchedKernel.cpp + memory.cpp + memoryPool.cpp + stream.cpp + streamTag.cpp) diff --git a/src/occa/internal/functional/CMakeLists.txt b/src/occa/internal/functional/CMakeLists.txt index 61ff9f855..82dd9f8df 100644 --- a/src/occa/internal/functional/CMakeLists.txt +++ b/src/occa/internal/functional/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(libocca - PRIVATE - functionStore.cpp -) +target_sources(libocca PRIVATE functionStore.cpp) diff --git a/src/occa/internal/io/CMakeLists.txt b/src/occa/internal/io/CMakeLists.txt index c26fae132..8fd56c8d5 100644 --- a/src/occa/internal/io/CMakeLists.txt +++ b/src/occa/internal/io/CMakeLists.txt @@ -1,6 +1 @@ -target_sources(libocca - PRIVATE - cache.cpp - output.cpp - utils.cpp -) +target_sources(libocca PRIVATE cache.cpp output.cpp utils.cpp) diff --git a/src/occa/internal/lang/CMakeLists.txt b/src/occa/internal/lang/CMakeLists.txt index 136715d52..04d8d680f 100644 --- a/src/occa/internal/lang/CMakeLists.txt +++ b/src/occa/internal/lang/CMakeLists.txt @@ -1,25 +1,24 @@ -target_sources(libocca - PRIVATE - attribute.cpp - enumerator.cpp - file.cpp - kernelMetadata.cpp - keyword.cpp - macro.cpp - operator.cpp - parser.cpp - preprocessor.cpp - printer.cpp - processingStages.cpp - qualifier.cpp - scope.cpp - specialMacros.cpp - statementContext.cpp - statementPeeker.cpp - tokenContext.cpp - tokenizer.cpp - variable.cpp -) +target_sources( + libocca + PRIVATE attribute.cpp + enumerator.cpp + file.cpp + kernelMetadata.cpp + keyword.cpp + macro.cpp + operator.cpp + parser.cpp + preprocessor.cpp + printer.cpp + processingStages.cpp + qualifier.cpp + scope.cpp + specialMacros.cpp + statementContext.cpp + statementPeeker.cpp + tokenContext.cpp + tokenizer.cpp + variable.cpp) add_subdirectory(builtins) add_subdirectory(expr) diff --git a/src/occa/internal/lang/builtins/CMakeLists.txt b/src/occa/internal/lang/builtins/CMakeLists.txt index d7b54a7c0..407f852a0 100644 --- a/src/occa/internal/lang/builtins/CMakeLists.txt +++ b/src/occa/internal/lang/builtins/CMakeLists.txt @@ -1,6 +1,3 @@ -target_sources(libocca - PRIVATE - types.cpp -) +target_sources(libocca PRIVATE types.cpp) add_subdirectory(attributes) diff --git a/src/occa/internal/lang/builtins/attributes/CMakeLists.txt b/src/occa/internal/lang/builtins/attributes/CMakeLists.txt index c822e7719..7b4eb7cc5 100644 --- a/src/occa/internal/lang/builtins/attributes/CMakeLists.txt +++ b/src/occa/internal/lang/builtins/attributes/CMakeLists.txt @@ -1,18 +1,17 @@ -target_sources(libocca - PRIVATE - atomic.cpp - barrier.cpp - dim.cpp - exclusive.cpp - globalPtr.cpp - implicitArg.cpp - inner.cpp - kernel.cpp - maxInnerDims.cpp - noBarrier.cpp - outer.cpp - restrict.cpp - shared.cpp - simdLength.cpp - tile.cpp -) +target_sources( + libocca + PRIVATE atomic.cpp + barrier.cpp + dim.cpp + exclusive.cpp + globalPtr.cpp + implicitArg.cpp + inner.cpp + kernel.cpp + maxInnerDims.cpp + noBarrier.cpp + outer.cpp + restrict.cpp + shared.cpp + simdLength.cpp + tile.cpp) diff --git a/src/occa/internal/lang/expr/CMakeLists.txt b/src/occa/internal/lang/expr/CMakeLists.txt index e827a99f9..93b01c997 100644 --- a/src/occa/internal/lang/expr/CMakeLists.txt +++ b/src/occa/internal/lang/expr/CMakeLists.txt @@ -1,40 +1,39 @@ -target_sources(libocca - PRIVATE - binaryOpNode.cpp - callNode.cpp - charNode.cpp - constCastNode.cpp - cudaCallNode.cpp - deleteNode.cpp - dpcppAtomicNode.cpp - dpcppLocalMemoryNode.cpp - dynamicCastNode.cpp - emptyNode.cpp - expr.cpp - expressionParser.cpp - exprNodeArray.cpp - exprNode.cpp - exprOpNode.cpp - funcCastNode.cpp - functionNode.cpp - identifierNode.cpp - lambdaNode.cpp - leftUnaryOpNode.cpp - newNode.cpp - pairNode.cpp - parenCastNode.cpp - parenthesesNode.cpp - primitiveNode.cpp - reinterpretCastNode.cpp - rightUnaryOpNode.cpp - sizeofNode.cpp - staticCastNode.cpp - stringNode.cpp - subscriptNode.cpp - ternaryOpNode.cpp - throwNode.cpp - tupleNode.cpp - typeNode.cpp - variableNode.cpp - vartypeNode.cpp -) +target_sources( + libocca + PRIVATE binaryOpNode.cpp + callNode.cpp + charNode.cpp + constCastNode.cpp + cudaCallNode.cpp + deleteNode.cpp + dpcppAtomicNode.cpp + dpcppLocalMemoryNode.cpp + dynamicCastNode.cpp + emptyNode.cpp + expr.cpp + expressionParser.cpp + exprNodeArray.cpp + exprNode.cpp + exprOpNode.cpp + funcCastNode.cpp + functionNode.cpp + identifierNode.cpp + lambdaNode.cpp + leftUnaryOpNode.cpp + newNode.cpp + pairNode.cpp + parenCastNode.cpp + parenthesesNode.cpp + primitiveNode.cpp + reinterpretCastNode.cpp + rightUnaryOpNode.cpp + sizeofNode.cpp + staticCastNode.cpp + stringNode.cpp + subscriptNode.cpp + ternaryOpNode.cpp + throwNode.cpp + tupleNode.cpp + typeNode.cpp + variableNode.cpp + vartypeNode.cpp) diff --git a/src/occa/internal/lang/loaders/CMakeLists.txt b/src/occa/internal/lang/loaders/CMakeLists.txt index ff1bd1193..8b8caa066 100644 --- a/src/occa/internal/lang/loaders/CMakeLists.txt +++ b/src/occa/internal/lang/loaders/CMakeLists.txt @@ -1,9 +1,3 @@ -target_sources(libocca - PRIVATE - attributeLoader.cpp - enumLoader.cpp - structLoader.cpp - typeLoader.cpp - unionLoader.cpp - variableLoader.cpp -) +target_sources( + libocca PRIVATE attributeLoader.cpp enumLoader.cpp structLoader.cpp + typeLoader.cpp unionLoader.cpp variableLoader.cpp) diff --git a/src/occa/internal/lang/modes/CMakeLists.txt b/src/occa/internal/lang/modes/CMakeLists.txt index 42c90bb0e..7b127c8b2 100644 --- a/src/occa/internal/lang/modes/CMakeLists.txt +++ b/src/occa/internal/lang/modes/CMakeLists.txt @@ -1,13 +1,12 @@ -target_sources(libocca - PRIVATE - cuda.cpp - dpcpp.cpp - hip.cpp - metal.cpp - okl.cpp - oklForStatement.cpp - opencl.cpp - openmp.cpp - serial.cpp - withLauncher.cpp -) +target_sources( + libocca + PRIVATE cuda.cpp + dpcpp.cpp + hip.cpp + metal.cpp + okl.cpp + oklForStatement.cpp + opencl.cpp + openmp.cpp + serial.cpp + withLauncher.cpp) diff --git a/src/occa/internal/lang/statement/CMakeLists.txt b/src/occa/internal/lang/statement/CMakeLists.txt index 448e8f6e9..378a59ba8 100644 --- a/src/occa/internal/lang/statement/CMakeLists.txt +++ b/src/occa/internal/lang/statement/CMakeLists.txt @@ -1,30 +1,29 @@ -target_sources(libocca - PRIVATE - blockStatement.cpp - breakStatement.cpp - caseStatement.cpp - classAccessStatement.cpp - commentStatement.cpp - continueStatement.cpp - declarationStatement.cpp - defaultStatement.cpp - directiveStatement.cpp - elifStatement.cpp - elseStatement.cpp - emptyStatement.cpp - expressionStatement.cpp - forStatement.cpp - functionDeclStatement.cpp - functionStatement.cpp - gotoLabelStatement.cpp - gotoStatement.cpp - ifStatement.cpp - namespaceStatement.cpp - pragmaStatement.cpp - returnStatement.cpp - sourceCodeStatement.cpp - statementArray.cpp - statement.cpp - switchStatement.cpp - whileStatement.cpp -) +target_sources( + libocca + PRIVATE blockStatement.cpp + breakStatement.cpp + caseStatement.cpp + classAccessStatement.cpp + commentStatement.cpp + continueStatement.cpp + declarationStatement.cpp + defaultStatement.cpp + directiveStatement.cpp + elifStatement.cpp + elseStatement.cpp + emptyStatement.cpp + expressionStatement.cpp + forStatement.cpp + functionDeclStatement.cpp + functionStatement.cpp + gotoLabelStatement.cpp + gotoStatement.cpp + ifStatement.cpp + namespaceStatement.cpp + pragmaStatement.cpp + returnStatement.cpp + sourceCodeStatement.cpp + statementArray.cpp + statement.cpp + switchStatement.cpp + whileStatement.cpp) diff --git a/src/occa/internal/lang/token/CMakeLists.txt b/src/occa/internal/lang/token/CMakeLists.txt index bbf285610..aa73814c7 100644 --- a/src/occa/internal/lang/token/CMakeLists.txt +++ b/src/occa/internal/lang/token/CMakeLists.txt @@ -1,19 +1,18 @@ -target_sources(libocca - PRIVATE - charToken.cpp - commentToken.cpp - directiveToken.cpp - functionToken.cpp - identifierToken.cpp - newlineToken.cpp - operatorToken.cpp - pragmaToken.cpp - primitiveToken.cpp - qualifierToken.cpp - stringToken.cpp - token.cpp - typeToken.cpp - unknownToken.cpp - variableToken.cpp - vartypeToken.cpp -) +target_sources( + libocca + PRIVATE charToken.cpp + commentToken.cpp + directiveToken.cpp + functionToken.cpp + identifierToken.cpp + newlineToken.cpp + operatorToken.cpp + pragmaToken.cpp + primitiveToken.cpp + qualifierToken.cpp + stringToken.cpp + token.cpp + typeToken.cpp + unknownToken.cpp + variableToken.cpp + vartypeToken.cpp) diff --git a/src/occa/internal/lang/type/CMakeLists.txt b/src/occa/internal/lang/type/CMakeLists.txt index 39bcb8a5c..549669b83 100644 --- a/src/occa/internal/lang/type/CMakeLists.txt +++ b/src/occa/internal/lang/type/CMakeLists.txt @@ -1,17 +1,16 @@ -target_sources(libocca - PRIVATE - array.cpp - class.cpp - enum.cpp - function.cpp - functionPtr.cpp - lambda.cpp - pointer.cpp - primitive.cpp - struct.cpp - structure.cpp - type.cpp - typedef.cpp - union.cpp - vartype.cpp -) +target_sources( + libocca + PRIVATE array.cpp + class.cpp + enum.cpp + function.cpp + functionPtr.cpp + lambda.cpp + pointer.cpp + primitive.cpp + struct.cpp + structure.cpp + type.cpp + typedef.cpp + union.cpp + vartype.cpp) diff --git a/src/occa/internal/modes/cuda/CMakeLists.txt b/src/occa/internal/modes/cuda/CMakeLists.txt index c8bbc3707..2f7705c55 100644 --- a/src/occa/internal/modes/cuda/CMakeLists.txt +++ b/src/occa/internal/modes/cuda/CMakeLists.txt @@ -1,12 +1,11 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp - utils.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp + utils.cpp) diff --git a/src/occa/internal/modes/dpcpp/CMakeLists.txt b/src/occa/internal/modes/dpcpp/CMakeLists.txt index c8bbc3707..2f7705c55 100644 --- a/src/occa/internal/modes/dpcpp/CMakeLists.txt +++ b/src/occa/internal/modes/dpcpp/CMakeLists.txt @@ -1,12 +1,11 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp - utils.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp + utils.cpp) diff --git a/src/occa/internal/modes/hip/CMakeLists.txt b/src/occa/internal/modes/hip/CMakeLists.txt index c8bbc3707..2f7705c55 100644 --- a/src/occa/internal/modes/hip/CMakeLists.txt +++ b/src/occa/internal/modes/hip/CMakeLists.txt @@ -1,12 +1,11 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp - utils.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp + utils.cpp) diff --git a/src/occa/internal/modes/metal/CMakeLists.txt b/src/occa/internal/modes/metal/CMakeLists.txt index 10fbb2b20..bf86f88d2 100644 --- a/src/occa/internal/modes/metal/CMakeLists.txt +++ b/src/occa/internal/modes/metal/CMakeLists.txt @@ -1,11 +1,10 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp) diff --git a/src/occa/internal/modes/opencl/CMakeLists.txt b/src/occa/internal/modes/opencl/CMakeLists.txt index c8bbc3707..2f7705c55 100644 --- a/src/occa/internal/modes/opencl/CMakeLists.txt +++ b/src/occa/internal/modes/opencl/CMakeLists.txt @@ -1,12 +1,11 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp - utils.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp + utils.cpp) diff --git a/src/occa/internal/modes/openmp/CMakeLists.txt b/src/occa/internal/modes/openmp/CMakeLists.txt index a4d89a71c..8d70dd6fa 100644 --- a/src/occa/internal/modes/openmp/CMakeLists.txt +++ b/src/occa/internal/modes/openmp/CMakeLists.txt @@ -1,6 +1 @@ -target_sources(libocca - PRIVATE - device.cpp - registration.cpp - utils.cpp -) +target_sources(libocca PRIVATE device.cpp registration.cpp utils.cpp) diff --git a/src/occa/internal/modes/serial/CMakeLists.txt b/src/occa/internal/modes/serial/CMakeLists.txt index 10fbb2b20..bf86f88d2 100644 --- a/src/occa/internal/modes/serial/CMakeLists.txt +++ b/src/occa/internal/modes/serial/CMakeLists.txt @@ -1,11 +1,10 @@ -target_sources(libocca - PRIVATE - buffer.cpp - device.cpp - kernel.cpp - memory.cpp - memoryPool.cpp - registration.cpp - stream.cpp - streamTag.cpp -) +target_sources( + libocca + PRIVATE buffer.cpp + device.cpp + kernel.cpp + memory.cpp + memoryPool.cpp + registration.cpp + stream.cpp + streamTag.cpp) diff --git a/src/occa/internal/utils/CMakeLists.txt b/src/occa/internal/utils/CMakeLists.txt index 3713de8f7..c1046f713 100644 --- a/src/occa/internal/utils/CMakeLists.txt +++ b/src/occa/internal/utils/CMakeLists.txt @@ -1,15 +1,14 @@ -target_sources(libocca - PRIVATE - cli.cpp - env.cpp - gc.cpp - lex.cpp - misc.cpp - string.cpp - styling.cpp - sys.cpp - testing.cpp - transpiler_utils.cpp - trie.cpp - vector.cpp -) +target_sources( + libocca + PRIVATE cli.cpp + env.cpp + gc.cpp + lex.cpp + misc.cpp + string.cpp + styling.cpp + sys.cpp + testing.cpp + transpiler_utils.cpp + trie.cpp + vector.cpp) diff --git a/src/types/CMakeLists.txt b/src/types/CMakeLists.txt index 6d5226ba8..0c1c88581 100644 --- a/src/types/CMakeLists.txt +++ b/src/types/CMakeLists.txt @@ -1,7 +1 @@ -target_sources(libocca - PRIVATE - dim.cpp - json.cpp - primitive.cpp - typeinfo.cpp -) +target_sources(libocca PRIVATE dim.cpp json.cpp primitive.cpp typeinfo.cpp) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index fc288153d..30538795f 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,8 +1,2 @@ -target_sources(libocca - PRIVATE - exception.cpp - hash.cpp - io.cpp - logging.cpp - mutex.cpp -) +target_sources(libocca PRIVATE exception.cpp hash.cpp io.cpp logging.cpp + mutex.cpp) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7602f1946..45f854194 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required (VERSION 3.21 FATAL_ERROR) -project(OCCATests +cmake_minimum_required(VERSION 3.21 FATAL_ERROR) +project( + OCCATests VERSION 2.0.0 - DESCRIPTION "OCCA Tests" + DESCRIPTION "OCCA Tests" HOMEPAGE_URL "https://github.com/libocca/occa" LANGUAGES C CXX) -if (NOT TARGET OCCA::libocca) +if(NOT TARGET OCCA::libocca) find_package(OCCA REQUIRED) endif() @@ -23,68 +24,57 @@ function(add_occa_test test_source) # Setup executable target add_executable(${cmake_test_target} ${test_source}) - set_target_properties(${cmake_test_target} PROPERTIES - OUTPUT_NAME ${test_name} - RUNTIME_OUTPUT_DIRECTORY ${test_directory}) + set_target_properties( + ${cmake_test_target} PROPERTIES OUTPUT_NAME ${test_name} + RUNTIME_OUTPUT_DIRECTORY ${test_directory}) # Build config - target_link_libraries(${cmake_test_target} - PRIVATE - OCCA::c_api - OCCA::libocca - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS} - ) - if (OCCA_ENABLE_FORTRAN) - target_link_libraries(${cmake_test_target} - PRIVATE - OCCA::fortran_api - ) + target_link_libraries( + ${cmake_test_target} PRIVATE OCCA::c_api OCCA::libocca + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + if(OCCA_ENABLE_FORTRAN) + target_link_libraries(${cmake_test_target} PRIVATE OCCA::fortran_api) endif() target_include_directories(${cmake_test_target} - PRIVATE - $ - ) - - if (${test_source} MATCHES "typedefs.f90") - target_link_libraries(${cmake_test_target} - PRIVATE - libtypedefs_helper) + PRIVATE $) + + if(${test_source} MATCHES "typedefs.f90") + target_link_libraries(${cmake_test_target} PRIVATE libtypedefs_helper) endif() - add_test( - NAME ${cmake_test_target} - COMMAND ${test_binary}) + add_test(NAME ${cmake_test_target} COMMAND ${test_binary}) # Expected defines - set_property(TEST ${cmake_test_target} APPEND PROPERTY - ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) + set_property( + TEST ${cmake_test_target} + APPEND + PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa) endfunction() -#---[ Setup Tests ]--------------------- +# ---[ Setup Tests ]--------------------- file( GLOB_RECURSE occa_tests - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "src/*.cpp") -if (OCCA_ENABLE_FORTRAN) +if(OCCA_ENABLE_FORTRAN) file( GLOB_RECURSE occa_fortran_tests - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.f90") + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "src/*.f90") list(APPEND occa_tests ${occa_fortran_tests}) - list(FILTER occa_tests - EXCLUDE REGEX "src/fortran/typedefs_helper.cpp") + list(FILTER occa_tests EXCLUDE REGEX "src/fortran/typedefs_helper.cpp") add_library(libtypedefs_helper SHARED "src/fortran/typedefs_helper.cpp") target_link_libraries(libtypedefs_helper OCCA::libocca) else() - list(FILTER occa_tests - EXCLUDE REGEX "src/fortran") + list(FILTER occa_tests EXCLUDE REGEX "src/fortran") endif() foreach(occa_test ${occa_tests}) add_occa_test("${occa_test}") endforeach() -#======================================= +# =======================================