Improvements to previous commit (cross-compile).

Fix typos and bad if statements discovered in 0.2.20.
This commit is contained in:
Sacha Refshauge 2017-08-20 22:50:31 +10:00
parent 0a7a527a92
commit 69b560751c
4 changed files with 113 additions and 133 deletions

View File

@ -34,11 +34,7 @@ else()
endif()
if (NOT ONLY_CBLAS)
# N.B. f_check is not cross-platform, so instead try to use CMake variables
# run f_check (appends to TARGET files)
# message(STATUS "Running f_check...")
# execute_process(COMMAND perl f_check ${TARGET_MAKE} ${TARGET_CONF} ${CMAKE_Fortran_COMPILER}
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
# TODO: set FEXTRALIB flags a la f_check?

View File

@ -42,23 +42,12 @@ if (DEFINED CPUIDEMU)
set(EXFLAGS "-DCPUIDEMU -DVENDOR=99")
endif ()
if(CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET_CORE)
# Detect target without running getarch
if(AARCH64)
set(TARGET_CORE "ARMV8")
else()
message(FATAL_ERROR "When cross compiling, a TARGET_CORE is required.")
endif()
endif()
if (DEFINED TARGET_CORE)
if (BUILD_KERNEL)
# set the C flags for just this file
set(GETARCH2_FLAGS "-DBUILD_KERNEL")
set(TARGET_MAKE "Makefile_kernel.conf")
set(TARGET_CONF "config_kernel.h")
set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR}/kernel_config/${TARGET_CORE})
else()
set(TARGET_MAKE "Makefile.conf")
set(TARGET_CONF "config.h")
set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR})
endif ()
@ -70,16 +59,26 @@ 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 (CMAKE_CROSSCOMPILING)
if (DEFINED CORE AND CMAKE_CROSSCOMPILING)
# Write to config as getarch would
# TODO: Set up defines that getarch sets up based on every other target
# Perhaps this should be inside a different file as it grows larger
file(APPEND ${TARGET_CONF_TEMP}
"#define ${TARGET_CORE}\n"
"#define CHAR_CORENAME \"${TARGET_CORE}\"\n")
if ("${TARGET_CORE}" STREQUAL "ARMV8")
"#define ${CORE}\n"
"#define CHAR_CORENAME \"${CORE}\"\n")
if ("${CORE}" STREQUAL "ARMV8")
file(APPEND ${TARGET_CONF_TEMP}
"#define L1_DATA_SIZE\t32768\n"
"#define L1_DATA_LINESIZE\t64\n"
@ -90,7 +89,7 @@ if (CMAKE_CROSSCOMPILING)
"#define L2_ASSOCIATIVE\t32\n")
set(SGEMM_UNROLL_M 4)
set(SGEMM_UNROLL_N 4)
elseif ("${TARGET_CORE}" STREQUAL "CORTEXA57")
elseif ("${CORE}" STREQUAL "CORTEXA57")
file(APPEND ${TARGET_CONF_TEMP}
"#define L1_CODE_SIZE\t49152\n"
"#define L1_CODE_LINESIZE\t64\n"
@ -107,14 +106,14 @@ if (CMAKE_CROSSCOMPILING)
"#define HAVE_VFPV3\n"
"#define HAVE_VFP\n"
"#define HAVE_NEON\n")
set(SGEMM_DEFAULT_UNROLL_M 16)
set(SGEMM_DEFAULT_UNROLL_N 4)
set(DGEMM_DEFAULT_UNROLL_M 8)
set(DGEMM_DEFAULT_UNROLL_N 4)
set(CGEMM_DEFAULT_UNROLL_M 8)
set(CGEMM_DEFAULT_UNROLL_N 4)
set(ZGEMM_DEFAULT_UNROLL_M 8)
set(ZGEMM_DEFAULT_UNROLL_N 4)
set(SGEMM_UNROLL_M 16)
set(SGEMM_UNROLL_N 4)
set(DGEMM_UNROLL_M 8)
set(DGEMM_UNROLL_N 4)
set(CGEMM_UNROLL_M 8)
set(CGEMM_UNROLL_N 4)
set(ZGEMM_UNROLL_M 8)
set(ZGEMM_UNROLL_N 4)
endif()
# Or should this actually be NUM_CORES?
@ -134,13 +133,13 @@ if (CMAKE_CROSSCOMPILING)
file(APPEND ${TARGET_CONF_TEMP}
"#define GEMM_MULTITHREAD_THRESHOLD\t${GEMM_MULTITHREAD_THRESHOLD}\n")
# Move to where gen_config_h would place it
file(RENAME ${TARGET_CONF_TEMP} "${PROJECT_BINARY_DIR}/config.h")
file(RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR}/${TARGET_CONF}")
else()
else(NOT CMAKE_CROSSCOMPILING)
# compile getarch
set(GETARCH_SRC
${PROJECT_SOURCE_DIR}/getarch.c
${CPUIDEMO}
${CPUIDEMU}
)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
@ -208,11 +207,7 @@ execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 1 OUTPUT_VARIABLE
# append config data from getarch_2nd to the TARGET file and read in CMake vars
file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
if (${BUILD_KERNEL})
configure_file(${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR}/kernel_config/${TARGET_CORE}/${TARGET_CONF} COPYONLY)
else ()
configure_file(${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR}/${TARGET_CONF} COPYONLY)
endif ()
configure_file(${TARGET_CONF_TEMP} ${TARGET_CONF_DIR}/${TARGET_CONF} COPYONLY)
ParseGetArchVars(${GETARCH2_MAKE_OUT})
@ -235,4 +230,4 @@ if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
endif ()
endif ()
endif(CMAKE_CROSSCOMPILING)
endif()

View File

@ -4,17 +4,9 @@
##
set(NETLIB_LAPACK_DIR "${PROJECT_SOURCE_DIR}/lapack-netlib")
# TODO: Makefile.system detects Darwin (mac) and switches to clang here -hpa
# http://stackoverflow.com/questions/714100/os-detecting-makefile
# TODO: Makefile.system sets HOSTCC = $(CC) here if not already set -hpa
# TARGET_CORE will override TARGET which is used in DYNAMIC_ARCH=1.
if (DEFINED TARGET_CORE)
set(TARGET ${TARGET_CORE})
if(NOT DEFINED CORE)
set(CORE ${TARGET_CORE})
endif()
endif ()
# Force fallbacks for 32bit
@ -107,9 +99,6 @@ if (NOT DEFINED NEED_PIC)
set(NEED_PIC 1)
endif ()
# TODO: I think CMake should be handling all this stuff -hpa
unset(ARFLAGS)
# OS dependent settings
include("${PROJECT_SOURCE_DIR}/cmake/os.cmake")

View File

@ -22,7 +22,7 @@ function (build_core TARGET_CORE KDIR TSUFFIX KERNEL_DEFINITIONS)
if (${ADD_COMMONOBJS})
if (${ARCH} STREQUAL "x86")
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
GenerateNamedObjects("${KERNELDIR}/cpuid.S" "" "" false "" "" true)
else()
GenerateNamedObjects("${KERNELDIR}/cpuid_win.c" "" "" false "" "" true)