Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kalcutter committed Aug 4, 2023
0 parents commit be844a7
Show file tree
Hide file tree
Showing 17 changed files with 2,769 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
common --enable_platform_specific_config

build --features=layering_check
build --repo_env=BAZEL_CXXOPTS=-std=c++14

build:ci --keep_going
build:ci --test_output=all

build:generic_gcc --copt=-Wall
build:generic_gcc --copt=-Wextra
build:generic_gcc --copt=-Wpointer-arith
build:generic_gcc --per_file_copt=^//@-Wundef,-Werror
build:generic_gcc --copt=-Wno-unused-parameter

build:clang --config=generic_gcc
build:clang --repo_env=BAZEL_COMPILER=clang
build:clang --repo_env=CC=clang
build:clang --repo_env=CXX=clang++
# https://github.com/bazelbuild/bazel/issues/11122
# https://github.com/bazelbuild/bazel/issues/12797
build:clang --linkopt=-fsanitize-link-c++-runtime

build:libc++ --cxxopt=-stdlib=libc++
build:libc++ --linkopt=-stdlib=libc++

build:libc++-static --config=libc++
build:libc++-static --repo_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a:-lm
build:libc++-static --repo_env=BAZEL_LINKOPTS=-pthread

build:macos --cxxopt=-std=c++14

build:macos-x86_64 --copt=-arch --copt=x86_64
build:macos-x86_64 --linkopt=-arch --linkopt=x86_64

build:msvc --per_file_copt=^external/@/W2
build:msvc --per_file_copt=^//@/W4,/WX
build:msvc --conlyopt=/Za
build:msvc --cxxopt=/std:c++14

build:asan --features=asan
build:asan --test_env=ASAN_OPTIONS=check_initialization_order=1:detect_invalid_pointer_pairs=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1

build:asan-msvc --config=asan
build:asan-msvc --copt=/fsanitize=address
build:asan-msvc --features=frame_pointer
build:asan-msvc --features=static_link_msvcrt

build:ubsan --features=ubsan
build:ubsan --test_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1

build:ubsan-extra --config=ubsan
build:ubsan-extra --copt=-fsanitize=implicit-signed-integer-truncation
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.3.1
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Chromium
AccessModifierOffset: -4
AlwaysBreakBeforeMultilineStrings: false
BraceWrapping:
AfterControlStatement: MultiLine
BreakBeforeBraces: Custom
ColumnLimit: 100
IndentWidth: 4
SpacesBeforeTrailingComments: 1
15 changes: 15 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Checks: "\
bugprone-*,\
readability-inconsistent-declaration-parameter-name,\
readability-redundant-*,\
readability-uppercase-literal-suffix,\
-bugprone-easily-swappable-parameters,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-narrowing-conversions,\
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
CheckOptions:
readability-inconsistent-declaration-parameter-name.IgnoreMacros: false
readability-inconsistent-declaration-parameter-name.Strict: true
WarningsAsErrors: '*'
...
256 changes: 256 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
name: Main

on:
push:
branches: [main, ci]

jobs:
bazel-linux-arm64-clang:
runs-on: [self-hosted, linux, arm64]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
echo "build --config=ci --config=clang" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Build (libc++)
run: |
bazel --bazelrc=job.rc build -c opt --config=libc++ //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan-extra //:bitshuffle_test --test_arg=--gtest_break_on_failure
- name: Bench
run: |
bazel --bazelrc=job.rc run -c opt --copt=-O3 //:bitshuffle_benchmark -- --benchmark_filter='BM_bitshuffle<.*>/.*/8192'
bazel-linux-arm64-gcc:
runs-on: [self-hosted, linux, arm64]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
echo "build --config=ci --config=generic_gcc" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan //:bitshuffle_test --test_arg=--gtest_break_on_failure
- name: Bench
run: |
bazel --bazelrc=job.rc run -c opt --copt=-O3 //:bitshuffle_benchmark -- --benchmark_filter='BM_bitshuffle<.*>/.*/8192'
bazel-linux-x86_64-icelake-clang:
strategy:
matrix:
m:
- "sse2"
- "avx2"
- "avx512bw avx512vl"
- "avx512bw avx512vl avx512vbmi gfni"
use_ifunc: [0, 1]
runs-on: [self-hosted, linux, x64]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
m="${{ matrix.m }}"
echo "build --config=ci --config=clang --copt=-m${m// / --copt=-m} --copt=-DBITSHUF_USE_IFUNC=${{ matrix.use_ifunc }}" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Build (libc++)
run: |
bazel --bazelrc=job.rc build -c opt --config=libc++ //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan-extra //:bitshuffle_test --test_arg=--gtest_break_on_failure
- name: Bench
run: |
bazel --bazelrc=job.rc run -c opt --copt=-O3 //:bitshuffle_benchmark -- --benchmark_filter='BM_bitshuffle<.*>/.*/8192'
bazel-linux-x86_64-icelake-gcc:
strategy:
matrix:
m:
- "no-sse2"
- "sse2"
- "avx2"
- "avx512bw avx512vl"
- "avx512bw avx512vl avx512vbmi gfni"
use_ifunc: [0, 1]
runs-on: [self-hosted, linux, x64]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
m="${{ matrix.m }}"
echo "build --config=ci --config=generic_gcc --copt=-m${m// / --copt=-m} --copt=-DBITSHUF_USE_IFUNC=${{ matrix.use_ifunc }}" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan //:bitshuffle_test --test_arg=--gtest_break_on_failure
- name: Bench
run: |
bazel --bazelrc=job.rc run -c opt --copt=-O3 //:bitshuffle_benchmark -- --benchmark_filter='BM_bitshuffle<.*>/.*/8192'
bazel-linux-x86_64-clang:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest]
m:
- "sse2"
- "avx2"
use_ifunc: [0, 1]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
m="${{ matrix.m }}"
echo "build --config=ci --config=clang --copt=-m${m// / --copt=-m} --copt=-DBITSHUF_USE_IFUNC=${{ matrix.use_ifunc }}" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan-extra //:bitshuffle_test --test_arg=--gtest_break_on_failure
bazel-linux-x86_64-gcc:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest]
m:
- "no-sse2"
- "sse2"
- "avx2"
use_ifunc: [0, 1]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install
run: |
# Bazel prefers LLD to GNU gold. Install LLD to avoid gold relocation overflow bug on ubuntu-20.04.
# https://mail.gnu.org/archive/html/bug-binutils/2020-04/msg00329.html
sudo apt-get update
sudo apt-get install lld
- name: Configure
run: |
m="${{ matrix.m }}"
echo "build --config=ci --config=generic_gcc --copt=-m${m// / --copt=-m} --copt=-DBITSHUF_USE_IFUNC=${{ matrix.use_ifunc }}" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan //:bitshuffle_test --test_arg=--gtest_break_on_failure
bazel-macos-x86_64:
strategy:
matrix:
os: [macos-11, macos-12, macos-13]
m:
- "sse2"
- "avx2"
exclude:
- {os: macos-11, m: "avx2"}
- {os: macos-12, m: "avx2"}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
m="${{ matrix.m }}"
echo "build --config=ci --config=generic_gcc --copt=-m${m// / --copt=-m}" | tee job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=-O3 --config=asan --config=ubsan-extra //:bitshuffle_test --test_arg=--gtest_break_on_failure
bazel-windows-msvc:
strategy:
matrix:
# FIXME(kal): Add windows-2022 once it works with bazel.
# https://github.com/bazelbuild/bazel/issues/18592
os: [windows-2019]
cpu: [x64, x64_x86]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
"build --cpu=${{ matrix.cpu }}_windows --config=ci --config=msvc" | Out-File -FilePath job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=/O2 --config=asan-msvc //:bitshuffle_test --test_arg=--gtest_break_on_failure
bazel-windows-msvc-arch:
strategy:
matrix:
include:
- {cpu: x64, arch: AVX}
- {cpu: x64, arch: AVX2}
- {cpu: x64_x86, arch: IA32}
- {cpu: x64_x86, arch: SSE}
- {cpu: x64_x86, arch: SSE2}
- {cpu: x64_x86, arch: AVX}
- {cpu: x64_x86, arch: AVX2}
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
"build --cpu=${{ matrix.cpu }}_windows --config=ci --config=msvc --copt=/arch:${{ matrix.arch }}" | Out-File -FilePath job.rc
- name: Build
run: |
bazel --bazelrc=job.rc build -c opt //...
- name: Test
run: |
bazel --bazelrc=job.rc test --copt=/O2 --config=asan-msvc //:bitshuffle_test --test_arg=--gtest_break_on_failure
clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clang-Format
run: |
set -eu
srcs=$(git ls-files -- '*.c' '*.cc' '*.h')
clang-format --dry-run --Werror --verbose -- ${srcs}
clang-tidy:
strategy:
matrix:
m:
- "no-sse2"
- "sse2"
- "avx2"
- "avx512bw avx512vl"
- "avx512bw avx512vl avx512vbmi gfni"
use_ifunc: [0, 1]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install
run: |
sudo apt-get update
sudo apt-get install clang-tidy-15
- name: Configure
run: |
m="${{ matrix.m }}"
echo "CFLAGS=-m${m// / -m} -DBITSHUF_USE_IFUNC=${{ matrix.use_ifunc }}" >>"${GITHUB_ENV}"
- name: Clang-Tidy
run: |
set -eu
clang-tidy-15 --warnings-as-errors='*' src/bitshuffle.c -- ${CFLAGS}
clang-tidy-15 --warnings-as-errors='*' src/bitshuffle.c -- ${CFLAGS} -DNDEBUG
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bazel-*
43 changes: 43 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

package(default_visibility = ["//visibility:public"])

cc_library(
name = "bitshuffle",
srcs = [
"src/bitshuffle.c",
],
hdrs = [
"src/bitshuffle.h",
],
)

cc_binary(
name = "bitshuffle_benchmark",
srcs = [
"tests/bitshuffle_benchmark.cc",
],
copts = [
"-Iexternal",
],
linkstatic = True,
deps = [
":bitshuffle",
"@benchmark",
"@benchmark//:benchmark_main",
"@bitshuffle//:bitshuffle_core",
],
)

cc_test(
name = "bitshuffle_test",
srcs = [
"tests/bitshuffle_test.cc",
],
linkstatic = True,
deps = [
":bitshuffle",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)
Loading

0 comments on commit be844a7

Please sign in to comment.