Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPENCL][UPD] opencl support cache on windows #1645

Merged
merged 8 commits into from
Apr 27, 2022
8 changes: 6 additions & 2 deletions source/tnn/device/opencl/opencl_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ bool OpenCLRuntime::BuildProgram(const std::string &build_options, cl::Program *

Status OpenCLRuntime::LoadProgramCache() {
Status ret = TNN_OK;
#ifdef __ANDROID__
#if (defined __ANDROID__) || (defined _WIN32)
if (!program_cache_file_path_.empty()) {
FILE* program_cache_fin = fopen(program_cache_file_path_.c_str(), "rb");
if (!program_cache_fin) {
Expand Down Expand Up @@ -554,7 +554,11 @@ Status OpenCLRuntime::LoadProgramCache() {
}
std::string program_cache_bin_file_path = program_cache_file_path_ + "_" + program_name +
"_" + md5(build_option) + "_" + program_source_md5;
#if (defined __ANDROID__)
FILE* program_binary_stream_fin = fopen(program_cache_bin_file_path.c_str(), "r");
#elif (defined _WIN32)
FILE* program_binary_stream_fin = fopen(program_cache_bin_file_path.c_str(), "rb");
#endif
if (!program_binary_stream_fin) {
ret = Status(TNNERR_OPENCL_KERNELBUILD_ERROR,
"open program cache binary file failed, input path: " +
Expand Down Expand Up @@ -611,7 +615,7 @@ Status OpenCLRuntime::LoadProgramCache() {

Status OpenCLRuntime::SaveProgramCache() {
Status ret = TNN_OK;
#ifdef __ANDROID__
#if (defined __ANDROID__) || (defined _WIN32)
if (!program_cache_file_path_.empty() && is_program_cache_changed_) {
FILE *program_cache_fout = fopen(program_cache_file_path_.c_str(), "wb");
if (!program_cache_fout) {
Expand Down