[go-nuts] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-26 Thread 'Michael Knyszek' via golang-nuts
Ignoring more efficient ways to pass memory to C for a moment, superficially I do think your code using Pinner should work. Do you have a full reproducer? It's hard to tell from just looking at your code if your code is the problem, or its just enough to trigger some other cgo issue elsewhere i

[go-nuts] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-26 Thread Tamás Gulácsi
To convert a Go slice to C array is easy with unsafe.Slice. The problem is that the multi-dimensional C array is an array of pointers (*(*float64)) which cannot travel between the C/Go barrier. In your example, you flatten your slice, and recreate the pointers in that one big slice. You could g