<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta> <meta name="copyright" content="(C) Copyright 2005"></meta> <meta name="DC.rights.owner" content="(C) Copyright 2005"></meta> <meta name="DC.Type" content="concept"></meta> <meta name="DC.Title" content="Maxwell Compatibility Guide for CUDA Applications"></meta> <meta name="abstract" content="The guide to building CUDA applications for GPUs based on the NVIDIA Maxwell Architecture."></meta> <meta name="description" content="The guide to building CUDA applications for GPUs based on the NVIDIA Maxwell Architecture."></meta> <meta name="DC.Coverage" content="Programming Guides"></meta> <meta name="DC.subject" content="CUDA Maxwell, CUDA Maxwell compatibility, CUDA Maxwell cubin, CUDA Maxwell PTX, CUDA Maxwell nvcc"></meta> <meta name="keywords" content="CUDA Maxwell, CUDA Maxwell compatibility, CUDA Maxwell cubin, CUDA Maxwell PTX, CUDA Maxwell nvcc"></meta> <meta name="DC.Format" content="XHTML"></meta> <meta name="DC.Identifier" content="abstract"></meta> <link rel="stylesheet" type="text/css" href="../common/formatting/commonltr.css"></link> <link rel="stylesheet" type="text/css" href="../common/formatting/site.css"></link> <title>Maxwell Compatibility Guide :: CUDA Toolkit Documentation</title> <!--[if lt IE 9]> <script src="../common/formatting/html5shiv-printshiv.min.js"></script> <![endif]--> <script type="text/javascript" charset="utf-8" src="../common/scripts/tynt/tynt.js"></script> <script type="text/javascript" charset="utf-8" src="../common/formatting/jquery.min.js"></script> <script type="text/javascript" charset="utf-8" src="../common/formatting/jquery.ba-hashchange.min.js"></script> <script type="text/javascript" charset="utf-8" src="../common/formatting/jquery.scrollintoview.min.js"></script> <script type="text/javascript" src="../search/htmlFileList.js"></script> <script type="text/javascript" src="../search/htmlFileInfoList.js"></script> <script type="text/javascript" src="../search/nwSearchFnt.min.js"></script> <script type="text/javascript" src="../search/stemmers/en_stemmer.min.js"></script> <script type="text/javascript" src="../search/index-1.js"></script> <script type="text/javascript" src="../search/index-2.js"></script> <script type="text/javascript" src="../search/index-3.js"></script> <link rel="canonical" href="http://docs.nvidia.com/cuda/maxwell-compatibility-guide/index.html"></link> <link rel="stylesheet" type="text/css" href="../common/formatting/qwcode.highlight.css"></link> </head> <body> <header id="header"><span id="company">NVIDIA</span><span id="site-title">CUDA Toolkit Documentation</span><form id="search" method="get" action="search"> <input type="text" name="search-text"></input><fieldset id="search-location"> <legend>Search In:</legend> <label><input type="radio" name="search-type" value="site"></input>Entire Site</label> <label><input type="radio" name="search-type" value="document"></input>Just This Document</label></fieldset> <button type="reset">clear search</button> <button id="submit" type="submit">search</button></form> </header> <div id="site-content"> <nav id="site-nav"> <div class="category closed"><a href="../index.html" title="The root of the site.">CUDA Toolkit v6.5</a></div> <div class="category"><a href="index.html" title="Maxwell Compatibility Guide">Maxwell Compatibility Guide</a></div> <ul> <li> <div class="section-link"><a href="#maxwell-compatibility">1. Maxwell Compatibility</a></div> <ul> <li> <div class="section-link"><a href="#about-this-document">1.1. About this Document</a></div> </li> <li> <div class="section-link"><a href="#application-compatibility-on-maxwell">1.2. Application Compatibility on Maxwell</a></div> </li> <li> <div class="section-link"><a href="#verifying-maxwell-compatibility">1.3. Verifying Maxwell Compatibility for Existing Applications</a></div> <ul> <li> <div class="section-link"><a href="#verifying-maxwell-compatibility-using-cuda-5-5">1.3.1. Applications Using CUDA Toolkit 5.5 or Earlier</a></div> </li> <li> <div class="section-link"><a href="#verifying-maxwell-compatibility-using-cuda-6-0">1.3.2. Applications Using CUDA Toolkit 6.0</a></div> </li> </ul> </li> <li> <div class="section-link"><a href="#building-applications-with-maxwell-support">1.4. Building Applications with Maxwell Support</a></div> <ul> <li> <div class="section-link"><a href="#building-maxwell-compatible-apps-using-cuda-5-5">1.4.1. Applications Using CUDA Toolkit 5.5 or Earlier</a></div> </li> <li> <div class="section-link"><a href="#building-maxwell-compatible-apps-using-cuda-6-0">1.4.2. Applications Using CUDA Toolkit 6.0</a></div> </li> </ul> </li> </ul> </li> <li> <div class="section-link"><a href="#revision-history">A. Revision History</a></div> </li> </ul> </nav> <div id="resize-nav"></div> <nav id="search-results"> <h2>Search Results</h2> <ol></ol> </nav> <div id="contents-container"> <div id="breadcrumbs-container"> <div id="release-info">Maxwell Compatibility Guide (<a href="../../pdf/Maxwell_Compatibility_Guide.pdf">PDF</a>) - v6.5 (<a href="https://developer.nvidia.com/cuda-toolkit-archive">older</a>) - Last updated August 1, 2014 - <a href="mailto:cudatools@nvidia.com?subject=CUDA Toolkit Documentation Feedback: Maxwell Compatibility Guide">Send Feedback</a> - <span class="st_facebook"></span><span class="st_twitter"></span><span class="st_linkedin"></span><span class="st_reddit"></span><span class="st_slashdot"></span><span class="st_tumblr"></span><span class="st_sharethis"></span></div> </div> <article id="contents"> <div class="topic nested0" id="abstract"><a name="abstract" shape="rect"> <!-- --></a><h2 class="title topictitle1"><a href="#abstract" name="abstract" shape="rect">Maxwell Compatibility Guide for CUDA Applications</a></h2> <div class="body conbody"></div> </div> <div class="topic concept nested0" xml:lang="en-US" id="maxwell-compatibility"><a name="maxwell-compatibility" shape="rect"> <!-- --></a><h2 class="title topictitle1"><a href="#maxwell-compatibility" name="maxwell-compatibility" shape="rect">1. Maxwell Compatibility</a></h2> <div class="topic concept nested1" xml:lang="en-US" id="about-this-document"><a name="about-this-document" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#about-this-document" name="about-this-document" shape="rect">1.1. About this Document</a></h3> <div class="body conbody"> <p class="p">This application note, <cite class="cite">Maxwell Compatibility Guide for CUDA Applications</cite>, is intended to help developers ensure that their NVIDIA<sup>®</sup> CUDA<sup>®</sup> applications will run on GPUs based on the NVIDIA<sup>®</sup> Maxwell Architecture. This document provides guidance to developers who are already familiar with programming in CUDA C/C++ and want to make sure that their software applications are compatible with Maxwell. </p> </div> </div> <div class="topic concept nested1" xml:lang="en-US" id="application-compatibility-on-maxwell"><a name="application-compatibility-on-maxwell" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#application-compatibility-on-maxwell" name="application-compatibility-on-maxwell" shape="rect">1.2. Application Compatibility on Maxwell</a></h3> <div class="body conbody"> <p class="p">The NVIDIA CUDA C compiler, <samp class="ph codeph">nvcc</samp>, can be used to generate both architecture-specific <dfn class="term">cubin</dfn> files and forward-compatible <dfn class="term">PTX</dfn> versions of each kernel. Each cubin file targets a specific compute-capability version and is forward-compatible <em class="ph i">only with GPU architectures of the same major version number</em>. For example, cubin files that target compute capability 3.0 are supported on all compute-capability 3.x (Kepler) devices but are <em class="ph i">not</em> supported on compute-capability 5.0 (Maxwell) devices. For this reason, to ensure forward compatibility with GPU architectures introduced after the application has been released, it is recommended that all applications include PTX versions of their kernels. </p> <div class="note note"><span class="notetitle">Note:</span> CUDA Runtime applications containing both cubin and PTX code for a given architecture will automatically use the cubin by default, keeping the PTX path strictly for forward-compatibility purposes. </div> <p class="p">Applications that already include PTX versions of their kernels should work as-is on Maxwell-based GPUs. Applications that only support specific GPU architectures via cubin files, however, will need to be updated to provide Maxwell-compatible PTX or cubins. </p> </div> </div> <div class="topic concept nested1" xml:lang="en-US" id="verifying-maxwell-compatibility"><a name="verifying-maxwell-compatibility" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#verifying-maxwell-compatibility" name="verifying-maxwell-compatibility" shape="rect">1.3. Verifying Maxwell Compatibility for Existing Applications</a></h3> <div class="body conbody"> <p class="p">The first step is to check that Maxwell-compatible device code (at least PTX) is compiled in to the application. The following sections show how to accomplish this for applications built with different CUDA Toolkit versions. </p> </div> <div class="topic concept nested2" xml:lang="en-US" id="verifying-maxwell-compatibility-using-cuda-5-5"><a name="verifying-maxwell-compatibility-using-cuda-5-5" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#verifying-maxwell-compatibility-using-cuda-5-5" name="verifying-maxwell-compatibility-using-cuda-5-5" shape="rect">1.3.1. Applications Using CUDA Toolkit 5.5 or Earlier</a></h3> <div class="body conbody"> <div class="p">CUDA applications built using CUDA Toolkit versions 2.1 through 5.5 are compatible with Maxwell as long as they are built to include PTX versions of their kernels. To test that PTX JIT is working for your application, you can do the following: <ul class="ul"> <li class="li">Download and install the latest driver from <a class="xref" href="http://www.nvidia.com/drivers" target="_blank" shape="rect">http://www.nvidia.com/drivers</a>. </li> <li class="li">Set the environment variable <samp class="ph codeph">CUDA_FORCE_PTX_JIT=1</samp>. </li> <li class="li">Launch your application.</li> </ul> </div> <p class="p">When starting a CUDA application for the first time with the above environment flag, the CUDA driver will JIT-compile the PTX for each CUDA kernel that is used into native cubin code. </p> <p class="p">If you set the environment variable above and then launch your program and it works properly, then you have successfully verified Maxwell compatibility. </p> <div class="note note"><span class="notetitle">Note:</span> Be sure to unset the CUDA_FORCE_PTX_JIT environment variable when you are done testing. </div> </div> </div> <div class="topic concept nested2" xml:lang="en-US" id="verifying-maxwell-compatibility-using-cuda-6-0"><a name="verifying-maxwell-compatibility-using-cuda-6-0" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#verifying-maxwell-compatibility-using-cuda-6-0" name="verifying-maxwell-compatibility-using-cuda-6-0" shape="rect">1.3.2. Applications Using CUDA Toolkit 6.0</a></h3> <div class="body conbody"> <p class="p">CUDA applications built using CUDA Toolkit 6.0 are compatible with Maxwell as long as they are built to include kernels in either Maxwell-native cubin format (see <a class="xref" href="index.html#building-applications-with-maxwell-support" shape="rect">Building Applications with Maxwell Support</a>) or PTX format (see <a class="xref" href="index.html#verifying-maxwell-compatibility-using-cuda-5-5" shape="rect">Applications Using CUDA Toolkit 5.5 or Earlier</a>) or both. </p> </div> </div> </div> <div class="topic concept nested1" xml:lang="en-US" id="building-applications-with-maxwell-support"><a name="building-applications-with-maxwell-support" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#building-applications-with-maxwell-support" name="building-applications-with-maxwell-support" shape="rect">1.4. Building Applications with Maxwell Support</a></h3> <div class="body conbody"> <p class="p">When a CUDA application launches a kernel, the CUDA Runtime determines the compute capability of each GPU in the system and uses this information to automatically find the best matching cubin or PTX version of the kernel that is available. If a cubin file supporting the architecture of the target GPU is available, it is used; otherwise, the CUDA Runtime will load the PTX and JIT-compile that PTX to the GPU's native cubin format before launching it. If neither is available, then the kernel launch will fail. </p> <p class="p">The method used to build your application with either native cubin or at least PTX support for Maxwell depend on the version of the CUDA Toolkit used. </p> <div class="p">The main advantages of providing native cubins are as follows: <ul class="ul"> <li class="li">It saves the end user the time it takes to JIT-compile kernels that are available only as PTX. All kernels compiled into the application must have native binaries at load time or else they will be built just-in-time from PTX, including kernels from all libraries linked to the application, even if those kernels are never launched by the application. Especially when using large libraries, this JIT compilation can take a significant amount of time. The CUDA driver will cache the cubins generated as a result of the PTX JIT, so this is mostly a one-time cost for a given user, but it is time best avoided whenever possible. </li> <li class="li">PTX JIT-compiled kernels often cannot take advantage of architectural features of newer GPUs, meaning that native-compiled code may be faster or of greater accuracy. </li> </ul> </div> </div> <div class="topic concept nested2" xml:lang="en-US" id="building-maxwell-compatible-apps-using-cuda-5-5"><a name="building-maxwell-compatible-apps-using-cuda-5-5" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#building-maxwell-compatible-apps-using-cuda-5-5" name="building-maxwell-compatible-apps-using-cuda-5-5" shape="rect">1.4.1. Applications Using CUDA Toolkit 5.5 or Earlier</a></h3> <div class="body conbody"> <div class="section"> <p class="p">The compilers included in CUDA Toolkit 5.5 or earlier generate cubin files native to earlier NVIDIA architectures such as Fermi and Kepler, but they <em class="ph i">cannot</em> generate cubin files native to the Maxwell architecture. To allow support for Maxwell and future architectures when using version 5.5 or earlier of the CUDA Toolkit, the compiler must generate a PTX version of each kernel. </p> <p class="p">Below are compiler settings that could be used to build <samp class="ph codeph">mykernel.cu</samp> to run on Fermi or Kepler devices natively and on Maxwell devices via PTX JIT. </p> <p class="p">Note that <samp class="ph codeph">compute_XX</samp> refers to a PTX version and <samp class="ph codeph">sm_XX</samp> refers to a cubin version. The <samp class="ph codeph">arch=</samp> clause of the <samp class="ph codeph">-gencode=</samp> command-line option to <samp class="ph codeph">nvcc</samp> specifies the front-end compilation target and must always be a PTX version. The <samp class="ph codeph">code=</samp> clause specifies the back-end compilation target and can either be cubin or PTX or both. <strong class="ph b">Only the back-end target version(s) specified by the <samp class="ph codeph">code=</samp> clause will be retained in the resulting binary; at least one must be PTX to provide Maxwell compatibility</strong>. </p> </div> <div class="example"> <h4 class="title sectiontitle">Windows</h4><pre class="pre screen" xml:space="preserve">nvcc.exe -ccbin "C:\vs2010\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT" -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_35,code=compute_35 --compile -o "Release\mykernel.cu.obj" "mykernel.cu"</pre></div> <div class="example"> <h4 class="title sectiontitle">Mac/Linux</h4><pre class="pre screen" xml:space="preserve">/usr/local/cuda/bin/nvcc -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_35,code=compute_35 -O2 -o mykernel.o -c mykernel.cu</pre></div> <div class="section"> <p class="p">Alternatively, you may be familiar with the simplified <samp class="ph codeph">nvcc</samp> command-line option <samp class="ph codeph">-arch=sm_XX</samp>, which is a shorthand equivalent to the following more explicit <samp class="ph codeph">-gencode=</samp> command-line options used above. <samp class="ph codeph">-arch=sm_XX</samp> expands to the following: </p><pre class="pre screen" xml:space="preserve">-gencode=arch=compute_XX,code=sm_XX -gencode=arch=compute_XX,code=compute_XX</pre><p class="p">However, while the <samp class="ph codeph">-arch=sm_XX</samp> command-line option does result in inclusion of a PTX back-end target by default, it can only specify a single target cubin architecture at a time, and it is not possible to use multiple <samp class="ph codeph">-arch=</samp> options on the same <samp class="ph codeph">nvcc</samp> command line, which is why the examples above use <samp class="ph codeph">-gencode=</samp> explicitly. </p> </div> </div> </div> <div class="topic concept nested2" xml:lang="en-US" id="building-maxwell-compatible-apps-using-cuda-6-0"><a name="building-maxwell-compatible-apps-using-cuda-6-0" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#building-maxwell-compatible-apps-using-cuda-6-0" name="building-maxwell-compatible-apps-using-cuda-6-0" shape="rect">1.4.2. Applications Using CUDA Toolkit 6.0</a></h3> <div class="body conbody"> <div class="section"> <p class="p">With version 6.0 of the CUDA Toolkit, <samp class="ph codeph">nvcc</samp> can generate cubin files native to the Maxwell architecture (compute capability 5.0). When using CUDA Toolkit 6.0, to ensure that <samp class="ph codeph">nvcc</samp> will generate cubin files for all recent GPU architectures as well as a PTX version for forward compatibility with future GPU architectures, specify the appropriate <samp class="ph codeph">-gencode=</samp> parameters on the <samp class="ph codeph">nvcc</samp> command line as shown in the examples below. </p> </div> <div class="example"> <h4 class="title sectiontitle">Windows</h4><pre class="pre screen" xml:space="preserve">nvcc.exe -ccbin "C:\vs2010\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT" -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_50,code=compute_50 --compile -o "Release\mykernel.cu.obj" "mykernel.cu"</pre></div> <div class="example"> <h4 class="title sectiontitle">Mac/Linux</h4><pre class="pre screen" xml:space="preserve">/usr/local/cuda/bin/nvcc -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_50,code=compute_50 -O2 -o mykernel.o -c mykernel.cu</pre></div> <div class="section"> <p class="p">Note that <samp class="ph codeph">compute_XX</samp> refers to a PTX version and <samp class="ph codeph">sm_XX</samp> refers to a cubin version. The <samp class="ph codeph">arch=</samp> clause of the <samp class="ph codeph">-gencode=</samp> command-line option to <samp class="ph codeph">nvcc</samp> specifies the front-end compilation target and must always be a PTX version. The <samp class="ph codeph">code=</samp> clause specifies the back-end compilation target and can either be cubin or PTX or both. <strong class="ph b">Only the back-end target version(s) specified by the <samp class="ph codeph">code=</samp> clause will be retained in the resulting binary; at least one should be PTX to provide compatibility with future architectures.</strong></p> </div> </div> </div> </div> </div> <div class="topic reference nested0" id="revision-history"><a name="revision-history" shape="rect"> <!-- --></a><h2 class="title topictitle1"><a href="#revision-history" name="revision-history" shape="rect">A. Revision History</a></h2> <div class="body refbody"> <div class="section"> <h2 class="title sectiontitle">Version 1.0</h2> <ul class="ul"> <li class="li">Initial public release.</li> </ul> </div> </div> </div> <div class="topic concept nested0" id="notices-header"><a name="notices-header" shape="rect"> <!-- --></a><h2 class="title topictitle1"><a href="#notices-header" name="notices-header" shape="rect">Notices</a></h2> <div class="topic reference nested1" id="notice"><a name="notice" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#notice" name="notice" shape="rect"></a></h3> <div class="body refbody"> <div class="section"> <h3 class="title sectiontitle">Notice</h3> <p class="p">ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, "MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. </p> <p class="p">Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication of otherwise under any patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all other information previously supplied. NVIDIA Corporation products are not authorized as critical components in life support devices or systems without express written approval of NVIDIA Corporation. </p> </div> </div> </div> <div class="topic reference nested1" id="trademarks"><a name="trademarks" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#trademarks" name="trademarks" shape="rect"></a></h3> <div class="body refbody"> <div class="section"> <h3 class="title sectiontitle">Trademarks</h3> <p class="p">NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA Corporation in the U.S. and other countries. Other company and product names may be trademarks of the respective companies with which they are associated. </p> </div> </div> </div> <div class="topic reference nested1" id="copyright"><a name="copyright" shape="rect"> <!-- --></a><h3 class="title topictitle2"><a href="#copyright" name="copyright" shape="rect"></a></h3> <div class="body refbody"> <div class="section"> <h3 class="title sectiontitle">Copyright</h3> <p class="p">© 2010-<span class="ph">2014</span> NVIDIA Corporation. All rights reserved. </p> <p class="p">This product includes software developed by the Syncro Soft SRL (http://www.sync.ro/).</p> </div> </div> </div> </div> <hr id="contents-end"></hr> </article> </div> </div> <script language="JavaScript" type="text/javascript" charset="utf-8" src="../common/formatting/common.min.js"></script> <script language="JavaScript" type="text/javascript" charset="utf-8" src="../common/scripts/google-analytics/google-analytics-write.js"></script> <script language="JavaScript" type="text/javascript" charset="utf-8" src="../common/scripts/google-analytics/google-analytics-tracker.js"></script> <script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher: "998dc202-a267-4d8e-bce9-14debadb8d92", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script></body> </html>