MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / writeCacheFile

Method writeCacheFile

src/library/fft_binary_lookup.cpp:487–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487cl_int FFTBinaryLookup::writeCacheFile(std::vector<unsigned char*> &data)
488{
489 if (! this->m_cache_enabled)
490 {
491 return 0;
492 }
493
494 // exclusive open to ensure that only one thread will write the file
495 const std::string & filename = this->m_path + this->m_cache_entry_name;
496
497 CacheEntry cache_file(filename);
498 bool created = cache_file.exclusive_create();
499
500 // try to exclusively create the cache file on the disk
501 if (created)
502 {
503 // if it was created by the current thread, this one will write into cache file
504 cache_file.close();
505
506 const std::string & filename = this->m_path + this->m_cache_entry_name;
507 std::ofstream file (filename.c_str(), std::ios_base::binary);
508
509 file.write((char*)&this->m_header, sizeof(m_header));
510 file.write((char*)data[0], this->m_header.binary_size);
511 file.write((char*)this->m_signature, this->m_header.signature_size);
512 file.close();
513
514#if ENABLE_SOURCE_DUMP
515 const std::string & srcFilename = this->m_path + this->m_cache_entry_name + ".cl";
516 std::ofstream srcFile (srcFilename.c_str());
517 srcFile << this->m_source;
518
519 srcFile.close();
520#endif
521
522 return CL_SUCCESS;
523 }
524
525 // other thread do not write the cache file
526 return 1;
527}
528
529cl_int FFTBinaryLookup::populateCache()
530{

Callers

nothing calls this directly

Calls 2

exclusive_createMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected