Kernel Tuning#

How To#

  1. Given a OpenCL kernel file

  2. Write a python file
    1. write a class, extend Tuner
      1. write a method in the class, this method should only accept kwargs

      2. add decorators to generate arguments for this method

        worksize_arg:

        can easily generate multi-dim work_size args

        values_arg:

        can enumerate some specific values

        range_arg:

        can generate ranged arguments like range

      3. add a decorator Tuner.tune() to mark it as a tunable method

        NOTE: decorator tune() should be the last decorator, all possible arguments are unpacked in tune() and passed to your method

      4. implement this method to run once with a specific arguments combination,

        call self.run() to run a kernel.

    2. write a setup() method if needed

      setup() is an abstract method, will be called before tuning, you can initialize some variabels with self

  3. execute and tune, two ways for you:
    1. execute in cli
      1. go to the directory where contains the tuner class above

      2. execute python -m oclk tune

      3. then will execute all tuner class under the directory and output results in a json file

      4. see more options with python -m oclk tune --help

    2. execute in python.
      1. Instantiate this class and call the above method

      2. Got the top k best result and arguments combination with tuner.top_result()

Example#

see tune examples