38
38
# CPUIDEMU = ../../cpuid/table.o
39
39
40
40
41
- # Cannot run getarch on target if we are cross-compiling
42
- if (NOT CMAKE_CROSSCOMPILING )
43
41
if (DEFINED CPUIDEMU )
44
42
set (EXFLAGS "-DCPUIDEMU -DVENDOR=99" )
45
43
endif ()
46
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
+
47
54
if (DEFINED TARGET_CORE )
48
55
# set the C flags for just this file
49
56
set (GETARCH2_FLAGS "-DBUILD_KERNEL" )
@@ -63,6 +70,73 @@ if (NOT NOFORTRAN)
63
70
include ("${PROJECT_SOURCE_DIR} /cmake/f_check.cmake" )
64
71
endif ()
65
72
73
+ # Cannot run getarch on target if we are cross-compiling
74
+ if (CMAKE_CROSSCOMPILING )
75
+ # Write to config as getarch would
76
+
77
+ # TODO: Set up defines that getarch sets up based on every other target
78
+ # Perhaps this should be inside a different file as it grows larger
79
+ file (APPEND ${TARGET_CONF_TEMP}
80
+ "#define ${TARGET_CORE} \n "
81
+ "#define CHAR_CORENAME \" ${TARGET_CORE} \"\n " )
82
+ if ("${TARGET_CORE} " STREQUAL "ARMV8" )
83
+ file (APPEND ${TARGET_CONF_TEMP}
84
+ "#define L1_DATA_SIZE\t 32768\n "
85
+ "#define L1_DATA_LINESIZE\t 64\n "
86
+ "#define L2_SIZE\t 262144\n "
87
+ "#define L2_LINESIZE\t 64\n "
88
+ "#define DTB_DEFAULT_ENTRIES\t 64\n "
89
+ "#define DTB_SIZE\t 4096\n "
90
+ "#define L2_ASSOCIATIVE\t 32\n " )
91
+ set (SGEMM_UNROLL_M 4 )
92
+ set (SGEMM_UNROLL_N 4 )
93
+ elseif ("${TARGET_CORE} " STREQUAL "CORTEXA57" )
94
+ file (APPEND ${TARGET_CONF_TEMP}
95
+ "#define L1_CODE_SIZE\t 49152\n "
96
+ "#define L1_CODE_LINESIZE\t 64\n "
97
+ "#define L1_CODE_ASSOCIATIVE\t 3\n "
98
+ "#define L1_DATA_SIZE\t 32768\n "
99
+ "#define L1_DATA_LINESIZE\t 64\n "
100
+ "#define L1_DATA_ASSOCIATIVE\t 2\n "
101
+ "#define L2_SIZE\t 2097152\n "
102
+ "#define L2_LINESIZE\t 64\n "
103
+ "#define L2_ASSOCIATIVE\t 16\n "
104
+ "#define DTB_DEFAULT_ENTRIES\t 64\n "
105
+ "#define DTB_SIZE\t 4096\n "
106
+ "#define HAVE_VFPV4\n "
107
+ "#define HAVE_VFPV3\n "
108
+ "#define HAVE_VFP\n "
109
+ "#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 )
118
+ endif ()
119
+
120
+ # Or should this actually be NUM_CORES?
121
+ if (${NUM_THREADS} GREATER 0 )
122
+ file (APPEND ${TARGET_CONF_TEMP} "#define NUM_CORES\t ${NUM_THREADS} \n " )
123
+ endif ()
124
+
125
+ # GetArch_2nd
126
+ foreach (float_char S;D;Q;C;Z;X )
127
+ if (NOT DEFINED ${float_char} GEMM_UNROLL_M )
128
+ set (${float_char} GEMM_UNROLL_M 2 )
129
+ endif ()
130
+ if (NOT DEFINED ${float_char} GEMM_UNROLL_N )
131
+ set (${float_char} GEMM_UNROLL_N 2 )
132
+ endif ()
133
+ endforeach ()
134
+ file (APPEND ${TARGET_CONF_TEMP}
135
+ "#define GEMM_MULTITHREAD_THRESHOLD\t ${GEMM_MULTITHREAD_THRESHOLD} \n " )
136
+ # Move to where gen_config_h would place it
137
+ file (RENAME ${TARGET_CONF_TEMP} "${PROJECT_BINARY_DIR} /config.h" )
138
+
139
+ else ()
66
140
# compile getarch
67
141
set (GETARCH_SRC
68
142
${PROJECT_SOURCE_DIR} /getarch.c
@@ -161,4 +235,4 @@ if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
161
235
endif ()
162
236
endif ()
163
237
164
- endif (NOT CMAKE_CROSSCOMPILING )
238
+ endif (CMAKE_CROSSCOMPILING )
0 commit comments