| 192 | } |
| 193 | |
| 194 | void CudaExecutable::FuncCache::compile( |
| 195 | const std::string& cache_category, int major, int minor, |
| 196 | const CudaExecutable* cuda_exe) { |
| 197 | RealTimer timer; |
| 198 | auto&& cache = PersistentCache::inst(); |
| 199 | PersistentCache::Blob key{cuda_exe->m_source.data(), cuda_exe->m_source.size()}; |
| 200 | auto ptx_cache = cache.get(cache_category, key); |
| 201 | if (ptx_cache.valid()) { |
| 202 | ptx.assign(static_cast<const char*>(ptx_cache->ptr), ptx_cache->size); |
| 203 | } else { |
| 204 | ptx = NVRTCCompile(cuda_exe->m_source, major, minor); |
| 205 | ptx_cache = PersistentCache::Blob{ptx.data(), ptx.size()}; |
| 206 | cache.put(cache_category, key, ptx_cache.val()); |
| 207 | mgb_log("NVRTC JIT: compile %s for %d.%d: source_len=%zu ptx_len=%zu " |
| 208 | "time=%.3fms", |
| 209 | cuda_exe->m_name.c_str(), major, minor, key.size, ptx.size(), |
| 210 | timer.get_msecs()); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | void CudaExecutable::FuncCache::exec( |
| 215 | const JITExecutor* fusion_opr, const CudaExecutable* cuda_exe) { |