Skip to content

Commit

Permalink
removing parallel build for OSS (pytorch#509)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#509

1) Removing parallel build to see if we overcome g++ internal compiler error for oss Ubuntu builds
2) remove adding masm=intel to all files in bazel build. Add it only to inline asm files.

Reviewed By: shz0116

Differential Revision: D26255490

fbshipit-source-id: 2adff04b5d8f0bc393cbfce2e0ec02c09d137a86
  • Loading branch information
dskhudia authored and facebook-github-bot committed Feb 8, 2021
1 parent 43570c8 commit c5e2273
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fbgemmci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
mkdir build_static
cd build_static
cmake -DUSE_SANITIZER=address -DFBGEMM_LIBRARY_TYPE=static ..
make -j
make
- name: Test static FBGEMM lib
if: contains(runner.os, 'linux') # not run on macos-latest now due to supporting AVX2
Expand All @@ -69,7 +69,7 @@ jobs:
mkdir build_shared
cd build_shared
cmake -DUSE_SANITIZER=address -DFBGEMM_LIBRARY_TYPE=shared ..
make -j
make
- name: Test shared FBGEMM lib
if: contains(runner.os, 'linux') # not run on macos-latest now due to supporting AVX2
Expand Down
40 changes: 39 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("defs.bzl", "get_fbgemm_avx2_srcs", "get_fbgemm_avx512_srcs", "get_fbgemm_base_srcs", "get_fbgemm_generic_srcs", "get_fbgemm_public_headers", "get_fbgemm_tests")
load("defs.bzl", "get_fbgemm_avx2_srcs", "get_fbgemm_inline_avx2_srcs", "get_fbgemm_avx512_srcs", "get_fbgemm_inline_avx512_srcs", "get_fbgemm_base_srcs", "get_fbgemm_generic_srcs", "get_fbgemm_public_headers", "get_fbgemm_tests")

cc_library(
name = "fbgemm_base",
Expand All @@ -32,7 +32,9 @@ cc_library(
],
deps = [
":fbgemm_avx2",
":fbgemm_inline_avx2",
":fbgemm_avx512",
":fbgemm_inline_avx512",
":fbgemm_base",
":fbgemm_headers",
],
Expand All @@ -43,6 +45,23 @@ cc_library(
name = "fbgemm_avx2",
srcs = get_fbgemm_avx2_srcs(),
hdrs = glob(["src/*.h"]),
copts = [
"-m64",
"-mavx2",
"-mfma",
"-mf16c",
],
deps = [
":fbgemm_base",
":fbgemm_headers",
],
linkstatic = 1,
)

cc_library(
name = "fbgemm_inline_avx2",
srcs = get_fbgemm_inline_avx2_srcs(),
hdrs = glob(["src/*.h"]),
copts = [
"-m64",
"-mavx2",
Expand All @@ -61,6 +80,25 @@ cc_library(
name = "fbgemm_avx512",
srcs = get_fbgemm_avx512_srcs(),
hdrs = glob(["src/*.h"]),
copts = [
"-m64",
"-mfma",
"-mavx512f",
"-mavx512bw",
"-mavx512dq",
"-mavx512vl",
],
deps = [
":fbgemm_base",
":fbgemm_headers",
],
linkstatic = 1,
)

cc_library(
name = "fbgemm_inline_avx512",
srcs = get_fbgemm_inline_avx512_srcs(),
hdrs = glob(["src/*.h"]),
copts = [
"-m64",
"-mfma",
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ endif()
# Define file lists
get_filelist("get_fbgemm_generic_srcs(with_base=True)" FBGEMM_GENERIC_SRCS)
get_filelist("get_fbgemm_avx2_srcs(msvc=${MSVC_BOOL})" FBGEMM_AVX2_SRCS)
get_filelist("get_fbgemm_inline_avx2_srcs(msvc=${MSVC_BOOL})"
FBGEMM_AVX2_INLINE_SRCS)
get_filelist("get_fbgemm_avx512_srcs(msvc=${MSVC_BOOL})" FBGEMM_AVX512_SRCS)
get_filelist("get_fbgemm_inline_avx512_srcs(msvc=${MSVC_BOOL})"
FBGEMM_AVX512_INLINE_SRCS)
get_filelist("get_fbgemm_public_headers()" FBGEMM_PUBLIC_HEADERS)

add_library(fbgemm_generic OBJECT ${FBGEMM_GENERIC_SRCS})
add_library(fbgemm_avx2 OBJECT ${FBGEMM_AVX2_SRCS})
add_library(fbgemm_avx512 OBJECT ${FBGEMM_AVX512_SRCS})
add_library(fbgemm_avx2 OBJECT ${FBGEMM_AVX2_SRCS} ${FBGEMM_AVX2_INLINE_SRCS})
add_library(fbgemm_avx512 OBJECT
${FBGEMM_AVX512_SRCS} ${FBGEMM_AVX512_INLINE_SRCS})

# Make libraries depend on defs.bzl
add_custom_target(defs.bzl DEPENDS defs.bzl)
Expand Down
8 changes: 8 additions & 0 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def get_fbgemm_avx2_srcs(msvc = False):
"src/PackDepthwiseConvMatrixAvx2.cc",
"src/QuantUtilsAvx2.cc",
"src/UtilsAvx2.cc",
]

def get_fbgemm_inline_avx2_srcs(msvc = False):
return [
#FP16 kernels contain inline assembly and inline assembly syntax for MSVC is different.
"src/FbgemmFP16UKernelsAvx2.cc" if not msvc else "src/FbgemmFP16UKernelsIntrinsicAvx2.cc",
]
Expand All @@ -94,6 +98,10 @@ def get_fbgemm_avx512_srcs(msvc = False):
"src/FbgemmFloat16ConvertAvx512.cc",
"src/QuantUtilsAvx512.cc",
"src/UtilsAvx512.cc",
]

def get_fbgemm_inline_avx512_srcs(msvc = False):
return [
#FP16 kernels contain inline assembly and inline assembly syntax for MSVC is different.
"src/FbgemmFP16UKernelsAvx512.cc" if not msvc else "src/FbgemmFP16UKernelsIntrinsicAvx512.cc",
"src/FbgemmFP16UKernelsAvx512_256.cc" if not msvc else "src/FbgemmFP16UKernelsIntrinsicAvx512_256.cc",
Expand Down

0 comments on commit c5e2273

Please sign in to comment.