| 3308 | } |
| 3309 | |
| 3310 | inline KernelInstantiation_impl::KernelInstantiation_impl( |
| 3311 | Kernel_impl const& kernel, std::vector<std::string> const& template_args) |
| 3312 | : _kernel(kernel), _options(kernel._options) { |
| 3313 | _template_inst = |
| 3314 | (template_args.empty() ? "" |
| 3315 | : reflection::reflect_template(template_args)); |
| 3316 | using detail::hash_combine; |
| 3317 | using detail::hash_larson64; |
| 3318 | _hash = _kernel._hash; |
| 3319 | _hash = hash_combine(_hash, hash_larson64(_template_inst.c_str())); |
| 3320 | JitCache_impl& cache = _kernel._program._cache; |
| 3321 | uint64_t cache_key = _hash; |
| 3322 | #if JITIFY_THREAD_SAFE |
| 3323 | std::lock_guard<std::mutex> lock(cache._kernel_cache_mutex); |
| 3324 | #endif |
| 3325 | if (cache._kernel_cache.contains(cache_key)) { |
| 3326 | #if JITIFY_PRINT_INSTANTIATION |
| 3327 | std::cout << "Found "; |
| 3328 | this->print(); |
| 3329 | #endif |
| 3330 | _cuda_kernel = &cache._kernel_cache.get(cache_key); |
| 3331 | } else { |
| 3332 | #if JITIFY_PRINT_INSTANTIATION |
| 3333 | std::cout << "Building "; |
| 3334 | this->print(); |
| 3335 | #endif |
| 3336 | _cuda_kernel = &cache._kernel_cache.emplace(cache_key); |
| 3337 | this->build_kernel(); |
| 3338 | } |
| 3339 | } |
| 3340 | |
| 3341 | inline void KernelInstantiation_impl::print() const { |
| 3342 | std::string options_string = reflection::reflect_list(_options); |
nothing calls this directly
no test coverage detected