| 485 | } |
| 486 | |
| 487 | cl_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 | |
| 529 | cl_int FFTBinaryLookup::populateCache() |
| 530 | { |
nothing calls this directly
no test coverage detected