MPL license를 사용하는 armadillo에 비해, ArrayFire는 BSD license를 사용하므로 상용 제품에 대한 프로그래밍에도 적합하다. Armadillo를 이용해서 상용 제품을 만드려면, 라이센스를 구입해야 한다.

MPL license

What is the license for Armadillo ? 

Armadillo is available under two licenses:

  1. Open source, under the restrictions of the Mozilla Public License (MPL) 2.0
  2. Commercial license (not open source), available for purchase. Please contact Conrad Sanderson for more information.

ArrryFire가 BSD license라는 것에 대한 안내

http://arrayfire.com/arrayfire-is-now-open-source/

ArrayFire is being released under the BSD 3-Clause License, which will enable unencumbered deployment and portability of ArrayFire for commercial use.

Interoperability with CUDA

cuda native code를 사용하고 싶을 때 ArrayFire에서 연 stream의 id를 받아 같은 stream에서 작동하게 하는 방법.

http://arrayfire.org/docs/interop_cuda.htm

1. ArrayFire, Armadillo fft 속도 비교

> comparison_speed_AF_arma_nativeCpp.exe        

                                                 

ArrayFire v3.3.2 (OpenCL, 64-bit Windows, build f65dd97)                                          

[0] NVIDIA  : GeForce GTX TITAN Black, 6144 MB                                                    

-1- INTEL   : Intel(R) HD Graphics 4600, 1425 MB                                                  

-2- INTEL   : Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz, 16299 MB                                  

-3- Experimental OpenCL 2.0 CPU Only Platform: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz, 16299 MB

elapsed seconds: 0.553387                                                                        

                                                                                                 

ArrayFire v3.3.2 (CUDA, 64-bit Windows, build f65dd97)                                            

Platform: CUDA Toolkit 7.5, Driver: CUDA Driver Version: 7050                                    

[0] GeForce GTX TITAN Black, 6144 MB, CUDA Compute 3.5                                            

elapsed seconds: 1.0508                                                                          

                                                                                                 

ArrayFire v3.3.2 (CPU, 64-bit Windows, build f65dd97)                                            

[0] Unknown: Unknown, 16299 MB, Max threads(1)                                                    

elapsed seconds: 0.727135                                                                         

                                                                                   

armadillo:

elapsed seconds: 1.932              

2. Benchmarking parallel vector libraries

http://arrayfire.com/benchmarking-parallel-vector-libraries/

참고

http://www.hnagata.net/archives/576


Build arrayfire using cmake on macbook air

  1. download, install cmake
    https://cmake.org/download/
  2. using cmake in terminal(실제로는 터미널로 빌드하지 않고 GUI cmake를 열어서 빌드하였다.)
    http://tudat.tudelft.nl/projects/tudat/wiki/Install_on_Mac_OS_X
  3. install homebrew
    http://brew.sh
  4. check dependencies for CPU environment
    install freeimage, fftw
    https://github.com/arrayfire/arrayfire/wiki/Build-Instructions-for-OSX#cpu-build-dependencies
  5. 아래와 같이 세팅
    Screen Shot 2016-07-23 at 2.04.09 AM.png
  6. cmake build 디렉토리의 ARRAYFIRE.xcodeproj를 열어 빌드
    하지만 xcode로 라이브러리를 빌드하던 도중 자꾸 238번째 프로젝트를 빌드하다가 멈추는 현상이 발생했다.
    그래서 그냥 arrayfire에서 제공하는 자동 설치 파일을 받아 설치하기로 하였다.
  7. 자동설치파일을 받아 설치하려 했지만, 마지막에 오류가 발생해서 설치 실패.
    인터넷을 검색하다가 brew를 이용하여 arrayfire를 설치할 수 있다는 사실을 알아내고 brew를 이용해 설치를 시도해 보았다.
  8. brew install homebrew/science/arrayfire
    이것을 실행하면 바로 설치가 되지 않고, 먼저 설치해야 하는 것들이 나타난다.
  9. brew cask install xquartz
    이걸 설치하라고 해서 설치하였다. 시간이 좀 걸린다.
  10. brew link --overwrite cmake
    brew link --overwrite --dry-run cmake
    cmake와 brew를 link한다는게 무슨 뜻인지는 잘 모르겠지만, 하라고 해서 했다.
  11. brew install hombrew/science/arrayfire
    마지막으로 이걸 실행하면 설치가 된다.
  12. arrayfire project templates repository에서 템플릿을 내려받는다.
    https://github.com/arrayfire/arrayfire-project-templates
    arrayfire-project-templates/XCode/ArrayFire-CPU/ArrayFire-CPU.xcodeproj 를 열어 빌드 후 실행해본다.

ArrayFire를 사용할 때 주의할 점

int main(void)

{

    array A = randu(16, 3, f32);

    array B = randu(16, 3, f32);

   

    // 원래 matrix의 row길이가 같지 않은 array는 gfor에서 column으로 표현된다 해도 붙일 수 없다.

    gfor(seq i, 3)

        array B(span, i) = fft(A(span, i)); // ERROR!

    array C = randu(16, 3, c32); // complex float array

    gfor(seq i, 3)

        array C(span, i) = fft(A(span, i)); // OK!

    return 0;

}

int main(void)

{

    array A = randu(4, 3);

   

    // 원래 matrix의 row길이가 같지 않은 array는 gfor에서 column으로 표현된다 해도 붙일 수 없다.

    gfor(seq i, 3)

        array B = join(0, A(span, i), constant(0, 1, 3)); // ERROR!

    array C = randu(2, 3);

    // 원래 matrix의 row길이가 같은 array끼리만 붙일 수 있다.

    gfor(seq i, 3)

        array B = join(0, A(span, i), C(span, i)); // OK!

       

    return 0;

}

int main(void)

{

    array A = randu(4, 3);

    // 4x3 matrix에서 각 column을 2x2 matrix로 reshaping하여 다시 사용하고 싶을 경우

    gfor(seq i, 3)

        array B = array(A(span, i), 2, 2); // ERROR!

       

    return 0;

}

int main(void)

{

    float* h_inds[] = {0, 1, 2, 3};

    array inds = array(4, 1, h_inds, afHost);

    array A = randu(4, 4);

    // 4x4 matrix에서 각 column을 indices에 따라 다시 새로운 array로 받고 싶을 때

    gfor(seq i, 4)

    {

        array B = A(span, i);

        array C = B(inds); // ERROR!

    }

       

    return 0;

}