tools_compiler-english.tex 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. \subsection{Compilation}
  2. \index{OpenCL compiler}%
  3. \index{oclh_cr@\texttt{oclh\_cr}}%
  4. Isolated compilation is performed by \verb|oclh_cr|.
  5. \subsubsection{Synopsis}
  6. \begin{CodeParWithCC}{\\\{\}}
  7. oclh_cr [--dev-idxs=\underline{\smash{\textit{#}}},\underline{\smash{\textit{#}}},... | --dev-name=\underline{\smash{\textit{mask}}}]
  8. [--verbatim-output-name] [-o \underline{\smash{\textit{outfile}}}]
  9. [COMPILER_OPTIONS] \underline{\smash{\textit{infile}}}...
  10. \end{CodeParWithCC}
  11. \subsubsection{Description}
  12. When \verb|oclh_сr| is called, source code is compiled from files
  13. \verbIU{infile}\verb|...| for all GPGPU devices available on the system. If the
  14. \verb|--dev-idxs=|\verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| option was
  15. specified, then compilation would be performed only for the GPGPU devices with
  16. the \verbIU{\#}\Verb|,|\verbIU{\#}\Verb|,...| indices (for details, see
  17. s.\ref{subsubsec:cr_args}). If the \verb|--dev-name=|\verbIU{mask} was
  18. specified, then compilation would be performed only for the GPGPU devices whose
  19. model matches the \verbIU{mask} (for details, see s.\ref{subsubsec:cr_args}).
  20. During the execution of the \verb|oclh_сr| tool, a detailed diagnostic log is
  21. being maintained in the \verb|oclh_cr.log| file, where excessive information is
  22. stored on all available GPGPU devices, used platforms, and contexts created for
  23. compilation. In fact, you can run \verb|oclh_сr| with any input file, even with
  24. itself as \verb|./oclh_сr oclh_сr|. The input file, of course, will not be
  25. compiled into an OpenCL object, but the \verb|oclh_сr.log| log file will contain
  26. complete information on GPGPU devices found in the system. The log file format
  27. is human-readable, adapted to search for substrings using the \verb|grep|
  28. command and analogues. The log file format is
  29. described~in~s.\ref{subsec:logformat}.
  30. Considering that compilation may be performed for several devices of different
  31. vendors, the program compilation log is maintained in different log files
  32. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|-trans.log|.
  33. The result of the compiler's work is an unlinked binary object saved in the
  34. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clo| file. If
  35. the option \verb|--verbatim-output-name| was specified, then the result would be
  36. saved in the \verbIU{outfile} file. Sometimes a situation arises when the
  37. vendor's OpenCL library generates several binary objects as a result, in which
  38. case all binary objects will be saved, but the postfix \verb|.|\verbI{N} will be
  39. added to the file names, where \verbI{N} is a decimal number denoting the
  40. sequence number (starting from zero) of the binary object generated by the
  41. compiler of the vendor of the GPGPU device.
  42. If the option \verb|-o| is not specified, then the \verbIU{outfile} in the file
  43. name will be replaced by a substring of the form \verb|program_0x|\verbI{HHHH}.
  44. In case if the GPGPU device model is not identified by the OpenCL means, then
  45. the \verbI{GPGPU\_device\_model} will be replaced by a substring of the form
  46. \verb|dev_0x|\verbI{HHHH}. In the replacements mentioned above, \verbI{HHHH} is
  47. hexadecimal representation of the last two bytes of the program and the GPGPU
  48. device addresses, respectively. Given that addresses of the program and GPGPU
  49. device are unique for one application run, it is highly likely that the
  50. combination of the name of the instance and the last two bytes of its address is
  51. also unique, so can be used as a substring to search related entries in the main
  52. log file \verb|oclh_сr.log|.
  53. The main log file name \verb|oclh_сr.log| and the file saving path can be
  54. changed when building the OpenCL\_helpers library in the header file\\*
  55. \indent\indent\verb|src/inc/oclh_settings.h|\\*
  56. That name and the path to save logs and compilation results are defined in
  57. macrodefinitions\\*
  58. \indent\indent\verb|#define _GHM_LOG_PATH "."|\\*
  59. \indent\indent\verb|#define _GHM_OCLH_COMPILER_LOG_FILENAME "oclh_cr.log"|
  60. The compiler always receives the \verb|-D_OCLH_OCL_COMPILER_| argument. It is
  61. hardcoded in the library code and introduced for ability to use header files
  62. both in programs for GPGPU programs and CPU without changing them. For details,
  63. see s.\ref{subsec:sharedheaders}.
  64. \subsubsection{Arguments}
  65. \label{subsubsec:cr_args}
  66. {\NmCnvDescript\verb|--dev-idxs=|\verbIU{\#}\Verb|,|\verbIU{\#}\verb|,...|\\*
  67. the \verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| numbers specified without spaces
  68. separated by commas after the \verb|--dev-idxs=| option are sequence numbers
  69. (indices) of GPGPU devices in the system for which the compilation will be
  70. performed. Indices start with zero. You can find out the indice of a specific
  71. device from the log file, in the first section of which in the device
  72. description the first line has the form\par
  73. {\hspace{2\leftskip}\verbI{YYYY}\verb|-|\verbI{MM}\verb|-|\verbI{DD}%
  74. \verb| |\verbI{hh}\verb|:|\verbI{mm}\verb|:|\verbI{ss}%
  75. \verb| ws_0x|\verbI{HHHH}\verb| dev_0x|\verbI{HHHH}%
  76. \verb+ | Device index: +\verbI{N}}\par
  77. \noindent where \verbI{N} is the indice of this device.\par}
  78. {\NmCnvDescript\verb|--dev-name=|\verbIU{mask}\\* the \verbIU{mask} string
  79. specified after the \verb|--dev-name=| option is a wildcard that defines which
  80. device models present in the system the compilation will be performed for.
  81. Wildcard characters are:\par
  82. \hspace{2\leftskip}\verb|?| -- matches any single character;\par
  83. \hspace{2\leftskip}\verb|*| -- matches any number of any characters including
  84. none.\par
  85. \noindent In the absence of wildcard characters the \verbIU{mask} is considered
  86. to be the exact name of the device model. You can find out the model of a
  87. specific device from the log file, in the first section of which in the device
  88. description there is the line of the form\par
  89. {\hspace{2\leftskip}\verbI{YYYY}\verb|-|\verbI{MM}\verb|-|\verbI{DD}%
  90. \verb| |\verbI{hh}\verb|:|\verbI{mm}\verb|:|\verbI{ss}%
  91. \verb| ws_0x|\verbI{HHHH}\verb| dev_0x|\verbI{HHHH}%
  92. \verb+ | Device name: +\verbI{model}}\par
  93. \noindent where \verbI{model} is the string that is checked for matching with
  94. the \verbIU{mask}.\par}
  95. {\NmCnvDescript\verb|--verbatim-output-name|\\* the given option instructs the
  96. compiler not to add the GPGPU device model and an extension to the output file
  97. name, but to use it exactly as described. But, if the result of the compiler's
  98. work was more than one binary object, then the \verb|.|\verbI{N} postfix would
  99. be added to the file name, where \verbI{N} is decimal number denoting the
  100. sequence number (starting from zero) of the binary object formed by the compiler
  101. of the GPGPU device vendor.\par}
  102. {\NmCnvDescript\verb|-o |\verbIU{outfile}\\* the \verbIU{outfile} string is the
  103. name of the output file. If the \verb|--verbatim-output-name| option was not
  104. specified, then the \verbIU{outfile} string would be used as the prefix of the
  105. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clo| file name, which
  106. contains the binary object generated as the result of compilation. If the
  107. \verb|--verbatim-output-name| option was specified, then the \verbIU{outfile}
  108. string would be used <<as is>>, unless several binary objects was generated as
  109. result of compilation~--~in this case, all binary objects would be saved with
  110. the \verbIU{outfile}\verb|.|\verbI{N} file names, where \verbI{N} is the
  111. sequence number of the binary object starting from zero. Additionally, the
  112. \verbIU{outfile} string is used as the prefix in the name of the compilation log
  113. file.\par
  114. \begin{ImpNote}
  115. Space characters at the beginning and the end of the \verbIU{outfile} string are
  116. deleted. Space characters inside of the \verbIU{outfile} string are replaced
  117. with underscores.
  118. \end{ImpNote}
  119. }
  120. {\NmCnvDescript\verb|COMPILER_OPTIONS|\\* compiler arguments. In unchanged form
  121. and with the preservation of the sequence passed to the compiler of the vendor.
  122. The compiler arguments themselves are described in the OpenCL specifications, in
  123. addition, the vendor's compiler can support additional arguments not fixed in
  124. the OpenCL specifications.\par}
  125. {\NmCnvDescript\verbIU{infile}\verb|...|\\* the list separated by spaces with
  126. the names of the files containing the source code of the OpenCL C or OpenCL C++
  127. program. The file name cannot begin with a~<<\verb|-|>>~character.\par}