Reputation: 81
How would one use NEON from Go? The following code
package main
// #include <arm_neon.h>
// #include <stdlib.h>
import "C"
func main() {
C.vld1q_s32(nil)
}
gives me:
➜ go build .
./main.go:9:2: could not determine kind of name for C.vld1q_s32
I'm pretty sure I have access to NEON since the following does work in C
void add(int *a, int *b, int *c, int size) {
for(int i = 0; i < size; i += 4) {
int32x4_t av = vld1q_s32(&(a[i]));
int32x4_t bv = vld1q_s32(&(b[i]));
int32x4_t cv = vaddq_s32(av, bv);
vst1q_s32(&(c[i]), cv);
}
}
I'm using a M1 mac if that helps.
Upvotes: 3
Views: 90
Reputation: 81
I've solved it by wrapping the macro around a function and the calling the function instead of the macro.
package main
// #include <arm_neon.h>
// #include <stdlib.h>
// int32x4_t _vld1q_s32(int32_t const * ptr) {
// return vld1q_s32(ptr);
// }
import "C"
func main() {
C._vld1q_s32(nil)
}
Upvotes: 1