Arrayfire学习笔记(一)安装

来源:互联网 发布:淘宝李宁乒乓球运动服 编辑:程序博客网 时间:2024/04/30 12:43

1.安装

arrayfire的官网上有教程。按照步骤基本就可以完成安装。http://arrayfire.org/docs/installing.htm

安装的过程就是很简单了,用户需要做的就是设置一个环境变量。即,In edit mode, append 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.

然后运行例程helloworld 即可。

在我运行例程的时候出现了一个错误。1>项目文件包含 ToolsVersion="12.0"。此工具集可能未知或缺失。在这种情况下,通过安装 MSBuild 的正确版本,或许可以解决此问题。否则,该 build 可能已因策略原因而被强制为某个特定 ToolsVersion。将该项目视为其已具有 ToolsVersion="4.0"。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=291333。

主要是因为我自己是VS2012,因此在项目——属性——配置属性——常规中,将平台工具集改成VS2012即可。

2.使用

(1)如果要将一个arrayfire添加到已存在的解决方案中,则需要完成一下步骤

  1. Add "$(AF_PATH)/include;" to Project Properties -> C/C++ -> General -> Additional Include Directories.
  2. Add "$(AF_PATH)/lib;" to Project Properties -> Linker -> General -> Additional Library Directories.
  3. Add afcpu.lib or afcuda.lib or afopencl.lib to Project Properties -> Linker -> Input -> Additional Dependencies. based on your preferred backend.
  4. (Optional) You may choose to define NOMINMAXAF_<CPU/CUDA/OPENCL> and/or AF_<DEBUG/RELEASE> in your projects. This can be added to Project Properties -> C/C++ -> General -> Preprocessor-> Preprocessory definitions.

(2)如果是用的CUDA工程, it is important to ensure that the CUDA NVVM DLLs are copied to the exectuable directory. This can be done by adding a post build event.

Open the Project Properties -> Build Events -> Post Build Events dialog and add the following lines to it.

echo copy "$(CUDA_PATH)\nvvm\bin\nvvm64*.dll""$(OutDir)"
copy"$(CUDA_PATH)\nvvm\bin\nvvm64*.dll""$(OutDir)"


(3)如果想要创建一个可以直接使用arrayfire的工程, 最好的办法就是去复制例程中的各种文档,然后改名字。

昨天真的是要日了狗了。由于我的电脑上没有装cuda,所以小伙伴拷给我的工程就不能直接跑。于是新建了一个空工程,想把文件拷进去,按照(1)的方法反正死活都不行。搞了一晚上,调试的时候老说我缺这个库缺那个文件,但是我在我电脑上搜索发现我确实没有那些文件...然后看到官网写

“If you wish to create a project that allows you to use all the ArrayFire backends with ease, the best way to go is to copy the HelloWorld sln/vcxproj/cpp file trio and rename them to suit your project.

All the ArrayFire examples are pre-configured for all ArrayFire backends as well as the Unified API. These can be chosen from the Solution/Platform configuration drop down boxes.

You can alternately download the template project from ArrayFire Template Projects 

好吧,于是我就把c++ source文件copy进了helloworld,简直完!美!

所以以后就是一直只能这样吗!

要死要死要死

我好方!

反正不管怎么样总算是可以用了不是!刚开始第一天,不要心急小姑娘!!

0 0
原创粉丝点击