From a3781c59a0538f50a1170ccbf0c0bf380d144185 Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Fri, 15 Sep 2023 17:20:55 +0100 Subject: [PATCH 01/10] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc2dde3f..47875b29 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

-![C++ Version](https://img.shields.io/badge/C++-17/20-purple.svg?style=flat&logo=c%2B%2B) ![License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat) [![Discord](https://img.shields.io/discord/848914274105557043?color=blue&label=Discord&logo=Discord)](https://discord.gg/cGxTFTgCAC) +![C++ Version](https://img.shields.io/badge/C++-20/23-purple.svg?style=flat&logo=c%2B%2B) ![License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat) [![Discord](https://img.shields.io/discord/848914274105557043?color=blue&label=Discord&logo=Discord)](https://discord.gg/cGxTFTgCAC) --- From 17554d137898decdf30731776475f4696813f207 Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Fri, 15 Sep 2023 19:43:26 +0100 Subject: [PATCH 02/10] Update Readme --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 47875b29..e8fadfaf 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,12 @@ submodules of the library -- you don't need to install anything manually): # Star History
- - Star History + + + + + Star History Chart +
From 0a3a33251ab1a30292b1040df68ab94917eb36b3 Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Mon, 2 Oct 2023 19:34:23 +0100 Subject: [PATCH 03/10] Support for Apple Accelerate --- CMakeLists.txt | 323 +++++++++--------- cmake/blasConfig.cmake | 117 +++++++ cmake/identifyBLAS.cmake | 27 -- librapid/cxxblas/drivers/accelerate.h | 21 ++ librapid/cxxblas/drivers/drivers.h | 2 + librapid/cxxblas/drivers/drivers.tcc | 2 +- .../include/librapid/array/arrayContainer.hpp | 7 +- librapid/include/librapid/array/fill.hpp | 311 ++++++++--------- 8 files changed, 463 insertions(+), 347 deletions(-) create mode 100644 cmake/blasConfig.cmake delete mode 100644 cmake/identifyBLAS.cmake create mode 100644 librapid/cxxblas/drivers/accelerate.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f7c3da8f..92b78dd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,9 +75,9 @@ if (LIBRAPID_USE_CUDA) find_package(CUDAToolkit QUIET) endif () -if (LIBRAPID_USE_BLAS) - find_package(BLAS QUIET) -endif () +#if (LIBRAPID_USE_BLAS) +# find_package(BLAS QUIET) +#endif () if (LIBRAPID_USE_OMP) find_package(OpenMP QUIET) @@ -190,164 +190,165 @@ if (LIBRAPID_USE_OMP) endif () # Include any required modules -include(identifyBLAS) - -# If LIBRAPID_MKL_CONFIG_PATH is set, use that instead of the default -if (LIBRAPID_MKL_CONFIG_PATH) - message(STATUS "[ LIBRAPID ] Using MKLConfig.cmake from ${LIBRAPID_MKL_CONFIG_PATH}") - include(${LIBRAPID_MKL_CONFIG_PATH}) - message(STATUS "[ LIBRAPID ] Linking against MKL") - message(STATUS "[ LIBRAPID ] MKL Libraries: ${MKL_LIBRARIES}") - message(STATUS "[ LIBRAPID ] MKL Include Directories: ${MKL_INCLUDE}") - target_link_libraries(${module_name} PUBLIC MKL::MKL) - target_include_directories(${module_name} PUBLIC ${MKL_INCLUDE}) - target_compile_definitions(${module_name} PUBLIC LIBRAPID_HAS_BLAS) - set(LIBRAPID_HAS_BLAS ON) - set_blas_definition("MKL") -endif () - -if (LIBRAPID_GET_BLAS AND NOT LIBRAPID_HAS_BLAS) - message(STATUS "[ LIBRAPID ] Downloading OpenBLAS Build...") - - FetchContent_Declare( - BuildOpenBLAS - GIT_REPOSITORY https://github.com/LibRapid/BuildOpenBLAS.git - ) - - FetchContent_MakeAvailable(BuildOpenBLAS) - - set(BLAS_FOUND TRUE) - set(LIBRAPID_USE_BLAS TRUE) - - if (${IS_WINDOWS}) - # Use openblas-windows-latest - set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-windows-latest/lib/openblas.lib") - elseif (${IS_MACOS}) - # Use openblas-macos-latest - set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-macos-latest/lib/libopenblas.a") - else () # Linux and other systems - # Use openblas-ubuntu-latest - set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-ubuntu-latest/lib/libopenblas.a") - endif () -endif () - -# See if BLAS should be linked against -if (LIBRAPID_USE_BLAS AND NOT LIBRAPID_HAS_BLAS) - if (${BLAS_FOUND}) - message(STATUS "[ LIBRAPID ] BLAS located was ${BLAS_LIBRARIES}") - - list(GET ${BLAS_LIBRARIES} 0 LIBRAPID_BLAS) - - if (NOT ${LIBRAPID_BLAS}) - set(LIBRAPID_BLAS ${BLAS_LIBRARIES}) - endif () - - message(STATUS "[ LIBRAPID ] Using BLAS (" ${LIBRAPID_BLAS} ")") - - get_filename_component(filepath ${LIBRAPID_BLAS} DIRECTORY) - get_filename_component(filename ${LIBRAPID_BLAS} NAME) - - # Attempt to identify which BLAS library is being used and - # set the appropriate compile definition - set_blas_definition_from_file(filename) - - # Copy include files - set(inc_path "${filepath}/../include") - message(STATUS "[ LIBRAPID ] Checking path ${inc_path} for include files") - FILE(GLOB_RECURSE files "${filepath}/..") - message(STATUS "[ LIBRAPID ] Information: ${files}") - if (NOT (EXISTS ${inc_path})) - message(STATUS "[ LIBRAPID ] Could not locate include path for BLAS") - endif () - - set(has_cblas OFF) - - if (EXISTS "${inc_path}/openblas") - FILE(GLOB_RECURSE include_files "${inc_path}/openblas/*.*") - foreach (file IN LISTS include_files) - get_filename_component(inc_file ${file} NAME) - if (${inc_file} STREQUAL "cblas.h") - set(has_cblas ON) - endif () - endforeach () - else () - FILE(GLOB_RECURSE include_files "${inc_path}/*.*") - foreach (file IN LISTS include_files) - get_filename_component(inc_file ${file} NAME) - if (${inc_file} STREQUAL "cblas.h") - set(has_cblas ON) - endif () - endforeach () - endif () - - if (${has_cblas}) - if (EXISTS "${inc_path}/openblas") - FILE(GLOB_RECURSE include_files "${inc_path}/openblas/*.*") - foreach (file IN LISTS include_files) - message(STATUS "[ LIBRAPID ] Found OpenBLAS include file " ${file}) - get_filename_component(inc_file ${file} NAME) - configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${inc_file}" COPYONLY) - endforeach () - endif () - # else () - - FILE(GLOB_RECURSE include_files "${inc_path}/*.*") - foreach (file IN LISTS include_files) - message(STATUS "[ LIBRAPID ] Found include file " ${file}) - get_filename_component(inc_file ${file} NAME) - configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${inc_file}" COPYONLY) - endforeach () - - # endif () - - # Copy library files - get_filename_component(lib_name ${LIBRAPID_BLAS} NAME) - # message(STATUS "[ LIBRAPID ] Found library file ${lib_name}") - configure_file(${LIBRAPID_BLAS} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${lib_name}" COPYONLY) - endif () - - # Copy binary files if on Windows - if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set(bin_path "${filepath}/../bin") - if (NOT (EXISTS ${bin_path})) - message(WARNING "Could not locate folder for BLAS") - else () - FILE(GLOB_RECURSE include_files "${bin_path}/*.dll") - foreach (file IN LISTS include_files) - message(STATUS "[ LIBRAPID ] Found binary file " ${file}) - get_filename_component(filename ${file} NAME) - configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${filename}" COPYONLY) - endforeach () - - FILE(GLOB_RECURSE bin_files "${CMAKE_CURRENT_SOURCE_DIR}/*.dll") - foreach (file IN LISTS bin_files) - message(STATUS "[ LIBRAPID ] Found packaged binary file " ${file}) - get_filename_component(filename ${file} NAME) - configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${filename}" COPYONLY) - endforeach () - endif () - endif () - - # Add the compile definition so LibRapid knows it has BLAS - if (${has_cblas}) - # Link the required library - target_link_libraries(${module_name} PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${lib_name}" - ) - - target_include_directories(${module_name} PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas" - ) - - target_compile_definitions(${module_name} PUBLIC LIBRAPID_HAS_BLAS) - set(LIBRAPID_HAS_BLAS true) - else () - message(WARNING "Although BLAS was found, no cblas.h file was found, so BLAS support is not enabled") - endif () - else () - message(WARNING "BLAS support was requested but a valid BLAS interface was not found") - endif () -endif () +include(blasConfig) +configure_blas() + +## If LIBRAPID_MKL_CONFIG_PATH is set, use that instead of the default +#if (LIBRAPID_MKL_CONFIG_PATH) +# message(STATUS "[ LIBRAPID ] Using MKLConfig.cmake from ${LIBRAPID_MKL_CONFIG_PATH}") +# include(${LIBRAPID_MKL_CONFIG_PATH}) +# message(STATUS "[ LIBRAPID ] Linking against MKL") +# message(STATUS "[ LIBRAPID ] MKL Libraries: ${MKL_LIBRARIES}") +# message(STATUS "[ LIBRAPID ] MKL Include Directories: ${MKL_INCLUDE}") +# target_link_libraries(${module_name} PUBLIC MKL::MKL) +# target_include_directories(${module_name} PUBLIC ${MKL_INCLUDE}) +# target_compile_definitions(${module_name} PUBLIC LIBRAPID_HAS_BLAS) +# set(LIBRAPID_HAS_BLAS ON) +# set_blas_definition("MKL") +#endif () +# +#if (LIBRAPID_GET_BLAS AND NOT LIBRAPID_HAS_BLAS) +# message(STATUS "[ LIBRAPID ] Downloading OpenBLAS Build...") +# +# FetchContent_Declare( +# BuildOpenBLAS +# GIT_REPOSITORY https://github.com/LibRapid/BuildOpenBLAS.git +# ) +# +# FetchContent_MakeAvailable(BuildOpenBLAS) +# +# set(BLAS_FOUND TRUE) +# set(LIBRAPID_USE_BLAS TRUE) +# +# if (${IS_WINDOWS}) +# # Use openblas-windows-latest +# set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-windows-latest/lib/openblas.lib") +# elseif (${IS_MACOS}) +# # Use openblas-macos-latest +# set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-macos-latest/lib/libopenblas.a") +# else () # Linux and other systems +# # Use openblas-ubuntu-latest +# set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-ubuntu-latest/lib/libopenblas.a") +# endif () +#endif () +# +## See if BLAS should be linked against +#if (LIBRAPID_USE_BLAS AND NOT LIBRAPID_HAS_BLAS) +# if (${BLAS_FOUND}) +# message(STATUS "[ LIBRAPID ] BLAS located was ${BLAS_LIBRARIES}") +# +# list(GET ${BLAS_LIBRARIES} 0 LIBRAPID_BLAS) +# +# if (NOT ${LIBRAPID_BLAS}) +# set(LIBRAPID_BLAS ${BLAS_LIBRARIES}) +# endif () +# +# message(STATUS "[ LIBRAPID ] Using BLAS (" ${LIBRAPID_BLAS} ")") +# +# get_filename_component(filepath ${LIBRAPID_BLAS} DIRECTORY) +# get_filename_component(filename ${LIBRAPID_BLAS} NAME) +# +# # Attempt to identify which BLAS library is being used and +# # set the appropriate compile definition +# set_blas_definition_from_file(filename) +# +# # Copy include files +# set(inc_path "${filepath}/../include") +# message(STATUS "[ LIBRAPID ] Checking path ${inc_path} for include files") +# FILE(GLOB_RECURSE files "${filepath}/..") +# message(STATUS "[ LIBRAPID ] Information: ${files}") +# if (NOT (EXISTS ${inc_path})) +# message(STATUS "[ LIBRAPID ] Could not locate include path for BLAS") +# endif () +# +# set(has_cblas OFF) +# +# if (EXISTS "${inc_path}/openblas") +# FILE(GLOB_RECURSE include_files "${inc_path}/openblas/*.*") +# foreach (file IN LISTS include_files) +# get_filename_component(inc_file ${file} NAME) +# if (${inc_file} STREQUAL "cblas.h") +# set(has_cblas ON) +# endif () +# endforeach () +# else () +# FILE(GLOB_RECURSE include_files "${inc_path}/*.*") +# foreach (file IN LISTS include_files) +# get_filename_component(inc_file ${file} NAME) +# if (${inc_file} STREQUAL "cblas.h") +# set(has_cblas ON) +# endif () +# endforeach () +# endif () +# +# if (${has_cblas}) +# if (EXISTS "${inc_path}/openblas") +# FILE(GLOB_RECURSE include_files "${inc_path}/openblas/*.*") +# foreach (file IN LISTS include_files) +# message(STATUS "[ LIBRAPID ] Found OpenBLAS include file " ${file}) +# get_filename_component(inc_file ${file} NAME) +# configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${inc_file}" COPYONLY) +# endforeach () +# endif () +# # else () +# +# FILE(GLOB_RECURSE include_files "${inc_path}/*.*") +# foreach (file IN LISTS include_files) +# message(STATUS "[ LIBRAPID ] Found include file " ${file}) +# get_filename_component(inc_file ${file} NAME) +# configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${inc_file}" COPYONLY) +# endforeach () +# +# # endif () +# +# # Copy library files +# get_filename_component(lib_name ${LIBRAPID_BLAS} NAME) +# # message(STATUS "[ LIBRAPID ] Found library file ${lib_name}") +# configure_file(${LIBRAPID_BLAS} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${lib_name}" COPYONLY) +# endif () +# +# # Copy binary files if on Windows +# if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") +# set(bin_path "${filepath}/../bin") +# if (NOT (EXISTS ${bin_path})) +# message(WARNING "Could not locate folder for BLAS") +# else () +# FILE(GLOB_RECURSE include_files "${bin_path}/*.dll") +# foreach (file IN LISTS include_files) +# message(STATUS "[ LIBRAPID ] Found binary file " ${file}) +# get_filename_component(filename ${file} NAME) +# configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${filename}" COPYONLY) +# endforeach () +# +# FILE(GLOB_RECURSE bin_files "${CMAKE_CURRENT_SOURCE_DIR}/*.dll") +# foreach (file IN LISTS bin_files) +# message(STATUS "[ LIBRAPID ] Found packaged binary file " ${file}) +# get_filename_component(filename ${file} NAME) +# configure_file(${file} "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${filename}" COPYONLY) +# endforeach () +# endif () +# endif () +# +# # Add the compile definition so LibRapid knows it has BLAS +# if (${has_cblas}) +# # Link the required library +# target_link_libraries(${module_name} PUBLIC +# "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas/${lib_name}" +# ) +# +# target_include_directories(${module_name} PUBLIC +# "${CMAKE_CURRENT_SOURCE_DIR}/librapid/blas" +# ) +# +# target_compile_definitions(${module_name} PUBLIC LIBRAPID_HAS_BLAS) +# set(LIBRAPID_HAS_BLAS true) +# else () +# message(WARNING "Although BLAS was found, no cblas.h file was found, so BLAS support is not enabled") +# endif () +# else () +# message(WARNING "BLAS support was requested but a valid BLAS interface was not found") +# endif () +#endif () # Check if CUDA should be used if (LIBRAPID_USE_CUDA) diff --git a/cmake/blasConfig.cmake b/cmake/blasConfig.cmake new file mode 100644 index 00000000..000a4b9d --- /dev/null +++ b/cmake/blasConfig.cmake @@ -0,0 +1,117 @@ +# Identify which BLAS library is being used based on the filename or path +macro(identifyBlas filename) + if ("${filename}" MATCHES "(openblas|/openblas/).*") + set(BLAS_LIB "OPENBLAS") + elseif ("${filename}" MATCHES "(mkl|/mkl/).*") + set(BLAS_LIB "MKLBLAS") + elseif ("${filename}" MATCHES "(atlas|/atlas/).*") + set(BLAS_LIB "ATLAS") + elseif ("${filename}" MATCHES "Accelerate\\.framework") + set(BLAS_LIB "ACCELERATE") + else () + set(BLAS_LIB "GENERIC") + endif () + + message(STATUS "[ LIBRAPID ] Identified BLAS Library: ${BLAS_LIB}") +endmacro() + +macro(set_blas_definition_from_file filename) + identifyBlas(filename) + target_compile_definitions(${module_name} PUBLIC LIBRAPID_BLAS_${BLAS_LIB}) +endmacro() + +macro(set_blas_definition name) + target_compile_definitions(${module_name} PUBLIC LIBRAPID_BLAS_${name}) +endmacro() + +macro(download_openblas) + message(STATUS "[ LIBRAPID ] Downloading OpenBLAS Build...") + + FetchContent_Declare( + BuildOpenBLAS + GIT_REPOSITORY https://github.com/LibRapid/BuildOpenBLAS.git + ) + + FetchContent_MakeAvailable(BuildOpenBLAS) + + set(BLAS_FOUND TRUE) + set(LIBRAPID_USE_BLAS TRUE) + + if (${IS_WINDOWS}) + # Use openblas-windows-latest + set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-windows-latest/lib/openblas.lib") + elseif (${IS_MACOS}) + # Use openblas-macos-latest + set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-macos-latest/lib/libopenblas.a") + else () # Linux and other systems + # Use openblas-ubuntu-latest + set(BLAS_LIBRARIES "${FETCHCONTENT_BASE_DIR}/buildopenblas-src/openblas-ubuntu-latest/lib/libopenblas.a") + endif () + + set_blas_definition("OPENBLAS") +endmacro() + +macro(link_openblas) + get_filename_component(filepath ${LIBRAPID_BLAS} DIRECTORY) + get_filename_component(filename ${LIBRAPID_BLAS} NAME) + + set(include_path "${filepath}/../include") + + # todo + + set_blas_definition("OPENBLAS") +endmacro() + +macro(link_accelerate) + target_link_libraries(${module_name} PUBLIC "-framework Accelerate") + + # If not using apple-clang, we need to relax some conditions + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + message(WARNING "[ LIBRAPID ] Accelerate is designed for AppleClang. Relaxing some conditions") + target_compile_options(${module_name} PUBLIC "-flax-vector-conversions") + endif () + + set_blas_definition("ACCELERATE") +endmacro() + +macro(configure_blas) + if (NOT LIBRAPID_USE_BLAS) + return() + endif () + + if (LIBRAPID_GET_BLAS) + download_openblas() + else () + find_package(BLAS QUIET) + endif () + + if (NOT BLAS_FOUND) + message(STATUS "[ LIBRAPID ] BLAS library not found on system. Consider enabling LIBRAPID_GET_BLAS") + return() + endif () + + message(STATUS "[ LIBRAPID ] Located BLAS at ${BLAS_LIBRARIES}") + + list(GET ${BLAS_LIBRARIES} 0 LIBRAPID_BLAS) + + if (NOT ${LIBRAPID_BLAS}) + set(LIBRAPID_BLAS ${BLAS_LIBRARIES}) + endif () + + message(STATUS "[ LIBRAPID ] Using BLAS") + + identifyBlas("${LIBRAPID_BLAS}") + + # Configure BLAS (different steps are needed for each library) + if (${BLAS_LIB} STREQUAL "OPENBLAS") + link_openblas() + elseif (${BLAS_LIB} STREQUAL "MKLBLAS") + link_mkl() + elseif (${BLAS_LIB} STREQUAL "ATLAS") + link_atlas() + elseif (${BLAS_LIB} STREQUAL "ACCELERATE") + link_accelerate() + else () + link_generic() + endif () +endmacro() diff --git a/cmake/identifyBLAS.cmake b/cmake/identifyBLAS.cmake deleted file mode 100644 index 74f9acea..00000000 --- a/cmake/identifyBLAS.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Identify which BLAS library is being used based on the -# *.lib filename - -macro(identifyBlas filename) - if (filename MATCHES "(openblas).*") - set(BLAS_LIB "OPENBLAS") - elseif (filename MATCHES "(mkl).*") - set(BLAS_LIB "MKLBLAS") - elseif (filename MATCHES "(atlas).*") - set(BLAS_LIB "ATLAS") - elseif (filename MATCHES "(accelerate).*") - set(BLAS_LIB "ACCELERATE") - else () - set(BLAS_LIB "GENERIC") - endif () - - message(STATUS "[ LIBRAPID ] Identified BLAS Library ${BLAS_LIB}") -endmacro() - -macro(set_blas_definition_from_file filename) - identifyBlas(filename) - target_compile_definitions(${module_name} PUBLIC LIBRAPID_BLAS_${BLAS_LIB}) -endmacro() - -macro(set_blas_definition name) - target_compile_definitions(${module_name} PUBLIC LIBRAPID_BLAS_${name}) -endmacro() diff --git a/librapid/cxxblas/drivers/accelerate.h b/librapid/cxxblas/drivers/accelerate.h new file mode 100644 index 00000000..d89b6821 --- /dev/null +++ b/librapid/cxxblas/drivers/accelerate.h @@ -0,0 +1,21 @@ +#ifndef CXXBLAS_DRIVERS_ACCELERATE_H +#define CXXBLAS_DRIVERS_ACCELERATE_H 1 + +#define HAVE_CBLAS 1 +#ifdef BLASINT +# define CBLAS_INT BLASINT +#else +# define CBLAS_INT int +#endif +#define BLAS_IMPL "Accelerate.framework" +#ifndef CBLAS_INDEX +# define CBLAS_INDEX size_t +#endif // CBLAS_INDEX + +#include + +#ifdef negativeInfinity // This breaks things +#undef negativeInfinity +#endif + +#endif // CXXBLAS_DRIVERS_ACCELERATE_H diff --git a/librapid/cxxblas/drivers/drivers.h b/librapid/cxxblas/drivers/drivers.h index b7ecdfca..00e02c4e 100644 --- a/librapid/cxxblas/drivers/drivers.h +++ b/librapid/cxxblas/drivers/drivers.h @@ -47,6 +47,8 @@ # include "cxxblas/drivers/veclib.h" #elif defined(LIBRAPID_BLAS_MKL) # include "cxxblas/drivers/mklblas.h" +#elif defined(LIBRAPID_BLAS_ACCELERATE) +# include "cxxblas/drivers/accelerate.h" #elif defined(LIBRAPID_BLAS_REFBLAS) # include "cxxblas/drivers/refblas.h" #endif diff --git a/librapid/cxxblas/drivers/drivers.tcc b/librapid/cxxblas/drivers/drivers.tcc index 39f5338a..8a05be2b 100644 --- a/librapid/cxxblas/drivers/drivers.tcc +++ b/librapid/cxxblas/drivers/drivers.tcc @@ -124,7 +124,7 @@ namespace cxxblas { typename RestrictTo::value, CBLAS_TRANSPOSE>::Type getCblasType(ENUM trans) { if (trans == NoTrans) { return CblasNoTrans; } -# if !defined(LIBRAPID_BLAS_MKL) +# if !defined(LIBRAPID_BLAS_MKL) && !defined(LIBRAPID_BLAS_ACCELERATE) if (trans == Conj) { return CblasConjNoTrans; } # endif if (trans == Trans) { return CblasTrans; } diff --git a/librapid/include/librapid/array/arrayContainer.hpp b/librapid/include/librapid/array/arrayContainer.hpp index 57cbdb14..4768ce6f 100644 --- a/librapid/include/librapid/array/arrayContainer.hpp +++ b/librapid/include/librapid/array/arrayContainer.hpp @@ -686,14 +686,15 @@ namespace librapid { sizeof...(Indices), m_shape.ndim()); + int dim = 0; int64_t index = 0; for (int64_t i : {indices...}) { LIBRAPID_ASSERT( - i >= 0 && i < static_cast(m_shape[index]), + i >= 0 && i < static_cast(m_shape[dim]), "Index {} out of bounds in ArrayContainer::operator() with dimension={}", i, - m_shape[index]); - index = index * m_shape[index] + i; + m_shape[dim]); + index = index * m_shape[dim++] + i; } return m_storage[index]; } diff --git a/librapid/include/librapid/array/fill.hpp b/librapid/include/librapid/array/fill.hpp index 2b280c50..2f68ff62 100644 --- a/librapid/include/librapid/array/fill.hpp +++ b/librapid/include/librapid/array/fill.hpp @@ -2,171 +2,172 @@ #define LIBRAPID_ARRAY_FILL_HPP namespace librapid { - template - LIBRAPID_ALWAYS_INLINE void fill(array::ArrayContainer &dst, - const Scalar &value) { - dst = array::ArrayContainer(dst.shape(), value); - } - - template - LIBRAPID_ALWAYS_INLINE void - fillRandom(array::ArrayContainer> &dst, const Lower &lower, - const Upper &upper) { - ShapeType shape = dst.shape(); - auto *data = dst.storage().begin(); - bool parallel = global::numThreads != 1 && shape.size() > global::multithreadThreshold; - - if (parallel) { + template + LIBRAPID_ALWAYS_INLINE void fill(array::ArrayContainer &dst, + const Scalar &value) { + dst = array::ArrayContainer(dst.shape(), value); + } + + template + LIBRAPID_ALWAYS_INLINE void + fillRandom(array::ArrayContainer> &dst, + const Lower &lower = 0, const Upper &upper = 1) { + ShapeType shape = dst.shape(); + auto *data = dst.storage().begin(); + bool parallel = global::numThreads != 1 && shape.size() > global::multithreadThreshold; + + if (parallel) { #pragma omp parallel for - for (int64_t i = 0; i < shape.size(); ++i) { - data[i] = random(static_cast(lower), - static_cast(upper)); - } - } else { - for (int64_t i = 0; i < shape.size(); ++i) { - data[i] = random(static_cast(lower), - static_cast(upper)); - } - } - } - - template - LIBRAPID_ALWAYS_INLINE void - fillRandomGaussian(array::ArrayContainer> &dst, - const Lower &lower, const Upper &upper) { - ShapeType shape = dst.shape(); - auto *data = dst.storage().begin(); - bool parallel = global::numThreads != 1 && shape.size() > global::multithreadThreshold; - - if (parallel) { + for (int64_t i = 0; i < shape.size(); ++i) { + data[i] = random(static_cast(lower), + static_cast(upper)); + } + } else { + for (int64_t i = 0; i < shape.size(); ++i) { + data[i] = random(static_cast(lower), + static_cast(upper)); + } + } + } + + template + LIBRAPID_ALWAYS_INLINE void + fillRandomGaussian(array::ArrayContainer> &dst, + const Lower &lower, const Upper &upper) { + ShapeType shape = dst.shape(); + auto *data = dst.storage().begin(); + bool parallel = global::numThreads != 1 && shape.size() > global::multithreadThreshold; + + if (parallel) { #pragma omp parallel for - for (int64_t i = 0; i < shape.size(); ++i) { - data[i] = randomGaussian(); - } - } else { - for (int64_t i = 0; i < shape.size(); ++i) { - data[i] = randomGaussian(); - } - } - } + for (int64_t i = 0; i < shape.size(); ++i) { + data[i] = randomGaussian(); + } + } else { + for (int64_t i = 0; i < shape.size(); ++i) { + data[i] = randomGaussian(); + } + } + } #if defined(LIBRAPID_HAS_OPENCL) - template - LIBRAPID_ALWAYS_INLINE void - fillRandom(array::ArrayContainer> &dst, - const Lower &lower, const Upper &upper) { - ShapeType shape = dst.shape(); - int64_t elements = shape.size(); - - // Initialize a buffer of random seeds - static int64_t numSeeds = 1024; - static bool initialized = false; - static Array seeds(Shape {numSeeds}); - if (global::reseed || !initialized) { - for (int64_t i = 0; i < numSeeds; ++i) { seeds(i) = randint(0, INT64_MAX); } - initialized = true; - - // reseed is controlled by the random module, so we don't need to worry about it here - } - - // Run the kernel - opencl::runLinearKernel("fillRandom", - elements, - dst.storage().data(), - elements, - static_cast(lower), - static_cast(upper), - seeds.storage().data(), - numSeeds); - } + template + LIBRAPID_ALWAYS_INLINE void + fillRandom(array::ArrayContainer> &dst, + const Lower &lower, const Upper &upper) { + ShapeType shape = dst.shape(); + int64_t elements = shape.size(); + + // Initialize a buffer of random seeds + static int64_t numSeeds = 1024; + static bool initialized = false; + static Array seeds(Shape {numSeeds}); + if (global::reseed || !initialized) { + for (int64_t i = 0; i < numSeeds; ++i) { seeds(i) = randint(0, INT64_MAX); } + initialized = true; + + // reseed is controlled by the random module, so we don't need to worry about it here + } + + // Run the kernel + opencl::runLinearKernel("fillRandom", + elements, + dst.storage().data(), + elements, + static_cast(lower), + static_cast(upper), + seeds.storage().data(), + numSeeds); + } #endif // LIBRAPID_HAS_OPENCL #if defined(LIBRAPID_HAS_CUDA) - template - LIBRAPID_ALWAYS_INLINE void - fillRandom(array::ArrayContainer> &dst, - const Lower &lower, const Upper &upper) { - ShapeType shape = dst.shape(); - int64_t elements = shape.size(); - - // Initialize a buffer of random seeds - static int64_t numSeeds = 1024; - static bool initialized = false; - static Array seeds(Shape {numSeeds}); - - if (global::reseed || !initialized) { - for (int64_t i = 0; i < numSeeds; ++i) { seeds(i) = randint(0, INT64_MAX); } - initialized = true; - - // reseed is controlled by the random module, so we don't need to worry about it here - } - - cuda::runKernel( - "fill", - std::is_same_v ? "fillRandomHalf" : "fillRandom", - elements, - dst.storage().data().get(), - elements, - static_cast(lower), - static_cast(upper), - seeds.storage().data().get(), - numSeeds); - } - - template - LIBRAPID_ALWAYS_INLINE void - fillRandom(array::ArrayContainer> &dst, const Lower &lower, - const Upper &upper) { - ShapeType shape = dst.shape(); - int64_t elements = shape.size(); - - // Create a pseudo-random number generator - static curandGenerator_t prng; - static bool initialized = false; - - if (!initialized) { - curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_DEFAULT); - curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); - initialized = true; - } - - if (global::reseed) { curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); } - - // Run the kernel - curandGenerateUniform(prng, dst.storage().data().get(), elements); - - // Scale the result to the desired range - dst = dst * (upper - lower) + lower; - } - - template - LIBRAPID_ALWAYS_INLINE void - fillRandom(array::ArrayContainer> &dst, const Lower &lower, - const Upper &upper) { - ShapeType shape = dst.shape(); - int64_t elements = shape.size(); - - // Create a pseudo-random number generator - static curandGenerator_t prng; - static bool initialized = false; - - if (!initialized) { - curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_DEFAULT); - curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); - initialized = true; - } - - if (global::reseed) { curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); } - - // Run the kernel - curandGenerateUniformDouble(prng, dst.storage().data().get(), elements); - - // Scale the result to the desired range - dst = dst * (upper - lower) + lower; - } + template + LIBRAPID_ALWAYS_INLINE void + fillRandom(array::ArrayContainer> &dst, + const Lower &lower, const Upper &upper) { + ShapeType shape = dst.shape(); + int64_t elements = shape.size(); + + // Initialize a buffer of random seeds + static int64_t numSeeds = 1024; + static bool initialized = false; + static Array seeds(Shape {numSeeds}); + + if (global::reseed || !initialized) { + for (int64_t i = 0; i < numSeeds; ++i) { seeds(i) = randint(0, INT64_MAX); } + initialized = true; + + // reseed is controlled by the random module, so we don't need to worry about it here + } + + cuda::runKernel( + "fill", + std::is_same_v ? "fillRandomHalf" : "fillRandom", + elements, + dst.storage().data().get(), + elements, + static_cast(lower), + static_cast(upper), + seeds.storage().data().get(), + numSeeds); + } + + template + LIBRAPID_ALWAYS_INLINE void + fillRandom(array::ArrayContainer> &dst, const Lower &lower, + const Upper &upper) { + ShapeType shape = dst.shape(); + int64_t elements = shape.size(); + + // Create a pseudo-random number generator + static curandGenerator_t prng; + static bool initialized = false; + + if (!initialized) { + curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_DEFAULT); + curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); + initialized = true; + } + + if (global::reseed) { curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); } + + // Run the kernel + curandGenerateUniform(prng, dst.storage().data().get(), elements); + + // Scale the result to the desired range + dst = dst * (upper - lower) + lower; + } + + template + LIBRAPID_ALWAYS_INLINE void + fillRandom(array::ArrayContainer> &dst, const Lower &lower, + const Upper &upper) { + ShapeType shape = dst.shape(); + int64_t elements = shape.size(); + + // Create a pseudo-random number generator + static curandGenerator_t prng; + static bool initialized = false; + + if (!initialized) { + curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_DEFAULT); + curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); + initialized = true; + } + + if (global::reseed) { curandSetPseudoRandomGeneratorSeed(prng, global::randomSeed); } + + // Run the kernel + curandGenerateUniformDouble(prng, dst.storage().data().get(), elements); + + // Scale the result to the desired range + dst = dst * (upper - lower) + lower; + } #endif // LIBRAPID_HAS_CUDA } // namespace librapid From dcfa19559f71870cbdc0715f66ac50ea3876361f Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Mon, 2 Oct 2023 19:44:43 +0100 Subject: [PATCH 04/10] Update to BLAS detection and linking --- cmake/blasConfig.cmake | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cmake/blasConfig.cmake b/cmake/blasConfig.cmake index 000a4b9d..cc2af961 100644 --- a/cmake/blasConfig.cmake +++ b/cmake/blasConfig.cmake @@ -21,6 +21,7 @@ macro(set_blas_definition_from_file filename) endmacro() macro(set_blas_definition name) + target_compile_definitions(${module_name} PUBLIC LIBRAPID_HAS_BLAS) target_compile_definitions(${module_name} PUBLIC LIBRAPID_BLAS_${name}) endmacro() @@ -56,8 +57,31 @@ macro(link_openblas) get_filename_component(filename ${LIBRAPID_BLAS} NAME) set(include_path "${filepath}/../include") + target_include_directories(${module_name} PUBLIC "${include_path}") - # todo + set(include_files "") + if (EXISTS "${include_path}/openblas") + FILE(GLOB_RECURSE include_files "${include_path}/openblas/*.*") + target_include_directories(${module_name} PUBLIC "${include_path}/openblas") + else () + FILE(GLOB_RECURSE include_files "${include_path}/*.*") + endif () + + set(has_cblas OFF) + + foreach (file IN LISTS include_files) + get_filename_component(inc_file ${file} NAME) + if (${inc_file} STREQUAL "cblas.h") + set(has_cblas ON) + endif () + endforeach () + + if (NOT ${has_cblas}) + message(WARNING "[ LIBRAPID ] OpenBLAS does not contain cblas.h. Consider enabling LIBRAPID_GET_BLAS") + return() + endif () + + target_link_libraries(${module_name} PUBLIC ${LIBRAPID_BLAS}) set_blas_definition("OPENBLAS") endmacro() From 2026ced90a03e0fcb2d9baee5e3f81fbd70af1ea Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Mon, 2 Oct 2023 20:38:01 +0100 Subject: [PATCH 05/10] Update to BLAS linking --- cmake/blasConfig.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/blasConfig.cmake b/cmake/blasConfig.cmake index cc2af961..837142af 100644 --- a/cmake/blasConfig.cmake +++ b/cmake/blasConfig.cmake @@ -50,9 +50,11 @@ macro(download_openblas) endif () set_blas_definition("OPENBLAS") + set(LIBRAPID_BLAS ${BLAS_LIBRARIES}) endmacro() macro(link_openblas) + get_filename_component(filepath ${LIBRAPID_BLAS} DIRECTORY) get_filename_component(filename ${LIBRAPID_BLAS} NAME) @@ -98,6 +100,9 @@ macro(link_accelerate) set_blas_definition("ACCELERATE") endmacro() +macro(link_generic) +endmacro() + macro(configure_blas) if (NOT LIBRAPID_USE_BLAS) return() From 0f26d2bbb01c738f04cbfdb3aaf8e186c5e51311 Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Mon, 2 Oct 2023 20:56:20 +0100 Subject: [PATCH 06/10] Fix for when BLAS is not enabled --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92b78dd1..51ad1938 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ endif () #endif () if (LIBRAPID_USE_OMP) - find_package(OpenMP QUIET) + find_package(OpenMP QUIET) endif () set(LIBRAPID_HAS_OMP false) @@ -190,8 +190,10 @@ if (LIBRAPID_USE_OMP) endif () # Include any required modules -include(blasConfig) -configure_blas() +if (LIBRAPID_USE_BLAS) + include(blasConfig) + configure_blas() +endif () ## If LIBRAPID_MKL_CONFIG_PATH is set, use that instead of the default #if (LIBRAPID_MKL_CONFIG_PATH) From 8395a58646a9287e0ab1a22ac09d23d876f5633f Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Tue, 3 Oct 2023 16:51:16 +0100 Subject: [PATCH 07/10] Specify latest XCode version? --- .github/workflows/continuous-integration.yaml | 2 ++ librapid/src/multiprecTrig.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 7aec68ef..bf6275f3 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -259,6 +259,8 @@ jobs: - name: Install XCode if: matrix.os == 'macos-latest' uses: maxim-lobanov/setup-xcode@v1.5.1 + with: + xcode-version: latest # Tests must pass in both debug and release mode - name: Compile (Debug) diff --git a/librapid/src/multiprecTrig.cpp b/librapid/src/multiprecTrig.cpp index 2f714ca1..d19e999b 100644 --- a/librapid/src/multiprecTrig.cpp +++ b/librapid/src/multiprecTrig.cpp @@ -1,4 +1,4 @@ -#include +#include #if defined(LIBRAPID_USE_MULTIPREC) From 334b57b29b4f38eb1831b095fb915b6133973ede Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Tue, 3 Oct 2023 17:07:55 +0100 Subject: [PATCH 08/10] Not sure if this'll work --- .github/workflows/continuous-integration.yaml | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index bf6275f3..5519a2f3 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -23,6 +23,7 @@ jobs: cxx: ../llvm/bin/clang++ clangVer: "15.0" blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -33,6 +34,7 @@ jobs: cxx: ../llvm/bin/clang++ clangVer: "15.0" blas: on + getBlas: on fftw: on mpfr: on cpp: 20 @@ -42,6 +44,7 @@ jobs: cc: gcc-10 cxx: g++-10 blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -51,6 +54,7 @@ jobs: cc: gcc-10 cxx: g++-10 blas: on + getBlas: on fftw: on mpfr: on cpp: 20 @@ -60,6 +64,7 @@ jobs: cc: gcc-10 cxx: g++-10 blas: off + getBlas: off fftw: off mpfr: on cpp: 23 @@ -69,6 +74,7 @@ jobs: cc: gcc-10 cxx: g++-10 blas: on + getBlas: on fftw: on mpfr: on cpp: 23 @@ -78,6 +84,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -87,6 +94,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: on + getBlas: on fftw: on mpfr: on cpp: 20 @@ -96,6 +104,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: off + getBlas: off fftw: off mpfr: on cpp: 23 @@ -105,6 +114,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: on + getBlas: on fftw: on mpfr: on cpp: 23 @@ -115,6 +125,7 @@ jobs: cxx: ../llvm/bin/clang++ clangVer: "15.0" blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -125,6 +136,7 @@ jobs: cxx: ../llvm/bin/clang++ clangVer: "15.0" blas: on + getBlas: off # Included with XCode fftw: on mpfr: on cpp: 20 @@ -134,6 +146,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -142,7 +155,8 @@ jobs: - os: macos-latest cc: gcc-11 cxx: g++-11 - blas: on + blas: on # Accelerate requires clang so we get blas + getBlas: on fftw: on mpfr: on cpp: 20 @@ -152,6 +166,7 @@ jobs: cc: gcc-11 cxx: g++-11 blas: off + getBlas: off fftw: off mpfr: on cpp: 23 @@ -160,7 +175,8 @@ jobs: - os: macos-latest cc: gcc-11 cxx: g++-11 - blas: on + blas: on # Accelerate Requires clang, so we get blas + getBlas: on fftw: on mpfr: on cpp: 23 @@ -267,7 +283,7 @@ jobs: run: | mkdir buildDebug cd buildDebug - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=${{ matrix.cpp }} -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_GET_BLAS=${{ matrix.blas }} -DLIBRAPID_USE_MULTIPREC=${{ matrix.mpfr }} + cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=${{ matrix.cpp }} -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_USE_BLAS=${{ matrix.blas }} -DLIBRAPID_GET_BLAS=${{ matrix.getBlas }} -DLIBRAPID_USE_MULTIPREC=${{ matrix.mpfr }} cmake --build . --config Debug env: CC: ${{ matrix.cc }} @@ -282,7 +298,7 @@ jobs: run: | mkdir buildRelease cd buildRelease - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{ matrix.cpp }} -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_GET_BLAS=${{ matrix.blas }} -DLIBRAPID_USE_MULTIPREC=${{ matrix.mpfr }} + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{ matrix.cpp }} -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_USE_BLAS=${{ matrix.blas }} -DLIBRAPID_GET_BLAS=${{ matrix.getBlas }} -DLIBRAPID_USE_MULTIPREC=${{ matrix.mpfr }} cmake --build . --config Release env: CC: ${{ matrix.cc }} @@ -646,7 +662,7 @@ jobs: run: | mkdir build cd build - cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBRAPID_CODE_COV=on -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_GET_BLAS=ON -DLIBRAPID_GET_FFTW=on -DLIBRAPID_USE_MULTIPREC=on + cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBRAPID_CODE_COV=on -DLIBRAPID_BUILD_EXAMPLES=on -DLIBRAPID_BUILD_TESTS=on -DLIBRAPID_USE_BLAS=ON -DLIBRAPID_GET_FFTW=on -DLIBRAPID_USE_MULTIPREC=on cmake --build . env: CC: gcc-11 From 52622823ce4167b1395e010a409ce973c444c6b6 Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Tue, 3 Oct 2023 17:46:57 +0100 Subject: [PATCH 09/10] In theory, this shouldn't change anything --- .github/workflows/continuous-integration.yaml | 2 +- CMakeLists.txt | 29 +++---------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 5519a2f3..513c698c 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -11,7 +11,7 @@ on: jobs: compile: - name: Compile on ${{ matrix.os }} with ${{ matrix.cxx }} (BLAS ${{ matrix.blas }}, FFTW ${{ matrix.fftw }}, MPFR ${{ matrix.mpfr }}, C++ ${{ matrix.cpp }}) + name: Compile on ${{ matrix.os }} with ${{ matrix.cxx }} (BLAS ${{ matrix.blas }}, Get BLAS ${{ matrix.getBlas }}, FFTW ${{ matrix.fftw }}, MPFR ${{ matrix.mpfr }}, C++ ${{ matrix.cpp }}) runs-on: ${{ matrix.os }} strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 51ad1938..ccb78093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,19 +69,7 @@ MACRO(SUBDIRLIST result curdir) SET(${result} ${dirlist}) ENDMACRO() -# Attempt to locate the required packages include(FetchContent) -if (LIBRAPID_USE_CUDA) - find_package(CUDAToolkit QUIET) -endif () - -#if (LIBRAPID_USE_BLAS) -# find_package(BLAS QUIET) -#endif () - -if (LIBRAPID_USE_OMP) - find_package(OpenMP QUIET) -endif () set(LIBRAPID_HAS_OMP false) set(LIBRAPID_HAS_BLAS false) @@ -137,12 +125,6 @@ if (LIBRAPID_STRICT AND LIBRAPID_QUIET) message(FATAL_ERROR "LIBRAPID_STRICT and LIBRAPID_QUIET cannot be enabled at the same time") endif () -# SIMD instructions do not currently work on MacOS -#if (IS_MACOS AND LIBRAPID_NATIVE_ARCH) -# message(WARNING "SIMD instructions are not currently supported on MacOS. Disabling LIBRAPID_NATIVE_ARCH") -# set(LIBRAPID_NATIVE_ARCH OFF) -#endif () - if (LIBRAPID_STRICT) # Enable all warnings and treat them as errors if (MSVC) @@ -150,13 +132,6 @@ if (LIBRAPID_STRICT) else () target_compile_options(${module_name} PRIVATE -Wall -Wextra -pedantic -Werror) endif () -else () - # Enable all warnings - if (MSVC) - target_compile_options(${module_name} PRIVATE /W4) - else () - target_compile_options(${module_name} PRIVATE -Wall -Wextra -pedantic) - endif () endif () if (LIBRAPID_QUIET) @@ -175,6 +150,8 @@ endif () # See if OpenMP should be linked against if (LIBRAPID_USE_OMP) + find_package(OpenMP QUIET) + if (${OpenMP_FOUND}) message(STATUS "[ LIBRAPID ] Linking against OpenMP") @@ -354,6 +331,8 @@ endif () # Check if CUDA should be used if (LIBRAPID_USE_CUDA) + find_package(CUDAToolkit QUIET) + if (${CUDAToolkit_FOUND}) message(STATUS "[ LIBRAPID ] Using CUDA ${CUDAToolkit_VERSION}") From 11588d12f492307bdaa6be137e678b1ea1c7e4ad Mon Sep 17 00:00:00 2001 From: Toby Davis Date: Tue, 3 Oct 2023 17:48:25 +0100 Subject: [PATCH 10/10] Small correction --- .github/workflows/continuous-integration.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 513c698c..343f4327 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -187,6 +187,7 @@ jobs: cxx: ../llvm/clang++ clangVer: "15.0" blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -197,6 +198,7 @@ jobs: cxx: ../llvm/clang++ clangVer: "15.0" blas: on + getBlas: on fftw: on mpfr: on cpp: 20 @@ -207,6 +209,7 @@ jobs: cxx: ./llvm/clang++ clangVer: "15.0" blas: off + getBlas: off fftw: off mpfr: on cpp: 23 @@ -217,6 +220,7 @@ jobs: cxx: ./llvm/clang++ clangVer: "15.0" blas: on + getBlas: on fftw: on mpfr: on cpp: 23 @@ -226,6 +230,7 @@ jobs: cc: msvc cxx: msvc blas: off + getBlas: off fftw: off mpfr: on cpp: 20 @@ -235,6 +240,7 @@ jobs: cc: msvc cxx: msvc blas: on + getBlas: on fftw: on mpfr: on cpp: 20 @@ -244,6 +250,7 @@ jobs: cc: msvc cxx: msvc blas: off + getBlas: off fftw: off mpfr: on cpp: 23 @@ -253,6 +260,7 @@ jobs: cc: msvc cxx: msvc blas: on + getBlas: on fftw: on mpfr: on cpp: 23