Skip to content

Commit

Permalink
export
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Apr 3, 2024
1 parent f217baf commit d053dcd
Showing 1 changed file with 86 additions and 56 deletions.
142 changes: 86 additions & 56 deletions internal/native/dispatch_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package native
import (
`unsafe`

// `github.com/bytedance/sonic/internal/cpu`
`github.com/bytedance/sonic/internal/cpu`
`github.com/bytedance/sonic/internal/native/avx`
// `github.com/bytedance/sonic/internal/native/avx2`
// `github.com/bytedance/sonic/internal/native/sse`
`github.com/bytedance/sonic/internal/native/avx2`
`github.com/bytedance/sonic/internal/native/sse`
`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
)
Expand Down Expand Up @@ -157,6 +157,42 @@ func ValidateUTF8Fast(s *string) (ret int) {
return __ValidateUTF8Fast(rt.NoEscape(unsafe.Pointer(s)))
}

func useSSE() {
sse.Use()
S_f64toa = sse.S_f64toa
__F64toa = sse.F_f64toa
S_f32toa = sse.S_f32toa
__F64toa = sse.F_f64toa
S_i64toa = sse.S_i64toa
__I64toa = sse.F_i64toa
S_u64toa = sse.S_u64toa
__U64toa = sse.F_u64toa
S_lspace = sse.S_lspace
S_quote = sse.S_quote
__Quote = sse.F_quote
S_unquote = sse.S_unquote
__Unquote = sse.F_unquote
S_value = sse.S_value
__Value = sse.F_value
S_vstring = sse.S_vstring
S_vnumber = sse.S_vnumber
S_vsigned = sse.S_vsigned
S_vunsigned = sse.S_vunsigned
S_skip_one = sse.S_skip_one
__SkipOne = sse.F_skip_one
__SkipOneFast = sse.F_skip_one_fast
S_skip_array = sse.S_skip_array
S_skip_object = sse.S_skip_object
S_skip_number = sse.S_skip_number
S_get_by_path = sse.S_get_by_path
__GetByPath = sse.F_get_by_path
__HTMLEscape = sse.F_html_escape
__ValidateOne = sse.F_validate_one
__ValidateUTF8= sse.F_validate_utf8
__ValidateUTF8Fast = sse.F_validate_utf8_fast
}


func useAVX() {
avx.Use()
S_f64toa = avx.S_f64toa
Expand Down Expand Up @@ -191,57 +227,51 @@ func useAVX() {
__ValidateUTF8= avx.F_validate_utf8
__ValidateUTF8Fast = avx.F_validate_utf8_fast
}

// func useAVX2() {
// S_f64toa = avx2.S_f64toa
// S_f32toa = avx2.S_f32toa
// S_i64toa = avx2.S_i64toa
// S_u64toa = avx2.S_u64toa
// S_lspace = avx2.S_lspace
// S_quote = avx2.S_quote
// S_unquote = avx2.S_unquote
// S_value = avx2.S_value
// S_vstring = avx2.S_vstring
// S_vnumber = avx2.S_vnumber
// S_vsigned = avx2.S_vsigned
// S_vunsigned = avx2.S_vunsigned
// S_skip_one = avx2.S_skip_one
// S_skip_one_fast = avx2.S_skip_one_fast
// S_skip_array = avx2.S_skip_array
// S_skip_object = avx2.S_skip_object
// S_skip_number = avx2.S_skip_number
// S_get_by_path = avx2.S_get_by_path
// }

// func useSSE() {
// S_f64toa = sse.S_f64toa
// S_f32toa = sse.S_f32toa
// S_i64toa = sse.S_i64toa
// S_u64toa = sse.S_u64toa
// S_lspace = sse.S_lspace
// S_quote = sse.S_quote
// S_unquote = sse.S_unquote
// S_value = sse.S_value
// S_vstring = sse.S_vstring
// S_vnumber = sse.S_vnumber
// S_vsigned = sse.S_vsigned
// S_vunsigned = sse.S_vunsigned
// S_skip_one = sse.S_skip_one
// S_skip_one_fast = sse.S_skip_one_fast
// S_skip_array = sse.S_skip_array
// S_skip_object = sse.S_skip_object
// S_skip_number = sse.S_skip_number
// S_get_by_path = sse.S_get_by_path
// }

func init() {
// if cpu.HasAVX2 {
// useAVX2()
// } else if cpu.HasAVX {
useAVX()
// } else if cpu.HasSSE {
// useSSE()
// } else {
// panic("Unsupported CPU, maybe it's too old to run Sonic.")
// }

func useAVX2() {
avx2.Use()
S_f64toa = avx2.S_f64toa
__F64toa = avx2.F_f64toa
S_f32toa = avx2.S_f32toa
__F64toa = avx2.F_f64toa
S_i64toa = avx2.S_i64toa
__I64toa = avx2.F_i64toa
S_u64toa = avx2.S_u64toa
__U64toa = avx2.F_u64toa
S_lspace = avx2.S_lspace
S_quote = avx2.S_quote
__Quote = avx2.F_quote
S_unquote = avx2.S_unquote
__Unquote = avx2.F_unquote
S_value = avx2.S_value
__Value = avx2.F_value
S_vstring = avx2.S_vstring
S_vnumber = avx2.S_vnumber
S_vsigned = avx2.S_vsigned
S_vunsigned = avx2.S_vunsigned
S_skip_one = avx2.S_skip_one
__SkipOne = avx2.F_skip_one
__SkipOneFast = avx2.F_skip_one_fast
S_skip_array = avx2.S_skip_array
S_skip_object = avx2.S_skip_object
S_skip_number = avx2.S_skip_number
S_get_by_path = avx2.S_get_by_path
__GetByPath = avx2.F_get_by_path
__HTMLEscape = avx2.F_html_escape
__ValidateOne = avx2.F_validate_one
__ValidateUTF8= avx2.F_validate_utf8
__ValidateUTF8Fast = avx2.F_validate_utf8_fast
}


func init() {
if cpu.HasAVX2 {
useAVX2()
} else if cpu.HasAVX {
useAVX()
} else if cpu.HasSSE {
useSSE()
} else {
panic("Unsupported CPU, maybe it's too old to run Sonic.")
}
}

0 comments on commit d053dcd

Please sign in to comment.