1 Debian patch touch this file
| •1 | #!/usr/bin/ruby -EUTF-8 |
| 2 | |
| 3 | # for Ruby 1.9 |
| 4 | |
| 5 | # Synopsis: |
| 6 | # |
| 7 | # pageNumberLookup.rb filename.html > outputFile.html |
| 8 | # |
| 9 | # This script is used to replace symbolic references to locations in the OpenCL |
| 10 | # specification with page number references. This can be used when you want the |
| 11 | # reference page to refer to section XYZ of the OpenCL spec with a link and have |
| 12 | # the link open the spec document to section XYZ. This approach is based on the |
| 13 | # "named destination" feature for PDF files. |
| 14 | # |
| 15 | # Ideally we wanted to link to the named destinations, but inconsistencies between |
| 16 | # versions of MS Word and other limitations prevent us from doing that at this time. |
| 17 | # So, this is a second-best solution in which we map symbolic names to page |
| 18 | # numbers, then the link will open the spec to the specified page. To use this |
| 19 | # solution, refer to a section in the spec using a symbolic name that you make up |
| 20 | # in a <olink /> element with a uri attribute that is the symbolic name. Then add |
| 21 | # the keyword to the lookup table below with the corresponding page number from |
| 22 | # the Spec. |
| 23 | # |
| 24 | # For example to link to the spec section for gl_sharing, use: |
| 25 | # |
| 26 | # <olink uri="gl_sharing">OpenCL Specification</olink> |
| 27 | # |
| 28 | # The xsltproc program generates a temporary HTML file where the XML line above |
| 29 | # is transformed into a line containing a placeholder URL: |
| 30 | # |
| 31 | # <a href="http://www.khronos.org/registry/cl/specs/opencl-XXX.pdf#namedest=gl_sharing"> |
| 32 | # OpenCL Specification</a> |
| 33 | # |
| 34 | # When this lookup program is run on the temporary HTML file, it will look up the |
| 35 | # keyword and replace the placeholder text in the HTML file with the final URL. |
| 36 | # The final URL is specified below in Specnames. This transforms the placeholder |
| 37 | # line into the final form, in this manner: |
| 38 | # |
| 39 | # <a href="http://www.khronos.org/registry/cl/specs/opencl-1.2.pdf#page=279"> |
| 40 | # OpenCL Specification</a> |
| 41 | # |
| 42 | # (You can control what the first part of the URL is by modifying the SpecBaseUrl |
| 43 | # variable in the opencl-man.xsl file.) |
| 44 | |
| 45 | |
| 46 | # Here are the real spec filenames of the OpenCL 1.2 spec documents (see comments above): |
| 47 | |
| 48 | Core = "opencl-1.2.pdf" |
| 49 | Ext = "opencl-1.2-extensions.pdf" |
| 50 | |
| 51 | |
| 52 | ############################################################################### |
| 53 | # Spec page number mapping here. First string in quotes. Commas between values. |
| 54 | # The comments are for reference to see where this content can be found in the spec. |
| 55 | # |
| 56 | Pagenums = { |
| 57 | "classDiagram" => [Core, 20], # 2.1 - OpenCL Class Diagram |
| 58 | "clGetPlatformIDs" => [Core, 33], # 4.1 - Querying Platform Info |
| 59 | "clGetPlatformInfo" => [Core, 33], # 4.1 - Querying Platform Info |
| 60 | "clGetDeviceIDs" => [Core, 35], # 4.2 - Querying Devices |
| 61 | "clGetDeviceInfo" => [Core, 37], # 4.2 - Querying Devices |
| 62 | "cl_khr_fp64" => [Core, 46], # 4.2 - Querying Devices |
| 63 | "clCreateSubDevices" => [Core, 49], # 4.3 - Partitioning a Device |
| 64 | "clRetainDevice" => [Core, 52], # 4.3 - Partitioning a Device |
| 65 | "clReleaseDevice" => [Core, 52], # 4.3 - Partitioning a Device |
| 66 | "clCreateContext" => [Core, 54], # 4.4 - Contexts |
| 67 | "clCreateContextFromType" => [Core, 56], # 4.4 - Contexts |
| 68 | "clRetainContext" => [Core, 57], # 4.4 - Contexts |
| 69 | "clReleaseContext" => [Core, 57], # 4.4 - Contexts |
| 70 | "clGetContextInfo" => [Core, 58], # 4.4 - Contexts |
| 71 | "clCreateCommandQueue" => [Core, 61], # 5.1 - Command Queues |
| 72 | "clRetainCommandQueue" => [Core, 62], # 5.1 - Command Queues |
| 73 | "clReleaseCommandQueue" => [Core, 63], # 5.1 - Command Queues |
| 74 | "clGetCommandQueueInfo" => [Core, 63], # 5.1 - Command Queues |
| 75 | "clCreateBuffer" => [Core, 66], # 5.2.1 - Creating Buffer Objects |
| 76 | "clCreateSubBuffer" => [Core, 69], # 5.2.1 - Creating Buffer Objects |
| 77 | "clEnqueueReadBuffer" => [Core, 72], # 5.2.2 - Reading, Writing, Copying Buffer Objects |
| 78 | "clEnqueueWriteBuffer" => [Core, 72], # 5.2.2 - Reading, Writing, Copying Buffer Objects |
| 79 | "clEnqueueReadBufferRect" => [Core, 74], # 5.2.2 - Reading, Writing and Copying Buffer Objects |
| 80 | "clEnqueueWriteBufferRect" => [Core, 75], # 5.2.2 - Reading, Writing and Copying Buffer Objects |
| 81 | "clEnqueueCopyBuffer" => [Core, 79], # 5.2.2 - Reading, Writing, Copying Buffer Objects |
| 82 | "clEnqueueCopyBufferRect" => [Core, 81], # 5.2.2 - Reading, Writing and Copying Buffer Objects |
| 83 | "clEnqueueFillBuffer" => [Core, 84], # 5.2.2 - Reading, Writing and Copying Buffer Objects |
| 84 | "clEnqueueMapBuffer" => [Core, 86], # 5.2.3 - Mapping Buffer Objects |
| 85 | "clCreateImage" => [Core, 90], # 5.3.1 - Creating Image Objects |
| 86 | "cl_image_format" => [Core, 92], # 5.3.1.1 - Image Format Descriptor |
| 87 | "imageDescriptor" => [Core, 95], # 5.3.1.2 - Image Descriptor |
| 88 | "clGetSupportedImageFormats" => [Core, 96], # 5.3.2 - Querying List of Supported Image Formats |
| 89 | "supportedImageFormats" => [Core, 97], # 5.3.2.1 - Supported Image Formats |
| 90 | "clEnqueueReadImage" => [Core, 98], # 5.3.3 - Reading, Writing and Copying Image Objects |
| 91 | "clEnqueueWriteImage" => [Core, 99], # 5.3.3 - Reading, Writing and Copying Image Objects |
| 92 | "clEnqueueCopyImage" => [Core, 104], # 5.3.3 - Reading, Writing and Copying Image Objects |
| 93 | "clEnqueueFillImage" => [Core, 105], # 5.3.3 - Reading, Writing and Copying Image Objects |
| 94 | "clEnqueueCopyImageToBuffer" => [Core, 107], # 5.3.4 - Copying between Image and Buffer Objects |
| 95 | "clEnqueueCopyBufferToImage" => [Core, 110], # 5.3.4 - Copying between Image and Buffer Objects |
| 96 | "clEnqueueMapImage" => [Core, 112], # 5.3.5 - Mapping Image Objects |
| 97 | "clGetImageInfo" => [Core, 116], # 5.3.6 - Image Object Queries |
| 98 | "clRetainMemObject" => [Core, 118], # 5.4.1 - Retaining and Releasing Memory Objects |
| 99 | "clReleaseMemObject" => [Core, 118], # 5.4.1 - Retaining and Releasing Memory Objects |
| 100 | "clSetMemObjectDestructorCallback" => [Core, 119], # 5.4.1 - Retaining and Releasing Memory Objects |
| 101 | "clEnqueueUnmapMemObject" => [Core, 120], # 5.4.2 - Unmapping Mapped Memory Objects |
| 102 | "clEnqueueMigrateMemObjects" => [Core, 123], # 5.4.4 - Migrating Memory Objects |
| 103 | "clGetMemObjectInfo" => [Core, 125], # 5.4.5 - Memory Object Queries |
| 104 | "clCreateSampler" => [Core, 128], # 5.5.1 - Creating Sampler Objects |
| 105 | "clRetainSampler" => [Core, 129], # 5.5.1 - Creating Sampler Objects |
| 106 | "clReleaseSampler" => [Core, 129], # 5.5.1 - Creating Sampler Objects |
| 107 | "clGetSamplerInfo" => [Core, 130], # 5.5.2 - Sampler Object Queries |
| 108 | "clCreateProgramWithSource" => [Core, 132], # 5.6.1 - Creating Program Objects |
| 109 | "clCreateProgramWithBinary" => [Core, 133], # 5.6.1 - Creating Program Objects |
| 110 | "clCreateProgramWithBuiltInKernels" => [Core, 135], # 5.6.1 - Creating Program Objects |
| 111 | "clRetainProgram" => [Core, 136], # 5.6.1 - Creating Program Objects |
| 112 | "clReleaseProgram" => [Core, 136], # 5.6.1 - Creating Program Objects |
| 113 | "clBuildProgram" => [Core, 137], # 5.6.2 - Building Program Executables |
| 114 | "clCompileProgram" => [Core, 139], # 5.6.3 - Separate Compilation and Linking of Programs |
| 115 | "clLinkProgram" => [Core, 142], # 5.6.3 - Separate Compilation and Linking of Programs |
| 116 | "clUnloadPlatformCompiler" => [Core, 149], # 5.6.6 - Unloading the OpenCL Compiler |
| 117 | "clGetProgramInfo" => [Core, 150], # 5.6.7 - Program Object Queries (updated for 1.2 rev 14) |
| 118 | "clGetProgramBuildInfo" => [Core, 153], # 5.6.7 - Program Object Queries |
| 119 | "clCreateKernel" => [Core, 157], # 5.7.1 - Creating Kernel Objects |
| 120 | "clCreateKernelsInProgram" => [Core, 158], # 5.7.1 - Creating Kernel Objects |
| 121 | "clRetainKernel" => [Core, 159], # 5.7.1 - Creating Kernel Objects |
| 122 | "clReleaseKernel" => [Core, 159], # 5.7.1 - Creating Kernel Objects |
| 123 | "clSetKernelArg" => [Core, 160], # 5.7.2 - Setting Kernel Arguments |
| 124 | "clGetKernelInfo" => [Core, 162], # 5.7.3 - Kernel Object Queries (updated for 1.2 rev 14) |
| 125 | "clGetKernelWorkGroupInfo" => [Core, 164], # 5.7.3 - Kernel Object Queries |
| 126 | "clGetKernelArgInfo" => [Core, 166], # 5.7.3 - Kernel Object Queries (updated for 1.2 rev 14) |
| 127 | "clEnqueueNDRangeKernel" => [Core, 169], # 5.8 - Executing Kernels (updated for 1.2 rev 14) |
| 128 | "clEnqueueTask" => [Core, 172], # 5.8 - Executing Kernels (updated for 1.2 rev 14) |
| 129 | "clEnqueueNativeKernel" => [Core, 174], # 5.8 - Executing Kernels (updated for 1.2 rev 14) |
| 130 | "clCreateUserEvent" => [Core, 178], # 5.9 - Event Objects |
| 131 | "clSetUserEventStatus" => [Core, 178], # 5.9 - Event Objects |
| 132 | "clWaitForEvents" => [Core, 179], # 5.9 - Event Objects |
| 133 | "clGetEventInfo" => [Core, 180], # 5.9 - Event Objects |
| 134 | "clSetEventCallback" => [Core, 183], # 5.9 - Event Objects |
| 135 | "clRetainEvent" => [Core, 184], # 5.9 - Event Objects |
| 136 | "clReleaseEvent" => [Core, 185], # 5.9 - Event Objects |
| 137 | "clEnqueueMarkerWithWaitList" => [Core, 186], # 5.10 - Markers, Barriers and Waiting for Events |
| 138 | "clEnqueueBarrierWithWaitList" => [Core, 187], # 5.10 - Markers, Barriers and Waiting for Events |
| 139 | "clGetEventProfilingInfo" => [Core, 190], # 5.12 - Profiling Operations on Memory Objects and Kernels |
| 140 | "clFlush" => [Core, 193], # 5.13 - Flush and Finish |
| 141 | "clFinish" => [Core, 193], # 5.13 - Flush and Finish |
| 142 | "scalarDataTypes" => [Core, 195], # 6.1.1 - Built-in Scalar Data Types |
| 143 | "vectorDataTypes" => [Core, 198], # 6.1.2 - Built-in Vector Data Types |
| 144 | "otherDataTypes" => [Core, 199], # 6.1.3 - Other Built-in Data Types |
| 145 | "reservedDataTypes" => [Core, 200], # 6.1.4 - Reserved Data Types |
| 146 | "convert_T" => [Core, 207], # 6.2.3 - Explicit Conversions |
| 147 | "as_typen" => [Core, 212], # 6.2.4.2 - Reinterpreting Types Using as_typen() |
| 148 | "operators" => [Core, 215], # 6.3 - Operators |
| 149 | "addressSpaceQualifier" => [Core, 222], # 6.5 - Address Space Qualifiers |
| 150 | "accessQualifiers" => [Core, 226], # 6.6 - Access Qualifiers |
| 151 | "functionQualifiers" => [Core, 227], # 6.7 - Function Qualifiers |
| 152 | "storageQualifiers" => [Core, 230], # 6.8 - Storage-class Qualifiers |
| 153 | "restrictions" => [Core, 231], # 6.9 - Restrictions |
| 154 | "preprocessorDirectives" => [Core, 234], # 6.10 - Preprocessor Directives and Macros |
| 155 | "attribute" => [Core, 236], # 6.11. - Attribute Qualifiers |
| 156 | "attributes-types" => [Core, 237], # 6.11.1 - Specifying Attributes of Types |
| 157 | "attributes-variables" => [Core, 239], # 6.11.3 - Specifying Attributes of Variables |
| 158 | "attributes-blocksAndControlFlow" => [Core, 241], # 6.11.4 - Specifying Attributes of Blocks and Control... |
| 159 | "workItemFunctions" => [Core, 242], # 6.12.1 - Work-Item Functions |
| 160 | "mathFunctions" => [Core, 244], # 6.12.2 - Math Functions |
| 161 | "mathConstants" => [Core, 251], # 6.12.2 - Table at end of Math Functions |
| 162 | "FP_CONTRACT" => [Core, 252], # 6.12.2.1 - Floating-point macros and pragmas |
| 163 | "macroLimits" => [Core, 252], # 6.12.2.1 - Floating-point macros and pragmas |
| 164 | "integerFunctions" => [Core, 256], # 6.12.3 - Integer Functions |
| 165 | "commonFunctions" => [Core, 260], # 6.12.4 - Common Functions |
| 166 | "geometricFunctions" => [Core, 262], # 6.12.5 - Geometric Functions |
| 167 | "relationalFunctions" => [Core, 264], # 6.12.6 - Relational Functions |
| 168 | "vectorDataLoadandStoreFunctions" => [Core, 267], # 6.12.7 - Vector Data Load and Store Functions |
| 169 | "synchFunctions" => [Core, 274], # 6.12.8 - Synchronization Functions |
| 170 | "explicitMemoryFenceFunctions" => [Core, 275], # 6.12.9 - Explicit Memory Fence Functions |
| 171 | "asyncCopyFunctions" => [Core, 276], # 6.12.10 - Async Copies from Global to Local Memory... |
| 172 | "atomicFunctions" => [Core, 279], # 6.12.11 - Atomic Functions for 32-bit integers |
| 173 | "miscVectorFunctions" => [Core, 282], # 6.12.12 Miscellaneous Vector Functions |
| 174 | "printfFunction" => [Core, 284], # 6.12.13 - printf |
| 175 | "imageFunctions" => [Core, 292], # 6.12.14 - Image Read and Write Functions |
| 176 | "sampler_t" => [Core, 292], # 6.12.14.1 - Samplers |
| 177 | "imageQueryFunctions" => [Core, 311], # 6.12.14.5 - Built-in Image Query Functions |
| 178 | "imageAddressFiltering" => [Core, 326], # 8 - Image Addressing and Filtering |
| 179 | "referenceWong" => [Core, 355], # 11 - References (to Wong paper) |
| 180 | "deprecated" => [Core, 373], # F - Changes |
| 181 | "EXTENSION" => [Ext, 6], # 9.1 - Compiler Directives for Optional Extensions |
| 182 | "clGetExtensionFunctionAddressForPlatform" => [Ext, 7], # 9.2 - Getting OpenCL API Extension Function Pointers |
| 183 | "cl_khr_int64_base_atomics" => [Ext, 10], # 9.3 - 64-bit Atomics |
| 184 | "cl_khr_int64_extended_atomics" => [Ext, 10], # 9.3 - 64-bit Atomics |
| 185 | "atom_add" => [Ext, 10], # 9.3 - 64-bit Atomics |
| 186 | "imageFunctions3D" => [Ext, 12], # 9.4 - Writing to 3D image memory objects |
| 187 | "cl_khr_3d_image_writes" => [Ext, 12], # 9.4 - Writing to 3D image memory objects |
| 188 | "cl_khr_fp16" => [Ext, 14], # 9.5 - Half Floating-Point |
| 189 | "imageFunctionsHalf" => [Ext, 27], # 9.5.8 - Image Read and Write Functions (half) |
| 190 | "cl_khr_gl_sharing" => [Ext, 39], # 9.6 - Creating CL context from a GL context or share group |
| 191 | "clGetGLContextInfoKHR" => [Ext, 43], # 9.6.5 - Additions to section 9.8 of the... |
| 192 | "clCreateFromGLBuffer" => [Ext, 49], # 9.7.2 - CL Buffer Objects -> GL Buffer Objects |
| 193 | "clCreateFromGLTexture" => [Ext, 50], # 9.7.3 - CL Image Objects -> GL Textures |
| 194 | "clCreateFromGLRenderbuffer" => [Ext, 53], # 9.7.4 - CL Image Objects -> GL Renderbuffers |
| 195 | "clGetGLObjectInfo" => [Ext, 54], # 9.7.5 - Querying GL object information from a CL... |
| 196 | "clGetGLTextureInfo" => [Ext, 55], # 9.7.5 - Querying GL object information from a CL... |
| 197 | "clEnqueueAcquireGLObjects" => [Ext, 56], # 9.7.6 - Sharing memory objects that map to GL objects... |
| 198 | "clEnqueueReleaseGLObjects" => [Ext, 58], # 9.7.6 - Sharing memory objects that map to GL objects... |
| 199 | "cl_khr_gl_event" => [Ext, 61], # 9.8 - Creating CL event objets |
| 200 | "clCreateEventFromGLsyncKHR" => [Ext, 62], # 9.8.4 - Additions to Chapter 5 |
| 201 | "cl_khr_d3d10_sharing" => [Ext, 66], # 9.9 - Sharing Memory Objects with Direct3D 10 |
| 202 | "clGetDeviceIDsFromD3D10KHR" => [Ext, 71], # 9.9.7.1 - Querying OpenCL Devices Corresponding to... 11... |
| 203 | "clCreateFromD3D10BufferKHR" => [Ext, 73], # 9.9.7.3 - Sharing Direct3D 10 Buffer Resources as OpenCL... |
| 204 | "clCreateFromD3D10Texture2DKHR" => [Ext, 74], # 9.9.7.4 - Sharing Direct3D 10 Texture and Resources... |
| 205 | "clCreateFromD3D10Texture3DKHR" => [Ext, 75], # 9.9.7.4 - Sharing Direct3D 10 Texture and... |
| 206 | "clEnqueueAcquireD3D10ObjectsKHR" => [Ext, 77], # 9.9.7.6 - Sharing memory objects created from Direct3D 10.. |
| 207 | "clEnqueueReleaseD3D10ObjectsKHR" => [Ext, 79], # 9.9.7.6 - Sharing memory objects created from... |
| 208 | "cl_khr_dx9_media_sharing" => [Ext, 83], # 9.10 - DX9 Media Surface Sharing |
| 209 | "clGetDeviceIDsFromDX9MediaAdapterKHR" => [Ext, 88], # 9.10.7.1 - Querying OpenCL Devices corresponding.... |
| 210 | "clCreateFromDX9MediaSurfaceKHR" => [Ext, 89], # 9.10.7.2 Creating Media Resources as OpenCL Image Objects |
| 211 | "clEnqueueAcquireDX9MediaSurfacesKHR" => [Ext, 92], # 9.10.7.4 - Sharing Memory Objects created from Media Surfaces |
| 212 | "clEnqueueReleaseDX9MediaSurfacesKHR" => [Ext, 93], # 9.10.7.4 - Sharing Memory Objects... |
| 213 | "cl_khr_d3d11_sharing" => [Ext, 97], # 9.11 - Sharing Memory Objects with Direct3D 11 |
| 214 | "clGetDeviceIDsFromD3D11KHR" => [Ext, 102], # 9.11.7.1 - Querying OpenCL Devices Corresponding to Direct3D |
| 215 | "clCreateFromD3D11BufferKHR" => [Ext, 104], # 9.11.7.3 - Sharing Direct3D 11 Buffer Resources |
| 216 | "clCreateFromD3D11Texture2DKHR" => [Ext, 105], # 9.11.7.4 - Sharing Direct3D 11 Texture and Resources... |
| 217 | "clCreateFromD3D11Texture3DKHR" => [Ext, 106], # 9.11.7.4 - Sharing Direct3D 11 Texture and Resources.... |
| 218 | "clEnqueueAcquireD3D11ObjectsKHR" => [Ext, 108], # 9.11.7.6 - Sharing memory objects created from Direct3D 11... |
| 219 | "clEnqueueReleaseD3D11ObjectsKHR" => [Ext, 110], # 9.11.7.6 - Sharing memory objects created from Direct3D 11... |
| 220 | "cl_khr_icd" => [Ext, 113], # 9.12 - OpenCL Installable Client Driver (ICD) |
| 221 | "clIcdGetPlatformIDsKHR" => [Ext, 116], # 9.12.9 - Additions to chapter 4... |
| 222 | } |
| 223 | |
| 224 | |
| 225 | ############################################################################### |
| 226 | # Copy the specified file to the output, substituting any references to spec page numbers |
| 227 | # |
| 228 | IO.foreach(ARGV[0]) do |line| |
| 229 | if line.match("namedest=") |
| 230 | keyword = line.sub(/^.*namedest=/, "").sub(/\".*$/, "").chomp.rstrip |
| 231 | if Pagenums.has_key?(keyword) |
| 232 | specName = Pagenums.fetch(keyword)[0] |
| 233 | pageNum = Pagenums.fetch(keyword)[1] |
| 234 | #puts "specName=" + specName + ", pageNum=" + pageNum.to_s |
| 235 | puts line.sub(/namedest=[^\s]*\"/, "page=" + pageNum.to_s + '"').sub(/opencl-1.x-latest.pdf/, specName) |
| 236 | else |
| 237 | abort("Spec page number for keyword \"" + keyword + "\" not found in " + $0) + '"' |
| 238 | end |
| 239 | else |
| 240 | puts line |
| 241 | end |
| 242 | end |
| 243 |