Skip to content
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

Feat/arm64 #581

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b18ecd6
feat: init decoder for aarch64 test
liuq19 Jan 29, 2024
1ec5218
feat: replace encoding.json wrapper with dev decoder in aarch64
liuq19 Jan 29, 2024
fa06530
fix: support options and fix lots bug
liuq19 Jan 29, 2024
4823eec
fix: bugs when decode into iface
liuq19 Jan 30, 2024
3135e27
feat: support copy string
liuq19 Jan 30, 2024
71bcbfa
feat: support stream decoder
liuq19 Jan 30, 2024
1cb4034
feat:(encoder) implement encoding on Virtual Machine for supporting A…
AsterDY Feb 1, 2024
da96707
feat: support AArch64 for native funcs
AsterDY Sep 11, 2023
d00cffe
fix: missing f32toa in native.h
xiegx94 Sep 11, 2023
e92d884
native/neon
AsterDY Sep 11, 2023
d652bdc
MaxFrameSize
AsterDY Sep 11, 2023
2ace228
fix: store x30 into [sp] for f64toa
xiegx94 Sep 19, 2023
8b11e54
tmp
xiegx94 Sep 25, 2023
e4fc9c5
tmp
xiegx94 Sep 26, 2023
5b7c7bb
fix: pcsp
xiegx94 Oct 8, 2023
fb322e1
fix: remove unused import module
xiegx94 Oct 8, 2023
882de6f
fix: add NOSPLIT for every function
xiegx94 Oct 8, 2023
e3c4d01
link arm native funcs to go stubs
AsterDY Oct 8, 2023
85e2b9b
remove build neon on makefile
AsterDY Oct 8, 2023
a6089de
test
AsterDY Oct 8, 2023
dca1689
test
AsterDY Oct 8, 2023
7bd5fe5
fix: failed for x86
xiegx94 Oct 9, 2023
9dbbea5
fix: typo of fast_float_arm64_test.go
xiegx94 Oct 9, 2023
93a3ce3
remake x86
AsterDY Oct 9, 2023
d4a2e49
feat: update x86 codes
xiegx94 Oct 9, 2023
d4603ab
fix: x86 uinttest failed
xiegx94 Oct 9, 2023
cd9d2ed
only support >=go1.20
AsterDY Oct 10, 2023
2ef895f
test
AsterDY Oct 12, 2023
5268e9d
test
AsterDY Oct 12, 2023
2dbe5cb
build: using Clang12
AsterDY Oct 12, 2023
6b96234
remove repeat benchmarks
AsterDY Oct 12, 2023
f49d058
f32toa
AsterDY Jan 23, 2024
9a0a436
build with special Clang
AsterDY Jan 30, 2024
e781b4f
update asm2arm
AsterDY Jan 30, 2024
f6ddef9
update
AsterDY Jan 30, 2024
a1719b3
update
AsterDY Jan 30, 2024
ec9e011
reserve x28
AsterDY Jan 31, 2024
67d843e
update benchmarks
AsterDY Feb 1, 2024
bd4b94c
build x86 with clang12
AsterDY Feb 1, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-linux-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.1
go-version: 1.21.1

- uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.1
go-version: 1.21.1

- uses: actions/cache@v2
with:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/compatibility_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x]
go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x]
os: [arm, X64]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -28,10 +28,16 @@ jobs:
${{ runner.os }}-go-

- name: main
run: GOMAXPROCS=4 go test -v -gcflags="all=-l" -race github.com/bytedance/sonic
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic

- name: encoder
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/internal/encoder

- name: issues
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/issue_test

- name: ast
run: GOMAXPROCS=4 go test -v -gcflags="all=-l" -race github.com/bytedance/sonic/ast
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/ast

- name: qemu
run: sh scripts/qemu.sh
7 changes: 5 additions & 2 deletions .github/workflows/fuzzing-linux-x64.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: Fuzz Test Linux-X64
name: Fuzz Test Linux

on: pull_request

jobs:
build:
runs-on: [self-hosted, X64]
strategy:
matrix:
os: [arm, X64]
runs-on: ${{ matrix.os }}
steps:
- name: Clear repository
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_test-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x]
go-version: [1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x]
runs-on: [self-hosted, X64]
steps:
- name: Clear repository
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "tools/asm2asm"]
path = tools/asm2asm
url = https://github.com/chenzhuoyu/asm2asm

[submodule "tools/simde"]
path = tools/simde
url = https://github.com/simd-everywhere/simde
55 changes: 31 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,35 @@ SRC_FILE := native/native.c
CPU_avx := amd64
CPU_avx2 := amd64
CPU_sse := amd64
CPU_neon := arm64

TMPL_avx := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_avx2 := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_sse := fastint_amd64_test fastfloat_amd64_test native_amd64_test recover_amd64_test
TMPL_amd64 := fastint_test fastfloat_test native_test recover_amd64_test
TMPL_arm64 := fastint_test fastfloat_test native_test recover_arm64_test native_export_arm64

CFLAGS_avx := -msse -mno-sse4 -mavx -mpclmul -mno-avx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=0
CFLAGS_avx2 := -msse -mno-sse4 -mavx -mpclmul -mavx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=1
CFLAGS_sse := -msse -mno-sse4 -mno-avx -mno-avx2 -mpclmul

CC_amd64 := clang
ASM2ASM_amd64 := tools/asm2asm/asm2asm.py
ASM2ASM_arm64 := tools/asm2arm/arm.py

ASM_FLAGS_amd64 := -r
ASM_FLAGS_arm64 :=

ASM_OUT_amd64 := native_text_amd64.go
ASM_OUT_arm64 := native_arm64.s

CC := clang

CFLAGS := -mno-red-zone
CFLAGS += -target x86_64-apple-macos11
CFLAGS += -fno-asynchronous-unwind-tables
CFLAGS += -fno-builtin
CFLAGS += -fno-exceptions
CFLAGS += -fno-rtti
CFLAGS += -fno-stack-protector
CFLAGS += -nostdlib
CFLAGS += -O3
CFLAGS += -Wall -Werror
# CFLAGS += -Wall -Werror
CFLAGS_avx := -target x86_64-apple-macos11 -msse -mno-sse4 -mavx -mpclmul -mno-avx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=0
CFLAGS_avx2 := -target x86_64-apple-macos11 -msse -mno-sse4 -mavx -mpclmul -mavx2 -mstack-alignment=0 -DUSE_AVX=1 -DUSE_AVX2=1
CFLAGS_sse := -target x86_64-apple-macos11 -msse -mno-sse4 -mno-avx -mno-avx2 -mpclmul
CFLAGS_neon := -target aarch64-apple-macos11 -march=armv8-a+simd -Itools/simde/simde

NATIVE_SRC := $(wildcard native/*.h)
NATIVE_SRC += $(wildcard native/*.c)
Expand All @@ -63,19 +70,12 @@ ${@dest}: ${@tmpl}
endef

define build_arch
$(eval @cpu := $(value CPU_$(1)))
$(eval @deps := $(foreach tmpl,$(value TMPL_$(1)),${OUT_DIR}/$(1)/${tmpl}.go))
$(eval @asmin := ${TMP_DIR}/$(1)/native.s)
$(eval @asmout := ${OUT_DIR}/$(1)/native_text_${@cpu}.go)
$(eval @stubin := ${OUT_DIR}/native_${@cpu}.tmpl)
$(eval @stubout := ${OUT_DIR}/$(1)/native_${@cpu}.go)

$(1): ${@asmout} ${@deps}

${@asmout}: ${@stubout} ${NATIVE_SRC}
mkdir -p ${TMP_DIR}/$(1)
$${CC_${@cpu}} $${CFLAGS} $${CFLAGS_$(1)} -S -o ${TMP_DIR}/$(1)/native.s ${SRC_FILE}
python3 $${ASM2ASM_${@cpu}} -r ${@stubout} ${TMP_DIR}/$(1)/native.s
$(eval @cpu := $(value CPU_$(1)))
$(eval @deps := $(foreach tmpl,$(value TMPL_${@cpu}),${OUT_DIR}/$(1)/${tmpl}.go))
$(eval @asmin := ${TMP_DIR}/$(1)/native.s)
$(eval @asmout := ${OUT_DIR}/$(1)/$(value ASM_OUT_${@cpu}))
$(eval @stubin := ${OUT_DIR}/native_${@cpu}.tmpl)
$(eval @stubout := ${OUT_DIR}/$(1)/native_${@cpu}.go)

$(eval $(call \
build_tmpl, \
Expand All @@ -84,9 +84,16 @@ $(eval $(call \
${@stubout} \
))

$(1): ${@asmout} ${@deps}

${@asmout}: ${@stubout} ${NATIVE_SRC}
mkdir -p ${TMP_DIR}/$(1)
$${CC} $${CFLAGS} $${CFLAGS_$(1)} -S -o ${TMP_DIR}/$(1)/native.s ${SRC_FILE}
python3 $${ASM2ASM_${@cpu}} $${ASM_FLAGS_${@cpu}} ${@stubout} ${TMP_DIR}/$(1)/native.s

$(foreach \
tmpl, \
$(value TMPL_$(1)), \
$(value TMPL_${@cpu}), \
$(eval $(call \
build_tmpl, \
$(1), \
Expand Down
11 changes: 1 addition & 10 deletions ast/api_amd64.go → ast/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.22
// +build amd64,go1.16,!go1.22 arm64,go1.20,!go1.22

/*
* Copyright 2022 ByteDance Inc.
Expand Down Expand Up @@ -27,7 +27,6 @@ import (
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
uq `github.com/bytedance/sonic/unquote`
`github.com/chenzhuoyu/base64x`
)

var typeByte = rt.UnpackEface(byte(0)).Type
Expand Down Expand Up @@ -77,14 +76,6 @@ func unquote(src string) (string, types.ParsingError) {
return uq.String(src)
}

func decodeBase64(src string) ([]byte, error) {
return base64x.StdEncoding.DecodeString(src)
}

func encodeBase64(src []byte) string {
return base64x.StdEncoding.EncodeToString(src)
}

func (self *Parser) decodeValue() (val types.JsonState) {
sv := (*rt.GoString)(unsafe.Pointer(&self.s))
flag := types.F_USE_NUMBER
Expand Down
57 changes: 0 additions & 57 deletions ast/api_amd64_test.go

This file was deleted.

Loading
Loading