Skip to main content

Minify OpenCL source files.

Project description

oclminify is an OpenCL™ source minifier. It takes OpenCL source code and makes it as small as possible by stripping comments, removing unnecessary space, renaming symbols, rewriting vector indices, etc. The minified source can be optionally compressed and then saved as is or as a C header. The latter makes it very easy to embed into a compiled application. The original source and the minified source are functionally identical and should compile into the exact same byte code.

If you’re targeting platforms with OpenCL 2.0 or later support, you should consider using SPIR™ instead.

oclminify was originally developed by the Phoduit team.

Prerequisites

Install

>From the command line:

pip install oclminify

If you want oclminify to support a compile check before minification, with an actual OpenCL driver, install pyopencl with:

pip install pyopencl

Usage

oclminify [-h] [--preprocessor-command PREPROCESSOR_COMMAND]
          [--preprocessor-no-stdin] [--no-preprocess] [--no-minify]
          [--compress] [--strip-zlib-header] [--header]
          [--header-function-args] [--minify-kernel-names]
          [--global-postfix GLOBAL_POSTFIX] [--try-build]
          [--output-file OUTPUT_FILE]
          input

oclminify takes a single input file. If the input file is - (a single hyphen), input will be read from STDIN. If the –output-file option is omitted, the output is written to STDOUT.

The available options are:

-h, --help            show this help message and exit
--preprocessor-command PREPROCESSOR_COMMAND
                      Command to preprocess input source before
                      minification. Defaults to "gcc -E -undef -P -std=c99
                      -"
--preprocessor-no-stdin
                      Pass input to preprocessor using a temporary file
                      instead of stdin.
--no-preprocess       Skip preprocessing step. Implies --no-minify.
--no-minify           Skip minification step. Useful when debugging.
--compress            Compress output using zlib.
--strip-zlib-header   Strips the two byte zlib header from the compressed
                      output when --compress is used.
--header              Embed output in a C header file.
--header-function-args
                      Include function argument mappings in C header file.
--minify-kernel-names
                      Replace kernel function names with shorter names.
--global-postfix GLOBAL_POSTFIX
                      Postfix appended to each symbol name in the global
                      scope. Used for preventing name collisions when
                      minifying multiple source files separately. Implies
                      --minify-kernel-names.
--try-build           Try to build the input using an OpenCL compiler before
                      minifying. The compiled output is discarded. Requires
                      pyopencl.
--output-file OUTPUT_FILE
                      File path where output should be saved. Omit to write
                      to stdout.

Examples

To simply minify an OpenCL source file and write the result to file, run:

oclminify --output-file output.minified.cl input.cl

The examples directory contains more examples:

  • examples/minimal — shows how to create a minimal project that minifies an OpenCL source file and builds a C based project using a shell script.

  • examples/cmake — shows how to integrate oclminify with a CMake based C++ project.

  • examples/compress — shows how to use oclminify in a CMake project to compress an OpenCL source file at compile time and then decompress it at run time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oclminify-0.8.0-2.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

oclminify-0.8.0-2-py2.py3-none-any.whl (28.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file oclminify-0.8.0-2.tar.gz.

File metadata

  • Download URL: oclminify-0.8.0-2.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for oclminify-0.8.0-2.tar.gz
Algorithm Hash digest
SHA256 a0c15fb98a11885acffdec2559a795563202d62124c8031b207e606089b407ec
MD5 4a8ba36d34dee7fb6630f97f8520cb48
BLAKE2b-256 a474e162247a22c4fd0c48f8682a2dc0b283f5dac7e29868aafe8f8d7e779f48

See more details on using hashes here.

File details

Details for the file oclminify-0.8.0-2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for oclminify-0.8.0-2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 996da4168b9ab55dc1ab56f241f0e11f26eae480f72990f2b6ac0d2517d6e150
MD5 be56315a10c6a6db034f19a06457e231
BLAKE2b-256 b528f2e409846ade042758ee177f9a26c7d01a12425d00525f160c2b37757297

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page