Changes between Version 10 and Version 11 of GPUApp


Ignore:
Timestamp:
Jul 8, 2010, 1:04:38 PM (14 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GPUApp

    v10 v11  
    33[[PageOutline]]
    44
    5 We have built sample BOINC-Cuda and BOINC-OpenCL applications as templates for making your own app.
     5We have built sample BOINC-Cuda and BOINC-OpenCL applications as templates
     6for making your own app.
     7The source files are in the [SourceCode BOINC source tree]
     8in samples/nvcuda, samples/nvopencl, and samples/atiopencl.
    69
    710== Windows == #windows
    811
     12The Windows versions compile under Visual Studio (TUAN: which versions?)
     13
    914=== NVIDIA Cuda ===
    1015
    11 BOINC-NVCuda sample app for Windows can be found at "/boinc/samples/nvcuda/".
    12 
    13 {{{
    14 cuda_kernel.cu; cuda.cu; cuda_config.h
    15 }}}
    16 The example_app_nvcuda.vcproj can be found at "boinc/win_build/". Note that NVIDIA Cuda SDK 3.0 or older supports device emulation mode. If your machine doesn't have a Cuda-enabled GPU, then you should build the sample app in the device emulation mode. Do so by setting "Build -> Configuration Manger -> Configuration" to either Emudebug|Emurelease. It comes to our attention that while compiling the sample app, the linker tries to link both the debug and release libraries, and thus causing the following errors:
     16The VS project file, example_app_nvcuda.vcproj, is in "boinc/win_build/".
     17Note that NVIDIA Cuda SDK 3.0 or older supports device emulation mode.
     18If your machine doesn't have a Cuda-enabled GPU,
     19then you should build the sample app in the device emulation mode.
     20Do so by setting "Build -> Configuration Manger -> Configuration" to either Emudebug|Emurelease.
     21It comes to our attention that while compiling the sample app,
     22the linker tries to link both the debug and release libraries, and thus causing the following errors:
    1723{{{
    1824LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
     
    2127...
    2228}}}
    23 One solution to this problem is to set the Hyprid Cuda/C++ Runtime Library point to "Multi-Threaded Debug (/MTd)". Do so by right click on the project. Set "Properties -> Configuration Properties -> Cuda Build Rule v3.0.14 -> Hybrid CUDA/C++ Options -> Runtime Library" to "Multi-Threaded Debug (/MTd)".
    24 
    25 The executable file can be found at "boinc/win_build/Build/Win32/build_mode/" (build_mode could be release, debug, emurelease or emudebug).
     29One solution to this problem is to set the Hyprid Cuda/C++ Runtime Library to "Multi-Threaded Debug (/MTd)".
     30Do so by right click on the project.
     31Set "Properties -> Configuration Properties -> Cuda Build Rule v3.0.14 -> Hybrid CUDA/C++ Options -> Runtime Library"
     32to "Multi-Threaded Debug (/MTd)".
     33
     34The executable file can be found at "boinc/win_build/Build/Win32/build_mode/"
     35(build_mode could be release, debug, emurelease or emudebug).
    2636
    2737=== NVIDIA OpenCL ===
    2838
    29 BOINC-NVOpenCL sample app for Windows can be found at "/boinc/samples/nvopencl/".
    30 
    31 {{{
    32 nvopencl.hpp; nvopencl.cpp; nvopencl_kernels.cl
    33 }}}
    34 The example_app_nvopencl.vcproj can be found at "boinc/win_build/". OpenCL doesn't have emulation mode, but it could run on CPU alone by specifying CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_ALL when creating an OpenCL context.
     39The project file, example_app_nvopencl.vcproj, is in "boinc/win_build/".
     40OpenCL doesn't have emulation mode,
     41but it could run on CPU alone by specifying CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_ALL when creating an OpenCL context.
    3542 
    36 The Runtime Library needs to be reset to point to "Multi-threaded Debug (/MTd)" to avoid linking issues. Do so by right click on the project. Set "Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library" to "Multi-threaded Debug (/MTd)".
     43The Runtime Library needs to be reset to point to "Multi-threaded Debug (/MTd)" to avoid linking issues.
     44Do so by right click on the project.
     45Set "Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library" to "Multi-threaded Debug (/MTd)".
    3746
    3847=== ATI Stream OpenCL ===
    3948
    40 BOINC-ATIOpenCL sample app for Windows can be found at "/boinc/samples/atiopencl/".
    41 
    42 {{{
    43 atiopencl.hpp; atiopencl.cpp; atiopencl_kernels.cl
    44 }}}
    45 The example_app_atiopencl.vcproj can be found at "boinc/win_build/". It is identical to NVIDIA OpenCL. Prior to build the app, make sure you have already reset the Runtime Library to point to "Multi-threaded Debug (/MTd)".
     49The project file, example_app_atiopencl.vcproj, is in "boinc/win_build/".
     50It is identical to NVIDIA OpenCL.
     51Prior to build the app, make sure you have already reset the Runtime Library to point to "Multi-threaded Debug (/MTd)".
    4652
    4753== Linux == #linux
    4854
    4955=== NVIDIA Cuda ===
    50 BOINC-NVCuda sample app for Linux can be found at "/boinc/samples/nvcuda/".
    51 
    52 {{{
    53 Makefile; common.mk; cuda_kernel.cu; cuda.cu; cuda_config.h; readme.txt
    54 }}}
    55  
    56 Before running Makefile, you will need to install gcc 4.3 and g++ 4.3. This is because the NVIDIA Cuda SDK 3.0 has not yet worked with gcc 4.0 and g++ 4.0. There should be no issue compiling cuda files with gcc 4.3 and g++ 4.3 on newer NVIDIA Cuda SDK versions. For a successful compilation, please follow these steps:
    57 
    58 {{{
     56
     57Before running the Makefile, you will need to install gcc 4.3 and g++ 4.3.
     58This is because the NVIDIA Cuda SDK 3.0 has not yet worked with gcc 4.0 and g++ 4.0.
     59There should be no issue compiling cuda files with gcc 4.3 and g++ 4.3 on newer NVIDIA Cuda SDK versions.
     60For a successful compilation, please follow these steps:
     61
    59621) Install gcc-4.3 and g++-4.3:
    60    $ sudo aptitude install gcc-4.3 g++-4.3
     63{{{
     64$ sudo aptitude install gcc-4.3 g++-4.3
     65}}}
    6166
    62672) Go to SDK source directory:
    63    $ cd ~/NVIDIA_GPU_Computing_SDK/C
     68{{{
     69$ cd ~/NVIDIA_GPU_Computing_SDK/C
     70}}}
    6471
    65723) Create a directory and create symlinks to gcc-4.3/g++-4.3
    66    $ mkdir mygcc
    67    $ cd mygcc
    68    $ ln -s $(which g++-4.3) g++
    69    $ ln -s $(which gcc-4.3) gcc
    70 }}}
    71 
    72 The Makefile for Linux is made with the assumption that the NVIDIA Cuda SDK is installed at the default location "$(ROOT)/home/USER_NAME/NVIDIA_GPU_Computing_SDK/". On my Linux machine, for example, it would be "$(ROOT)/home/tuanle/NVIDIA_GPU_Computing_SDK/". Since the absolute path is used in Makefile, you will probably need to edit file "common.mk" before compiling the sample app. Do so by looking for "/home/tuanle/NVIDIA_GPU_Computing_SDK" in file "common.mk" and replace this path with an appropriate path on your machine.
    73 
    74 What if your machine doesn't have an NVIDIA Cuda-enabled GPU? Then, you can compile and run your app in emulation mode. As far as we know, NVIDIA Cuda SDK 3.1 no longer supports emulation mode. Thus, you will need to install an older Cuda SDK version, like version 3.0, on your machine. To make an executable file in emulation mode, simply type "make emu=1".
     73{{{
     74$ mkdir mygcc
     75$ cd mygcc
     76$ ln -s $(which g++-4.3) g++
     77$ ln -s $(which gcc-4.3) gcc
     78}}}
     79
     80The Makefile for Linux is made with the assumption that the NVIDIA Cuda SDK
     81is installed at the default location "$(ROOT)/home/USER_NAME/NVIDIA_GPU_Computing_SDK/".
     82On my Linux machine, for example, it would be "$(ROOT)/home/tuanle/NVIDIA_GPU_Computing_SDK/".
     83Since the absolute path is used in Makefile, you will probably need to edit file "common.mk" before compiling the sample app.
     84Do so by looking for "/home/tuanle/NVIDIA_GPU_Computing_SDK" in file "common.mk"
     85and replace this path with an appropriate path on your machine.
     86
     87What if your machine doesn't have an NVIDIA Cuda-enabled GPU?
     88Then, you can compile and run your app in emulation mode.
     89As far as we know, NVIDIA Cuda SDK 3.1 no longer supports emulation mode.
     90Thus, you will need to install an older Cuda SDK version, like version 3.0, on your machine.
     91To make an executable file in emulation mode, simply type "make emu=1".
    7592
    7693Also, note that you will need to define some environment variables before running the executable file.
     
    8299=== NVIDIA OpenCL ===
    83100
    84 BOINC-NVOpenCL sample app for Linux can be found at "/boinc/samples/nvopencl/".
    85 
    86 {{{
    87 Makefile; common_opencl; nvopencl.h; nvopencl.cpp; nvopencl_kernels; readme.txt
    88 }}}
    89 It appears that NVIDIA OpenCL SDK is missing shared library file libOpenCL.so which is needed at compile time. This library file comes with the kernel driver package which can be installed only when your machine has an NVIDIA Cuda-enabled GPU. Thus, any attempt to compile OpenCL sample codes on a non-cuda-enabled GPU machine might result in the following error:
     101It appears that NVIDIA OpenCL SDK is missing shared library file libOpenCL.so which is needed at compile time.
     102This library file comes with the kernel driver package
     103which can be installed only when your machine has an NVIDIA Cuda-enabled GPU.
     104Thus, any attempt to compile OpenCL sample codes on a non-cuda-enabled GPU machine might result in the following error:
    90105{{{
    91106/usr/bin/ld: cannot find -lOpenCL
    92107}}}
    93 The Makefile for Linux is made with the assumption that the NVIDIA Cuda SDK is installed at the default location "$(ROOT)/home/USER_NAME/NVIDIA_GPU_Computing_SDK/". On my Linux machine, for example, it would be "$(ROOT)/home/tuanle/NVIDIA_GPU_Computing_SDK/". Since the absolute path is used in Makefile, you will probably need to edit file "common.mk" before compiling the sample app. Do so by looking for "/home/tuanle/NVIDIA_GPU_Computing_SDK" in file "common.mk" and replace this path with an appropriate path on your machine.
     108The Makefile for Linux is made with the assumption that the NVIDIA Cuda SDK
     109is installed at the default location "$(ROOT)/home/USER_NAME/NVIDIA_GPU_Computing_SDK/".
     110On my Linux machine, for example, it would be "$(ROOT)/home/tuanle/NVIDIA_GPU_Computing_SDK/".
     111Since the absolute path is used in Makefile, you will probably need to edit file "common.mk" before compiling the sample app.
     112Do so by looking for "/home/tuanle/NVIDIA_GPU_Computing_SDK" in file "common.mk"
     113and replace this path with an appropriate path on your machine.
    94114
    95115=== ATI Stream OpenCL ===
    96116
    97 BOINC-ATIOpenCL sample app for Linux can be found at "/boinc/samples/atiopencl/".
    98 
    99 {{{
    100 Makefile; atiopencl.h; atiopencl.cpp; atiopencl_kernels; readme.txt
    101 }}}
    102 The Makefile for Linux is made with the assumption that the ATI Stream OpenCL SDK version 2.1 for 32-bit Linux and Boinc are installed in the same parent directory, i.e. "ati-stream-sdk-v.2.1-lnx32" directory and "boinc" directory are both installed at "$(ROOT)/home/" directory. If you are using the SDK v2.1 for 64-bit Linux, or if Boinc and the OpenCL SDK are not installed in the same parent directory, then Makefile needs to be edited prior to any compilation. Do so by looking for
    103 {{{
    104 
     117The Makefile for Linux is made with the assumption that the ATI Stream OpenCL
     118SDK version 2.1 for 32-bit Linux and Boinc are installed in the same parent directory,
     119i.e. "ati-stream-sdk-v.2.1-lnx32" directory and "boinc" directory are both installed at "$(ROOT)/home/" directory.
     120If you are using the SDK v2.1 for 64-bit Linux, or if Boinc and the OpenCL SDK
     121are not installed in the same parent directory,
     122then Makefile needs to be edited prior to any compilation.
     123Do so by looking for
     124{{{
    105125CXXFLAGS2 = -g \
    106126     ...
     
    115135in file "Makefile" and replace these paths with appropriate paths on your machine.
    116136
    117 Most problems related to running the ATI Stream OpenCL executable files can be found in ATI_Stream_SDK_Installation_Notes.pdf section 2.2. Here are the two most common run-time errors:
    118 
    119         1) ./atiopencl: error while loading shared libraries: libOpenCL.so: cannot open shared object file: No such file or directory -> Solution:
    120         {{{
     137Most problems related to running the ATI Stream OpenCL executable files
     138can be found in ATI_Stream_SDK_Installation_Notes.pdf section 2.2.
     139Here are the two most common run-time errors:
     140
     1411) ./atiopencl: error while loading shared libraries: libOpenCL.so: cannot open shared object file: No such file or directory -> Solution:
    121142Set the environment variable ATISTREAMSDKROOT
    122     $ export ATISTREAMSDKROOT=<location where Stream SDK is extracted>
     143{{{
     144$ export ATISTREAMSDKROOT=<location where Stream SDK is extracted>
     145}}}
    123146
    124147Set the library path LD_LIBRARY_PATH
    125148- For 32-bit systems:
    126     $ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86:$LD_LIBRARY_PATH
     149{{{
     150$ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86:$LD_LIBRARY_PATH
     151}}}
    127152- For 64-bit systems:
    128     $ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86_64:$LD_LIBRARY_PATH
     153{{{
     154$ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86_64:$LD_LIBRARY_PATH
     155}}}
    129156- For the 32-bit SDK to run on 64-bit systems:
    130     $ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86:$ATISTREAMSDKROOT/lib/x86_64:$LD_LIBRARY_PATH
    131         }}}
    132 
    133         2) ./atiopencl: error CL_PLATFORM_NOT_FOUND -> Solution:
    134         {{{
    135 Need to register the OpenCL ICD by following these steps:
    136 - Download icd-registration.tgz at http://developer.amd.com/Downloads/icd-registration.tgz
    137 - In the command shell, type "cd /"
    138 - Type "ls", you will see a directory named "etc". The icd-registration.tgz needs to be unzipped to that directory.
    139 - Now copy icd-registration.tgz to "cd /" by typing "sudo cp -r /home/tuanle/Downloads/icd-registration.tgz ."
    140 - You will need to replace the specified path above with the appropriate path on your machine, and don't forget "sudo". Otherwise you will get a "Permission denied".
    141 - Unzip by typing "sudo tar xzf icd-registration.tgz"
    142 - Now you should be able to find an "OpenCL" directory in "etc". Check etc/OpenCL/vendors/, make sure there are "atiocl32.icd" and "atiocl64.icd" there.
    143 - Done!
    144         }}}
     157{{{
     158$ export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86:$ATISTREAMSDKROOT/lib/x86_64:$LD_LIBRARY_PATH
     159}}}
     160
     1612) ./atiopencl: error CL_PLATFORM_NOT_FOUND ->
     162
     163Solution: Register the OpenCL ICD by following these steps:
     164 * Download icd-registration.tgz at http://developer.amd.com/Downloads/icd-registration.tgz
     165 * In the command shell, type "cd /"
     166 * Type "ls", you will see a directory named "etc".
     167  The icd-registration.tgz needs to be unzipped to that directory.
     168 * Now copy icd-registration.tgz to "cd /" by typing "sudo cp -r /home/tuanle/Downloads/icd-registration.tgz ."
     169 * You will need to replace the specified path above with the appropriate path on your machine, and don't forget "sudo".
     170  Otherwise you will get a "Permission denied".
     171 * Unzip by typing "sudo tar xzf icd-registration.tgz"
     172 * Now you should be able to find an "OpenCL" directory in "etc".
     173  Check etc/OpenCL/vendors/, make sure there are "atiocl32.icd" and "atiocl64.icd" there.
     174 * Done!
    145175
    146176== Mac OS X == #mac
    147177
     178The Mac versions are built using gcc/make (not xcode).
     179
    148180=== NVIDIA Cuda ===
    149181
    150 BOINC-Cuda sample app for Mac OS X can be found at "/boinc/samples/nvcuda/"
    151 
    152 {{{
    153 Makefile_mac; common_mac.mk; cuda_kernel_mac.cu; cuda_mac.c; cuda_config.h; readme_mac.txt
    154 }}}
    155 
    156182Unlike Windows and Linux, the 'nvcc' cuda compiler for Mac has some trouble compiling .cu files that
    157 contain both BOINC and Cuda codes. Any attempt to compile such .cu files might result in errors like
     183contain both BOINC and Cuda codes.
     184Any attempt to compile such .cu files might result in errors like
    158185these:
    159186{{{
     
    163190...
    164191}}}
    165 The solution that we came up with is to compile BOINC and Cuda seperately, meaning that compile .c files that have BOINC codes with
    166 gcc and compile .u files that have Cuda codes such as kernel definitions with nvcc (This can simply be done by putting .cu and .c
    167 file names at corresponding "CUFILES := " and "CCFILES := " entries in Makefile_mac). To handle the results computed by the kernels,
    168 you will need to write external functions. The function definitions that make kernel calls will be put in .cu file while the function headers with "extern" prefix are put in .c file and can be called in main function or elsewhere.
    169 
    170 What if your machine doesn't have an NVIDIA Cuda-enabled GPU? Then, you can compile and run your app in emulation mode. As far as we know, NVIDIA Cuda SDK 3.1 no longer supports emulation mode. Thus, you will need to install an older Cuda SDK version, like version 3.0, on your machine. To make an executable file in emulation mode, simply type "make -f Makefile_mac emu=1".
     192The solution that we came up with is to compile BOINC and Cuda separately,
     193meaning that compile .c files that have BOINC codes with
     194gcc and compile .u files that have Cuda codes such as kernel definitions with nvcc
     195(This can simply be done by putting .cu and .c
     196file names at corresponding "CUFILES := " and "CCFILES := " entries in Makefile_mac).
     197To handle the results computed by the kernels,
     198you will need to write external functions.
     199The function definitions that make kernel calls will be put in .cu file
     200while the function headers with "extern" prefix are put in .c file and can be called in main function or elsewhere.
     201
     202What if your machine doesn't have an NVIDIA Cuda-enabled GPU? Then, you can compile and run your app in emulation mode.
     203As far as we know, NVIDIA Cuda SDK 3.1 no longer supports emulation mode.
     204Thus, you will need to install an older Cuda SDK version, like version 3.0, on your machine.
     205To make an executable file in emulation mode, simply type "make -f Makefile_mac emu=1".
    171206
    172207Also, note that you will need to define some environment variables before running the executable file.
     
    176211}}}
    177212
    178 One last thing to mention, the makefile for Mac is made with the assumption that the NVIDIA Cuda SDK is installed at the default location: "$ROOT/Developer/GPU Computing/" on Mac. If it is installed at a different location on your machine, then you will need to edit file "common_mac.mk". Do so by looking for "ROOTDIR  ?= /Developer/GPU\ Computing" in file "common_mac.mk" and replace this path with an appropriate path on your machine.
     213One last thing to mention, the makefile for Mac is made with the assumption
     214that the NVIDIA Cuda SDK is installed at the default location: "$ROOT/Developer/GPU Computing/" on Mac.
     215If it is installed at a different location on your machine, then you will need to edit file "common_mac.mk".
     216Do so by looking for "ROOTDIR  ?= /Developer/GPU\ Computing" in file "common_mac.mk"
     217and replace this path with an appropriate path on your machine.
     218