Skip to content

Commit fc08d8c

Browse files
luweizhou2016xczhai
authored andcommitted
[ARM] Windows ARM64 support
1 parent b39ffaa commit fc08d8c

10 files changed

+51
-55
lines changed

CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ if(POLICY CMP0082)
6464
cmake_policy(SET CMP0082 NEW)
6565
endif()
6666

67-
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
68-
message(STATUS "CMAKE_BUILD_TYPE is unset, defaulting to Release")
69-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
70-
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel RelWithAssert RelWithMDd...")
67+
get_property(ONEDNN_GENERATOR_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
68+
if(NOT ONEDNN_GENERATOR_MULTI_CONFIG)
69+
if(NOT CMAKE_BUILD_TYPE)
70+
message(STATUS "CMAKE_BUILD_TYPE is unset, defaulting to 'Release'")
71+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
72+
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel RelWithAssert RelWithMDd...")
73+
endif()
74+
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_CMAKE_BUILD_TYPE)
7175
endif()
7276

7377
set(PROJECT_NAME "oneDNN")
@@ -109,8 +113,6 @@ set(CMAKE_SRC_CCXX_FLAGS) # SRC specifics
109113
set(CMAKE_EXAMPLE_CCXX_FLAGS) # EXAMPLE specifics
110114
set(CMAKE_TEST_CCXX_FLAGS) # TESTS specifics
111115

112-
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_CMAKE_BUILD_TYPE)
113-
114116
set(LIB_PACKAGE_NAME "dnnl")
115117

116118
include("cmake/dnnl_compat.cmake")

cmake/platform.cmake

+25-30
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ set(CMAKE_CCXX_FLAGS)
3939
set(CMAKE_CCXX_NOWARN_FLAGS)
4040
set(CMAKE_CCXX_NOEXCEPT_FLAGS)
4141
set(DEF_ARCH_OPT_FLAGS)
42+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG)
4243

4344
# Compatibility with DNNL
4445
if($ENV{ONEDNN_WERROR})
@@ -119,7 +120,7 @@ endif()
119120
if(MSVC)
120121
set(USERCONFIG_PLATFORM "x64")
121122
append_if(DNNL_WERROR CMAKE_CCXX_FLAGS "/WX")
122-
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
123+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
123124
append(CMAKE_CCXX_FLAGS "/MP")
124125
# increase number of sections in obj file
125126
append(CMAKE_CCXX_FLAGS "/bigobj")
@@ -235,9 +236,7 @@ elseif(UNIX OR MINGW)
235236
# compiler specific settings
236237
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
237238
if(DNNL_TARGET_ARCH MATCHES "^(AARCH64|ARM)$")
238-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
239-
set(DEF_ARCH_OPT_FLAGS "-O3")
240-
endif()
239+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
241240
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
242241
# Defaults to a generic cpu target, equivalent to setting -mtune=generic -march=armv8-a.
243242
# This ensures no implementation specific tuning, or architectural features beyond
@@ -247,21 +246,17 @@ elseif(UNIX OR MINGW)
247246
append(DEF_ARCH_OPT_FLAGS "-mcpu=generic")
248247
endif()
249248
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
250-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
251-
set(DEF_ARCH_OPT_FLAGS "-O3")
252-
endif()
253-
# For native compilation tune for the host processor
254-
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
255-
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
256-
endif()
249+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
250+
# For native compilation tune for the host processor
251+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
252+
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
253+
endif()
257254
elseif(DNNL_TARGET_ARCH STREQUAL "S390X")
258-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
259-
set(DEF_ARCH_OPT_FLAGS "-O3")
260-
endif()
261-
# For native compilation tune for the host processor
262-
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
263-
append(DEF_ARCH_OPT_FLAGS "-march=native")
264-
endif()
255+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
256+
# For native compilation tune for the host processor
257+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
258+
append(DEF_ARCH_OPT_FLAGS "-march=native")
259+
endif()
265260
elseif(DNNL_TARGET_ARCH STREQUAL "X64")
266261
platform_clang_x64_arch_ccxx_flags(DEF_ARCH_OPT_FLAGS)
267262
endif()
@@ -326,7 +321,7 @@ elseif(UNIX OR MINGW)
326321
endif()
327322
endif()
328323

329-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
324+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
330325
# XXX: Suppress a warning that pops up when using a function pointer
331326
# to an OpenCL function as a template argument (GCC Bugzilla – Bug 71463).
332327
if (DNNL_GPU_RUNTIME STREQUAL "OCL")
@@ -340,9 +335,8 @@ elseif(UNIX OR MINGW)
340335
endif()
341336

342337
if(DNNL_TARGET_ARCH MATCHES "^(AARCH64|ARM)$")
343-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
344-
set(DEF_ARCH_OPT_FLAGS "-O3")
345-
endif()
338+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
339+
# For native compilation tune for the host processor
346340
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
347341
# Defaults to a generic cpu target, equivalent to setting -mtune=generic -march=armv8-a.
348342
# This ensures no implementation specific tuning, or architectural features beyond
@@ -352,18 +346,14 @@ elseif(UNIX OR MINGW)
352346
append(DEF_ARCH_OPT_FLAGS "-mcpu=generic")
353347
endif()
354348
elseif(DNNL_TARGET_ARCH STREQUAL "PPC64")
355-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
356-
set(DEF_ARCH_OPT_FLAGS "-O3")
357-
endif()
349+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
358350
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
359351
# For native compilation tune for the host processor
360352
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
361353
append(DEF_ARCH_OPT_FLAGS "-mcpu=native")
362354
endif()
363355
elseif(DNNL_TARGET_ARCH STREQUAL "S390X")
364-
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
365-
set(DEF_ARCH_OPT_FLAGS "-O3")
366-
endif()
356+
set(DEF_ARCH_OPT_FLAGS_NON_DEBUG "-O3")
367357
# In GCC, -ftree-vectorize is turned on under -O3 since 2007.
368358
# For native compilation tune for the host processor
369359
if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
@@ -418,8 +408,13 @@ if(DNNL_ARCH_OPT_FLAGS STREQUAL "HostOpts")
418408
set(DNNL_ARCH_OPT_FLAGS "${DEF_ARCH_OPT_FLAGS}")
419409
endif()
420410

421-
append(CMAKE_C_FLAGS "${CMAKE_CCXX_FLAGS} ${DNNL_ARCH_OPT_FLAGS}")
422-
append(CMAKE_CXX_FLAGS "${CMAKE_CCXX_FLAGS} ${DNNL_ARCH_OPT_FLAGS}")
411+
append(CMAKE_C_FLAGS "${CMAKE_CCXX_FLAGS}")
412+
append(CMAKE_CXX_FLAGS "${CMAKE_CCXX_FLAGS}")
413+
414+
foreach(config RELEASE RELWITHDEBINFO MINSIZEREL)
415+
append(CMAKE_CXX_FLAGS_${config} "${DEF_ARCH_OPT_FLAGS_NON_DEBUG}")
416+
append(CMAKE_C_FLAGS_${config} "${DEF_ARCH_OPT_FLAGS_NON_DEBUG}")
417+
endforeach()
423418

424419
if(APPLE)
425420
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

src/cpu/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ if(DNNL_TARGET_ARCH STREQUAL "PPC64")
4040
file(GLOB FILES_REQUIRED_OPT
4141
${CMAKE_CURRENT_SOURCE_DIR}/gemm/*.[ch]pp
4242
)
43-
if(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
44-
set_source_files_properties(${FILES_REQUIRED_OPT}
45-
PROPERTIES COMPILE_FLAGS "-O3 -funroll-loops")
46-
endif()
43+
set_source_files_properties(${FILES_REQUIRED_OPT}
44+
PROPERTIES COMPILE_FLAGS <$<NOT:$<CONFIG:Debug>>,"-O3 -funroll-loops">)
4745
endif()
4846

4947
if(NOT DNNL_ENABLE_JIT_PROFILING)

src/cpu/aarch64/acl_convolution_utils.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*******************************************************************************/
1616

17+
#include <cstdint>
18+
1719
#include "acl_convolution_utils.hpp"
1820
#include "common/convolution_pd.hpp"
1921
#include "common/utils.hpp"

src/cpu/aarch64/acl_gemm_convolution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ status_t acl_gemm_convolution_fwd_t<src_t, wei_t, dst_t, bia_t>::pd_t::init(
5555
using smask_t = primitive_attr_t::skip_mask_t;
5656

5757
bool ok = is_fwd() && set_default_alg_kind(alg_kind::convolution_direct)
58-
&& expect_data_types(src_t, wei_t, bia_t, dst_t, undef)
58+
&& expect_data_types(src_t, wei_t, bia_t, dst_t, data_type::undef)
5959
&& !has_zero_dim_memory()
6060
&& attr()->has_default_values(
6161
smask_t::post_ops | smask_t::fpmath_mode, dst_t);

src/cpu/aarch64/acl_indirect_gemm_convolution.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ status_t acl_indirect_gemm_convolution_fwd_t::pd_t::init(engine_t *engine) {
9494
using namespace data_type;
9595
using smask_t = primitive_attr_t::skip_mask_t;
9696

97-
const bool is_fp16_ok = expect_data_types(f16, f16, f16, f16, undef)
97+
const bool is_fp16_ok = expect_data_types(f16, f16, f16, f16, data_type::undef)
9898
&& attr()->has_default_values(smask_t::post_ops, f16);
99-
const bool is_fp32_ok = expect_data_types(f32, f32, f32, f32, undef)
99+
const bool is_fp32_ok = expect_data_types(f32, f32, f32, f32, data_type::undef)
100100
&& attr()->has_default_values(
101101
smask_t::post_ops | smask_t::fpmath_mode, f32);
102102
bool ok = is_fwd() && set_default_alg_kind(alg_kind::convolution_direct)

src/cpu/aarch64/cpu_isa_traits.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
#include "common/utils.hpp"
2626
#include "dnnl_types.h"
2727

28-
/* in order to make selinux happy memory that would be marked with X-bit should
29-
* be obtained with mmap */
30-
#if !defined(_WIN32)
31-
#define XBYAK_USE_MMAP_ALLOCATOR
32-
#endif
28+
// /* in order to make selinux happy memory that would be marked with X-bit should
29+
// * be obtained with mmap */
30+
// #if !defined(_WIN32)
31+
// #define XBYAK_USE_MMAP_ALLOCATOR
32+
// #endif
3333

3434
#include "cpu/aarch64/xbyak_aarch64/xbyak_aarch64/xbyak_aarch64.h"
3535
#include "cpu/aarch64/xbyak_aarch64/xbyak_aarch64/xbyak_aarch64_util.h"

src/cpu/aarch64/jit_uni_deconv_zp_pad_str_kernel.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*******************************************************************************/
1717

1818
#include <cassert>
19+
#include <cstdint>
1920
#include "common/dnnl_thread.hpp"
2021
#include "common/utils.hpp"
2122
#include "cpu/aarch64/jit_primitive_conf.hpp"
@@ -128,7 +129,7 @@ template <cpu_isa_t isa>
128129
uint32_t jit_uni_deconv_zp_pad_str_kernel_t<isa>::get_next_vmm_idx() {
129130
static constexpr int max_v_regs = cpu_isa_traits<isa>::n_vregs;
130131

131-
const ZReg vmm {static_cast<unsigned int>(current_vmm_++)};
132+
const ZReg vmm {static_cast<uint32_t>(current_vmm_++)};
132133

133134
if (current_vmm_ == max_v_regs) current_vmm_ = number_reserved_vmms_;
134135

src/cpu/x64/CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,8 @@ if(MSVC)
5050
set_source_files_properties(${FILES_WITHOUT_OPT}
5151
PROPERTIES COMPILE_FLAGS "/Od")
5252
else()
53-
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
54-
# Some compilers enable optimizations by default.
55-
set(OPT_LEVEL "-O0")
56-
else()
57-
set(OPT_LEVEL "-O1")
58-
endif()
53+
# Some compilers enable optimizations by default.
54+
set(OPT_LEVEL $<IF:$<CONFIG:Debug>,-O0,-O1>)
5955
set_source_files_properties(${FILES_WITHOUT_OPT}
6056
PROPERTIES COMPILE_FLAGS "${OPT_LEVEL}")
6157
endif()

src/cpu/x64/xbyak/xbyak_util.h

+2
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ class Cpu {
303303
}
304304
return;
305305
}
306+
#ifdef XBYAK_INTEL_CPU_SPECIFIC
306307
// intel
307308
const uint32_t NO_CACHE = 0;
308309
const uint32_t DATA_CACHE = 1;
@@ -347,6 +348,7 @@ class Cpu {
347348
dataCacheLevels_++;
348349
}
349350
}
351+
#endif // XBYAK_INTEL_CPU_SPECIFIC
350352
}
351353

352354
public:

0 commit comments

Comments
 (0)