MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / findKernel

Function findKernel

src/library/common/kern_cache.c:349–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349Kernel
350*findKernel(
351 struct KernelCache *kcache,
352 solver_id_t sid,
353 const KernelKey *key,
354 const void *extraKey)
355{
356 Kernel *kern = NULL;
357 KcacheKey kkey;
358 KernelNode *knode;
359 ListNode *lnode;
360
361 if ((unsigned)sid >= kcache->nrSolvers || key->nrDims > MAX_SUBDIMS) {
362 return NULL;
363 }
364
365 kkey.hash = kernHash(key->subdims, key->nrDims);
366 kkey.extra = extraKey;
367
368 kkey.key.device = key->device;
369 kkey.key.context = key->context;
370 kkey.key.nrDims = key->nrDims;
371 memset(kkey.key.subdims, 0, sizeof(kkey.key.subdims));
372 memcpy(kkey.key.subdims, key->subdims, sizeof(SubproblemDim) * kkey.key.nrDims);
373
374 KCACHE_LOCK(kcache);
375 lnode = listNodeSearch(&kcache->dimKern[sid], &kkey, knodeCmp);
376 if (lnode) {
377 knode = container_of(lnode, dimNode, KernelNode);
378 knode->refcnt++;
379 kern = &knode->kern;
380
381 // move the kernel to the top of the LRU list
382 listDel(&knode->lruNode);
383 listAddToHead(&kcache->lruKern, &knode->lruNode);
384 }
385 KCACHE_UNLOCK(kcache);
386
387 return kern;
388}
389
390size_t
391availKernelCacheSize(struct KernelCache *kcache)

Callers 3

makeSolutionSeqFunction · 0.85
errorCacheTestCaseFunction · 0.85
testCacheFunction · 0.85

Calls 4

kernHashFunction · 0.85
listNodeSearchFunction · 0.85
listDelFunction · 0.85
listAddToHeadFunction · 0.85

Tested by 2

errorCacheTestCaseFunction · 0.68
testCacheFunction · 0.68