1*1cddb830SAndroid Build Coastguard Worker# OpenCL ICD Loader Code Generation 2*1cddb830SAndroid Build Coastguard Worker 3*1cddb830SAndroid Build Coastguard Worker## Introduction 4*1cddb830SAndroid Build Coastguard Worker 5*1cddb830SAndroid Build Coastguard WorkerIn order to ease maintenance and enable faster development of related OpenCL ICD loader features, the OpenCL ICD loader API dispatch functions are generated from the OpenCL XML machine readable grammar. 6*1cddb830SAndroid Build Coastguard Worker 7*1cddb830SAndroid Build Coastguard Worker## Dependencies 8*1cddb830SAndroid Build Coastguard Worker 9*1cddb830SAndroid Build Coastguard WorkerThe API dispatch functions are generated using Python [Mako Templates](https://www.makotemplates.org/). 10*1cddb830SAndroid Build Coastguard Worker 11*1cddb830SAndroid Build Coastguard WorkerIn most cases, after installing Python for your platform, Mako may be installed using: 12*1cddb830SAndroid Build Coastguard Worker 13*1cddb830SAndroid Build Coastguard Worker```sh 14*1cddb830SAndroid Build Coastguard Worker$ pip install Mako 15*1cddb830SAndroid Build Coastguard Worker``` 16*1cddb830SAndroid Build Coastguard Worker 17*1cddb830SAndroid Build Coastguard Worker## Making Changes 18*1cddb830SAndroid Build Coastguard Worker 19*1cddb830SAndroid Build Coastguard WorkerMost changes only require modifications to the Mako templates. 20*1cddb830SAndroid Build Coastguard WorkerSmall changes modifying syntax or layout are simple and straightforward. 21*1cddb830SAndroid Build Coastguard WorkerOccasionally more complicated changes will be required, say when a new API is added that is unlike any previous API, but this should be rare. 22*1cddb830SAndroid Build Coastguard Worker 23*1cddb830SAndroid Build Coastguard WorkerThe Python script should only need to be modified if additional information needs to be propagated from the XML file into the Mako template itself. 24*1cddb830SAndroid Build Coastguard Worker 25*1cddb830SAndroid Build Coastguard Worker## Generating Files 26*1cddb830SAndroid Build Coastguard Worker 27*1cddb830SAndroid Build Coastguard WorkerFiles for the OpenCL ICD loader, or the test layer, may be generated by executing the scripts `gen_loader.py`, or `gen_print_layer.py`, respectively. 28*1cddb830SAndroid Build Coastguard Worker 29*1cddb830SAndroid Build Coastguard WorkerThe script requires the `cl.xml` machine readable grammar. 30*1cddb830SAndroid Build Coastguard WorkerBy default, the script searches for `cl.xml` in the current directory. 31*1cddb830SAndroid Build Coastguard WorkerThe latest version of `cl.xml` may be found in the Khronos OpenCL-Docs repo [here](https://github.com/KhronosGroup/OpenCL-Docs/blob/main/xml/cl.xml). 32*1cddb830SAndroid Build Coastguard Worker 33*1cddb830SAndroid Build Coastguard WorkerThe output from the script is placed in the current directory by default, to allow easy comparisons between the generated files and the current files. 34*1cddb830SAndroid Build Coastguard WorkerAfter the generated files are evaluated, they should be manually copied into the source tree. 35*1cddb830SAndroid Build Coastguard WorkerThese steps may be automated in the future. 36