@@ -42,23 +42,12 @@ if (DEFINED CPUIDEMU)
42
42
set (EXFLAGS "-DCPUIDEMU -DVENDOR=99" )
43
43
endif ()
44
44
45
- if (CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET_CORE )
46
- # Detect target without running getarch
47
- if (AARCH64 )
48
- set (TARGET_CORE "ARMV8" )
49
- else ()
50
- message (FATAL_ERROR "When cross compiling, a TARGET_CORE is required." )
51
- endif ()
52
- endif ()
53
-
54
- if (DEFINED TARGET_CORE )
45
+ if (BUILD_KERNEL )
55
46
# set the C flags for just this file
56
47
set (GETARCH2_FLAGS "-DBUILD_KERNEL" )
57
- set (TARGET_MAKE "Makefile_kernel.conf" )
58
48
set (TARGET_CONF "config_kernel.h" )
59
49
set (TARGET_CONF_DIR ${PROJECT_BINARY_DIR} /kernel_config/${TARGET_CORE} )
60
50
else ()
61
- set (TARGET_MAKE "Makefile.conf" )
62
51
set (TARGET_CONF "config.h" )
63
52
set (TARGET_CONF_DIR ${PROJECT_BINARY_DIR} )
64
53
endif ()
@@ -70,16 +59,26 @@ if (NOT NOFORTRAN)
70
59
include ("${PROJECT_SOURCE_DIR} /cmake/f_check.cmake" )
71
60
endif ()
72
61
62
+ # This check requires c_check for arch but it should probably be done earlier
63
+ if (CMAKE_CROSSCOMPILING AND NOT DEFINED CORE )
64
+ # Detect target without running getarch
65
+ if (ARM64 )
66
+ set (CORE "ARMV8" )
67
+ else ()
68
+ message (FATAL_ERROR "When cross compiling, a CORE is required." )
69
+ endif ()
70
+ endif ()
71
+
73
72
# Cannot run getarch on target if we are cross-compiling
74
- if (CMAKE_CROSSCOMPILING )
73
+ if (DEFINED CORE AND CMAKE_CROSSCOMPILING )
75
74
# Write to config as getarch would
76
75
77
76
# TODO: Set up defines that getarch sets up based on every other target
78
77
# Perhaps this should be inside a different file as it grows larger
79
78
file (APPEND ${TARGET_CONF_TEMP}
80
- "#define ${TARGET_CORE } \n "
81
- "#define CHAR_CORENAME \" ${TARGET_CORE } \"\n " )
82
- if ("${TARGET_CORE } " STREQUAL "ARMV8" )
79
+ "#define ${CORE } \n "
80
+ "#define CHAR_CORENAME \" ${CORE } \"\n " )
81
+ if ("${CORE } " STREQUAL "ARMV8" )
83
82
file (APPEND ${TARGET_CONF_TEMP}
84
83
"#define L1_DATA_SIZE\t 32768\n "
85
84
"#define L1_DATA_LINESIZE\t 64\n "
@@ -90,7 +89,7 @@ if (CMAKE_CROSSCOMPILING)
90
89
"#define L2_ASSOCIATIVE\t 32\n " )
91
90
set (SGEMM_UNROLL_M 4 )
92
91
set (SGEMM_UNROLL_N 4 )
93
- elseif ("${TARGET_CORE } " STREQUAL "CORTEXA57" )
92
+ elseif ("${CORE } " STREQUAL "CORTEXA57" )
94
93
file (APPEND ${TARGET_CONF_TEMP}
95
94
"#define L1_CODE_SIZE\t 49152\n "
96
95
"#define L1_CODE_LINESIZE\t 64\n "
@@ -107,14 +106,14 @@ if (CMAKE_CROSSCOMPILING)
107
106
"#define HAVE_VFPV3\n "
108
107
"#define HAVE_VFP\n "
109
108
"#define HAVE_NEON\n " )
110
- set (SGEMM_DEFAULT_UNROLL_M 16 )
111
- set (SGEMM_DEFAULT_UNROLL_N 4 )
112
- set (DGEMM_DEFAULT_UNROLL_M 8 )
113
- set (DGEMM_DEFAULT_UNROLL_N 4 )
114
- set (CGEMM_DEFAULT_UNROLL_M 8 )
115
- set (CGEMM_DEFAULT_UNROLL_N 4 )
116
- set (ZGEMM_DEFAULT_UNROLL_M 8 )
117
- set (ZGEMM_DEFAULT_UNROLL_N 4 )
109
+ set (SGEMM_UNROLL_M 16 )
110
+ set (SGEMM_UNROLL_N 4 )
111
+ set (DGEMM_UNROLL_M 8 )
112
+ set (DGEMM_UNROLL_N 4 )
113
+ set (CGEMM_UNROLL_M 8 )
114
+ set (CGEMM_UNROLL_N 4 )
115
+ set (ZGEMM_UNROLL_M 8 )
116
+ set (ZGEMM_UNROLL_N 4 )
118
117
endif ()
119
118
120
119
# Or should this actually be NUM_CORES?
@@ -134,105 +133,101 @@ if (CMAKE_CROSSCOMPILING)
134
133
file (APPEND ${TARGET_CONF_TEMP}
135
134
"#define GEMM_MULTITHREAD_THRESHOLD\t ${GEMM_MULTITHREAD_THRESHOLD} \n " )
136
135
# Move to where gen_config_h would place it
137
- file (RENAME ${TARGET_CONF_TEMP} "${PROJECT_BINARY_DIR} /config.h" )
138
-
139
- else ()
140
- # compile getarch
141
- set (GETARCH_SRC
142
- ${PROJECT_SOURCE_DIR} /getarch.c
143
- ${CPUIDEMO}
144
- )
145
-
146
- if ("${CMAKE_C_COMPILER_ID} " STREQUAL "MSVC" )
147
- #Use generic for MSVC now
148
- message ("MSVC" )
149
- set (GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC )
150
- else ()
151
- list (APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR} /cpuid.S )
152
- endif ()
153
-
154
- if ("${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
155
- # disable WindowsStore strict CRT checks
156
- set (GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS )
157
- endif ()
136
+ file (RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR} /${TARGET_CONF} " )
158
137
159
- set (GETARCH_DIR "${PROJECT_BINARY_DIR} /getarch_build" )
160
- set (GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX} " )
161
- file (MAKE_DIRECTORY ${GETARCH_DIR} )
162
- configure_file (${TARGET_CONF_TEMP} ${GETARCH_DIR} /${TARGET_CONF} COPYONLY )
163
- if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
164
- try_compile (GETARCH_RESULT ${GETARCH_DIR}
165
- SOURCES ${GETARCH_SRC}
166
- COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${GETARCH_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
167
- OUTPUT_VARIABLE GETARCH_LOG
168
- COPY_FILE ${PROJECT_BINARY_DIR} /${GETARCH_BIN}
138
+ else (NOT CMAKE_CROSSCOMPILING )
139
+ # compile getarch
140
+ set (GETARCH_SRC
141
+ ${PROJECT_SOURCE_DIR} /getarch.c
142
+ ${CPUIDEMU}
169
143
)
170
144
171
- if (NOT ${GETARCH_RESULT} )
172
- MESSAGE (FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG} " )
145
+ if ("${CMAKE_C_COMPILER_ID} " STREQUAL "MSVC" )
146
+ #Use generic for MSVC now
147
+ message ("MSVC" )
148
+ set (GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC )
149
+ else ()
150
+ list (APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR} /cpuid.S )
173
151
endif ()
174
- endif ()
175
- message (STATUS "Running getarch" )
176
-
177
- # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
178
- execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT )
179
- execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT )
180
-
181
- message (STATUS "GETARCH results:\n ${GETARCH_MAKE_OUT} " )
182
-
183
- # append config data from getarch to the TARGET file and read in CMake vars
184
- file (APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT} )
185
- ParseGetArchVars (${GETARCH_MAKE_OUT} )
186
-
187
- set (GETARCH2_DIR "${PROJECT_BINARY_DIR} /getarch2_build" )
188
- set (GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX} " )
189
- file (MAKE_DIRECTORY ${GETARCH2_DIR} )
190
- configure_file (${TARGET_CONF_TEMP} ${GETARCH2_DIR} /${TARGET_CONF} COPYONLY )
191
- if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
192
- try_compile (GETARCH2_RESULT ${GETARCH2_DIR}
193
- SOURCES ${PROJECT_SOURCE_DIR} /getarch_2nd.c
194
- COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${GETARCH2_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
195
- OUTPUT_VARIABLE GETARCH2_LOG
196
- COPY_FILE ${PROJECT_BINARY_DIR} /${GETARCH2_BIN}
197
- )
198
152
199
- if (NOT ${GETARCH2_RESULT} )
200
- MESSAGE (FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG} " )
153
+ if ("${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
154
+ # disable WindowsStore strict CRT checks
155
+ set (GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS )
201
156
endif ()
202
- endif ()
203
157
204
- # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
205
- execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT )
206
- execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT )
158
+ set (GETARCH_DIR "${PROJECT_BINARY_DIR} /getarch_build" )
159
+ set (GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX} " )
160
+ file (MAKE_DIRECTORY ${GETARCH_DIR} )
161
+ configure_file (${TARGET_CONF_TEMP} ${GETARCH_DIR} /${TARGET_CONF} COPYONLY )
162
+ if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
163
+ try_compile (GETARCH_RESULT ${GETARCH_DIR}
164
+ SOURCES ${GETARCH_SRC}
165
+ COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${GETARCH_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
166
+ OUTPUT_VARIABLE GETARCH_LOG
167
+ COPY_FILE ${PROJECT_BINARY_DIR} /${GETARCH_BIN}
168
+ )
169
+
170
+ if (NOT ${GETARCH_RESULT} )
171
+ MESSAGE (FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG} " )
172
+ endif ()
173
+ endif ()
174
+ message (STATUS "Running getarch" )
175
+
176
+ # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
177
+ execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT )
178
+ execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT )
179
+
180
+ message (STATUS "GETARCH results:\n ${GETARCH_MAKE_OUT} " )
181
+
182
+ # append config data from getarch to the TARGET file and read in CMake vars
183
+ file (APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT} )
184
+ ParseGetArchVars (${GETARCH_MAKE_OUT} )
185
+
186
+ set (GETARCH2_DIR "${PROJECT_BINARY_DIR} /getarch2_build" )
187
+ set (GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX} " )
188
+ file (MAKE_DIRECTORY ${GETARCH2_DIR} )
189
+ configure_file (${TARGET_CONF_TEMP} ${GETARCH2_DIR} /${TARGET_CONF} COPYONLY )
190
+ if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
191
+ try_compile (GETARCH2_RESULT ${GETARCH2_DIR}
192
+ SOURCES ${PROJECT_SOURCE_DIR} /getarch_2nd.c
193
+ COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${GETARCH2_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
194
+ OUTPUT_VARIABLE GETARCH2_LOG
195
+ COPY_FILE ${PROJECT_BINARY_DIR} /${GETARCH2_BIN}
196
+ )
197
+
198
+ if (NOT ${GETARCH2_RESULT} )
199
+ MESSAGE (FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG} " )
200
+ endif ()
201
+ endif ()
207
202
208
- # append config data from getarch_2nd to the TARGET file and read in CMake vars
209
- file (APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT} )
203
+ # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
204
+ execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT )
205
+ execute_process (COMMAND ${PROJECT_BINARY_DIR} /${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT )
210
206
211
- if (${BUILD_KERNEL} )
212
- configure_file (${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR} /kernel_config/${TARGET_CORE}/${TARGET_CONF} COPYONLY )
213
- else ()
214
- configure_file (${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR} /${TARGET_CONF} COPYONLY )
215
- endif ()
207
+ # append config data from getarch_2nd to the TARGET file and read in CMake vars
208
+ file (APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT} )
216
209
217
- ParseGetArchVars (${GETARCH2_MAKE_OUT} )
210
+ configure_file (${TARGET_CONF_TEMP} ${TARGET_CONF_DIR} /${TARGET_CONF} COPYONLY )
218
211
219
- # compile get_config_h
220
- set (GEN_CONFIG_H_DIR "${PROJECT_BINARY_DIR} /genconfig_h_build" )
221
- set (GEN_CONFIG_H_BIN "gen_config_h${CMAKE_EXECUTABLE_SUFFIX} " )
222
- set (GEN_CONFIG_H_FLAGS "-DVERSION=\" ${OpenBLAS_VERSION} \" " )
223
- file (MAKE_DIRECTORY ${GEN_CONFIG_H_DIR} )
212
+ ParseGetArchVars (${GETARCH2_MAKE_OUT} )
224
213
225
- if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
226
- try_compile (GEN_CONFIG_H_RESULT ${GEN_CONFIG_H_DIR}
227
- SOURCES ${PROJECT_SOURCE_DIR} /gen_config_h.c
228
- COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GEN_CONFIG_H_FLAGS} -I${PROJECT_SOURCE_DIR}
229
- OUTPUT_VARIABLE GEN_CONFIG_H_LOG
230
- COPY_FILE ${PROJECT_BINARY_DIR} /${GEN_CONFIG_H_BIN}
231
- )
214
+ # compile get_config_h
215
+ set (GEN_CONFIG_H_DIR "${PROJECT_BINARY_DIR} /genconfig_h_build" )
216
+ set (GEN_CONFIG_H_BIN "gen_config_h${CMAKE_EXECUTABLE_SUFFIX} " )
217
+ set (GEN_CONFIG_H_FLAGS "-DVERSION=\" ${OpenBLAS_VERSION} \" " )
218
+ file (MAKE_DIRECTORY ${GEN_CONFIG_H_DIR} )
232
219
233
- if (NOT ${GEN_CONFIG_H_RESULT} )
234
- MESSAGE (FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG} " )
235
- endif ()
220
+ if (NOT "${CMAKE_SYSTEM_NAME} " STREQUAL "WindowsStore" )
221
+ try_compile (GEN_CONFIG_H_RESULT ${GEN_CONFIG_H_DIR}
222
+ SOURCES ${PROJECT_SOURCE_DIR} /gen_config_h.c
223
+ COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GEN_CONFIG_H_FLAGS} -I${PROJECT_SOURCE_DIR}
224
+ OUTPUT_VARIABLE GEN_CONFIG_H_LOG
225
+ COPY_FILE ${PROJECT_BINARY_DIR} /${GEN_CONFIG_H_BIN}
226
+ )
227
+
228
+ if (NOT ${GEN_CONFIG_H_RESULT} )
229
+ MESSAGE (FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG} " )
230
+ endif ()
236
231
endif ()
237
232
238
- endif (CMAKE_CROSSCOMPILING )
233
+ endif ()
0 commit comments