Kernel Tuning#
How To#
Given a OpenCL kernel file
- Write a python file
- write a class, extend Tuner
write a method in the class, this method should only accept kwargs
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
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 intune()and passed to your method- implement this method to run once with a specific arguments combination,
call self.run() to run a kernel.
write a
setup()method if neededsetup()is an abstract method, will be called before tuning, you can initialize some variabels with self
- execute and tune, two ways for you:
- execute in cli
go to the directory where contains the tuner class above
execute
python -m oclk tunethen will execute all tuner class under the directory and output results in a json file
see more options with
python -m oclk tune --help
- execute in python.
Instantiate this class and call the above method
Got the top
kbest result and arguments combination with tuner.top_result()
Example#
see tune examples