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

Function getSCImage

src/library/blas/scimage.c:149–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149cl_mem VISIBILITY_HIDDEN
150getSCImage(
151 cl_context ctx,
152 cl_device_id devID,
153 cl_ulong bestSize,
154 cl_ulong minSize,
155 size_t minWidth)
156{
157 cl_mem img = NULL;
158 DeviceNode *devNode;
159 SearchContext sctx;
160
161 sctx.ctx = ctx;
162 sctx.devID = devID;
163 sctx.bestSize = bestSize;
164 sctx.minSize = minSize;
165 sctx.minWidth = minWidth;
166 sctx.minExtraSize = (cl_ulong)1 << 63;
167 sctx.bestImgNode = NULL;
168
169 devNode = malloc(sizeof(DeviceNode));
170 if (devNode == NULL) {
171 return NULL;
172 }
173
174 /*
175 * find an image serving turn to minimum of either
176 * unused image space or unfitted data size
177 */
178 IMAGES_LOCK();
179 listDoForEachPriv(&images, checkBestImage, &sctx);
180 if (sctx.bestImgNode != NULL) {
181 img = sctx.bestImgNode->image;
182 devNode->devID = devID;
183 listAddToTail(&sctx.bestImgNode->usingDevices, &devNode->node);
184 clRetainMemObject(img);
185 }
186 IMAGES_UNLOCK();
187
188 if (img == NULL) {
189 free(devNode);
190 }
191
192 return img;
193}
194
195void VISIBILITY_HIDDEN
196putSCImage(cl_device_id devID, cl_mem image)

Callers 1

getStepResourcesFunction · 0.85

Calls 2

listDoForEachPrivFunction · 0.85
listAddToTailFunction · 0.85

Tested by

no test coverage detected