BinaryLookup defines an API to manage the kernel cache on the disk The BinaryLookup object provides methods to: check if a cache file exists on the disk or not fill-up the signature to characterize the program beeing built on the disk build a cl_program from a string kernel or from a binary A cache entry is a file stored on the disk which contains 3 sections: A header section (providing informat
| 107 | // |
| 108 | // |
| 109 | class BinaryLookup |
| 110 | { |
| 111 | public: |
| 112 | // Constructor |
| 113 | // \param ctxt the context for which the cl_program should be built |
| 114 | // \param device the device for which the cl_program should be built |
| 115 | // \param kernel_name the kernel identifier |
| 116 | BinaryLookup(cl_context ctxt, cl_device_id device, const std::string & kernel_name); |
| 117 | ~BinaryLookup(); |
| 118 | |
| 119 | // Methods to fill up the signature of the cache entry |
| 120 | void variantInt(int num); |
| 121 | void variantDouble(double num); |
| 122 | void variantCompileOptions(const std::string & opts); |
| 123 | void variantRaw(const void * data, size_t bytes); |
| 124 | |
| 125 | // Indicates whether or not the cache entry was found on the disk |
| 126 | // If the cache entry was found and is complete on the disk, its content |
| 127 | // is loaded |
| 128 | // \return true if a cache entry was found, false else |
| 129 | bool found(); |
| 130 | |
| 131 | // Build a cl_program from the source code and init attributes |
| 132 | // of the current structure |
| 133 | // so that the program can be accessed with the getProgram method |
| 134 | // Write the file to the cache |
| 135 | cl_int buildFromSource(const char * source); |
| 136 | |
| 137 | // Build a cl_program from the source code and init attributes |
| 138 | // so that the program can be accessed with the getProgram method |
| 139 | // Write the file to the cache |
| 140 | cl_int buildFromBinary(const void * data, |
| 141 | size_t len, |
| 142 | const char * BuildOption); |
| 143 | |
| 144 | // Returns the cl_program built from binary or loaded from disk |
| 145 | cl_program getProgram(); |
| 146 | |
| 147 | // Set the current m_program to the given program |
| 148 | void setProgram(cl_program program); |
| 149 | |
| 150 | // Build a cl_program from a text |
| 151 | static cl_program buildProgramFromSource(const char * filename, |
| 152 | cl_context context, |
| 153 | cl_device_id device, |
| 154 | cl_int & err, |
| 155 | const char * options = 0); |
| 156 | |
| 157 | // Build a cl_program from binary |
| 158 | static cl_program buildProgramFromBinary(const char * data, |
| 159 | size_t data_size, |
| 160 | cl_context context, |
| 161 | cl_device_id device, |
| 162 | cl_int & err, |
| 163 | const char * options = 0); |
| 164 | |
| 165 | // Initialize the whole cache file information (magic_key, header and program) |
| 166 | // and dump on the disk |
nothing calls this directly
no outgoing calls
no test coverage detected