Before you get started, make sure you have the necessary pre-requisites.
The ArrayFire installer ships with a few pre-built executables with the examples. These should run out of the box.
Note: For the CUDA executables, you will need to copy CUDA_PATH\nvvm\bin\nvvm64_30_0.dll to the location of the executables.
The ArrayFire installer for Windows creates a user PATH
variable containing AF_PATH%/lib
. This is required so that Windows knows where to find the ArrayFire DLLs. This variable fixes the DLL finding only for the user that installs ArrayFire.
To allow DLL detection for all users, it needs to be added to the system PATH
variable. For this, follow the steps:
PATH
, and click on it.AF_PATH%/lib
. NOTE: Ensure that there is a semi-colon separating AF_PATH%/lib
from any existing content (e.g. EXISTING_PATHS;AF_PATH%/lib;
) otherwise other software may not function correctly.AF_PATH/examples/helloworld/helloworld.sln
.helloworld
example. Be sure to, select the platform/configuration of your choice using the platform drop-down (the options are CPU, CUDA, and OpenCL) and Solution Configuration drop down (options of Release and Debug) menus.helloworld
exampleIf you are creating a new project which is intended to be platform-independent, the best option is to simply copy the existing helloworld
solution files and modify them to suit your needs. This will retain all the platform based settings that have been configured in the examples.
If you are adding ArrayFire to a new or existing project that will contain custom CPU or OpenCL kernels, you only need to make a few modifications to your project soultion:
/include;
to Project Properties -> C/C++ -> General -> Additional Include Directories/lib;
to Project Properties -> Linker -> General -> Additional Library Directoriesafcpu.lib
or afcuda.lib
or afopencl.lib
to Project Properties -> Linker -> Input -> Additional Dependencies based on your preferred backend.NOMINMAX
, AF_<CPU/CUDA/OPENCL>
and/or AF_<DEBUG/RELEASE>
in your projects. This can be added to Project Properties -> C/C++ -> General -> Preprocessor-> Preprocessory definitions.Lastly, if your project contains custom CUDA code, the instructions are slightly different:
Add the following lines to the Project Properties -> Build Events -> Post Build Events dialog:
``` echo copy "$(CUDA_PATH)\nvvm\bin\nvvm64*.dll" "$(OutDir)" copy "$(CUDA_PATH)\nvvm\bin\nvvm64*.dll" "$(OutDir)" ```
Please note that this method will not work with the ArrayFire examples as our implementations are built with the Visual Studio CL compiler rather than NVCC to ensure they are supported across various platforms.