[openblas] Revise, enable better cross builds (#42398)

This commit is contained in:
Kai Pastor 2024-12-06 21:00:23 +01:00 committed by GitHub
parent 9179239a21
commit 8a6bfb5abd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 476 additions and 307 deletions

View File

@ -9,7 +9,7 @@ SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)
# sometimes are unable.
#
# If we are on Windows and arm or uwp, that we use gfortran as our fortran compiler creates an issue
# because there is no available libgfortran. This means ew can't use lapack-reference at all.
# because there is no available libgfortran. This means we can't use lapack-reference at all.
#
# If we are on Windows and static, there is a linking problem caused by static gfortran in the same
# link as openblas, so we have to use the blas implementation from lapack-reference.

View File

@ -2,10 +2,9 @@
"$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!",
"name": "blas",
"version-date": "2023-04-14",
"port-version": 1,
"port-version": 2,
"description": "Metapackage for packages which provide BLAS",
"license": null,
"supports": "!(android & arm32) & !(android & x64)",
"dependencies": [
{
"name": "lapack-reference",

View File

@ -0,0 +1,21 @@
diff --git a/common_arm.h b/common_arm.h
index a3db995..5f45976 100644
--- a/common_arm.h
+++ b/common_arm.h
@@ -104,9 +104,16 @@ static inline int blas_quickdivide(blasint x, blasint y){
#if defined(ASSEMBLER) && !defined(NEEDPARAM)
+#if !defined(__APPLE__) && !defined(_WIN32)
+#define OPENBLAS_ARM_TYPE_FUNCTION .type REALNAME, %function ;
+#else
+#define OPENBLAS_ARM_TYPE_FUNCTION
+#endif
+
#define PROLOGUE \
.arm ;\
.global REALNAME ;\
+ OPENBLAS_ARM_TYPE_FUNCTION \
REALNAME:
#define EPILOGUE

View File

@ -0,0 +1,66 @@
# TARGET: The target architecture
#
# Originally, OpenBLAS tries to optimize for the host CPU unless
# - being given an explixit TARGET, and
# - CMAKE_CROSSCOMPILING, and
# - not building for uwp (aka WINDOWSSTORE)
# For this optimization, it runs 'getarch' and 'getarch_2nd' which it builds
# from source. The getarch executables are not built when not optimizing.
#
# Consequences:
# - The port must ensure that TARGET is set when cross compiling for a different CPU or OS.
# - The port must install getarch executables when possible.
#
# DYNAMIC_ARCH enables support "for multiple targets with runtime detection".
# (But not for MSVC, https://github.com/OpenMathLib/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio#cmake-and-visual-studio.)
# The OpenBLAS README.md suggests that this shall be used with TARGET being
# set "to the oldest model you expect to encounter". This affects "all the
# common code in the library".
set(need_target 0)
if(NOT "${TARGET}" STREQUAL "")
message(STATUS "TARGET: ${TARGET} (user-defined)")
elseif(DYNAMIC_ARCH)
message(STATUS "DYNAMIC_ARCH: ${DYNAMIC_ARCH}")
set(need_target 1) # for C
elseif(CMAKE_CROSSCOMPILING AND NOT GETARCH_BINARY_DIR)
set(need_target 1) # for C and for optimized kernel
else()
message(STATUS "TARGET: <native> (OpenBLAS getarch/getarch_2nd)")
endif()
if(need_target)
set(target_default "GENERIC")
if(MSVC)
# "does not support the dialect of assembly used in the cpu-specific optimized files"
# https://github.com/OpenMathLib/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio#cmake-and-visual-studio
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^x64|^x86")
set(target_default "ATOM")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^arm64")
set(target_default "ARMV8")
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")
set(target_default "ARMV7")
endif()
set(TARGET "${target_default}" CACHE STRING "")
message(STATUS "TARGET: ${TARGET}")
endif()
# NUM_THREADS: The number of threads expected to be used.
#
# This setting affects both the configuration with USE_THREAD enabled
# (multithreaded OpenBLAS) and disabled (multithreaded access to OpenBLAS).
# This shouldn't be set too low for generic packages. But it comes with a
# memory footprint.
if(DEFINED NUM_THREADS)
message(STATUS "NUM_THREADS: ${NUM_THREADS} (user-defined)")
elseif(EMSCRIPTEN)
message(STATUS "NUM_THREADS: <default> (for EMSCRIPTEN)")
elseif(need_target)
set(num_threads_default 24)
if(ANDROID OR IOS)
set(num_threads_default 8)
endif()
set(NUM_THREADS "${num_threads_default}" CACHE STRING "")
message(STATUS "NUM_THREADS: ${NUM_THREADS}")
endif()

View File

@ -0,0 +1,20 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2006604..c9fedb9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -323,6 +323,7 @@ if (USE_THREAD)
endif()
endif()
+if(BUILD_TESTING)
#if (MSVC OR NOT NOFORTRAN)
if (NOT NO_CBLAS)
if (NOT ONLY_CBLAS)
@@ -348,6 +349,7 @@ endif()
if (CPP_THREAD_SAFETY_TEST OR CPP_THREAD_SAFETY_GEMV)
add_subdirectory(cpp_thread_test)
endif()
+endif()
if (NOT FIXED_LIBNAME)
set_target_properties(${OpenBLAS_LIBS} PROPERTIES

View File

@ -1,28 +0,0 @@
diff --git a/openblas_config_template.h b/openblas_config_template.h
index 52dd49d..239219d 100644
--- a/openblas_config_template.h
+++ b/openblas_config_template.h
@@ -64,6 +64,7 @@ typedef int blasint;
#ifndef __cplusplus
#include <complex.h>
#endif
+ #ifndef OPENBLAS_COMPLEX_STRUCT
typedef float _Complex openblas_complex_float;
typedef double _Complex openblas_complex_double;
typedef xdouble _Complex openblas_complex_xdouble;
@@ -76,7 +77,9 @@ typedef int blasint;
#define openblas_complex_double_imag(z) (cimag(z))
#define openblas_complex_xdouble_real(z) (creal(z))
#define openblas_complex_xdouble_imag(z) (cimag(z))
+ #endif
#else
+ #ifndef OPENBLAS_COMPLEX_STRUCT
#define OPENBLAS_COMPLEX_STRUCT
typedef struct { float real, imag; } openblas_complex_float;
typedef struct { double real, imag; } openblas_complex_double;
@@ -90,4 +93,5 @@ typedef int blasint;
#define openblas_complex_double_imag(z) ((z).imag)
#define openblas_complex_xdouble_real(z) ((z).real)
#define openblas_complex_xdouble_imag(z) ((z).imag)
+ #endif
#endif

View File

@ -1,19 +0,0 @@
Index: cmake/system.cmake
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/cmake/system.cmake b/cmake/system.cmake
--- a/cmake/system.cmake (revision ce3f668c992cb3cc80849d5c30ed637f5adbd5b2)
+++ b/cmake/system.cmake (date 1718638483744)
@@ -160,6 +160,10 @@
endif ()
endif ()
+if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+ set(CCOMMON_OPT "${CCOMMON_OPT} -Wno-error=incompatible-pointer-types")
+endif ()
+
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
if (DEFINED TARGET)
if (${TARGET} STREQUAL COOPERLAKE AND NOT NO_AVX512)

View File

@ -0,0 +1,73 @@
diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake
index 609fbe2..daeb25c 100644
--- a/cmake/prebuild.cmake
+++ b/cmake/prebuild.cmake
@@ -95,7 +95,7 @@ else ()
endif ()
# Cannot run getarch on target if we are cross-compiling
-if (DEFINED CORE AND CMAKE_CROSSCOMPILING AND NOT (${HOST_OS} STREQUAL "WINDOWSSTORE"))
+if(CMAKE_CROSSCOMPILING AND NOT DEFINED GETARCH_BINARY_DIR)
# Write to config as getarch would
if (DEFINED TARGET_CORE)
set(TCORE ${TARGET_CORE})
@@ -1373,7 +1373,11 @@ endif ()
file(MAKE_DIRECTORY ${TARGET_CONF_DIR})
file(RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR}/${TARGET_CONF}")
-else(NOT CMAKE_CROSSCOMPILING)
+else()
+ if(NOT CMAKE_CROSSCOMPILING)
+ set(GETARCH_BINARY_DIR "${PROJECT_BINARY_DIR}")
+ endif()
+
# compile getarch
set(GETARCH_SRC
${PROJECT_SOURCE_DIR}/getarch.c
@@ -1420,6 +1424,7 @@ else(NOT CMAKE_CROSSCOMPILING)
if (NOT ${GETARCH_RESULT})
MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
endif ()
+ install(PROGRAMS "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" DESTINATION bin)
endif ()
unset (HAVE_AVX2)
unset (HAVE_AVX)
@@ -1439,8 +1444,8 @@ else(NOT CMAKE_CROSSCOMPILING)
message(STATUS "Running getarch")
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
+execute_process(COMMAND "${GETARCH_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
+execute_process(COMMAND "${GETARCH_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
@@ -1463,11 +1468,12 @@ execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE
if (NOT ${GETARCH2_RESULT})
MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
endif ()
+ install(PROGRAMS "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" DESTINATION bin)
endif ()
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
+execute_process(COMMAND "${GETARCH_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
+execute_process(COMMAND "${GETARCH_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
# append config data from getarch_2nd to the TARGET file and read in CMake vars
file(APPEND "${TARGET_CONF_TEMP}" ${GETARCH2_CONF_OUT})
diff --git a/cmake/system.cmake b/cmake/system.cmake
index eae7436..b2a6da7 100644
--- a/cmake/system.cmake
+++ b/cmake/system.cmake
@@ -13,7 +13,7 @@ if(CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET)
set(TARGET "ARMV8")
elseif(ARM)
set(TARGET "ARMV7") # TODO: Ask compiler which arch this is
- else()
+ elseif(NOT DEFINED GETARCH_BINARY_DIR)
message(FATAL_ERROR "When cross compiling, a TARGET is required.")
endif()
endif()

View File

@ -1,22 +0,0 @@
diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake
index 0c126e3..bb0124b 100644
--- a/cmake/prebuild.cmake
+++ b/cmake/prebuild.cmake
@@ -558,6 +558,8 @@ else(NOT CMAKE_CROSSCOMPILING)
if (NOT ${GETARCH_RESULT})
MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
endif ()
+
+ install(FILES "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" DESTINATION bin)
endif ()
unset (HAVE_AVX2)
unset (HAVE_AVX)
@@ -601,6 +603,8 @@ execute_process(COMMAND "${BLASHELPER_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIA
if (NOT ${GETARCH2_RESULT})
MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
endif ()
+
+ install(FILES "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" DESTINATION bin)
endif ()
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way

View File

@ -11,121 +11,73 @@ vcpkg_from_github(
SHA512 358301c8a60bedf920c07a110c772feb639e52412bd783789741fd2fd0686aac97e6b17ebcdf01ce48a2a15841058f82df0fee551af952f6e70b58140c055133
HEAD_REF develop
PATCHES
uwp.patch
fix-redefinition-function.patch
install-tools.patch
gcc14.patch
arm32-asm-function.diff
disable-testing.diff
getarch.diff
system-check-msvc.diff
win32-uwp.diff
${ARM64_WINDOWS_UWP_PATCH}
)
find_program(GIT NAMES git git.cmd)
# sed and awk are installed with git but in a different directory
get_filename_component(GIT_EXE_PATH "${GIT}" DIRECTORY)
set(SED_EXE_PATH "${GIT_EXE_PATH}/../usr/bin")
# openblas requires perl to generate .def for exports
vcpkg_find_acquire_program(PERL)
get_filename_component(PERL_EXE_PATH "${PERL}" DIRECTORY)
set(PATH_BACKUP "$ENV{PATH}")
vcpkg_add_to_path("${PERL_EXE_PATH}")
vcpkg_add_to_path("${SED_EXE_PATH}")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
vcpkg_check_features(OUT_FEATURE_OPTIONS OPTIONS
FEATURES
threads USE_THREAD
simplethread USE_SIMPLE_THREADED_LEVEL3
"dynamic-arch" DYNAMIC_ARCH
dynamic-arch DYNAMIC_ARCH
)
set(COMMON_OPTIONS -DBUILD_WITHOUT_LAPACK=ON)
if(VCPKG_TARGET_IS_OSX)
list(APPEND COMMON_OPTIONS -DONLY_CBLAS=1)
if("dynamic-arch" IN_LIST FEATURES)
set(conf_opts GENERATOR "Unix Makefiles")
endif()
# If not explicitly configured for a cross build, OpenBLAS wants to run
# getarch executables in order to optimize for the target.
# Adapting this to vcpkg triplets:
# - install-getarch.diff introduces and uses GETARCH_BINARY_DIR,
# - architecture and system name are required to match for GETARCH_BINARY_DIR, but
# - uwp (aka WindowsStore) may run windows getarch.
string(REPLACE "WindowsStore_" "_" SYSTEM_KEY "${VCPKG_CMAKE_SYSTEM_NAME}_${VCPKG_TARGET_ARCHITECTURE}")
set(GETARCH_BINARY_DIR "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}/${SYSTEM_KEY}")
if(EXISTS "${GETARCH_BINARY_DIR}")
message(STATUS "OpenBLAS cross build, but may use ${PORT}:${HOST_TRIPLET} getarch")
list(APPEND OPTIONS "-DGETARCH_BINARY_DIR=${GETARCH_BINARY_DIR}")
elseif(VCPKG_CROSSCOMPILING)
message(STATUS "OpenBLAS cross build, may not be able to use getarch")
else()
message(STATUS "OpenBLAS native build")
endif()
if(VCPKG_TARGET_IS_ANDROID)
list(APPEND COMMON_OPTIONS -DONLY_CBLAS=1)
endif()
set(OPENBLAS_EXTRA_OPTIONS)
# For UWP version, must build non-UWP first for helper binaries
if(VCPKG_TARGET_IS_UWP)
list(APPEND OPENBLAS_EXTRA_OPTIONS "-DBLASHELPER_BINARY_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
elseif(NOT (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW))
string(APPEND VCPKG_C_FLAGS " -DNEEDBUNDERSCORE") # Required to get common BLASFUNC to append extra _
string(APPEND VCPKG_CXX_FLAGS " -DNEEDBUNDERSCORE")
list(APPEND OPENBLAS_EXTRA_OPTIONS
-DNOFORTRAN=ON
-DBU=_ # Required for all BLAS functions to append extra _ using NAME
)
endif()
if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND OPENBLAS_EXTRA_OPTIONS -DCORE=GENERIC)
endif()
# For emscripten only the riscv64 kernel with riscv64_generic target is supported
if(VCPKG_TARGET_IS_EMSCRIPTEN)
list(APPEND OPENBLAS_EXTRA_OPTIONS
-DEMSCRIPTEN_SYSTEM_PROCESSOR=riscv64
-DTARGET=RISCV64_GENERIC)
# Only the riscv64 kernel with riscv64_generic target is supported.
# Cf. https://github.com/OpenMathLib/OpenBLAS/issues/3640#issuecomment-1144029630 et al.
list(APPEND OPTIONS
-DEMSCRIPTEN_SYSTEM_PROCESSOR=riscv64
-DTARGET=RISCV64_GENERIC
)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
${conf_opts}
OPTIONS
${FEATURE_OPTIONS}
${COMMON_OPTIONS}
${OPENBLAS_EXTRA_OPTIONS}
${OPTIONS}
-DCMAKE_POLICY_DEFAULT_CMP0054=NEW
"-DCMAKE_PROJECT_INCLUDE=${CURRENT_PORT_DIR}/cmake-project-include.cmake"
-DBUILD_TESTING=OFF
-DBUILD_WITHOUT_LAPACK=ON
-DNOFORTRAN=ON
MAYBE_UNUSED_VARIABLES
GETARCH_BINARY_DIR
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/OpenBLAS)
if (EXISTS "${CURRENT_PACKAGES_DIR}/bin/getarch${VCPKG_HOST_EXECUTABLE_SUFFIX}")
vcpkg_copy_tools(TOOL_NAMES getarch AUTO_CLEAN)
endif()
if (EXISTS "${CURRENT_PACKAGES_DIR}/bin/getarch_2nd${VCPKG_HOST_EXECUTABLE_SUFFIX}")
vcpkg_copy_tools(TOOL_NAMES getarch_2nd AUTO_CLEAN)
endif()
set(ENV{PATH} "${PATH_BACKUP}")
set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/openblas.pc")
if(EXISTS "${pcfile}")
file(READ "${pcfile}" _contents)
set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}")
file(WRITE "${pcfile}" "${_contents}")
#file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc" COPY_ON_ERROR)
endif()
set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/openblas.pc")
if(EXISTS "${pcfile}")
file(READ "${pcfile}" _contents)
set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}")
file(WRITE "${pcfile}" "${_contents}")
#file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc" COPY_ON_ERROR)
endif()
vcpkg_fixup_pkgconfig()
# Maybe we need also to write a wrapper inside share/blas to search implicitly for openblas,
# whenever we feel it's ready for its own -config.cmake file.
# openblas does not have a config file, so I manually made this.
# But I think in most cases, libraries will not include these files, they define their own used function prototypes.
# This is only to quite vcpkg.
file(COPY "${CMAKE_CURRENT_LIST_DIR}/openblas_common.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
vcpkg_replace_string(
"${SOURCE_PATH}/cblas.h"
"#include \"common.h\""
"#include \"openblas_common.h\""
)
# Required from native builds, optional from cross builds.
if(NOT VCPKG_CROSSCOMPILING OR EXISTS "${CURRENT_PACKAGES_DIR}/bin/getarch${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
vcpkg_copy_tools(
TOOL_NAMES getarch getarch_2nd
DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}/${SYSTEM_KEY}"
AUTO_CLEAN
)
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

View File

@ -0,0 +1,21 @@
diff --git a/cmake/system_check.cmake b/cmake/system_check.cmake
index e94497a..d884727 100644
--- a/cmake/system_check.cmake
+++ b/cmake/system_check.cmake
@@ -36,6 +36,16 @@ if(CMAKE_CL_64 OR MINGW64)
else()
set(X86_64 1)
endif()
+elseif(MSVC)
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ set(X86_64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM")
+ set(ARM 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
+ set(ARM64 1)
+ else()
+ set(X86 1)
+ endif()
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
set(X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc.*|power.*|Power.*" OR (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc.*"))

View File

@ -1,85 +0,0 @@
diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake
index 730555a..1b09e00 100644
--- a/cmake/prebuild.cmake
+++ b/cmake/prebuild.cmake
@@ -39,6 +39,9 @@
# CPUIDEMU = ../../cpuid/table.o
+if (NOT DEFINED BLASHELPER_BINARY_DIR)
+ set(BLASHELPER_BINARY_DIR "${PROJECT_BINARY_DIR}")
+endif ()
if (DEFINED CPUIDEMU)
set(EXFLAGS "-DCPUIDEMU -DVENDOR=99")
@@ -1401,8 +1404,8 @@ else(NOT CMAKE_CROSSCOMPILING)
message(STATUS "Running getarch")
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
+execute_process(COMMAND "${BLASHELPER_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
+execute_process(COMMAND "${BLASHELPER_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
@@ -1430,8 +1433,8 @@ execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE
endif ()
# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
-execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
+execute_process(COMMAND "${BLASHELPER_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
+execute_process(COMMAND "${BLASHELPER_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
# append config data from getarch_2nd to the TARGET file and read in CMake vars
file(APPEND "${TARGET_CONF_TEMP}" ${GETARCH2_CONF_OUT})
diff --git a/cmake/system.cmake b/cmake/system.cmake
index 631e7fe..83220ce 100644
--- a/cmake/system.cmake
+++ b/cmake/system.cmake
@@ -13,6 +13,9 @@ if(CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET)
set(TARGET "ARMV8")
elseif(ARM)
set(TARGET "ARMV7") # TODO: Ask compiler which arch this is
+ elseif(${HOST_OS} STREQUAL "WINDOWSSTORE")
+ set(CMAKE_CROSSCOMPILING 0)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
else()
message(FATAL_ERROR "When cross compiling, a TARGET is required.")
endif()
diff --git a/common_stackalloc.h b/common_stackalloc.h
index d3d5466..cd157fc 100644
--- a/common_stackalloc.h
+++ b/common_stackalloc.h
@@ -36,7 +36,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define STACK_ALLOC_PROTECT_CHECK
#endif
-#if defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0
+#if defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0 && !(defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP))
/*
* Allocate a buffer on the stack if the size is smaller than MAX_STACK_ALLOC.
@@ -63,7 +63,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
-#if defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0
+#if defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0 && !(defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP))
#define STACK_FREE(BUFFER) \
STACK_ALLOC_PROTECT_CHECK \
if(!stack_alloc_size) \
diff --git a/interface/zgemv.c b/interface/zgemv.c
index 3e98dba..ee597f7 100644
--- a/interface/zgemv.c
+++ b/interface/zgemv.c
@@ -244,7 +244,7 @@ void CNAME(enum CBLAS_ORDER order,
buffer_size = (buffer_size + 3) & ~3;
STACK_ALLOC(buffer_size, FLOAT, buffer);
-#if defined(ARCH_X86_64) && defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0
+#if defined(ARCH_X86_64) && defined(MAX_STACK_ALLOC) && MAX_STACK_ALLOC > 0 && !(defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP))
// cgemv_t.S return NaN if there are NaN or Inf in the buffer (see bug #746)
if(trans && stack_alloc_size)
memset(buffer, 0, MIN(BUFFER_SIZE, sizeof(FLOAT) * buffer_size));

View File

@ -1,19 +1,15 @@
{
"name": "openblas",
"version": "0.3.28",
"port-version": 1,
"description": "OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.",
"homepage": "https://github.com/OpenMathLib/OpenBLAS",
"license": "BSD-3-Clause",
"supports": "!arm | arm64 | !uwp",
"dependencies": [
{
"name": "openblas",
"host": true
},
{
"name": "pthread",
"platform": "!windows & !uwp"
},
{
"name": "vcpkg-cmake",
"host": true
@ -29,7 +25,10 @@
"supports": "!windows | mingw"
},
"simplethread": {
"description": "Use simple thread",
"description": [
"Use simple thread safety for level3 functions",
"Alternative to serialization of concurrent access to parallelized level3 functions."
],
"dependencies": [
{
"name": "openblas",
@ -40,11 +39,11 @@
]
},
"threads": {
"description": "Use a threading backend",
"description": "Enable multi-threading",
"dependencies": [
{
"name": "pthread",
"platform": "!windows & !uwp"
"name": "pthreads",
"platform": "!windows"
}
]
}

View File

@ -0,0 +1,67 @@
diff --git a/cmake/os.cmake b/cmake/os.cmake
index 2effbe0..538ede2 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -18,7 +18,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
endif ()
# TODO: this is probably meant for mingw, not other windows compilers
-if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (WIN32)
set(NEED_PIC 0)
set(NO_EXPRECISION 1)
@@ -69,7 +69,7 @@ if (CYGWIN)
set(NO_EXPRECISION 1)
endif ()
-if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Interix" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
+if (NOT WIN32 AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Interix" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
if (USE_THREAD)
set(EXTRALIB "${EXTRALIB} -lpthread")
endif ()
diff --git a/cmake/system.cmake b/cmake/system.cmake
index 683c318..eae7436 100644
--- a/cmake/system.cmake
+++ b/cmake/system.cmake
@@ -502,7 +502,7 @@ if (USE_SIMPLE_THREADED_LEVEL3)
set(CCOMMON_OPT "${CCOMMON_OPT} -DUSE_SIMPLE_THREADED_LEVEL3")
endif ()
-if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (NOT WIN32)
if (DEFINED MAX_STACK_ALLOC)
if (NOT ${MAX_STACK_ALLOC} EQUAL 0)
set(CCOMMON_OPT "${CCOMMON_OPT} -DMAX_STACK_ALLOC=${MAX_STACK_ALLOC}")
@@ -511,7 +511,7 @@ else ()
set(CCOMMON_OPT "${CCOMMON_OPT} -DMAX_STACK_ALLOC=2048")
endif ()
endif ()
-if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (NOT WIN32)
if (DEFINED BLAS3_MEM_ALLOC_THRESHOLD)
if (NOT ${BLAS3_MEM_ALLOC_THRESHOLD} EQUAL 32)
set(CCOMMON_OPT "${CCOMMON_OPT} -DBLAS3_MEM_ALLOC_THRESHOLD=${BLAS3_MEM_ALLOC_THRESHOLD}")
@@ -628,7 +628,7 @@ endif()
set(LAPACK_FPFLAGS "${LAPACK_FPFLAGS} ${FPFLAGS}")
#Disable -fopenmp for LAPACK Fortran codes on Windows.
-if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (WIN32)
set(FILTER_FLAGS "-fopenmp;-mp;-openmp;-xopenmp=parallel")
foreach (FILTER_FLAG ${FILTER_FLAGS})
string(REPLACE ${FILTER_FLAG} "" LAPACK_FFLAGS ${LAPACK_FFLAGS})
@@ -660,11 +660,11 @@ if (INTERFACE64)
set(LAPACK_CFLAGS "${LAPACK_CFLAGS} -DLAPACK_ILP64")
endif ()
-if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (WIN32)
set(LAPACK_CFLAGS "${LAPACK_CFLAGS} -DOPENBLAS_OS_WINDOWS")
endif ()
-if (${CMAKE_C_COMPILER} STREQUAL "LSB" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+if (${CMAKE_C_COMPILER} STREQUAL "LSB" OR WIN32)
set(LAPACK_CFLAGS "${LAPACK_CFLAGS} -DLAPACK_COMPLEX_STRUCTURE")
endif ()

View File

@ -85,50 +85,53 @@ bit7z:arm-neon-android=fail
################################################################
# <BLAS+LAPACK>
# These skips need to match the decision tree for which backends we use; see ports/blas/portfile.cmake
blas-test:x86-windows=pass # openblas
vcpkg-ci-blas:x86-windows=pass # openblas
lapack-test:x86-windows=pass # lapack-reference[noblas]
blas-test:x64-windows=pass # openblas
vcpkg-ci-blas:x64-windows=pass # openblas
lapack-test:x64-windows=pass # lapack-reference[noblas]
blas-test:x64-windows-static=pass # lapack-reference[blas]
vcpkg-ci-blas:x64-windows-static=pass # lapack-reference[blas]
lapack-test:x64-windows-static=pass # lapack-reference[blas]
blas-test:x64-windows-static-md=pass # lapack-reference[blas]
vcpkg-ci-blas:x64-windows-static-md=pass # lapack-reference[blas]
lapack-test:x64-windows-static-md=pass # lapack-reference[blas]
blas-test:x64-uwp=pass # openblas
vcpkg-ci-blas:x64-uwp=pass # openblas
lapack-test:x64-uwp=pass # clapack
blas-test:arm64-windows=pass # openblas
vcpkg-ci-blas:arm64-windows=pass # openblas
lapack-test:arm64-windows=pass # clapack
blas-test:arm64-windows-static-md=pass # openblas
vcpkg-ci-blas:arm64-windows-static-md=pass # openblas
lapack-test:arm64-windows-static-md=pass # clapack
blas-test:arm64-uwp=pass # openblas
vcpkg-ci-blas:arm64-uwp=pass # openblas
lapack-test:arm64-uwp=pass # clapack
blas-test:x64-osx=pass # accelerate framework
vcpkg-ci-blas:x64-osx=pass # accelerate framework
lapack-test:x64-osx=pass # accelerate framework
blas-test:arm64-osx=pass # accelerate framework
vcpkg-ci-blas:arm64-osx=pass # accelerate framework
lapack-test:arm64-osx=pass # accelerate framework
blas-test:x64-linux=pass # openblas
vcpkg-ci-blas:x64-linux=pass # openblas
lapack-test:x64-linux=pass # lapack-reference[noblas]
blas-test:arm64-android=pass # openblas
vcpkg-ci-blas:arm64-android=pass # openblas
clapack:arm-neon-android=fail
clapack:arm64-android=fail
clapack:arm64-osx=skip
clapack:x64-android=fail
clapack:x64-linux=skip
clapack:x64-osx=skip
clapack:x64-windows-static-md=skip
clapack:x64-windows-static=skip
clapack:x64-windows=skip
clapack:x86-windows=skip
lapack-reference:arm-neon-android=fail
lapack-reference:arm64-android=fail
lapack-reference:arm64-osx=skip
lapack-reference:arm64-uwp=skip
lapack-reference:arm64-windows=skip
lapack-reference:arm64-windows-static-md=skip
lapack-reference:x64-android=fail
lapack-reference:x64-osx=skip
lapack-reference:x64-uwp=skip
openblas:arm64-osx=skip
openblas:x64-android=fail
openblas:x64-osx=skip
openblas:x64-windows-static-md=skip
openblas:x64-windows-static=skip
#openblas:arm64-osx=skip
#openblas:x64-osx=skip
#openblas:x64-windows-static-md=skip
#openblas:x64-windows-static=skip
# </BLAS+LAPACK>
################################################################
blitz:x64-android=fail

View File

@ -1,6 +0,0 @@
cmake_minimum_required(VERSION 3.17)
project(Find_BLAS_external)
find_package(BLAS REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(BLAS_PC REQUIRED IMPORTED_TARGET blas)

View File

@ -1,5 +0,0 @@
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)
# Make sure BLAS can be found
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}"
OPTIONS -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET})

View File

@ -1,19 +0,0 @@
{
"$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!",
"name": "blas-test",
"version-date": "2022-04-22",
"description": "Metapackage for packages which provide BLAS",
"license": null,
"dependencies": [
"blas",
{
"name": "pkgconf",
"host": true,
"platform": "windows"
},
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -0,0 +1,10 @@
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()

View File

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.18) # for BLAS::BLAS
project(vcpkg-ci-blas C)
find_package(BLAS REQUIRED)
add_executable(fortran-interface main.c)
target_link_libraries(fortran-interface PRIVATE BLAS::BLAS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(BLAS_PC REQUIRED IMPORTED_TARGET blas)
add_executable(fortran-interface-pc main.c)
target_link_libraries(fortran-interface-pc PRIVATE PkgConfig::BLAS_PC)

View File

@ -0,0 +1,17 @@
extern void dgemm_(char*, char*, int*, int*,int*, double*, double*, int*, double*, int*, double*, double*, int*);
int main()
{
char ta = 'N';
char tb = 'N';
int m = 2;
int n = 2;
int k = 1;
double alpha = 0.5;
double A[2] = {1.0, 2.0}; // m x k
double B[2] = {3.0, 4.0}; // k x n
double beta = 0.05;
double C[4] = {100.0, 200.0, 300.0, 400.0}; // 2 x 2
dgemm_(&ta, &tb, &m, &n, &k, &alpha, A, &m, B, &k, &beta, C, &m);
return 0;
}

View File

@ -0,0 +1,13 @@
{
"name": "vcpkg-ci-blas",
"version-string": "ci",
"description": "Testing packages which provide BLAS",
"license": null,
"dependencies": [
"blas",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -0,0 +1,4 @@
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project")
vcpkg_cmake_build()

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(vcpkg-ci-openblas C)
find_package(OpenBLAS CONFIG REQUIRED)
add_executable(fortran-interface main.c)
target_link_libraries(fortran-interface PRIVATE OpenBLAS::OpenBLAS)

View File

@ -0,0 +1,19 @@
#include <../openblas/cblas.h> /* check for header. */
extern void dgemm_(char*, char*, int*, int*,int*, double*, double*, int*, double*, int*, double*, double*, int*);
int main()
{
char ta = 'N';
char tb = 'N';
int m = 2;
int n = 2;
int k = 1;
double alpha = 0.5;
double A[2] = {1.0, 2.0}; // m x k
double B[2] = {3.0, 4.0}; // k x n
double beta = 0.05;
double C[4] = {100.0, 200.0, 300.0, 400.0}; // 2 x 2
dgemm_(&ta, &tb, &m, &n, &k, &alpha, A, &m, B, &k, &beta, C, &m);
return 0;
}

View File

@ -0,0 +1,37 @@
{
"name": "vcpkg-ci-openblas",
"version-string": "ci",
"description": "Test openblas",
"license": null,
"dependencies": [
"openblas",
{
"name": "vcpkg-cmake",
"host": true
}
],
"default-features": [
"all"
],
"features": {
"all": {
"description": "Test (mostly) everything",
"dependencies": [
{
"name": "openblas",
"features": [
"dynamic-arch"
],
"platform": "linux"
},
{
"name": "openblas",
"features": [
"threads"
],
"platform": "!windows"
}
]
}
}
}

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b5910f73b446a5f52ca520bafd134f3360b1698f",
"version-date": "2023-04-14",
"port-version": 2
},
{
"git-tree": "996094c62f01e190855a43a036b6ec2e10375bd9",
"version-date": "2023-04-14",

View File

@ -694,7 +694,7 @@
},
"blas": {
"baseline": "2023-04-14",
"port-version": 1
"port-version": 2
},
"blaze": {
"baseline": "3.8.2",
@ -6626,7 +6626,7 @@
},
"openblas": {
"baseline": "0.3.28",
"port-version": 0
"port-version": 1
},
"opencascade": {
"baseline": "7.8.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "73b8d762190120c2155870da8e148f307d9a4294",
"version": "0.3.28",
"port-version": 1
},
{
"git-tree": "0ea117557042e4d6a0ee7659828c44938e322ee3",
"version": "0.3.28",