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 (${file_text} MATCHES ".+")
42 # Remember, four backslashes is escaped to one backslash in the string.
43 string(REGEX REPLACE ";" "\\\\;" file_text ${file_text})
44 string(REGEX REPLACE "\ncode" ";code" file_text ${file_text})
46 list(LENGTH file_text len)
48 foreach(line ${file_text})
50 # Only look at "code { }" blocks.
51 if(line MATCHES "^code")
53 # Break into individual lines.
54 string(REGEX REPLACE "\n" ";" line ${line})
56 foreach(entry ${line})
58 # Extract kernel names.
59 if (${entry} MATCHES "[^g]name = ([^ ]+)")
60 string(REGEX REPLACE ".* = ([^ ]+)" "\\1" entry ${entry})
62 # Check to see if the kernel name starts with "_"
64 # if (${entry} MATCHES "^_")
65 # Skip the rest of this block.
66 # message("Skipping ${entry}")
68 # else (${entry} MATCHES "^_")
69 message("Kernel: ${entry}")
70 # endif (${entry} MATCHES "^_")
72 endif(${entry} MATCHES "[^g]name = ([^ ]+)")
74 # Skip the rest of the block if necessary
78 if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
79 string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
80 message("Registers: ${entry}")
84 if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
85 string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
86 message("Local: ${entry}")
90 if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
91 string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
92 message("Shared: ${entry}")
95 if (${entry} MATCHES "^}")
104 endif(line MATCHES "^code")
109 # message("FOUND NO DEPENDS")