list(APPEND FLOAT_TYPES "ZCOMPLEX") # defines COMPLEX and DOUBLE
endif ()
-set(SUBDIRS_ALL ${SUBDIRS} test ctest utest exports benchmark ../laswp ../bench)
-
-# all :: libs netlib tests shared
-
-# libs :
if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN")
message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.")
endif ()
# Only generate .def for dll on MSVC and always produce pdb files for debug and release
if(MSVC)
set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
endif()
-#ifeq ($(DYNAMIC_ARCH), 1)
-# @$(MAKE) -C kernel commonlibs || exit 1
-# @for d in $(DYNAMIC_CORE) ; \
-# do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
-# done
-# @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
-#endif
if (${DYNAMIC_ARCH})
add_subdirectory(kernel)
foreach(TARGET_CORE ${DYNAMIC_CORE})
SOVERSION ${OpenBLAS_MAJOR_VERSION}
)
-
-# TODO: Why is the config saved here? Is this necessary with CMake?
-#Save the config files for installation
-# @cp Makefile.conf Makefile.conf_last
-# @cp config.h config_last.h
-#ifdef QUAD_PRECISION
-# @echo "#define QUAD_PRECISION">> config_last.h
-#endif
-#ifeq ($(EXPRECISION), 1)
-# @echo "#define EXPRECISION">> config_last.h
-#endif
-###
-
-#ifdef USE_THREAD
-# @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
-#endif
-# @touch lib.grd
-
# Install project
# Install libraries
## Description: Ported from portion of OpenBLAS/Makefile.system
## Sets various variables based on architecture.
-if (${ARCH} STREQUAL "x86" OR ${ARCH} STREQUAL "x86_64")
+if (X86 OR X86_64)
- if (${ARCH} STREQUAL "x86")
+ if (X86)
if (NOT BINARY)
set(NO_BINARY_MODE 1)
endif ()
if (DYNAMIC_ARCH)
- if (${ARCH} STREQUAL "x86")
+ if (X86)
set(DYNAMIC_CORE KATMAI COPPERMINE NORTHWOOD PRESCOTT BANIAS CORE2 PENRYN DUNNINGTON NEHALEM ATHLON OPTERON OPTERON_SSE3 BARCELONA BOBCAT ATOM NANO)
endif ()
- if (${ARCH} STREQUAL "x86_64")
+ if (X86_64)
set(DYNAMIC_CORE PRESCOTT CORE2 PENRYN DUNNINGTON NEHALEM OPTERON OPTERON_SSE3 BARCELONA BOBCAT ATOM NANO)
if (NOT NO_AVX)
set(DYNAMIC_CORE ${DYNAMIC_CORE} SANDYBRIDGE BULLDOZER PILEDRIVER STEAMROLLER EXCAVATOR)
endif ()
endif ()
-if (${ARCH} STREQUAL "mips64")
+if (MIPS64)
set(NO_BINARY_MODE 1)
endif ()
set(BINARY_DEFINED 1)
endif ()
-if (${ARCH} STREQUAL "arm")
+if (ARM)
set(NO_BINARY_MODE 1)
set(BINARY_DEFINED 1)
endif ()
-if (${ARCH} STREQUAL "arm64")
+if (ARM64)
set(NO_BINARY_MODE 1)
set(BINARY_DEFINED 1)
endif ()
if (NO_BINARY_MODE)
- if (${ARCH} STREQUAL "mips64")
+ if (MIPS64)
if (BINARY64)
set(CCOMMON_OPT "${CCOMMON_OPT} -mabi=64")
else ()
set(BINARY_DEFINED 1)
endif ()
- if (${CORE} STREQUAL "LOONGSON3A")
+ if (${CORE} STREQUAL "LOONGSON3A" OR ${CORE} STREQUAL "LOONGSON3B")
set(CCOMMON_OPT "${CCOMMON_OPT} -march=mips64")
set(FCOMMON_OPT "${FCOMMON_OPT} -march=mips64")
endif ()
- if (${CORE} STREQUAL "LOONGSON3B")
- set(CCOMMON_OPT "${CCOMMON_OPT} -march=mips64")
- set(FCOMMON_OPT "${FCOMMON_OPT} -march=mips64")
- endif ()
-
- if (${OSNAME} STREQUAL "AIX")
+ if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(BINARY_DEFINED 1)
endif ()
endif ()
if (${CMAKE_C_COMPILER} STREQUAL "OPEN64")
- if (${ARCH} STREQUAL "mips64")
+ if (MIPS64)
if (NOT BINARY64)
set(CCOMMON_OPT "${CCOMMON_OPT} -n32")
if (${CMAKE_C_COMPILER} STREQUAL "SUN")
set(CCOMMON_OPT "${CCOMMON_OPT} -w")
- if (${ARCH} STREQUAL "x86")
+ if (X86)
set(CCOMMON_OPT "${CCOMMON_OPT} -m32")
else ()
- set(FCOMMON_OPT "${FCOMMON_OPT} -m64")
+ set(CCOMMON_OPT "${CCOMMON_OPT} -m64")
endif ()
endif ()
set(EXTRALIB "{EXTRALIB} -lgfortran")
endif ()
if (NO_BINARY_MODE)
- if (${ARCH} STREQUAL "mips64")
+ if (MIPS64)
if (BINARY64)
set(FCOMMON_OPT "${FCOMMON_OPT} -mabi=64")
else ()
endif ()
endif ()
- if (NOT ${ARCH} STREQUAL "mips64")
+ if (NOT MIPS64)
if (NOT BINARY64)
set(FCOMMON_OPT "${FCOMMON_OPT} -m32")
else ()
endif ()
endif ()
- if (${ARCH} STREQUAL "mips64")
+ if (MIPS64)
if (NOT BINARY64)
set(FCOMMON_OPT "${FCOMMON_OPT} -n32")
if (${F_COMPILER} STREQUAL "SUN")
set(CCOMMON_OPT "${CCOMMON_OPT} -DF_INTERFACE_SUN")
- if (${ARCH} STREQUAL "x86")
+ if (X86)
set(FCOMMON_OPT "${FCOMMON_OPT} -m32")
else ()
set(FCOMMON_OPT "${FCOMMON_OPT} -m64")
# Ensure the correct stack alignment on Win32
# http://permalink.gmane.org/gmane.comp.lib.openblas.general/97
- if (${ARCH} STREQUAL "x86")
+ if (X86)
if (NOT MSVC AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(CCOMMON_OPT "${CCOMMON_OPT} -mincoming-stack-boundary=2")
endif ()
set(NO_EXPRECISION 1)
endif ()
-if (${ARCH} STREQUAL "x86")
+if (X86)
set(NO_EXPRECISION 1)
endif ()
endif ()
set(TARGET_CONF_TEMP "${PROJECT_BINARY_DIR}/${TARGET_CONF}.tmp")
-include("${PROJECT_SOURCE_DIR}/cmake/c_check.cmake")
+# c_check
+set(FU "")
+if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
+ set(FU "_")
+endif()
+
+set(COMPILER_ID ${CMAKE_C_COMPILER_ID})
+if (${COMPILER_ID} STREQUAL "GNU")
+ set(COMPILER_ID "GCC")
+endif ()
+
+string(TOUPPER ${ARCH} UC_ARCH)
+
+file(WRITE ${TARGET_CONF_TEMP}
+ "#define OS_${HOST_OS}\t1\n"
+ "#define ARCH_${UC_ARCH}\t1\n"
+ "#define C_${COMPILER_ID}\t1\n"
+ "#define __${BINARY}BIT__\t1\n"
+ "#define FUNDERSCORE\t${FU}\n")
+
+if (${HOST_OS} STREQUAL "WINDOWSSTORE")
+ file(APPEND ${TARGET_CONF_TEMP}
+ "#define OS_WINNT\t1\n")
+endif ()
+
+# f_check
if (NOT NOFORTRAN)
include("${PROJECT_SOURCE_DIR}/cmake/f_check.cmake")
endif ()
-# This check requires c_check for arch but it should probably be done earlier
-if(CMAKE_CROSSCOMPILING AND NOT DEFINED CORE)
- # Detect target without running getarch
- if(ARM64)
- set(CORE "ARMV8")
- else()
- message(FATAL_ERROR "When cross compiling, a CORE is required.")
- endif()
-endif()
-
# Cannot run getarch on target if we are cross-compiling
if (DEFINED CORE AND CMAKE_CROSSCOMPILING)
# Write to config as getarch would
file(APPEND ${TARGET_CONF_TEMP}
"#define ${CORE}\n"
"#define CHAR_CORENAME \"${CORE}\"\n")
- if ("${CORE}" STREQUAL "ARMV8")
+ if ("${CORE}" STREQUAL "ARMV7")
+ file(APPEND ${TARGET_CONF_TEMP}
+ "#define L1_DATA_SIZE\t65536\n"
+ "#define L1_DATA_LINESIZE\t32\n"
+ "#define L2_SIZE\t512488\n"
+ "#define L2_LINESIZE\t32\n"
+ "#define DTB_DEFAULT_ENTRIES\t64\n"
+ "#define DTB_SIZE\t4096\n"
+ "#define L2_ASSOCIATIVE\t4\n"
+ "#define HAVE_VFPV3\n"
+ "#define HAVE_VFP\n")
+ set(SGEMM_UNROLL_M 4)
+ set(SGEMM_UNROLL_N 4)
+ set(DGEMM_UNROLL_M 4)
+ set(DGEMM_UNROLL_N 4)
+ elseif ("${CORE}" STREQUAL "ARMV8")
file(APPEND ${TARGET_CONF_TEMP}
"#define L1_DATA_SIZE\t32768\n"
"#define L1_DATA_LINESIZE\t64\n"
##
set(NETLIB_LAPACK_DIR "${PROJECT_SOURCE_DIR}/lapack-netlib")
+# System detection, via CMake.
+include("${PROJECT_SOURCE_DIR}/cmake/system_check.cmake")
+
+if(CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET)
+ # Detect target without running getarch
+ if (ARM64)
+ set(TARGET "ARMV8")
+ elseif(ARM)
+ set(TARGET "ARMV7") # TODO: Ask compiler which arch this is
+ else()
+ message(FATAL_ERROR "When cross compiling, a TARGET is required.")
+ endif()
+endif()
+
+# Other files expect CORE, which is actually TARGET and will become TARGET_CORE for kernel build. Confused yet?
+# It seems we are meant to use TARGET as input and CORE internally as kernel.
+if(NOT DEFINED CORE AND DEFINED TARGET)
+ set(CORE ${TARGET})
+endif()
+
# TARGET_CORE will override TARGET which is used in DYNAMIC_ARCH=1.
if (DEFINED TARGET_CORE)
set(TARGET ${TARGET_CORE})
endif ()
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_PARALLEL_MAKE=${NO_PARALLEL_MAKE}")
-if (CMAKE_CXX_COMPILER STREQUAL loongcc)
+if (CMAKE_C_COMPILER STREQUAL loongcc)
set(GETARCH_FLAGS "${GETARCH_FLAGS} -static")
endif ()
endif()
if (NOT NUM_CORES EQUAL 0)
+ # HT?
set(NUM_THREADS ${NUM_CORES})
endif ()
endif()
set(CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX")
endif ()
-if (${ARCH} STREQUAL "x86")
+if (X86)
set(CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX")
endif ()
# NO_AFFINITY = 1
set(CCOMMON_OPT "${CCOMMON_OPT} -DSMP_SERVER")
- if (${ARCH} STREQUAL "mips64")
+ if (MIPS64)
if (NOT ${CORE} STREQUAL "LOONGSON3B")
set(USE_SIMPLE_THREADED_LEVEL3 1)
endif ()
set(NO_AFFINITY 1)
endif ()
-if (NOT ${ARCH} STREQUAL "x86_64" AND NOT ${ARCH} STREQUAL "x86" AND NOT ${CORE} STREQUAL "LOONGSON3B")
+if (NOT X86_64 AND NOT X86 AND NOT ${CORE} STREQUAL "LOONGSON3B")
set(NO_AFFINITY 1)
endif ()
set(USE_GEMM3M 0)
if (DEFINED ARCH)
- if (${ARCH} STREQUAL "x86" OR ${ARCH} STREQUAL "x86_64" OR ${ARCH} STREQUAL "ia64" OR ${ARCH} STREQUAL "MIPS")
+ if (X86 OR X86_64 OR ${ARCH} STREQUAL "ia64" OR MIPS64)
set(USE_GEMM3M 1)
endif ()
# export CUFLAGS
# export CULIB
#endif
-
-#.SUFFIXES: .$(PSUFFIX) .$(SUFFIX) .f
-#
-#.f.$(SUFFIX):
-# $(FC) $(FFLAGS) -c $< -o $(@F)
-#
-#.f.$(PSUFFIX):
-# $(FC) $(FPFLAGS) -pg -c $< -o $(@F)
-
-# these are not cross-platform
-#ifdef BINARY64
-#PATHSCALEPATH = /opt/pathscale/lib/3.1
-#PGIPATH = /opt/pgi/linux86-64/7.1-5/lib
-#else
-#PATHSCALEPATH = /opt/pathscale/lib/3.1/32
-#PGIPATH = /opt/pgi/linux86/7.1-5/lib
-#endif
-
-#ACMLPATH = /opt/acml/4.3.0
-#ifneq ($(OSNAME), Darwin)
-#MKLPATH = /opt/intel/mkl/10.2.2.025/lib
-#else
-#MKLPATH = /Library/Frameworks/Intel_MKL.framework/Versions/10.0.1.014/lib
-#endif
-#ATLASPATH = /opt/atlas/3.9.17/opteron
-#FLAMEPATH = $(HOME)/flame/lib
-#ifneq ($(OSNAME), SunOS)
-#SUNPATH = /opt/sunstudio12.1
-#else
-#SUNPATH = /opt/SUNWspro
-#endif
-
## This is triggered by prebuild.cmake and runs before any of the code is built.
## Creates config.h and Makefile.conf.
-# CMake vars set by this file:
-# OSNAME (use CMAKE_SYSTEM_NAME)
-# ARCH
-# C_COMPILER (use CMAKE_C_COMPILER)
-# BINARY32
-# BINARY64
-# FU
-# CROSS_SUFFIX
-# CROSS
-# CEXTRALIB
-
-# Defines set by this file:
-# OS_
-# ARCH_
-# C_
-# __32BIT__
-# __64BIT__
-# FUNDERSCORE
-# PTHREAD_CREATE_FUNC
-
-# N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
-set(FU "")
-if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
- set(FU "_")
-endif()
-
# Convert CMake vars into the format that OpenBLAS expects
string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS)
if (${HOST_OS} STREQUAL "WINDOWS")
endif ()
if(CMAKE_COMPILER_IS_GNUCC AND WIN32)
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE OPENBLAS_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(OPENBLAS_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
set(X86_64 1)
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
set(X86 1)
-elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc.*|power.*|Power.*")
set(PPC 1)
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "mips64.*")
+ set(MIPS64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
set(X86_64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
endif ()
if (NOT BINARY)
- if (X86_64 OR ARM64 OR PPC OR ARCH STREQUAL "mips64")
+ if (X86_64 OR ARM64 OR PPC OR MIPS64)
set(BINARY 64)
else ()
set(BINARY 32)
set(BINARY32 1)
endif()
-set(COMPILER_ID ${CMAKE_C_COMPILER_ID})
-if (${COMPILER_ID} STREQUAL "GNU")
- set(COMPILER_ID "GCC")
-endif ()
-
-string(TOUPPER ${ARCH} UC_ARCH)
-
-file(WRITE ${TARGET_CONF_TEMP}
- "#define OS_${HOST_OS}\t1\n"
- "#define ARCH_${UC_ARCH}\t1\n"
- "#define C_${COMPILER_ID}\t1\n"
- "#define __${BINARY}BIT__\t1\n"
- "#define FUNDERSCORE\t${FU}\n")
-
-if (${HOST_OS} STREQUAL "WINDOWSSTORE")
- file(APPEND ${TARGET_CONF_TEMP}
- "#define OS_WINNT\t1\n")
-endif ()
-
endif ()
if (${ADD_COMMONOBJS})
- if (${ARCH} STREQUAL "x86")
+ if (X86)
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
GenerateNamedObjects("${KERNELDIR}/cpuid.S" "" "" false "" "" true)
else()
# Makefile.L3
set(USE_TRMM false)
- if (${ARCH} STREQUAL "arm" OR ${ARCH} STREQUAL "arm64" OR "${TARGET}" STREQUAL "LONGSOON3B" OR "${TARGET}" STREQUAL "GENERIC" OR "${CORE}" STREQUAL "generic" OR "${TARGET}" STREQUAL "HASWELL" OR "${CORE}" STREQUAL "haswell" OR "{CORE}" STREQUAL "zen")
+ if (ARM OR ARM64 OR "${TARGET}" STREQUAL "LONGSOON3B" OR "${TARGET}" STREQUAL "GENERIC" OR "${CORE}" STREQUAL "generic" OR "${TARGET}" STREQUAL "HASWELL" OR "${CORE}" STREQUAL "haswell" OR "{CORE}" STREQUAL "zen")
set(USE_TRMM true)
endif ()