Why does Go not have intrinsic functions?

211 views
Skip to first unread message

Arthur Comte

unread,
Apr 7, 2022, 2:04:02 PM4/7/22
to golang-nuts
Intrinsic functions (functions that compile down to one hardware instruction) are common in (relatively) low-level languages. Go even supports embed ASM (though a weird flavour of it)
Can someone explain why we do not have an intrinsic function package? This seems like it would greatly ease the use of SIMD
Thanks in advance

Axel Wagner

unread,
Apr 7, 2022, 2:29:08 PM4/7/22
to Arthur Comte, golang-nuts
Go does have them.
math/big compiles down to single instructions on platforms where it's supported. sync/atomic does as well.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7d95b9b9-9b94-48c1-9784-c5b7c54bc6b9n%40googlegroups.com.

Ian Lance Taylor

unread,
Apr 7, 2022, 4:35:35 PM4/7/22
to Arthur Comte, golang-nuts
On Thu, Apr 7, 2022 at 11:03 AM Arthur Comte <ad...@arthurcomte.com> wrote:
>
> Intrinsic functions (functions that compile down to one hardware instruction) are common in (relatively) low-level languages. Go even supports embed ASM (though a weird flavour of it)
> Can someone explain why we do not have an intrinsic function package? This seems like it would greatly ease the use of SIMD

Go does have a couple of intrinsic function packages: sync/atomic and
math/bits. Many of the functions in those packages are implemented
directly in the compiler.

What Go does not have is a generalized way to write intrinsic
functions apart from implementing them in the compiler. That was
https://go.dev/issue/17373, which was declined.

Go also does not have a SIMD package, but that is more because nobody
has figured out the right approach for such a thing in Go. There was
at least one attempt at https://go.dev/issue/35307, but that too was
declined.

Ian

Sam Hughes

unread,
Apr 8, 2022, 1:32:40 AM4/8/22
to golang-nuts
FWIW, I took a stab at a SIMD-oriented feature (https://go.dev/issue/48499), but as @Ian%20Lance%20Taylor put it, it's about the right approach. I skewed too far towards convenience in what I proposed, gaining significant maintainability concerns.
Reply all
Reply to author
Forward
0 new messages