Skip to content

Commit

Permalink
[FORK][FEATURE] Cc based on master (#135)
Browse files Browse the repository at this point in the history
* select build v26

* fix constexpr in cc onednn v26

* fix bug on test model yolov3

* clean code deleta unused constexpr version

* ONEDNN 3.2 migration squashed commits:
   - Fix Windows+CPU Plugin+CC compile fail issue.
   - Remove f16 kernel instances
   - remove unused primitive (#127)

Add FP16 kernel back.
Fix missing FP16 reorder ref kernel.

[FORK][FIX] Fix CC caused compiling problem when merging 3.5
[FORK][FEATURE] Cc based on master (#135)

ONEDNN 3.5 squash list:
[FORK][UPDATE] use ov_mark_target_as_cc instead of deprecated ie_mark_target_as_cc

[ARM] Fixed missed using stmt for ARM target
  • Loading branch information
zhwuwuwu authored and xczhai committed Dec 31, 2024
1 parent 2419b0a commit cf4bb22
Show file tree
Hide file tree
Showing 46 changed files with 1,669 additions and 1,467 deletions.
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ if(UNIX)
endif()
endif()

macro(enable_conditional_compilation4 target)
if(COMMAND ov_mark_target_as_cc)
ov_mark_target_as_cc(${target})
if(SELECTIVE_BUILD STREQUAL "ON")
# After disabling a block of code, some variables might be unused.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
target_compile_options(${target} PRIVATE -Wno-unused-variable)
endif()
endif()
endif()
endmacro()

add_subdirectory(common)

if(NOT DNNL_CPU_RUNTIME STREQUAL "NONE")
Expand Down
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ set(OBJ_LIB ${LIB_PACKAGE_NAME}_common)
add_library(${OBJ_LIB} OBJECT ${SOURCES})
set_property(GLOBAL APPEND PROPERTY DNNL_LIB_DEPS
$<TARGET_OBJECTS:${OBJ_LIB}>)
enable_conditional_compilation4(${OBJ_LIB})
1 change: 1 addition & 0 deletions src/common/concat_pd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ struct concat_pd_t : public primitive_desc_t {
&primitive, \
dnnl::impl::engine_t *engine, const cache_blob_t &cache_blob) \
const override { \
DNNL_PRIMITIVE_CREATE(pd_t) \
return primitive_t::create_primitive_common<__VA_ARGS__, pd_t>( \
primitive, this, engine, false, cache_blob); \
} \
Expand Down
103 changes: 103 additions & 0 deletions src/common/dnnl_sel_build.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*******************************************************************************
* Copyright 2020 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#pragma once


#define DNNL_MACRO_EXPAND(x) x

#define DNNL_MACRO_CAT_(x, y) x ## y
#define DNNL_MACRO_CAT(x, y) DNNL_MACRO_CAT_(x, y)
#define DNNL_MACRO_CAT3_(x, y, z) x ## y ## z
#define DNNL_MACRO_CAT3(x, y, z) DNNL_MACRO_CAT3_(x, y, z)

#define DNNL_MACRO_TOSTRING(...) DNNL_MACRO_TOSTRING_(__VA_ARGS__)
#define DNNL_MACRO_TOSTRING_(...) #__VA_ARGS__

#define DNNL_MACRO_NARG(...) DNNL_MACRO_EXPAND( DNNL_MACRO_NARG_(__VA_ARGS__, DNNL_MACRO_RSEQ_N()) )
#define DNNL_MACRO_NARG_(...) DNNL_MACRO_EXPAND( DNNL_MACRO_ARG_N(__VA_ARGS__) )
#define DNNL_MACRO_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define DNNL_MACRO_RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

#define DNNL_MACRO_EVAL_(NAME, N) NAME ## _ ## N
#define DNNL_MACRO_EVAL(NAME, N) DNNL_MACRO_EVAL_(NAME, N)

#define DNNL_MACRO_OVERLOAD(NAME, ...) \
DNNL_MACRO_EXPAND( DNNL_MACRO_EVAL(NAME, DNNL_MACRO_EXPAND( DNNL_MACRO_NARG(__VA_ARGS__) ))(__VA_ARGS__) )

#if defined(SELECTIVE_BUILD_ANALYZER)

# include <openvino/cc/selective_build.h>

namespace dnnl {

OV_CC_DOMAINS(DNNL)

} // namespace dnnl

# define DNNL_CSCOPE(region) OV_SCOPE(DNNL, region)

# define DNNL_PRIMITIVE_NAME_INIT(pd_t) name = typeid(pd_t).name();
# define DNNL_PRIMITIVE_CREATE(pd_t) OV_ITT_SCOPED_TASK(dnnl::FACTORY_DNNL, std::string("CREATE$CPUEngine$") + typeid(pd_t).name());
# define DNNL_PRIMITIVE_IMPL(...) DNNL_MACRO_OVERLOAD(DNNL_PRIMITIVE_IMPL, __VA_ARGS__),
# define DNNL_PRIMITIVE_IMPL_2(expr, type) dnnl::impl::move(expr(type), OV_CC_TOSTRING(type))
# define DNNL_PRIMITIVE_IMPL_3(expr, type, t1) dnnl::impl::move(expr(type<t1>), OV_CC_TOSTRING(type ## _ ## t1))
# define DNNL_PRIMITIVE_IMPL_4(expr, type, t1, t2) dnnl::impl::move(expr(type<t1, t2>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2))
# define DNNL_PRIMITIVE_IMPL_5(expr, type, t1, t2, t3) dnnl::impl::move(expr(type<t1, t2, t3>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2 ## _ ## t3))
# define DNNL_PRIMITIVE_IMPL_6(expr, type, t1, t2, t3, t4) dnnl::impl::move(expr(type<t1, t2, t3, t4>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4))
# define DNNL_PRIMITIVE_IMPL_7(expr, type, t1, t2, t3, t4, t5) dnnl::impl::move(expr(type<t1, t2, t3, t4, t5>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5))
# define DNNL_PRIMITIVE_IMPL_8(expr, type, t1, t2, t3, t4, t5, t6) dnnl::impl::move(expr(type<t1, t2, t3, t4, t5, t6>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5 ## _ ## t6))
# define DNNL_PRIMITIVE_IMPL_9(expr, type, t1, t2, t3, t4, t5, t6, t7) dnnl::impl::move(expr(type<t1, t2, t3, t4, t5, t6, t7>), OV_CC_TOSTRING(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5 ## _ ## t6 ## _ ## t7))

#elif defined(SELECTIVE_BUILD)

# include <openvino/cc/selective_build.h>

# define DNNL_CSCOPE(region) OV_SCOPE(DNNL, region)

# define DNNL_OBJ_BUILDER_0(...)
# define DNNL_OBJ_BUILDER_1(...) __VA_ARGS__,
# define DNNL_OBJ_BUILDER(name, ...) OV_CC_EXPAND(OV_CC_CAT(DNNL_OBJ_BUILDER_, OV_CC_EXPAND(OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT(DNNL_, name))))(__VA_ARGS__))

# define DNNL_PRIMITIVE_NAME_INIT(pd_t)
# define DNNL_PRIMITIVE_CREATE(pd_t)
# define DNNL_PRIMITIVE_IMPL(...) DNNL_MACRO_OVERLOAD(DNNL_PRIMITIVE_IMPL, __VA_ARGS__)
# define DNNL_PRIMITIVE_IMPL_2(expr, type) DNNL_OBJ_BUILDER(type, expr(type))
# define DNNL_PRIMITIVE_IMPL_3(expr, type, t1) DNNL_OBJ_BUILDER(type ## _ ## t1, expr(type<t1>))
# define DNNL_PRIMITIVE_IMPL_4(expr, type, t1, t2) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2, expr(type<t1, t2>))
# define DNNL_PRIMITIVE_IMPL_5(expr, type, t1, t2, t3) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2 ## _ ## t3, expr(type<t1, t2, t3>))
# define DNNL_PRIMITIVE_IMPL_6(expr, type, t1, t2, t3, t4) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4, expr(type<t1, t2, t3, t4>))
# define DNNL_PRIMITIVE_IMPL_7(expr, type, t1, t2, t3, t4, t5) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5, expr(type<t1, t2, t3, t4, t5>))
# define DNNL_PRIMITIVE_IMPL_8(expr, type, t1, t2, t3, t4, t5, t6) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5 ## _ ## t6, expr(type<t1, t2, t3, t4, t5, t6>))
# define DNNL_PRIMITIVE_IMPL_9(expr, type, t1, t2, t3, t4, t5, t6, t7) DNNL_OBJ_BUILDER(type ## _ ## t1 ## _ ## t2 ## _ ## t3 ## _ ## t4 ## _ ## t5 ## _ ## t6 ## _ ## t7, expr(type<t1, t2, t3, t4, t5, t6, t7>))

#else

# define DNNL_CSCOPE(region)

# define DNNL_PRIMITIVE_NAME_INIT(pd_t)
# define DNNL_PRIMITIVE_CREATE(pd_t)
# define DNNL_PRIMITIVE_IMPL(...) DNNL_MACRO_OVERLOAD(DNNL_PRIMITIVE_IMPL, __VA_ARGS__),
# define DNNL_PRIMITIVE_IMPL_2(expr, type) expr(type)
# define DNNL_PRIMITIVE_IMPL_3(expr, type, t1) expr(type<t1>)
# define DNNL_PRIMITIVE_IMPL_4(expr, type, t1, t2) expr(type<t1, t2>)
# define DNNL_PRIMITIVE_IMPL_5(expr, type, t1, t2, t3) expr(type<t1, t2, t3>)
# define DNNL_PRIMITIVE_IMPL_6(expr, type, t1, t2, t3, t4) expr(type<t1, t2, t3, t4>)
# define DNNL_PRIMITIVE_IMPL_7(expr, type, t1, t2, t3, t4, t5) expr(type<t1, t2, t3, t4, t5>)
# define DNNL_PRIMITIVE_IMPL_8(expr, type, t1, t2, t3, t4, t5, t6) expr(type<t1, t2, t3, t4, t5, t6>)
# define DNNL_PRIMITIVE_IMPL_9(expr, type, t1, t2, t3, t4, t5, t6, t7) expr(type<t1, t2, t3, t4, t5, t6, t7>)

#endif
47 changes: 36 additions & 11 deletions src/common/impl_list_item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "c_types_map.hpp"
#include "primitive_desc.hpp"
#include "dnnl_sel_build.hpp"
#include "utils.hpp"

namespace dnnl {
Expand Down Expand Up @@ -89,24 +90,35 @@ struct impl_list_item_t {
: public type_deduction_helper_t<pd_t> {};

template <typename pd_t>
constexpr impl_list_item_t(type_deduction_helper_t<pd_t>)
: create_pd_func_(&primitive_desc_t::create<
typename type_deduction_helper_t<pd_t>::type>) {}
impl_list_item_t(type_deduction_helper_t<pd_t>) {
using deduced_pd_t = typename type_deduction_helper_t<pd_t>::type;
create_pd_func_ = &primitive_desc_t::create<deduced_pd_t>;
DNNL_PRIMITIVE_NAME_INIT(pd_t);
}

template <typename pd_t>
constexpr impl_list_item_t(concat_type_deduction_helper_t<pd_t>)
: create_concat_pd_func_(
concat_type_deduction_helper_t<pd_t>::type::create) {}
impl_list_item_t(concat_type_deduction_helper_t<pd_t>) {
using deduced_pd_t =
typename concat_type_deduction_helper_t<pd_t>::type;
create_concat_pd_func_ = deduced_pd_t::create;
DNNL_PRIMITIVE_NAME_INIT(pd_t);
}

template <typename pd_t>
constexpr impl_list_item_t(sum_type_deduction_helper_t<pd_t>)
: create_sum_pd_func_(sum_type_deduction_helper_t<pd_t>::type::create) {
impl_list_item_t(sum_type_deduction_helper_t<pd_t>) {
using deduced_pd_t = typename sum_type_deduction_helper_t<pd_t>::type;
create_sum_pd_func_ = deduced_pd_t::create;
DNNL_PRIMITIVE_NAME_INIT(pd_t);
}

template <typename pd_t>
constexpr impl_list_item_t(reorder_type_deduction_helper_t<pd_t>)
: create_reorder_pd_func_(
reorder_type_deduction_helper_t<pd_t>::type::create) {}
impl_list_item_t(reorder_type_deduction_helper_t<pd_t>) {
using deduced_pd_t =
typename reorder_type_deduction_helper_t<pd_t>::type;
create_reorder_pd_func_ = deduced_pd_t::create;
DNNL_PRIMITIVE_NAME_INIT(pd_t);
}


explicit operator bool() const {
return !utils::everyone_is(nullptr, create_pd_func_,
Expand All @@ -127,6 +139,10 @@ struct impl_list_item_t {
return -1;
}

#if defined(SELECTIVE_BUILD_ANALYZER)
const char *name = {};
#endif

private:
status_t operator()(primitive_desc_t **pd, const op_desc_t *adesc,
const primitive_attr_t *attr, engine_t *engine,
Expand Down Expand Up @@ -206,6 +222,15 @@ struct impl_list_item_t {
engine_t *, const primitive_attr_t *);
};

#if defined(SELECTIVE_BUILD_ANALYZER)
inline impl_list_item_t&& move(impl_list_item_t &&t, const char *name) {
OV_ITT_SCOPED_TASK(
dnnl::FACTORY_DNNL,
openvino::itt::handle(std::string("REG$CPUEngine$") + t.name + "$" + name));
return static_cast<impl_list_item_t&&>(t);
}
#endif

} // namespace impl
} // namespace dnnl

Expand Down
10 changes: 5 additions & 5 deletions src/common/impl_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#define REG_BWD_D_PK(...) __VA_ARGS__
#else
#define REG_BWD_PK(...) \
{ nullptr }
{ nullptr },
#define REG_BWD_D_PK(...) \
{ nullptr }
{ nullptr },
#endif

// Primitives section
Expand All @@ -56,7 +56,7 @@
#define REG_CONCAT_P(...) __VA_ARGS__
#else
#define REG_CONCAT_P(...) \
{ nullptr }
{ nullptr },
#endif

#if BUILD_PRIMITIVE_ALL || BUILD_CONVOLUTION
Expand Down Expand Up @@ -128,7 +128,7 @@
#define REG_MATMUL_P(...) __VA_ARGS__
#else
#define REG_MATMUL_P(...) \
{ nullptr }
{ nullptr },
#endif

#if BUILD_PRIMITIVE_ALL || BUILD_POOLING
Expand All @@ -149,7 +149,7 @@
#define REG_REDUCTION_P(...) __VA_ARGS__
#else
#define REG_REDUCTION_P(...) \
{ nullptr }
{ nullptr },
#endif

#if BUILD_PRIMITIVE_ALL || BUILD_REORDER
Expand Down
10 changes: 7 additions & 3 deletions src/common/memory_zero_pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

#include "dnnl_thread.hpp"
#include "dnnl_traits.hpp"
#include "dnnl_sel_build.hpp"
#include "stream.hpp"
#include "type_helpers.hpp"
#include "utils.hpp"

#include "memory.hpp"
#include "primitive_exec_types.hpp"

using namespace dnnl;
using namespace dnnl::impl;
using namespace dnnl::impl::data_type;
using namespace dnnl::impl::status;
Expand Down Expand Up @@ -219,9 +221,11 @@ status_t typed_zero_pad(const memory_t *memory, const exec_ctx_t &ctx) {
#define CASE(blksize_, blk_kind) \
do { \
if (blksize == (blksize_)) { \
typed_zero_pad_blk<dt, blk_kind, blksize_>(mdw, data); \
ctx.unmap_memory_storage( \
memory_storage, mapped_ptr, ctx.stream()); \
DNNL_CSCOPE(DNNL_MACRO_CAT3(typed_zero_pad_blk_, blksize_, blk_kind)) { \
typed_zero_pad_blk<dt, blk_kind, blksize_>(mdw, data); \
ctx.unmap_memory_storage( \
memory_storage, mapped_ptr, ctx.stream()); \
} \
return success; \
} \
} while (0)
Expand Down
2 changes: 2 additions & 0 deletions src/common/primitive_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "cache_blob.hpp"
#include "cache_blob_id.hpp"
#include "cache_hit_types.hpp"
#include "dnnl_sel_build.hpp"
#include "memory_tracking.hpp"
#include "nstl.hpp"
#include "opdesc.hpp"
Expand Down Expand Up @@ -528,6 +529,7 @@ struct primitive_desc_t : public c_compatible {
&primitive, \
dnnl::impl::engine_t *engine, const cache_blob_t &cache_blob) \
const override { \
DNNL_PRIMITIVE_CREATE(pd_t) \
return primitive_t::create_primitive_common<impl_type, pd_t>( \
primitive, this, engine, use_global_scratchpad, cache_blob); \
} \
Expand Down
1 change: 1 addition & 0 deletions src/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ set(OBJ_LIB ${LIB_PACKAGE_NAME}_cpu)
add_library(${OBJ_LIB} OBJECT ${SOURCES})
set_property(GLOBAL APPEND PROPERTY DNNL_LIB_DEPS
$<TARGET_OBJECTS:${OBJ_LIB}>)
enable_conditional_compilation4(${OBJ_LIB})

if (DNNL_TARGET_ARCH STREQUAL "X64")
add_subdirectory(x64)
Expand Down
1 change: 1 addition & 0 deletions src/cpu/aarch64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ set(OBJ_LIB ${LIB_PACKAGE_NAME}_cpu_aarch64)
add_library(${OBJ_LIB} OBJECT ${SOURCES})
set_property(GLOBAL APPEND PROPERTY DNNL_LIB_DEPS
$<TARGET_OBJECTS:${OBJ_LIB}>)
enable_conditional_compilation4(${OBJ_LIB})

add_subdirectory(xbyak_aarch64)
Loading

0 comments on commit cf4bb22

Please sign in to comment.