|
|
Automatic performance tuning, or auto-tuning, describes a process of automatic selection of run-time parameters to achieve the best possible performance. In DKS we are focusing on the execution time so this measure of performance will be used in the auto-tuning framework.
|
|
|
|
|
|
In DKS we are focusing on the offline auto-tuning by using previously created benchmark tests. The benchmark tests provide the function that needs to be tested and the parameters that should be adjusted. The parameters to be configured for each function need to be set by developer. The limits of the parameters may be also set by the developer or these limits may be extracted from device properties, depending on the device that is installed on the system (like max threads per block on the GPU, or max threads for OpenMP, etc.).
|
|
|
|
|
|
```C++
|
|
|
//create the function to be timed, with the necessary parameters
|
|
|
std::function<int()> f = std::bind(&ChiSquareRuntime::launchChiSquare, chiSq, fitType, mem_data, mem_err, length, numpar, numfunc, nummap, timeStart, timeStep, result);
|
|
|
|
|
|
//add the function to the auto-tuning framework
|
|
|
autoTuning->setFunction(f, "launchChiSquare");
|
|
|
|
|
|
//set the adjustable parameters and their ranges
|
|
|
autoTuning->addParameter(&chiSq->blockSize_m, minThreads, maxThreads, step, "BlockSize");
|
|
|
autoTuning->addParameter(&chiSq->numBlocks_m, minBlocks, maxBlocs, step, "NumBlocks");
|
|
|
|
|
|
//perform the parameter search
|
|
|
autoTuning->hillClimbing(restarts);
|
|
|
```
|
|
|
The example of auto-tuning test setup is shown in code example above. The auto-tuning framework executes the function varying the parameters in order to find the parameter set that gives the best (fastest) execution time. The developer is responsible of providing the function for the auto-tuning with the necessary parameters, parameters that should be auto-tuned and there ranges, and the search method that should be used. After the benchmark tests are done a small database is created that stores the launch configurations for each kernel on the tested devices. This database is used by DKS at run-time to determine the kernel launch parameters. If the auto-tuning tests are not performed the DKS uses default parameters, that are set by the developer. |