arrayfire-go icon indicating copy to clipboard operation
arrayfire-go copied to clipboard

Discussion for API and implementation of the go wrapper

Open pavanky opened this issue 10 years ago • 5 comments

Use cgo to bind the C API: https://golang.org/cmd/cgo/

Needs more discussion.

pavanky avatar Sep 24 '15 13:09 pavanky

@rabarar We already have a functional C API for all functions in ArrayFire. You can perhaps look at https://github.com/arrayfire/arrayfire-python and https://github.com/arrayfire/arrayfire-rust wrappers to see how the C functions are being called from the respective languages.

I foresee something similar happening in go as well.

pavanky avatar Sep 26 '15 03:09 pavanky

Perfect - I'll start there.

On Sep 25, 2015, at 11:03 PM, Pavan Yalamanchili [email protected] wrote:

@rabarar We already have a functional C API for all functions in ArrayFire. You can perhaps look at https://github.com/arrayfire/arrayfire-python and https://github.com/arrayfire/arrayfire-rust wrappers to see how the C functions are being called from the respective languages.

I foresee something similar happening in go as well.

— Reply to this email directly or view it on GitHub.

rabarar avatar Sep 26 '15 11:09 rabarar

Okay, correct me if I'm wrong, but it appears that I can build mappings between the calls in the ./src/api/unified directory and I should have a full coverage of the api? Correct?

Take a look at the repo src/arrayfire/*.go and you'll see the beginning of a mapping. If you think this is the way to go, I'll continue to build out the mapping and we should have something to play with. I'm going to pause here unit you give me feedback.

rabarar avatar Sep 27 '15 19:09 rabarar

@rabarar The easier way to do this is to look at the bottom half functions in every header file in arrayfire/include/af/ after the section extern "C" {

pavanky avatar Sep 27 '15 19:09 pavanky

The structure you have so far looks good, but the one thing I am concerned about is users doing something like this (if the API allows it)

x := randu(2, 3)
y := randu(2, 3)
x = add(x, y) // This will leak memory

pavanky avatar Sep 27 '15 19:09 pavanky