Home
ME964 CMake & CUDA Debugging
Contents
1. 49 Nsight Requirements From http http developer nvidia com ParallelNs ight 1 51 UserGuide HT ML webframe html OS e Windows Vista 32 or 64 bit with SP1 or e Windows 7 32 or 64 bit or e Windows HPC Server 2008 32 or 64 bit Local debugging Headed Mode host and target on same machine e 2GPUs each must be either a G92 GT200 or oly GPU See below for supported graphics cards Remote debugging Headless Mode host and target on different machines e On the target machine 1 GPU on target machine must be a G92 GT200 or GT400 GPU e On the host machine with Visual Studio 1 GPU on host machine can be any GPU Current supported cards at left GeForce GeForce GTX 580 GeForce GTX 570 GeForce GTX 560 GeForce GTX 480 GeForce GTX 470 GeForce GTX 460 ION GeForce GTX 260 GeForce GTX 260 GeForce GTX 275 GeForce GTX 280 GeForce GTX 285 GeForce GTX 295 GeForce 8800 GS GeForce 9600 GSO GeForce 8800 GT GeForce 9800 GT GeForce GTS 240 GeForce 8800 GTS 512 GeForce 9800 GTX GeForce 9800 GTX GeForce GTS 250 GeForce 9800 GX2 GeForce 9600 GS GeForce 9600 GSO 512 GeForce 9600 GT GeForce G210 GeForce 9400 GT GeForce 9500 GS GeForce GT 120 GeForce 9500 GT GeForce G100 GeForce 9300 GE GeForce 8400 GeForce 9300 SE GeForce 8400 GS GeForce 9300 GS GeForce GT 220 GeForce NVS 2100 GeForce G210 GeForce NVS 3100 GeForce 210 GeForce 310 Quadro Quadro 6000 Quadro 5000 Quad
2. e Copy CMakeLists txt vanilla to CMakeLists txt file e Delete cache if necessary if you tried previous project e Configure and Generate project e Browse to e trunk build ME964 sIn project trunk source cpp project1_ vanilla Source e Very simple example project is generated Example Project Using Vanilla CMake ace Root CMakeLists txt file check required version of CMake CMAKE_MINIMUM_REQUIRED VERSION 2 0 IF CMAKE_BACKWARDS_COMPATIBILITY GREATER 2 0 6 SET CMAKE_BACKWARDS_COMPATIBILITY 2 0 6 CACHE STRING Latest version of CMake when this project was released FORCE ENDIF CMAKE_BACKWARDS_COMPATIBILITY GREATER 2 0 6 if COMMAND cmake_policy cmake_policy SET CMP0003 NEW endif COMMAND cmake_policy Declare the project PROJECT ME964 SET MY_STR HELLO CACHE STRING hello text FORCE SET MY_BOOL YES CACHE BOOL my boolean add_subdirectory source cpp project vanilla src project vanilla 27 Example Project Using Vanilla CMake 5 e cmake_policy As CMake evolves it is sometimes necessary to change existing behavior in order to fix bugs or improve implementations of existing features The CMake Policy mechanism is designed to help keep existing projects building as new versions of CMake introduce changes in behavior Each new policy behavioral change is given an identifier of the form CMP lt NNNN gt where lt NNNN gt is an integer index Documentation
3. B float dev_data A list of CU sources size_t size BLOCK_SIZE CU SOURCES float host _data BLOCK SIZE project cu cudaMalloc 6dev_ data siz A list of opp sources en CPP_SOURCES 2 dim3 numBlocks i 1 1 main cpp 5 project1 lt lt lt numBlocks numT iz s INCLUDE_DIRECTORIES soluti Epi Ra Val 2 cudaMemcpy host data dev Names the file object u include id INSTALL DIRECTORIES bin 24 Example Project ss e What did add e add project not fully implemented it s a WIP really just a place holder for now Goal was to have namespace resolution at least a form that would be possible in Cmake by prepending variables with project name e add project configuration allows specification of a configuration which can be inherited e add project executable creates a executable and can inherit project configurations multiple e add project library creates a library which compiles C C CUDA and can inherit configurations multiple e patch patches files e unpack unzips tar bz2 and zip e Remember Cmake was unmodified these scripts are in the CMake directory at root of tree CMake build tool and related source is found in platform S3rdParty tools directory when extracted from zip archive 25 Example Project Using Vanilla 33 CMake 33 e Browse to location of CMAKE HOME DIRECTORY which is the path to top of source tree where root CMakeLists txt file is located
4. obj file needs to be rebuilt which then rebuilds the dll or exe e Controls what gets built in what order Execute generators Such as the compiler which coverts source to output files e Generate configuration files e Specify install and testing locations and put all files in correct locations e Generate code Lexx Yacc or Flex and Bison Extended Backus Naur Form EBNF context free grammars e SWIG C C C Mono Language integration in Linux Check system for build dependencies some do VS not so much e CUDA nvcc Library dependencies VTK ITK etc e What are capabilities versions of C and C stdlib etc Whatever you command them to do MESSAGE Executing world domination script now execute_process COMMAND world_domination bat WORKING_DIRECTORY world_domination_scripts milky_way_galaxy earth INPUT_FILE world_domination cfg OUTPUT_FILE world_domination_result log ERROR_FILE world_domination_error log Build Tools ose e What have used What comparisons can make BorlandBuilder 5 02 Builder C 4 and 6 MS VisualStudio GNU Make autoconf and friends BJam BoostBuildV2 part of Boost C e hitp www boost org boost build2 e Perforce Software not related to Boost Jam Tutorial only put here due to use of Jam http www perforce com perforce conferences us 2001 wingerd WPLa ura pdf have not used the Perforce version only Boost s version CMake Visual Studio as a build t
5. CPack e Package software for distributions e We will focus on CMake in this talk Project life cycle aes e Code e Build e Run tests e Report test results e Bug reports e Consume coffee or other caffeinated beverage of choice e Rinse wash repeat e Finally after project completion e Requirements Analysis i e what should we have done in the beginning keeps us programmers employed Why use CMake eee e Cross platform support e Plain text files for build specification which can be tracked and diffed WinMerge Meld easily with source control tools git e Code generation configuration file generation and text manipulation with configure_file e Powerful scripting e Create your own generator e Regular Expressions e Not an exhaustive list What does CMake Look Like The name of our project is HELLO CMakeLists files in this project can refer to the root source directory of the project as HELLO SOURCE DIR and to the root binary directory of the project as HELLO BINARY DIR cmake_minimum_required VERSION 2 6 project HELLO Recurse into the Hello and Demo subdirectories This does not actually cause another CMake executable to run The same process will walk through the project s entire directory structure add_subdirectory Hello add_subdirectory Demo Source http www CMake org CMake help examples html What does CMake Look Like Make sure
6. associated with each policy describes the OLD and NEW behavior and the reason the policy was introduced Projects may set each policy to select the desired behavior When CMake needs to know which behavior to use it checks for a setting specified by the project If no setting is available the OLD behavior is assumed and a warning is produced requesting that the policy be set e Want to know more then see policies section of reference listed below e _ project lt projectname gt languageName1 languageNamez2 e Sets language to be used e Default C C e Not what was expecting as projects can have multiple subprojects e find Sie SCOPEn e gt version EXACT QUIET REQUIRED COMPONENTS componenrts NO POLICY SCOPE e FIND PACKAGE CUDA e add_subdirectory source_dir binary_dir EXCLUDE_FROM_ALL e add_subdirectory source cpp project_vanilla src project_vanilla Adds the subdirectory source cpp project_vanilla src containing a CMakeLists txt file for the exe and library e Example CMakeLists txt file to follow EXCLUDE_FROM_ALL removes from all target such as make all requiring a manual build command specifying target 28 Source http www CMake org CMake help CMake 2 8 docs html Example Project Using Vanilla CMake e Fairly self explanatory which is nice e Override where CMake would like to pu the files default C Program illes ME964 e Include directories e Need to use CUDA ADD LI
7. dereferenced with syntax ARG_LIST1 and ARG_OPTION2 as an example CMake Commands e message STATUS WARNING AUTHOR _ WARNING FATAL_ERROR SEND_ ERROR message to display e Output shows up in Cmake GUI output window e Very handy when trouble shooting build scripts CMake Commands ose e if else endif if expression then section COMMAND1 ARGS COMMAND2 ARGS elseif expression2 elseif section COMMAND1 ARGS COMMAND2 ARGS else expression else section COMMAND1 ARGS COMMAND2 ARGS endif expression e You might see this expression where beginning if and else need same expression never do this and only ever put expression in first if and not in trailing else elseif and endif etc e From CMake FAQ As of CMake 2 6 0 the ELSE and ENDIF constructs can be empty There are more than thoes shown below Just showing most commonly ones use Documentation is omitted see online refrence manual for more if lt constant gt if lt variable gt if NOT lt expression gt if lt expr1 gt AND lt expr2 gt if lt expr1 gt OR lt expr2 gt if TARGET target name if EXISTS file name if EXISTS directory name f IS DIRECTORY directory name f IS_ ABSOLUTE path if lt variable string gt MATCHES regex if lt variable string gt LESS lt variable string gt if lt variable string gt GREATER lt variable string gt if lt variable string gt
8. v3 2 CUDA_SDK_ROOT_DIR C Documents and Settings All Users Application Data NVIDIA Corporation NVIDIA GPU Compu FORCING CUDA CUDA_TOOLKIT_BIN_DIR TO C Program Files NVIDIA GPU Computing Toolkit CUDA v3 2 bin Linking libs Configuring done Generating done 23 Example Project Ree Browse to location of top trunk directory e CMakeLists txt file then to e trunk build ME964 sIn project f 5 ME964 Microsoft Visual Studio trunk source cpp project1 source Ea E E iee b eee eee nd Very simple example project is generated CHEM SEAMEN TRAER akh Jaba Debu BANA DERUG DISPLAY Uses SAP my CMake code PA EASE E l e Submitted as feature request a PEPE EE projectLcu zx ME e http www CMake org Bug view php id 11807 5 Band 1 main cpp File Properties NEVER USE SEMICOLONS AFTER EF p Bua i ar include lt gt Iles COMMANDS IN CMake can lead to all kinds ha al gawene Cendant B Mis of confusion as to where the error is IS ZB projet 5 Name main cpp 1x d Ka Face 6 _ global void projecti floaf Content False 3 Z main c 7 l File Type C C Code add_project_executable E EEE 5 pees ag pyc I Full Path C projects ME964 brar 2 data index index the name of your executable 2 projectl cu een oe proj ect 1 6 GA ZERO CHECK Relative Path C projects ME964 brar Defines if you need any define BLOCK SIZE 8 DEFINES MY DEF void entry_foo void 4
9. 0000600606060 OQ 47 Nsight Monitor and Debugger e Nsight monitor must be started before the program to be debugged can be launched e Nsight debugger attaches to monitor e Secured Connections e Allows only certain computers to connect e File synchronization e Needed if remote debugging and dlls config files etc are needed Nsight Configuration ss e Nsight Monitor e Headed Mode now called Local Mode e Can be used when computer has more than 1 GPUs installed e WDDM TDR TDR stands for Timeout Detection and Recovery This is a feature of the Windows operating system which detects response problems from a graphics card and recovers to a functional desktop by resetting the card If the operating system does not receive a response from a graphics card within a certain amount of time default is 2 seconds the operating system resets the graphics card Before TDR existed problems of this nature would have resulted in a system freeze and required a reboot of the operating system If TDR is enabled and you see the TDR error message Display driver stopped responding and has recovered this means that the Windows operating system reset the display driver refrence Nsight User manual TDR crashes will also be seen on long running kernels e Headless Mode now called Remote Mode e Used when there is no display e Connections are made remotely from client running Nsight have not tried this yet as run headed mode
10. 24 Debug C Program Files T utorial 1500 Right click on a cache value for additional options delete ignore and help Press Configure to update and display new values in red Press OK to generate selected build files and exit Cancel Delete Cache Help Single output directory for building all executables ee ER http www CMake org CMake help runningCMake html posted a desirement in the CMake Mantis bug tracker only to find out that all one has to do in CMake GUI is File gt Delete Cache then config config generate wait for CMake VS Macros to notice something is aw and update the projects still wish there were a button If could get a heart rate monitor to sense my level df frustration and automatically rerun a script to delete the cache think this would be the optimal solution Brian J Davis http comments gmane org gmane comp lib boost CMake 821 2010 What Does CMake Circa 2 8 Look LIKE ects NIH2009 source branches trunk build dvip4 Win64 File Tools remmen Help Where is the source code C projects NIH2009 source branches trunk _ C projects NIH2009 source branches trunk build dvip4 Win64 Value an i source cpp app BOOST_INCLUDE_DIR C projects NIH2009 source branches trunk bui BOOST_LIB_DIR C projects NIH2009 source branches trunk bui BUILD_64BIT BUILD_DIR area branches trunk bui BUILD_MATRIX_MULTIPLY CMAKE BACKWARDS_ COMPATIBILITY 24 rea le nie base
11. B BFB9 7F947F5DD01 4 Debug Win32 Build 0 Debug Win32 O8C6F31 1 7AA6 46EB BFB9 7F947F5DD014 Debug x64 ActiveCfg Debug x64 08C6F31 1 7AA6 46EB BFB9 7F947F5DD01 4 Debug x64 Build 0 Debug x64 08C6F31 1 7AA6 46EB BFB9 7F947F5DD014 Release Win32 ActiveCfg Release Win32 A0B424D7 6CCD 465C A90E D5589E73954E Release Win32 Build 0 Release Win32 A0B424D7 6CCD 465C A90E D5589E73954E Release x64 ActiveCfg Release x64 A0B424D7 6CCD 465C A90E D5589E73954E Release x64 Build 0 Release x64 EndGlobalSection GlobalSection SolutionProperties preSolution HideSolutionNode FALSE EndGlobalSection EndGlobal Looking at diffing VS project files cees WHEN things go wrong sIn ee lt xml version 1 0 encoding Windows 1252 gt lt VisualStudioProject ProjectType Visual C Version 9 00 Name CudaCollision ProjectGUID 08C6F31 1 7AA6 46EB BFB9 7F947F5DD014 RootNamespace CudaCollision Keyword x64Proj TargetFrameworkVersion 0 gt lt Platforms gt lt Platform Name x64 gt lt Platform Name Win32 gt lt Platforms gt lt ToolFiles gt lt DefaultToolFile FileName NvCudaRuntimeApi v3 2 rules gt _ Blah Blah Blah GOBS and GOBS more where this came from lt File RelativePath cuda_timer cu gt lt File gt lt Files gt lt Globals gt lt Globals gt lt VisualStudioProject gt What does VS do ess e Ok well prj is better than sIn not that don t lik
12. BRARY which is from part of FindCUDA when we called find_package CUDA e Set link flags to export function in dll e Specify where to install the ap and lib in SICMAKE INSTALL PREFIX bin and SICMAKE INSTALL PREFIX lib respectively e Configure a file which uses a variable in the file throug use of syntax SOME_VAR e When Configured the place holder in the file will be replaced with the value Ee WHERE CMake WOULD LIKE TO INSTALL THE FILES ET CMAKE_INSTALL_PREFIX CMAKE HOME DIRECTORY install CACHE STRING FORCE include_directories include SET MY_LIB_NAME libv SET MY_APP_NAME project_vanilla for normal C C code add_library would be used but since this contains a cu file CUDA ADD LIBRARY must be used CUDA_ADD_LIBRARY MY_LIB_ NAME pole vane ibv cpp need to export the function set_target_properties MY_LIB_NAME PROPERTIES LINK_FLAGS export my_entry_function add_executable MY_APP_NAME main cpp target_link_libraries MY_APP_NAME MY_LIB_NAME install TARGETS MY_APP_NAME DESTINATION bin install TARGETS MY_LIB_NAME DESTINATION lib SET SOME_VAR This is what gets put in run_program bat when configured 29 configure_file run_program txt CMAKE_INSTALL_PREFIX bin run_program bat CMake 20 80 e Along the lines of Dan s 20 80 rule e This is more like the 80 5 rule 80 percent of the functions there aren t that many to d
13. Back To Vanilla CMake ese e Directory listing e Want find and grep then install Cygwin or GNUWin32 Utils e Gates did not kill the command prompt and as we all know with out massive amounts of data compression 640k just isn t going to cut It oe ae CMakeLists txt vanilla go go bat install install bin Jinstall bin project vanilla exe Jinstall bin run_program bat install lib install lib libv lib JREADME txt source source cpp source cpp project_vanilla source cpp project_vanilla include source cpp project_vanilla include project_vanilla h source cpp project_vanilla src source cpp project_vanilla src CMakeLists txt source cpp project_vanilla src libv cpp source cpp project_vanilla src main cpp source cpp project_vanilla src project_vanilla cu source cpp project_vanilla src run_program txt 32 Vanilla CMake Example Cont e Main cpp below e project_vanilla cu left include lt iostream gt include lt project_vanilla h gt int main void my_entry_function std cout lt lt all is well in the universe n include lt project_vanilla h gt include lt iostream gt include lt cuda h gt __global__ void project1 float data int index threadldx x blockDim x threadldx y data index index define BLOCK_SIZE 8 _EXPORT_FUNCTION void my_entry_function void float dev_data size_t size BLOCK SIZE BLOCK SI
14. EQUAL lt variable string gt if lt variable string gt STRLESS lt variable string gt if lt variable string gt STRGREATER lt variable string gt if lt variable string gt STREQUAL lt variable string gt if DEFINED lt variable gt if expression AND expression OR expression a fm git ian ial gan falta sanity stint jen sist iin sll jan 37 CMake Commands ace file WRITE filename message to write file APPEND filename message to write file READ filename variable LIMIT numBytes OFFSET offset HEX file STRINGS filename variable LIMIT COUNT num LIMIT_INPUT numBytes LIMIT_OUTPUT numBytes LENGTH_MINIMUM numBytes LENGTH_MAXIMUM numBytes NEWLINE_CONSUME REGEX regex NO_HEX_CONVERSION file GLOB variable RELATIVE path globbing expressions file GLOB RECURSE variable RELATIVE path FOLLOW_SYMLINKS globbing expressions file RENAME lt oldname gt lt newname gt file REMOVE file1 file REMOVE RECURSE file1 file MAKE DIRECTORY directory1 directory2 file RELATIVE PATH variable directory file file TO_CMAKE PATH path result file TO_NATIVE PATH path result file DOWNLOAD url file TIMEOUT timeout STATUS status LOG log EXPECTED_MD5 sum SHOW _PROGRESSI 38 CMake Commands ose e String regex regular expression e String comparisons e To Upper Lower case string REGEX MATCH lt regular_expression gt lt output variable
15. ME964 CMake amp CUDA Debugging 66 Spring 2011 0000 6600670 Brian J Davis Oo M S PhD Candidate Biomedical Engineering 6606 Research Assistant amp amp School of Medicine and Public Health Research Area Medical Physics bdavis5 wisc edu Dan Negrut 2011 ME964 UW Madison Brian J Davis 2011 CMake Build tools What do they do What is CMake Why use CMake What can CMake do Example Project Don t listen to me go to the source hey man am just spreading the word e Google Tech Talk e en Open Source Tools to Build Test and Deploy C Software e http www youtube com watch v 8Ut904OdSCO amp feature youtube gdata am not affiliated in any way with ln Just a poor schlep trying to get his code to compile The Source e CMake by Kitware e http www CMake org e Documentation e hitp www cmake org cmake help documentation html e hitp www cmake org cmake help cmake 2 8 docs html e FAQ e hitp www CMake org Wiki CMake FAQ e Download e htto Awww CMake org CMake resources software html e Source Repository e http www CMake org Wiki CMake Git e Tutorial e htip www CMake org CMake help CMake tutorial html Go right to the source and ask the horse He ll give you the answer that you ll endorse He s ane on a steady course Talk to Mr Ed Theme song Mr Ed 1961 1966 Build tools what do they do Check dependencies You changed a source file and the
16. NMake Makefiles JOM Unix Makefiles Visual Studio 10 Visual Studio 10 Win64 Visual Studio 6 Visual Studio 7 Visual Studio 7 NET 2003 Visual Studio 8 2005 Visual Studio 8 2005 Wi nod Visual Studi io 9 2008 Visual Studio 9 2008 Win d Watcom Wmake CodeBlocks MinGW Makefiles CodeBlocks NMake Makefi les CodeBlocks Unix Makefiles Eclipse CDT4 MinGW Makefiles Eclipse CDT4 NMake Makefiles Eclipse CDT4 Unix Makefiles e First experience was with cygwin where CMake bootstraped itself built itself which was then used to generate the build files for ITK which were then used to build FTK using GNU Make This resulted in a 4 stage to compile Awesome Jbootstrap make make install Run CMake to generate Makefiles Build VTK using gnu make and makefiles e was flabbergasted and my command prompt cursor must have been exhausted had never seen the little guy do so much tearing across the screen to build a SrdParty Package Thankfully he was still blinking at the same rate as when he started tough little bugger e vowed never to use CMake after that Well then 2009 rolled around and the need to use VTK ITK demtk boost etc all of witch had versions which used CMake Quoting Homer Simpson not Greek poet of Iliad Doh What else is CMake ese e What is meant by family of tools e CTest and CDash e Automated test CTest and reporting CDash e http www cdash org CDash index php project C Make e
17. ReconSingleProjectionPlugin_generated cudaDevProps enumerate c cudaDevProps display cud mexPrintf GPU device en Specifies the project name Registry Key use sadens me The very concept the registry is an attack on my sensibilities cleanse my thoughts with a couple of pages of Linux kernel code and thoughts of apple pie Davis CMake Forums CUDA CMake and an attempt to build nbody 2010 indino E st now Baran J Looking at diffing VS project files 3555 WHEN things go wrong sin oe Microsoft Visual Studio Solution File Format Version 10 00 Visual Studio 2008 Project 8BC9CEB8 8B4A 1 1D0 8D1 1 00A0C91BC942 CudaCollision CudaCollision CudaCollision vcproj O8C6F31 1 7AA6 46EB BFB9 7F947F5DD01 4 EndProject Project 8BC9CEB8 8B4A 1 1D0 8D1 1 00A0C91BC942 BulletValidation BulletValidation BulletValidation vcproj 8644F016 E5EF 432D 98C6 91D27D459746 EndProject Project 8BC9CEB8 8B4A 11D0 8D11 00A0C91BC942 DataGeneration DataGeneration DataGeneration vcproj A0B424D7 6CCD 465C A90E D5589E73954E EndProject Global GlobalSection SolutionConfigurationPlatforms preSolution Debug Win32 Debug Win32 Debug x64 Debug x64 Release Win32 Release Win32 Release x64 Release x64 EndGlobalSection GlobalSection ProjectConfigurationPlatforms postSolution 08C6F31 1 7AA6 46EB BFB9 7F947F5DD014 Debug Win32 ActiveCfg Debug Win32 08C6F311 7AA6 46E
18. ZE sizeof float float host_data BLOCK_SIZE BLOCK_SIZE cudaMalloc amp dev_data size std cout lt lt entry_foo has been entered n dim3 numThreads BLOCK_SIZE BLOCK _ SIZE dim3 numBlocks 1 1 1 project1 lt lt lt num locks numThreads gt gt gt dev_data cudaMemcpy host_data dev_data size cudaMemcpyDeviceToHost for int row 0 row lt BLOCK SIZE row for int col 0 col lt BLOCK_SIZE col std cout lt lt t lt lt host_data col row BLOCK_SIZE std cout lt lt std endl cudaFree dev_data 33 Vanilla CMake Example Cont e run_program txt which becomes run_program bat after configure_file SET PWD CD Note SOME_VAR usage Will be replaced with value defined in CMake when bat file is generated cmd k cmd k e Just keeps command window from disappearing so commands can be typed after double clicking bat file in file explorer PWD sets present working directory to current directory echo SOME_VAR 34 CMake Macros Functions and 332 Parse Arguments a e When writing your own functions and macros you ll likely need the parse_arguments function e htto www itk org Wiki CMakeMacroParseArguments e You can probably guess what it is good for SET arguments hello OPTIONS world LIST3 foo bar OPTION2 LIST1 fuz baz PARSE ARGUMENTS ARG LIST1 LIST2 LIST3 OPTION1 OPTION2 OPTION3 arguments e The parameters are then
19. a debugger e Where did printf go e Current state of tools e NSight e cuda gdb Ope n C L might at this point be better off programming an 256x256x256 array of industrial robots to move around beads on a matched series of abacuses At least could physically see where the problem was occurring Brian J Davis NVIDIA Developer Zone posting NSIGHT Confused by shows know am confused 2011 Bug types ss e Bohr bug A repeatable bug one that manifests reliably under a possibly unknown but well defined set of conditions Antonym of heisenbug e Heisenbug A bug that disappears or alters its behavior when one attempts to probe or isolate it This usage is not even particularly fanciful the use of a debugger sometimes alters a program s operating environment significantly enough that buggy code such as that which relies on the values of uninitialized memory behaves quite differently Antonym of Bohr bug Mandelbug Mandelbrot A bug whose underlying causes are so complex and obscure as to make its behavior appear chaotic or even non deterministic Schroedinbug Schroedinger s Cat thought experiment A design or implementation bug in a program that doesn t manifest until someone reading source or using the program in an unusual way notices that it never should have worked at which point the program promptly stops working for everybody until fixed Though like bit roi this sou
20. at can be better utilized playing Angry Birds or sailing 44 Where did printf go e Removed prior to 3 0 not sure exactly release NVIDIA CUDA Linux Release Notes Version 3 1 e Added the ability to call printf from kernels This feature is supported only on the Fermi architecture e Even a better question why printf in the first place Let s think about this for a second Which thread in what block int the grid is this printf running e When does it run Might need it in he future so add a define ifdef endif Result messy code Without if statements this can generate a lot of text How do read this text This text has to be copied over to the CPU Who s going to read all that text Even armed with grep not me Should be optimizing GPU code for calculation throughput not printf statements 45 Current Tools e From NVIDIA s Website http developer nvidia com to ols ecosystem Debugging e There are likely more as this is not meant to be an exhaustive list and discussion of every debugger e This talk will focus on 2 e Parallel Nsight e cuda gdb e Visual Profiler was covered in a previous talk DEBUGGING amp PROFILING PRODUCT BRIEF DESCRIPTION COMPANY ORGANIZATION A single tool that can debug hybrid MPI Allir DOT OpenMP and CUDA applications on a single workstation or GPU cluster Allows Linux X86 64 users to debug both the CPU and the J code in CUDA Rog T
21. date command PATCH COMMAND cmd Command to patch downloaded source Configure step SOURCE_DIR dir Source dir to be used for build CONFIGURE_COMMAND cmd Build tree configuration command CMAKE COMMAND CMake Specify alternative CMake executable CMAKE_GENERATOR gen Specify generator for native build CMAKE_ARGS args Arguments to CMake command line CMAKE CACHE ARGS args Initial cache arguments of the form Dvar string on Build step BINARY_DIR dir Specify build dir location BUILD COMMAND cmd Command to drive the native build BUILD_IN_ SOURCE 1 Use source dir for build dir Install step INSTALL DIR dir Installation prefix INSTALL COMMAND cmd Command to drive install after build Test step TEST BEFORE INSTALL 1 Add test step executed before install step TEST AFTER INSTALL 1 Add test step executed after install step TEST COMMAND cmd Command to drive test Output logging LOG_DOWNLOAD 1 Wrap download in script to log output LOG_UPDATE 1 Wrap update in script to log output LOG_CONFIGURE 1 Wrap configure in script to log output LOG BUILD 1 Wrap build in script to log output LOG TEST 1 Wrap test in script to log output 40 LOG_INSTALL 1 Wrap install in script to log output Custom targets kh st1 st2 Generate custom targets for these step
22. e looking at hash codes or anything e counted 698 lines ok well SciTE htto www scintilla org SciTE html line numbering did of good wholesome xml e Seriously 698 lines of xml to specify 1 executable CollisionDetection to generate a handfull of command lines e Who s selling hardrives these days need to invest e The point here is that this is the text output which can be viewed and diffed with diff tools and should be preferably clean and it should be a relatively short time to figure out what changed and broke the build What is CMake ose e From http www CMake org e Welcome to CMake the cross platform open source build system CMake is a family of tools designed to build test and package software CMake is used to control the software compilation process using simple platform and compiler independent configuration files CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice e Product of Kitware due to the need for a cross platform build environment for Insight Segmentation and Registration Toolkit ITK as part of the Visible Human Project Meta build ae e Meta build tool e A built tool that builds build files defined by build specifications CMakeLists txt files e CMakeLists txt files which generate Make Linux and friends and Nmake on Windows or project files VS e Borland Makefiles MSYS Makefiles MinGW Makefiles NMake Makefiles
23. emcpy_block_test Configuration Platform Active x64 3 G dsacudautil S GA dsamedib a GA dsamexmatrixtest a GA ffan H GA fftFilterPlugin w A fmt_reg_plugin A GP_Loader 3 CF gpu_backprojection_test_app CMake Rules Ey Source Files gpu_backprojection_test c CMakeLists tt 4 gpu_backprojection_test_app_ gpuBackprojection cu A gpuBackprojectionPlugin S Gil CMake Rules 5 Source Files C gpuBackprojection cpp L CMakeLists ot gpuBackprojection cu 42 gpuBackprojectionPlugin_gen 6 GA gpuReconPlugin 3 GA gpuReconSingleProjectionPlugin Cl CMake Rules a O Source Files Common Properties Configuration Properties General Debugging C C General Optimization Preprocessor Code Generation Language Precompiled Headers Output Files Browse Information Advanced Command Line Linker Manifest Tool XML Document Generator Browse Information Build Events Custom Build Step 01 02 Ox Optimization Inline Function Expansion Enable Intrinsic Functions Favor Size or Speed Omit Frame Pointers Enable Fiber safe Optimizations Whole Program Optimization Optimization Select option for code optimization choose Custom to use specific optimization options Od ax IST Josa e CMakeLists ot 2 gpuPMatrixReconSingleProjection cu a ja INSTALL 1 TA matrix serialize lt i cr Solution Explorer Bq Class View Ready gpu
24. gt lt input gt lt input gt string REGEX MATCHALL lt regular_expression gt lt output variable gt lt input gt lt input gt string REGEX REPLACE lt regular_expression gt lt replace_expression gt lt output variable gt lt input gt lt input gt string REPLACE lt match_string gt lt replace_string gt lt output variable gt lt input gt lt input gt string COMPARE EQUAL lt siring1 gt lt string2 gt lt output variable gt string COMPARE NOTEQUAL lt siring1 gt lt string2 gt lt output variable gt string COMPARE LESS lt string1 gt lt string2 gt lt output variable gt string COMPARE GREATER sstring1 gt lt string2 gt lt output variable gt string ASCIl lt number gt lt number gt lt output variable gt string CONFIGURE lt string1 gt lt output variable gt ONLY ESCAPE_QUOTES string TOUPPER lt string1 gt lt output variable gt string TOLOWER lt string1 gt lt output variable gt string LENGTH lt string gt lt output variable gt string SUBSTRING lt string gt lt begin gt lt length gt lt output variable gt string STRIP lt string gt lt output variable gt string RANDOM LENGTH lt length gt ALPHABET lt alphabet gt RANDOM_SEED lt seed gt lt output variable gt 39 ExternalProject_ADD ess e Adds external 3rdParty packages to your projects e Can download source from repositories SVN GIT CVS e Build and install source
25. ion e Very good success using this method e ssh X usernam wherever e Stop your display manager Ubuntu 10 10 x64 cmd shown below using gnome e sudo stop gdm e set PATH and LD_LIBARY_PATH as necessary e ddd debugger cuda gdb app name OpenCL er what e Q Is there a OpenCL debugger There is some support for OpenCL in Parallel Nsight e Remember what said If it doesn t have a debugger don t use it e When OpenCL does then I ll switch http developer nvidia com cuda faq
26. keLists txt example to Checkout Depth CMakelists xt to see example use of SAP my mis use of CMake D Omit externals Run go bat Revision e Extracts CMake from HEAD revision zip archive downloaded from D Revision CMake website It is not modified Launches CMake Simply for ease of use to get started svn ssh bdavis svn cae wisc edu filespace people b bdavis svn me964cmake trunk Example Project e Click Configure e Click Generate File Tools Options Where is the source code _C projects ME964 branches trunk Where to build the binaries C projects ME964 branches trunk build Search E Grouped F Advanced I Remove Entry APP_SRC_DIR BUILD_64BIT BUILD_BOOST BUILD_DIR CMAKE_BACKWARDS_COMPATIBILITY CMAKE_BUILD_TYPE CMAKE_CXX_FLAGS_DEBUG_INIT CMAKE_CXX_FLAGS_INIT CMAKE_CXX_FLAGS_MINSIZEREL_INIT Value C projects ME964 branches trunk build Windows 6 1 24 Debug D_DEBUG MDd Zi Ob0 Od DWIN32 D_WINDOWS W3 Zm1000 EHsc GR MD O1 Ob1 D NDEBUG source cpp app A Press Configure to update and display new values in red then press Generate to generate selected build files Generate Current Generator Visual Studio 9 2008 Win64 CMAKE_SYSTEM_NAME indows CUDA_GPU_FLAGS g G0 00 gencode arch compute_10 code sm_10 compute_10 gencode arch compute_13 code CUDA_TOOLKIT_ROOT_DIR C Program Files NVIDIA GPU Computing Toolkit CUDA
27. n aa ll Kel eisten configure Generate Current Generator Visual Studio 9 2008 Win64 CMAKE SYSTEM NAME Windows Value of DVIP4 GPU USE DOUBLE OFF Value of GPU USE DOUBLE Boost build touch file WHEW Boost is built CONSIDER YOURSELF LUCKY VERY LUCKY CUDA_GPU_FLAGS g G0 00 gencode arch compute_10 code sm_10 compute_10 gencode arch compute_13_ CUDA_TOOLKIT_ROOT_DIR C Program Files NVIDIA GPU Computing Toolkit CUDA v3 2 CUDA_SDK_ROOT_DIR C ProgramData NVIDIA Corporation NVIDIA GPU Computing SDK 3 2 C FORCING CUDA CUDA_TOOLKIT_BIN_DIR TO C Program Files NVIDIA GPU Computing Toolkit CUDA v3 2 bin CMake Error File C projects NIH2009 source branches trunk platform tools cmake 2 8 2 win32 x86 share CMake Error at CMake dvip4 Finddvip4 cmake 173 configure file en CMake cache os e Cache is generated when all build parameters have been set in GUI e Cache generation can require multiple configure steps as when build parameters change others can be activated which require user to ok or allow the user to change e Changes are in red until accepted and new ones based on user changes will appear in red e Clearing the cache e File gt Delete Cache CMake cache ose e Why acache e Speed no need to reparse all CMakeLists txt unless they change e There is a dependency on CMakeLists txt files e Consequences e Do not track VS project files or Makefiles CMake output with sou
28. nds impossible it happens some programs have harbored latent schroedinbugs for years e Phase of the Moon bug The phase of the moon is sometimes spouted as a silly parameter on which a bug might depend such as when exasperated after trying to isolate the true cause The Jargon File documents two rare instances in which data processing problems were actually caused by phase of the moon timing Think Y2K Yes computers do manifest certain weird behavior based on the alignment of the planets Statistical Stat bug Statistical bugs can only be detected in aggregates and not in Single runs of a section of code These are bugs that usually affect code that is supposed to produce random or pseudo random output Source http en wikipedia org wiki Jargon_File Jargon File http www catb org jargon e http www dourish com goodies jargon html a The Meaning of hack http www catb org jargon html meaning of hack html 43 Why use a debugger ees e Clean code no need to sprinkle with printf ifdef DEBUG endif or macros e Zero inon the thread block and grid ID that is causing the problem and see state of variables e Set watch points and if equals less and more boolean operations etc e fit Language does not have a debugger in this day and age don t use it i e don t waste my time except for playing Angry Birds but that s a choice e SAVE TIME SAVE TIME SAVE TIME Th
29. o 5 of your work which is the build specification And some of these are paired like if else elseif etc so maybe it s like the 40 5 half as much rule with the remaining 95 percent of the number in denominator going to coding in C which is what we should be doing anyway If you look at the example there are even fewer used but this is a simple example CMake allows things to get much much more complicated which is good Complexity when you need it simplicity when you don t add_custom_command add_custom_target add_ definitions add_dependencies add executable add library add subdirectory break cmake_policy configure_file else elseif endforeach endfunction endif endmacro endwhile execute_process Inchon i include include_directories install link_directories macro message option project return set string target_link_libraries while add_custom_command 30 CMake project regeneration EE e If VS is open and CMake regenerates project files the dialog CMake has regenerated 5 sIn and or vcproj files to the left will appear oe reload the whole solution and issue a new Build Solution comman d e CMake cannot be a akan e solution and sto prak build used it IS locked up ara lt Viu al Studi ae ompt to reload each vcproj file until this dialog in VS k is accepted Yes and any remaining Regenerate project dialogs that may appear
30. ool gt gt gt MY OPINIONS lt lt lt e Based on What 10 years experience e Great for simple projects e Unwieldy for complex projects e Modal Dialog boxes that can t be resized e Build Spec is not searchable e Which spec am changing all debug release Is this for 32 or x64 e What did change that made the build break know can diff the sIn and prj shies We will take a look at those next slide e All seems hidden behind GUI which is difficult access change and maintain Especially with broad sweeping changes Ok there Is project inheritance e _ Is this the best Microsoft can do Well no they do have nmake Of course laying out a path to project destruction is no help either e Wizards are no Merlin e Good for wear leveling of your mouse ee through increased use of right clic xoq ool O Jajordx3 Janas i lt p dvip4 Microsoft Vi File Edit View Project Build Debug Tools Gy oF ea 2a R 2 all Le Solution dvip4 20 projects co GF AUL_BUILD gt SE 5 Ey Source Files cpu_matrix_test_app cpp orgaga es AX cpu_matrix test app cpp Test Window Help gt SS b Debug gt 64 DEBUG DISPLAY ISARA Bles x Properties Global Scope 1111 112 cpu_matrix_test_app Property Pages vy Ymain int argc char arg v pu test app Project Properties Log what we received s Torz 3 CMakelists bt o a cuda_m
31. otalView E applications usi miliar TotalView GUI methods The CUDA GDB debugger is an extended version of the open source gdb NVIDIA CUDA GDB debugger providing ss native hardware debugging across CPUs and GPUs NVIDIA Parallel Nsight Visual Profiler NVIDIA Parallel Nsight is a free powerful plugin that allows programmers to develop for both GPUs and CPUs within Microsoft Visual Studio Visual Profiler is a cro atform erfor NVIDIA levelo r c i NVIDIA CUDA MEMCHECK CUDA MEMCHECK checks for misaligned memory out of bounds addresse4 Gd ors many other application erro Parallel Nsight oe e CUDA C C D e b u g g n g All NVIDIA Parallel Nsight Professional features are now available free of charge in a no cost download e CUDA Kernel Feature Trace Profi ng Integrated into Visual Studio 2008 SP1 i or Visual Studio 2010 e Data breakpoints for C U DA C DirectX 10 11 Shader Debugging cod e DirectX 10 11 Frame Debugging DirectX 10 11 Frame Profiling Parallel Nsight Features No cost Download CUDA C C Debugging e OpenCL Kernel Trace Profiling OK but what about debugging Now with VS 2010 support CUDA Kernel Trace Profiling OpenCL Kernel Trace Profiling DirectX 10 11 API amp HW Trace Data breakpoints for CUDA C C code Analyzer System Trace Tesla Compute Cluster TCC Support Forum Support All Version Upgrades 000
32. rce control management SCM Show of hands Who is Using a SCM tool Should be everyone neers file explorer copy directory does not count nor does zip and copy e VS projects and Makefiles will be regenerated e Never Change CMake output Except from my understanding you can change the cache Though not a good idea unless careful what you change Cache is loaded when CMake is loaded to acquire previous build settings CMake cache os e Cache and SET e To set variables in CMake SET is used set lt variable gt lt value gt CACHE lt type gt lt docstring gt FORCE PARENT SCOPE e Example SET MY_STR HELLO CACHE STRING hello text FORCE e What does FORCE do e No matter what is typed in the GUI in an attempt to change the variable the variable will always be HELLO e Be careful wit FORCE as remember the cache gets reloaded when CMake is run if you decide to change a value from FORCE to not FORCED then you need to delete the cache and regenerate e Anon FORCE example with use of booleans SET MY_BOOL YES CACHE BOOL my boolean ae the user to change MY_BOOL in the GUI and have the modified value change in the cache e Can also use option MY_BOOL YES 21 Example Project Ree Checkout using SVN e was forced to use SVN Repository Use CAE username and EE password CEREM Create your own Deet CMakeLists txt C projects ME964 branches me964cmake Rename CMa
33. rce 9500 GT GeForce G100 GeForce 9300 GE GeForce 8400 GeForce 9300 SE GeForce 8400 GS GeForce 9300 GS GeForce GT 220 GeForce NVS 2100 GeForce G210 GeForce NVS 3100 GeForce 210 GeForce 310 Quadro Quadro 6000 Quadro 5000 Quadro 4000 Quadro FX 4800 Quadro CX Quadro FX 5800 Quadro FX 3800 Quadro FX 3700 Quadro FX 1800 Quadro FX 380 Quadro FX 580 Quadro FX 370 Quadro FX 380 LP Tesla Tesla C2050 Tesla C2070 Tesla C1060 Tesla 1070 Nsight in Action Debugger gt NVIDIA NVIDIA Instructional Video http developer nvidia com parallel nsight videos Nsight in Action Profiler NVIDIA NVIDIA Instructional Video 53 http developer nvidia com parallel nsight videos cuda gdb ees e More evolved than Nsight though v2 0 is promising Released before Nsight DDD with cuda gdb e ddd debugger cuda gdb e Emacs below text is from the url at the bottom of the slide CUDA GBD works with GUD in Emacs and XEmacs No extra step is required besides pointing to the right binary To use cuda gdb the gud gdb command name variable must be set to cuda gdb annotate 3 Use M x customize variable to set the variable Ensure that cuda gdb is present in the Emacs XEmacs PATH http developer download nvidia com compute cuda 4 0 rc2 toolkit docs cud a gdb pdf pg 16 cuda gdb ees e Remote ssh for instance remote debug my single gpu on my laptop using a remote ssh sess
34. ro 4000 Quadro FX 4800 Quadro CX Quadro FX 5800 Quadro FX 3800 Quadro FX 3700 Quadro FX 1800 Quadro FX 380 Quadro FX 580 Quadro FX 370 Quadro FX 380 LP Tesla Tesla C2050 Tesla C2070 Tesla C1060 Tesla 1070 Nsight Requirements From http http developer nvidia com ParallelNs ight 1 51 UserGuide HT ML webframe html Disable D3D acceleration for WPF applies to local debugging only Open Windows Explorer e Browse to the Common folder Ona Windows 32 bit system browse to C Program Files NVIDIA Parallel Nsight 1 51 Common Ona Windows 64 bit system browse to C Program Files x86 NVIDIA Parallel Nsight 1 51 Common Double click on the file named DisableWpfHardwareAcceleration reg Known working from experience Foxconn destroyer motherboard with onboard NVIDIA 780a SLI Chipset and 4 Teslac1050s works just fine Also now Remote Desktop debugging works without device enumeration issue GeForce GeForce GTX 580 GeForce GTX 570 GeForce GTX 560 GeForce GTX 480 GeForce GTX 470 GeForce GTX 460 ION GeForce GTX 260 GeForce GTX 260 GeForce GTX 275 GeForce GTX 280 GeForce GTX 285 GeForce GTX 295 GeForce 8800 GS GeForce 9600 GSO GeForce 8800 GT GeForce 9800 GT GeForce GTS 240 GeForce 8800 GTS 512 GeForce 9800 GTX GeForce 9800 GTX GeForce GTS 250 GeForce 9800 GX2 GeForce 9600 GS GeForce 9600 GSO 512 GeForce 9600 GT GeForce G210 GeForce 9400 GT GeForce 9500 GS GeForce GT 120 GeFo
35. s Some points about CMake ase Flexible and powerful through use of a few commands There are more CMAKE_ variables see doc for more info Build settings are local to the directory o What does this mean e Build settings specified are Global to the directory unless set_target_properties is used e set_target_properties useful when you have 2 libs which use same source file with ifdefs and you want to build them with different settings Settings can have build configuration specific settings such as e LINK_FLAGS_ lt CONFIG gt e LINK_FLAGS_DEBUG e LINK_FLAGS_RELEASE Beware of CACHE FORCE and clear cache if you think something is not quite right IMO Needs the concept of namespaces as CMake variables can grow in large projects project is not what expected par euler does not work for third party packages such as vtk dcmtk ITK etc and ExternalProject_Add must e used e This IMO does not allow to build for only what you need No true dependency checking across files What gets build is all or none Use fully qualified names for paths NOT relative e Try relative first but when it doesn t work switch to fully qualified names Tar was supported in CMake E but not zip used for unpacking source zip and tarballs Watch for deprecated functions Mostly what see is consolidation consolidating functions into one and 41 increasing parameters which makes sense CUDA Debugging eee e Bug types e Why use
36. that it CMake friendly e Havent figured out how to get it to mow my lawn yet or make coffee but look at the number of parameters it s huge there s got to be a way e Once it was elusive and it s documentation could only be accessed by the command prompt ExternalProject_Add lt name gt Name for custom target DEPENDS projects Targets on which the project depends PREFIX dir Root dir for entire project LIST SEPARATOR sep Sep to be replaced by in cmd lines TMP_DIR dir Directory to store temporary files STAMP_DIR dir Directory to store step timestamps Download step DOWNLOAD DIR dir Directory to store downloaded files DOWNLOAD COMMAND cmd Command to download source tree CVS_REPOSITORY cvsroot CVSROOT of CVS repository CVS_MODULE mod Module to checkout from CVS repo CVS_TAG tag Tag to checkout from CVS repo SVN_REPOSITORY url URL of Subversion repo SVN_REVISION rev Revision to checkout from Subversion repo SVN USERNAME john Username for Subversion checkout and update SVN_PASSWORD doe Password for Subversion checkout and update GIT REPOSITORY url URL of git repo GIT_TAG tag Git branch name commit id or tag URL src tgz Full path or URL of source URL_MD5 md5 MD5 checksum of file at URL TIMEOUT seconds Time allowed for file download operations Update Patch step UPDATE_COMMAND cmd Source work tree up
37. the compiler can find include files from our Hello library include directories HELLO SOURCE_DIR Hello Make sure the linker can find the Hello library once it is built link_directories HELLO_BINARY_DIR Hello Add executable called helloDemo that is built from the source files demo cxx and demo_b cxx The extensions are automatically found add executable helloDemo demo cxx demo_b cxx Link the executable to the Hello library target _link_libraries helloDemo Hello Source http www CMake org CMake help examples html What does CMake Look Like CMake provides a GUI CMake GUI Processes root CMakeLists txt file e Not CMakelists txt or CMakelist txt or CMakeList txt or CMakelists txt or CMakellSts TxT remember cross platform Linux Allows user to interact with the build and change build parameters Build spec creator can specify their one SR which appear in the Where to build the binaries recommended out of source builds Delete Cache button was moved to File gt Delete Cache in newer versions 2 6 When generating build specs use copious amounts of Delete Cache and wish it were still a button speed Kitware needs to update their website with screen shots of 2 8 CMake 2 4 patch 8 Where is the source code C hoffman Step Browse Where to build the binaries Ie hoffman Step7 build v Browse m Cache Values Show Advanced Values ON
Download Pdf Manuals
Related Search
Related Contents
ASUS Z87-K G8191 User's Manual Odds & Ends #33 - Fourth Bde JROTC Severin KA 5992 coffee maker EVOLUTION - DiscreetFX BIBRAUN Emerson Fisher GX Instruction Manual REAR SHOCK USER MANUAL Carrier 33CS User's Manual DISPLAY LINE Copyright © All rights reserved.
Failed to retrieve file