| 489 | } |
| 490 | |
| 491 | ConstGPUProcessorRcPtr Processor::Impl::getGPUProcessor(const OpRcPtrVec & gpuOps, |
| 492 | OptimizationFlags oFlags) const |
| 493 | { |
| 494 | // Helper method. |
| 495 | auto CreateProcessor = [](const OpRcPtrVec & ops, |
| 496 | OptimizationFlags oFlags) -> GPUProcessorRcPtr |
| 497 | { |
| 498 | GPUProcessorRcPtr gpu = GPUProcessorRcPtr(new GPUProcessor(), &GPUProcessor::deleter); |
| 499 | gpu->getImpl()->finalize(ops, oFlags); |
| 500 | return gpu; |
| 501 | }; |
| 502 | |
| 503 | oFlags = EnvironmentOverride(oFlags); |
| 504 | |
| 505 | if (m_gpuProcessorCache.isEnabled()) |
| 506 | { |
| 507 | AutoMutex guard(m_gpuProcessorCache.lock()); |
| 508 | |
| 509 | // As the entry is a shared pointer instance, having an empty one means that the entry does |
| 510 | // not exist in the cache. So, it provides a fast existence check & access in one call. |
| 511 | GPUProcessorRcPtr & processor = m_gpuProcessorCache[oFlags]; |
| 512 | if (!processor) |
| 513 | { |
| 514 | processor = CreateProcessor(gpuOps, oFlags); |
| 515 | } |
| 516 | |
| 517 | return processor; |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | return CreateProcessor(gpuOps, oFlags); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | /////////////////////////////////////////////////////////////////////////// |
| 526 |
nothing calls this directly
no test coverage detected