Skip to content

Commit

Permalink
[xDNN] Update xDNN library to support more intrinsic.
Browse files Browse the repository at this point in the history
  • Loading branch information
changqi1 committed Nov 8, 2023
1 parent 577c8e1 commit a44bddf
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ dist/
/3rdparty/onednn
/3rdparty/cmdline
/3rdparty/sentencepiece
/3rdparty/ig
/3rdparty/xdnn
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ endif()

include("cmake/mklml.cmake")
include("cmake/onednn.cmake")
include("cmake/ig.cmake")
include("cmake/xdnn.cmake")
include(GNUInstallDirs)

include_directories(${CMAKE_SOURCE_DIR}/3rdparty/)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/mklml/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/build/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/ig)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/xdnn)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src/kernels)
include_directories(${CMAKE_SOURCE_DIR}/src/layers)
Expand All @@ -75,18 +75,18 @@ include_directories(${CMAKE_SOURCE_DIR}/src/common)
link_directories(${CMAKE_SOURCE_DIR}/src/kernels)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/mklml/lib)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/build/src)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/ig)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/xdnn)

set(3RDPART_LIB_LIST "MPI::MPI_CXX" "ccl" "dnnl" "numa")
set(DEPEND_LIST "onednn" "mklml" "ig_lib")
set(DEPEND_LIST "onednn" "mklml" "xdnn_lib")

option(BUILD_WITH_SHARED_LIBS "Build with shared libraries" OFF)
if(BUILD_WITH_SHARED_LIBS)
message("Building with shared libraries.")
list(APPEND 3RDPART_LIB_LIST "ig")
list(APPEND 3RDPART_LIB_LIST "xdnn")
else()
message("Building with static libraries.")
list(APPEND 3RDPART_LIB_LIST "ig_static")
list(APPEND 3RDPART_LIB_LIST "xdnn_static")
endif()

# Enable AVX512_FP16 optimization
Expand Down
8 changes: 4 additions & 4 deletions cmake/ig.cmake → cmake/xdnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ project(dependency NONE)
include(ExternalProject)

# cmake-format: off
ExternalProject_Add(ig_lib
URL https://github.com/intel/xFasterTransformer/releases/download/IntrinsicGemm/ig_v1.1.tar.gz
URL_HASH MD5=47e5a2cd021caad2b1367c0b71dff2e7
ExternalProject_Add(xdnn_lib
URL https://github.com/intel/xFasterTransformer/releases/download/IntrinsicGemm/xdnn_v1.1.tar.gz
URL_HASH MD5=b49bf8808d66ea75cfba80a406c9a587
TIMEOUT 60
SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/ig
SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/xdnn
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand Down
35 changes: 0 additions & 35 deletions src/common/intrinsic_ext.h

This file was deleted.

4 changes: 2 additions & 2 deletions src/layers/attention.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ class Attention {
C = result.Row(b * ctx->inputSeqLen + startSeq) + i * ctx->attHeadSize;

if constexpr (std::is_same_v<KVCacheT, float>) {
ig_sgemm_single_thread(false, false, m, n, k, 1.0f, A, lda, B, ldb, 0.0f, C, ldc);
xdnn_sgemm_single_thread(false, false, m, n, k, 1.0f, A, lda, B, ldb, 0.0f, C, ldc);
} else if constexpr (std::is_same_v<KVCacheT, float16_t>) {
ig_sgemm_f32f16f32_single_thread(false, false, m, n, k, 1.0f, A, lda, B, ldb, 0.0f, C, ldc);
xdnn_sgemm_f32f16f32_single_thread(false, false, m, n, k, 1.0f, A, lda, (const XDNN_FP16 *)B, ldb, 0.0f, C, ldc);
}

#ifdef DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/utils/decoder_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ class DecoderUtil {

// C = A * B
// bTranspose: B need to be transposed or not
// ig_sgemm_single_thread(transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc);
// xdnn_sgemm_single_thread(transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc);
static void sgemm(const float* A, const float* B, float* C, int m, int n, int k,
bool transa, bool transb) {
int lda = (transa ? m : k);
Expand Down
Loading

0 comments on commit a44bddf

Please sign in to comment.