Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactoring the repo to use ffi
  • Loading branch information
pavanky committed Feb 23, 2017
commit b6210b4a70c1490e1c444d7b94b259c0ee6846fe
21 changes: 0 additions & 21 deletions CMakeLists.txt

This file was deleted.

76 changes: 0 additions & 76 deletions CMakeModules/build_lua.cmake

This file was deleted.

21 changes: 0 additions & 21 deletions CMakeModules/lua_MSVC.patch

This file was deleted.

77 changes: 11 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,11 @@

[ArrayFire](https://github.com/arrayfire/arrayfire) is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices. This project provides Lua bindings for the ArrayFire library.

The wrapper is currently compliant with ArrayFire 3.2 API (and higher). If you find any bugs, please report them [here](https://github.com/arrayfire/arrayfire-lua/issues).
The wrapper is currently compliant with ArrayFire 3.4 API (and higher). If you find any bugs, please report them [here](https://github.com/arrayfire/arrayfire-lua/issues).

## Example

```lua
local AF = require("arrayfire")

AF.main(function()
local x = AF.randu(5, "f32")
AF.print("x", x)
AF.print("min of x", AF.min(x))
AF.print("max of x", AF.max(x))
end)
```

```
$ lua examples/lua/helloworld/intro.lua
ArrayFire v3.2.1 (CUDA, 64-bit Linux, build f263db0)
Platform: CUDA Toolkit 7.5, Driver: 358.16
[0] GeForce GTX 690, 2047 MB, CUDA Compute 3.0
-1- GeForce GTX 690, 2048 MB, CUDA Compute 3.0

x
[5 1 1 1]
0.7402
0.9210
0.0390
0.9690
0.9251

min of x
[1 1 1 1]
0.0390
max of x
[1 1 1 1]
0.9690

```
TODO

## Documentation

Expand All @@ -52,6 +19,11 @@ TODO
- `cmake`
- `Visual Studio` on Windows, `clang` / `gcc` on Linux / OSX.

Addiitonally, if you install the following Lua packages:

- [luarocks](https://github.com/keplerproject/luarocks)
- [luaffi](https://github.com/facebook/luaffifb) (Not required for LuaJIT)

### Get ArrayFire libraries

You can install ArrayFire using one of the following two ways.
Expand All @@ -65,37 +37,10 @@ You can install ArrayFire using one of the following two ways.

### Building the Lua module

**Windows**

1. Launch `cmake-gui`. Set source and build directories.
2. Press configure.
3. Select `generator` as `Visual Studio 12 2013 Win64`.
- You can choose a different generator as long as it is Win64.
4. Set `CMAKE_INSTALL_PREFIX` to a location of choice.
5. Press generate. The generated visual studio solution file will be present in the build directory.
6. Open the VS solution file and build the `INSTALL` project.

**Linux / OSX**

1. Make sure the environment variable `ArrayFire_DIR` is set to `/path/to/arrayfire/share/ArrayFire/cmake`.
2. Create a build directory and `cd` into it.
3. Run `cmake /path/to/arrayfire-lua/ -DCMAKE_INSTALL_PREFIX=package`.
4. Run `make`

### Setting up Lua paths

**Windows**

> SET LUA_PATH=C:\path\to\install\location\arrayfire\?.lua;;
> SET LUA_CPATH=C:\path\to\install\location\?.dll;;
> lua.exe helloworld/helloworld.lua

**Linux**

$ export LUA_PATH="/path/to/install/location/arrayfire/?.lua;;"
$ export LUA_CPATH="/path/to/install/location/?.so;;"
$ lua helloworld/helloworld.lua

```
cd /path/to/arrayfire-lua/
luarocks make
```

You should now be good to go!

Expand Down
23 changes: 23 additions & 0 deletions arrayfire-3.4-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package = "arrayfire"
version = "3.4-0"
source = {
url = "git://github.com/arrayfire/arrayfire-lua",
tag = "master",
dir = "."
}
description = {
summary = "Lua Bindings for ArrayFire",
homepage = "http://github.com/arrayfire",
license = "BSD-3"
}
dependencies = {
"lua >= 5.1, < 5.4",
}
build = {
type = "builtin",
modules = {
arrayfire = "arrayfire.lua",
["arrayfire.lib"] = "arrayfire/lib.lua",
["arrayfire.device"] = "arrayfire/device.lua",
},
}
3 changes: 3 additions & 0 deletions arrayfire.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('arrayfire.lib')
require('arrayfire.device')
return af
4 changes: 4 additions & 0 deletions arrayfire/device.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require('arrayfire.lib')
af.info = function()
af.lib.af_info()
end
Loading