MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / save_program_cache_to_file

Function save_program_cache_to_file

src/runtime/CL/Utils.cpp:73–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void 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

Callers 3

do_setupMethod · 0.85
do_setupMethod · 0.85
do_setupMethod · 0.85

Calls 6

is_initialisedMethod · 0.80
is_openMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected