| 71 | } |
| 72 | |
| 73 | void save_program_cache_to_file(const std::string &filename) |
| 74 | { |
| 75 | if (CLScheduler::get().is_initialised()) |
| 76 | { |
| 77 | std::ofstream cache_file(filename, std::ios::binary); |
| 78 | if (cache_file.is_open()) |
| 79 | { |
| 80 | for (const auto &it : CLKernelLibrary::get().get_built_programs()) |
| 81 | { |
| 82 | std::vector<std::vector<unsigned char>> binaries = it.second.getInfo<CL_PROGRAM_BINARIES>(); |
| 83 | ARM_COMPUTE_ERROR_ON(binaries.size() != 1); |
| 84 | const std::string kernel_name = it.first; |
| 85 | size_t kernel_name_size = kernel_name.length(); |
| 86 | size_t binary_size = binaries[0].size(); |
| 87 | cache_file.write(reinterpret_cast<char *>(&kernel_name_size), sizeof(size_t)); |
| 88 | cache_file.write(reinterpret_cast<char *>(&binary_size), sizeof(size_t)); |
| 89 | cache_file.write(kernel_name.c_str(), kernel_name_size); |
| 90 | cache_file.write(reinterpret_cast<const char *>(binaries[0].data()), binaries[0].size()); |
| 91 | } |
| 92 | cache_file.close(); |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | ARM_COMPUTE_ERROR("Cannot open cache file"); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | } // namespace arm_compute |
no test coverage detected