tools_linker-english.tex 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. \subsection{Linking}
  2. \index{OpenCL linker}%
  3. \index{oclh_lr@\texttt{oclh\_lr}}%
  4. Isolated linking is performed by \verb|oclh_lr|.
  5. \subsubsection{Synopsis}
  6. \begin{CodeParWithCC}{\\\{\}}
  7. oclh_lr [--dev-idxs=\underline{\smash{\textit{#}}},\underline{\smash{\textit{#}}},... | --dev-name=\underline{\smash{\textit{mask}}}]
  8. [--verbatim-output-name] [-o \underline{\smash{\textit{outfile}}}]
  9. [LINKER_OPTIONS] \underline{\smash{\textit{infile}}}...
  10. \end{CodeParWithCC}
  11. \subsubsection{Description}
  12. When \verb|oclh_lr| is called, OpenCL objects are linked from files
  13. \verbIU{infile}\verb|...| for all GPGPU devices available on the system. It
  14. should be understood that only objects compiled for one GPGPU architecture can
  15. be linked, and GPGPU architectures can differ even from one vendor's devices. An
  16. attempt to link object compiled for an architecture different from the device
  17. architecture will result in error \verb|-42|
  18. OpenCL API:\\*
  19. \centerline{\Verb|oclerr: clCreateProgramWithBinary returned error -42 - CL\_INVALID\_BINARY|}\\*
  20. According to mentioned above, it is recommended to run the linker for only one device or device model using option
  21. \verb|--dev-idxs=|\verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| or
  22. \verb|--dev-name=|\verbIU{mask}. If the
  23. \verb|--dev-idxs=|\verbIU{\#}\verb|,|\verbIU{\#}\verb|,...| option was
  24. specified, then linking would be performed only for the GPGPU devices with
  25. the \verbIU{\#}\Verb|,|\verbIU{\#}\Verb|,...| indices (for details, see
  26. s.\ref{subsubsec:lr_args}). If the \verb|--dev-name=|\verbIU{mask} was
  27. specified, then linking would be performed only for the GPGPU devices whose
  28. model matches the \verbIU{mask} (for details, see s.\ref{subsubsec:lr_args}).
  29. During the execution of the \verb|oclh_lr| tool, a detailed diagnostic log is
  30. being maintained in the \verb|oclh_lr.log| file, where excessive information is
  31. stored on all available GPGPU devices, used platforms, and contexts created for
  32. linking. The log file format is described~in~s.\ref{subsec:logformat}.
  33. The linking log is maintained in log files
  34. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|-link.log|.
  35. The result of the linker's work is an executable binary object or a shared
  36. binary object (library) saved in the
  37. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clexe| or
  38. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clso| file,
  39. respectively. If the option \verb|--verbatim-output-name| was specified, then
  40. the result would be saved in the \verbIU{outfile} file. Sometimes a situation
  41. arises when the vendor's OpenCL library generates several binary objects as a
  42. result, in which case all binary objects will be saved, but the postfix
  43. \verb|.|\verbI{N} will be added to the file names, where \verbI{N} is a decimal
  44. number denoting the sequence number (starting from zero) of the binary object
  45. generated by the linker of the vendor of the GPGPU device.
  46. If the option \verb|-o| is not specified, then the \verbIU{outfile} in the file
  47. name will be replaced by a substring of the form \verb|program_0x|\verbI{HHHH}.
  48. In case if the GPGPU device model is not identified by the OpenCL means, then
  49. the \verbI{GPGPU\_device\_model} will be replaced by a substring of the form
  50. \verb|dev_0x|\verbI{HHHH}. In the replacements mentioned above, \verbI{HHHH} is
  51. hexadecimal representation of the last two bytes of the program and the GPGPU
  52. device addresses, respectively. Given that addresses of the program and GPGPU
  53. device are unique for one application run, it is highly likely that the
  54. combination of the name of the instance and the last two bytes of its address is
  55. also unique, so can be used as a substring to search related entries in the main
  56. log file \verb|oclh_lr.log|.
  57. The main log file name \verb|oclh_lr.log| and the file saving path can be
  58. changed when building the OpenCL\_helpers library in the header file\\*
  59. \indent\indent\verb|src/inc/oclh_settings.h|\\*
  60. That name and the path to save logs and linking results are defined in
  61. macrodefinitions\\*
  62. \indent\indent\verb|#define _GHM_LOG_PATH "."|\\*
  63. \indent\indent\verb|#define _GHM_OCLH_LINKER_LOG_FILENAME "oclh_lr.log"|
  64. \subsubsection{Arguments}
  65. \label{subsubsec:lr_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 linking 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 linking 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. linker 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 linker'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 linker
  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|.clexe| or
  106. \verbIU{outfile}\verb|-|\verbI{GPGPU\_device\_model}\verb|.clso| file name,
  107. which contains the binary object generated as the result of linking. If the
  108. \verb|--verbatim-output-name| option was specified, then the \verbIU{outfile}
  109. string would be used <<as is>>, unless several binary objects was generated as
  110. result of linking~--~in this case, all binary objects would be saved with
  111. the \verbIU{outfile}\verb|.|\verbI{N} file names, where \verbI{N} is the
  112. sequence number of the binary object starting from zero. Additionally, the
  113. \verbIU{outfile} string is used as the prefix in the name of the linking log
  114. file.\par
  115. \begin{ImpNote}
  116. Space characters at the beginning and the end of the \verbIU{outfile} string are
  117. deleted. Space characters inside of the \verbIU{outfile} string are replaced
  118. with underscores.
  119. \end{ImpNote}
  120. }
  121. {\NmCnvDescript\verb|LINKER_OPTIONS|\\* linker arguments. In unchanged form
  122. and with the preservation of the sequence passed to the linker of the vendor.
  123. The linker arguments themselves are described in the OpenCL specifications, in
  124. addition, the vendor's linker can support additional arguments not fixed in
  125. the OpenCL specifications.\par}
  126. {\NmCnvDescript\verbIU{infile}\verb|...|\\* the list separated by spaces with
  127. the names of the files containing the OpenCL compiled objects. The file name
  128. cannot begin with a~<<\verb|-|>>~character.\par}