Skip to content

Remove fbgemm autovec #4123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# A minimum CMake version of 3.21+ is needed to support the required C and C++
# standard versions
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

Expand Down Expand Up @@ -105,6 +105,7 @@ option(FBGEMM_BUILD_TESTS "Build fbgemm unit tests" ON)
option(FBGEMM_BUILD_BENCHMARKS "Build fbgemm benchmarks" ON)
option(FBGEMM_BUILD_DOCS "Build fbgemm documentation" OFF)
option(FBGEMM_BUILD_FBGEMM_GPU "Build fbgemm_gpu library" OFF)
option(DISABLE_FBGEMM_AUTOVEC "Disable FBGEMM Autovec" OFF)

if(FBGEMM_BUILD_TESTS)
enable_testing()
Expand Down Expand Up @@ -422,3 +423,11 @@ endif()
if(FBGEMM_BUILD_FBGEMM_GPU)
add_subdirectory(fbgemm_gpu)
endif()

if(HAVE_GNU_F2H_IEEE)
add_definitions(-DHAVE_GNU_F2H_IEEE)
endif()

if(DISABLE_FBGEMM_AUTOVEC)
add_definitions(-DDISABLE_FBGEMM_AUTOVEC)
endif()
2 changes: 1 addition & 1 deletion bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
21 changes: 21 additions & 0 deletions cmake/modules/FindGnuH2fIeee.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.


################################################################################
# Finds and sets GNU_FH2_IEEE compilation flags
################################################################################

INCLUDE(CheckCXXSourceCompiles)

CHECK_CXX_SOURCE_COMPILES("
#include <arm_neon.h>
int main() {
float f = 1.0f;
uint16_t h = __gnu_f2h_ieee(f);
return 0;
}
" HAVE_GNU_F2H_IEEE)
2 changes: 1 addition & 1 deletion fbgemm_gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# CMake Prelude
################################################################################

cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)

set(CMAKEMODULES ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules)
set(FBGEMM_GPU ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
5 changes: 4 additions & 1 deletion fbgemm_gpu/cmake/Fbgemm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

set(fbgemm_sources_normal
"${FBGEMM}/src/EmbeddingSpMDM.cc"
"${FBGEMM}/src/EmbeddingSpMDMAutovec.cc"
"${FBGEMM}/src/EmbeddingSpMDMNBit.cc"
"${FBGEMM}/src/QuantUtils.cc"
"${FBGEMM}/src/RefImplementations.cc"
"${FBGEMM}/src/RowWiseSparseAdagradFused.cc"
"${FBGEMM}/src/SparseAdagrad.cc"
"${FBGEMM}/src/Utils.cc")

if(NOT DISABLE_FBGEMM_AUTOVEC)
list(APPEND fbgemm_sources_normal "${FBGEMM}/src/EmbeddingSpMDMAutovec.cc")
endif()

set(fbgemm_sources_avx2
"${FBGEMM}/src/EmbeddingSpMDMAvx2.cc"
"${FBGEMM}/src/QuantUtilsAvx2.cc")
Expand Down
4 changes: 2 additions & 2 deletions include/fbgemm/FloatConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ inline float cpu_half2float_ref(const float16 h) {
// Same as the previous function, but use the built-in fp16 to fp32
// conversion provided by the compiler
inline float cpu_half2float(const float16 h) {
#ifdef HAS_NATIVE_FP16_TYPE
#if defined(HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
__fp16 h_fp16;
std::memcpy(&h_fp16, &h, sizeof(__fp16));
return h_fp16;
Expand All @@ -297,7 +297,7 @@ inline float cpu_half2float(const float16 h) {
}

inline float16 cpu_float2half(const float f) {
#ifdef HAS_NATIVE_FP16_TYPE
#if defined(HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
__fp16 h = f;
float16 res;
std::memcpy(&res, &h, sizeof(__fp16));
Expand Down
2 changes: 2 additions & 0 deletions src/EmbeddingSpMDMAutovec.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#include "fbgemm/FbgemmEmbedding.h"

#ifndef DISABLE_FBGEMM_AUTOVEC
#define FBGEMM_AUTOVEC_AVAILABLE
#endif

namespace fbgemm {

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
Loading