tools_builder-english.tex 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. \subsection{Complete build routine}
  2. \index{OpenCL builder}%
  3. \index{oclh_br@\texttt{oclh\_br}}%
  4. Complete build routine is performed by \verb|oclh_br|.
  5. \subsubsection{Synopsis}
  6. \begin{CodeParWithCC}{\\\{\}}
  7. oclh_br [--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] [LINKER_OPTIONS] \underline{\smash{\textit{infile}}}...
  10. \end{CodeParWithCC}
  11. \subsubsection{Description}
  12. When \verb|oclh_br| is called, a complete build routine (compilation and linking) of the source code from from files \verbIU{infile}\verb|...| is performed for all GPGPU devices available on the system. If the
  13. \verb|--dev-idxs=|\verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| option was
  14. specified, then build would be performed only for the GPGPU devices with
  15. the \verbIU{\#}\Verb|,|\verbIU{\#}\Verb|,...| indices (for details, see
  16. s.\ref{subsubsec:br_args}). If the \verb|--dev-name=|\verbIU{mask} was
  17. specified, then build would be performed only for the GPGPU devices whose
  18. model matches the \verbIU{mask} (for details, see s.\ref{subsubsec:br_args}).
  19. \begin{ImpNote}
  20. At first glance, using the builder seems preferable than separate compilation
  21. and linking, as it allows to get executable files from the source code for all
  22. OpenCL devices at once. However, there are nuances that are related to the fact
  23. that the work of the builder is determined by the library of the GPGPU device
  24. vendor. So, during testing, the following problems were identified:\par
  25. {\NmCnvDescript\noindent(1) not all builders support the generation of
  26. libraries, most of them create an executable file, so to create exactly the
  27. library, it is necessary to use the linker with the \verb|-create-library|
  28. option (according to the current OpenCL specification);\par}
  29. {\NmCnvDescript\noindent(2) for some unclear reason, some builders ignore the
  30. declaration of a function and interpret only its definition, what leads to the
  31. necessity of specifying files with the definition of the function in the
  32. \verbIU{infile}\verb|...| list of files with source codes strictly before the
  33. first use of the function, despite the declaration of the function in the
  34. headers.\par}
  35. \noindent Perhaps there are or will appear other pitfalls in using vendors'
  36. builders, so it is recommended to use separate compilation and linking.
  37. \end{ImpNote}
  38. During the execution of the \verb|oclh_br| tool, a detailed diagnostic log is
  39. being maintained in the \verb|oclh_br.log| file, where excessive information is
  40. stored on all available GPGPU devices, used platforms, and contexts created for build. The log file format is described~in~s.\ref{subsec:logformat}.
  41. Considering that build may be performed for several devices of different
  42. vendors, the program build log is maintained in different log files
  43. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|-build.log|.
  44. The result of the builder's work is an executable binary object saved in the
  45. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clexe| file. If
  46. the option \verb|--verbatim-output-name| was specified, then the result would be
  47. saved in the \verbIU{outfile} file. Sometimes a situation arises when the
  48. vendor's OpenCL library generates several binary objects as a result, in which
  49. case all binary objects will be saved, but the postfix \verb|.|\verbI{N} will be
  50. added to the file names, where \verbI{N} is a decimal number denoting the
  51. sequence number (starting from zero) of the binary object generated by the
  52. builder of the vendor of the GPGPU device. An introduction to the file name of this number is due to the fact that, when implementing OpenCL, vendors are free to choose the output format of the built program. So, for example, the implementation from Intel will create and output a binary object, which is an ELF-file; and the NVidia's OpenCL implementation will output a human-readable text block of ptx-code (it's kind of Assembler variation for GPGPU, also named IR/IL~--~Intermediate Representation/Intermediate Language). Moreover, sometimes several binary objects with different contents can be generated. Before saving, what exactly is contained in the binary object is not possible by OpenCL means, therefore binary objects are simply numbered by \verbI{N} in the order in which they are stored in memory by the OpenCL implementation.
  53. If the option \verb|-o| is not specified, then the \verbIU{outfile} in the file
  54. name will be replaced by a substring of the form \verb|program_0x|\verbI{HHHH}.
  55. In case if the GPGPU device model is not identified by the OpenCL means, then
  56. the \verbI{GPGPU\_device\_model} will be replaced by a substring of the form
  57. \verb|dev_0x|\verbI{HHHH}. In the replacements mentioned above, \verbI{HHHH} is
  58. hexadecimal representation of the last two bytes of the program and the GPGPU
  59. device addresses, respectively. Given that addresses of the program and GPGPU
  60. device are unique for one application run, it is highly likely that the
  61. combination of the name of the instance and the last two bytes of its address is
  62. also unique, so can be used as a substring to search related entries in the main
  63. log file \verb|oclh_br.log|.
  64. The main log file name \verb|oclh_br.log| and the file saving path can be
  65. changed when building the OpenCL\_helpers library in the header file\\*
  66. \indent\indent\verb|src/inc/oclh_settings.h|\\*
  67. That name and the path to save logs and build results are defined in
  68. macrodefinitions\\*
  69. \indent\indent\verb|#define _GHM_LOG_PATH "."|\\*
  70. \indent\indent\verb|#define _GHM_OCLH_BUILDER_LOG_FILENAME "oclh_br.log"|
  71. The builder always receives the \verb|-D_OCLH_OCL_COMPILER_| argument. It is
  72. hardcoded in the library code and introduced for ability to use header files
  73. both in programs for GPGPU programs and CPU without changing them. For details,
  74. see s.\ref{subsec:sharedheaders}.
  75. \subsubsection{Arguments}
  76. \label{subsubsec:br_args}
  77. {\NmCnvDescript\verb|--dev-idxs=|\verbIU{\#}\Verb|,|\verbIU{\#}\verb|,...|\\*
  78. the \verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| numbers specified without spaces
  79. separated by commas after the \verb|--dev-idxs=| option are sequence numbers
  80. (indices) of GPGPU devices in the system for which the build will be performed.
  81. Indices start with zero. You can find out the indice of a specific
  82. device from the log file, in the first section of which in the device
  83. description the first line has the form\par
  84. {\hspace{2\leftskip}\verbI{YYYY}\verb|-|\verbI{MM}\verb|-|\verbI{DD}%
  85. \verb| |\verbI{hh}\verb|:|\verbI{mm}\verb|:|\verbI{ss}%
  86. \verb| ws_0x|\verbI{HHHH}\verb| dev_0x|\verbI{HHHH}%
  87. \verb+ | Device index: +\verbI{N}},\par
  88. \noindent where \verbI{N} -- is the indice of this device.\par}
  89. {\NmCnvDescript\verb|--dev-name=|\verbIU{mask}\\* the \verbIU{mask} string
  90. specified after the \verb|--dev-name=| option is a wildcard that defines which
  91. device models present in the system the build will be performed for. Wildcard
  92. characters are:\par
  93. \hspace{2\leftskip}\verb|?| -- matches any single character;\par
  94. \hspace{2\leftskip}\verb|*| -- matches any number of any characters including
  95. none.\par
  96. \noindent In the absence of wildcard characters the \verbIU{mask} is considered
  97. to be the exact name of the device model. You can find out the model of a
  98. specific device from the log file, in the first section of which in the device
  99. description there is the line of the form\par
  100. {\hspace{2\leftskip}\verbI{YYYY}\verb|-|\verbI{MM}\verb|-|\verbI{DD}%
  101. \verb| |\verbI{hh}\verb|:|\verbI{mm}\verb|:|\verbI{ss}%
  102. \verb| ws_0x|\verbI{HHHH}\verb| dev_0x|\verbI{HHHH}%
  103. \verb+ | Device name: +\verbI{model}}\par
  104. \noindent where \verbI{model} is the string that is checked for matching with
  105. the \verbIU{mask}.\par}
  106. {\NmCnvDescript\verb|--verbatim-output-name|\\* the given option instructs the
  107. builder not to add the GPGPU device model and an extension to the output file
  108. name, but to use it exactly as described. But, if the result of the builder's
  109. work was more than one binary object, then the \verb|.|\verbI{N} postfix would
  110. be added to the file name, where \verbI{N} is decimal number denoting the
  111. sequence number (starting from zero) of the binary object formed by the builder
  112. of the GPGPU device vendor.\par}
  113. {\NmCnvDescript\verb|-o |\verbIU{outfile}\\* the \verbIU{outfile} string is the
  114. name of the output file. If the \verb|--verbatim-output-name| option was not
  115. specified, then the \verbIU{outfile} string would be used as the prefix of the
  116. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clexe| file name,
  117. which contains the binary object generated as the result of build. If the
  118. \verb|--verbatim-output-name| option was specified, then the \verbIU{outfile}
  119. string would be used <<as is>>, unless several binary objects was generated as
  120. result of build~--~in this case, all binary objects would be saved with
  121. the \verbIU{outfile}\verb|.|\verbI{N} file names, where \verbI{N} is the
  122. sequence number of the binary object starting from zero. Additionally, the
  123. \verbIU{outfile} string is used as the prefix in the name of the build log
  124. file.\par
  125. \begin{ImpNote}
  126. Space characters at the beginning and the end of the \verbIU{outfile} string are
  127. deleted. Space characters inside of the \verbIU{outfile} string are replaced
  128. with underscores.
  129. \end{ImpNote}
  130. }
  131. {\NmCnvDescript\verb|COMPILER_OPTIONS|\\* compiler arguments. In unchanged form
  132. and with the preservation of the sequence passed to the builder of the vendor.
  133. The compiler arguments themselves are described in the OpenCL specifications, in
  134. addition, the vendor's builder can support additional arguments not fixed in
  135. the OpenCL specifications.\par}
  136. {\NmCnvDescript\verb|LINKER_OPTIONS|\\* linker arguments. In unchanged form
  137. and with the preservation of the sequence passed to the builder of the vendor.
  138. The linker arguments themselves are described in the OpenCL specifications, in
  139. addition, the vendor's builder can support additional arguments not fixed in
  140. the OpenCL specifications.\par}
  141. {\NmCnvDescript\verbIU{infile}\verb|...|\\* the list separated by spaces with
  142. the names of the files containing the source code of the OpenCL C or OpenCL C++
  143. program. The file name cannot begin with a~<<\verb|-|>>~character.\par}