1. 程式人生 > >Arrayfire學習筆記(一)安裝

Arrayfire學習筆記(一)安裝

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,簡直完!美!

所以以後就是一直只能這樣嗎!

要死要死要死

我好方!

反正不管怎麼樣總算是可以用了不是!剛開始第一天,不要心急小姑娘!!