I’m currently facing a problem while porting the embree api to go.
I’m using the syscall.LoadLibrary and syscall.Syscall functions instead of CGO
However I really don’t know how to tell GO to align the structures that are given as parameters to the functions on a 16-byte boundry. It seems that GO has no annotations telling the compiler to always lay down a type at a user defined memory alignment. Because of that I would have to choose one of two workarounds:
Write a Call-Wrapper-Function in CGO and copy the unaligned structure to an aligned one before calling the DLL-Function
-> Slow when the function will be called often
Create a GO Wrapper-function for C’s “aligned_alloc” and “free” in CGO and allocate every structure by that function
-> Not captured by go’s garbage collector and therefore not very elegant
I’m still wondering how a language can be made for performance programming yet not giving you features like mem-aligned structures for external functions that use SSE or AVX Instructions
I’m curious if someone knows a better solution to that problem.