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

Function initStorageCache

src/library/tools/tune/toolslib.c:465–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465void
466initStorageCache(void)
467{
468 cl_uint numberPlatform = 0;
469 cl_platform_id *platforms = NULL;
470 cl_device_id *devices = NULL;
471 StorageCacheImpl* cur = NULL;
472 cl_int ret;
473
474 unsigned int deviceCount = 0;
475 unsigned int i, j, k;
476
477 assert (storageCacheLock == NULL);
478 assert (storageCacheArray == NULL);
479 assert (storageCacheArrayCount == 0);
480
481 storageCacheLock = mutexInit();
482 numberPlatform = getPlatforms(&platforms);
483
484 if (numberPlatform ==0) {
485 return;
486 }
487
488 for (i =0; i < numberPlatform; ++i) {
489 cl_uint dc;
490
491 ret = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &dc);
492 if (ret == CL_SUCCESS) {
493 deviceCount += dc;
494 }
495 }
496
497 storageCacheArray = calloc(deviceCount, sizeof(*storageCacheArray));
498
499 for (i =0; i < numberPlatform; ++i) {
500 cl_uint dc;
501
502 ret = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &dc);
503 if (ret != CL_SUCCESS) {
504 continue;
505 }
506
507 devices = calloc(dc, sizeof(*devices));
508
509 ret = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, dc, devices, NULL);
510
511 for (j = 0; j < dc; ++ j) {
512 TargetDevice td;
513 bool isUnique = true;
514
515 td.id = devices[j];
516 identifyDevice(&td);
517
518 for (k = 0; k < storageCacheArrayCount; ++k) {
519 if (isDeviceEQ(&td.ident, &storageCacheArray[k].devIdent) ) {
520 isUnique = false;
521 }
522 }

Callers 2

writeStorageCacheFunction · 0.85
clblasSetupFunction · 0.85

Calls 5

mutexInitFunction · 0.85
getPlatformsFunction · 0.85
identifyDeviceFunction · 0.85
isDeviceEQFunction · 0.85
clearPatternsNumberFunction · 0.85

Tested by

no test coverage detected