This is a quick introduction to getting your first ArrayFire example running.
Compiling and running examples requires:
All included examples assume the ArrayFire directory structure to find headers and common build files. If you wish to build projects outside this directory structure, be sure to set the AF_PATH
environment variable to point to the ArrayFire install, or adjust it directly in the Makefile or project configuration.
By default, ArrayFire authenticates for free using hosted license servers at www.accelereyes.com
(ports 27001 and 27901).
ArrayFire Pro adds several features not found in the free version, including the ability to run offline, run multiple devices in parallel, double-precision linear algebra, sparse linear algebra, and more. Use the Manage Licenses page to start a Pro trial or download a purchased license file.
You can save your license file to one of several locations depending on operating system:
%HOME%
to jump to that folder (Windows XP uses %HOMEPATH%
instead), and save your file there (%HOME%\arrayfire.lic
).$HOME/arrayfire.lic
(or $HOME/.arrayfire.lic
to make it a hidden file).CUDA_INC_PATH
, CUDA_LIB_PATH
and CUDA_BIN_PATH
environment variables for you and will also update your PATH
variable to include the necessary DLLs.AF_PATH/examples/misc/hello_world_vs2008.sln
for VS2008. Choose the appropriate configuration (e.g. Win32 Release). When you build and run, you should see something like the output below.AF_PATH
environment variable to where you installed ArrayFire. This is used to locate ArrayFire headers and libraries to link against (libaf.lib, libafGFX.lib).PATH
environment variable%AF_PATH%/examples/bin_x64
%AF_PATH%/examples/bin_Win32
/usr/local/cuda
or nvcc
is in the PATH
. You can specify an alternate installation by setting the CUDA
environment variable (e.g., CUDA=/opt/software/cuda4.0
) or modifying the default variable setting in $AF_PATH/examples/common.mk
.AF_PATH
environment variable to where you installed ArrayFire.sh$ cd arrayfire/examples/misc sh$ make hello_world sh$ ./hello_world ArrayFire v1.0 (build 2746as9) by AccelerEyes (32-bit Linux) License Type: Concurrent Network (27000@www.accelereyes.com) Addons: none CUDA toolkit 4.0, driver 290.10 GPU0 Quadro 600, 1024 MB, Compute 2.1 (single,double) Display Device: GPU0 Quadro 600 Memory Usage: 852 MB free (1024 MB total) create a 5-by-3 matrix of random floats on the GPU A = 0.7402 0.4464 0.7762 0.9210 0.6673 0.2948 0.0390 0.1099 0.7140 0.9690 0.4702 0.3585 0.9251 0.5132 0.6814 element-wise arithmetic B = 0.7744 0.5317 0.8006 0.8962 0.7189 0.3905 0.1390 0.2097 0.7549 0.9243 0.5531 0.4509 0.8987 0.5910 0.7299 Fourier transform the result C = 3.6327 + 0.0000i 2.6043 + 0.0000i 3.1267 + 0.0000i 0.4689 + 0.4640i 0.3193 + 0.0802i 0.1713 + 0.1441i -0.3491 - 0.7454i -0.2923 - 0.4018i 0.2667 + 0.4886i -0.3491 + 0.7454i -0.2923 + 0.4018i 0.2667 - 0.4886i 0.4689 - 0.4640i 0.3193 - 0.0802i 0.1713 - 0.1441i grab last row c = 0.4689 - 0.4640i 0.3193 - 0.0802i 0.1713 - 0.1441i zero out every other column negate the first three elements of middle column B = 0.0000 -0.5317 0.0000 0.0000 -0.7189 0.0000 0.0000 -0.2097 0.0000 0.0000 0.5531 0.0000 0.0000 0.5910 0.0000 create 2-by-3 matrix from host data D = 1.0000 3.0000 5.0000 2.0000 4.0000 6.0000 copy last column onto first D = 5.0000 3.0000 5.0000 6.0000 4.0000 6.0000