1 # James Bigler, NVIDIA Corp (nvidia.com - jbigler)
2 # Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
4 # Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
6 # Copyright (c) 2007-2009
7 # Scientific Computing and Imaging Institute, University of Utah
9 # This code is licensed under the MIT License. See the FindCUDA.cmake script
10 # for the text of the license.
14 # License for the specific language governing rights and limitations under
15 # Permission is hereby granted, free of charge, to any person obtaining a
16 # copy of this software and associated documentation files (the "Software"),
17 # to deal in the Software without restriction, including without limitation
18 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 # and/or sell copies of the Software, and to permit persons to whom the
20 # Software is furnished to do so, subject to the following conditions:
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31 # DEALINGS IN THE SOFTWARE.
34 #######################################################################
35 # Parses a .cubin file produced by nvcc and reports statistics about the file.
38 file(READ ${input_file} file_text)
40 if (NOT "${file_text}" STREQUAL "")
42 string(REPLACE ";" "\\;" file_text ${file_text})
43 string(REPLACE "\ncode" ";code" file_text ${file_text})
45 list(LENGTH file_text len)
47 foreach(line ${file_text})
49 # Only look at "code { }" blocks.
50 if(line MATCHES "^code")
52 # Break into individual lines.
53 string(REGEX REPLACE "\n" ";" line ${line})
55 foreach(entry ${line})
57 # Extract kernel names.
58 if (${entry} MATCHES "[^g]name = ([^ ]+)")
59 set(entry "${CMAKE_MATCH_1}")
61 # Check to see if the kernel name starts with "_"
63 # if (${entry} MATCHES "^_")
64 # Skip the rest of this block.
65 # message("Skipping ${entry}")
68 message("Kernel: ${entry}")
73 # Skip the rest of the block if necessary
77 if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
78 set(entry "${CMAKE_MATCH_3}")
79 message("Registers: ${entry}")
83 if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
84 set(entry "${CMAKE_MATCH_3}")
85 message("Local: ${entry}")
89 if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
90 set(entry "${CMAKE_MATCH_3}")
91 message("Shared: ${entry}")
94 if (${entry} MATCHES "^}")
108 # message("FOUND NO DEPENDS")