/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to cuda/normxcorr_hw.cu

  • Committer: Suren A. Chilingaryan
  • Date: 2009-01-16 23:37:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090116233717-ycbj2qqk5bdyed6a
Support for different optimization modes

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
 
272
272
 
273
273
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
274
 
//    int i;
 
274
    int deviceCount;
 
275
    cudaDeviceProp deviceProp;
275
276
    
276
277
    mxArray *idMatrix;
277
 
    uint32_t id, *idPtr;
 
278
    int32_t id, *idPtr;
278
279
 
279
280
    TProcessingState *ps;
280
281
 
308
309
 
309
310
 
310
311
        // Initialising, for now a single client is supported only
311
 
        idMatrix = mxCreateNumericMatrix(1, 1, mxUINT32_CLASS, mxREAL);
 
312
        idMatrix = mxCreateNumericMatrix(1, 1, mxINT32_CLASS, mxREAL);
312
313
        if (!idMatrix) {
313
314
            reportError("Initialization is failed");
314
315
            return;
315
316
        }
316
317
 
317
 
        pstate = pstateInit();
318
 
        if (!pstate) {
319
 
            mxDestroyArray(idMatrix);
320
 
            reportError("State structure initialization is failed");
321
 
            return;
 
318
        // Detecting cuda devices
 
319
        cudaGetDeviceCount(&deviceCount);
 
320
        if (deviceCount) {
 
321
            cudaGetDeviceProperties(&deviceProp, 0);
 
322
            if ((deviceProp.major > 1)||((deviceProp.major == 1)&&(deviceProp.minor > 2))) {
 
323
                id = 1;
 
324
            } else { // Hardware capabilities are bellow 1.3
 
325
                id = 0;
 
326
            }
 
327
        } else { // No cuda device, using software
 
328
            id = -1;
 
329
        }
 
330
        
 
331
        
 
332
        if (id > 0) {
 
333
            pstate = pstateInit();
 
334
            if (!pstate) {
 
335
                mxDestroyArray(idMatrix);
 
336
                reportError("State structure initialization is failed");
 
337
                return;
 
338
            }
 
339
        } else {
 
340
            pstate = NULL;
322
341
        }
323
342
 
324
 
        id = 1;
325
 
        
326
 
        idPtr = (uint32_t*)mxGetData(idMatrix);
 
343
        idPtr = (int32_t*)mxGetData(idMatrix);
327
344
        idPtr[0] = id;
328
345
        
329
346
        plhs[0] = idMatrix;
332
349
 
333
350
        return;
334
351
    } else {
335
 
/*      idMatrix = (mxArray*)prhs[0];
336
 
        if ((mxGetClassID(idMatrix) != mxUINT32_CLASS)||(mxGetM(idMatrix) != 1)||(mxGetN(idMatrix) != 1)) {
 
352
/*
 
353
        idMatrix = (mxArray*)prhs[0];
 
354
        if ((mxGetClassID(idMatrix) != mxINT32_CLASS)||(mxGetM(idMatrix) != 1)||(mxGetN(idMatrix) != 1)) {
337
355
            reportError("Invalid parameter is supplied in place of process identificator");
338
356
            return;
339
357
        }
340
358
 
341
 
        idPtr = (uint32_t*)mxGetData(idMatrix);
 
359
        idPtr = (int32_t*)mxGetData(idMatrix);
342
360
        if (!idPtr) {
343
361
            reportError("Mex is not able to obtain process identificator");
344
362
            return;
353
371
        if (!pstate) {
354
372
            reportError("The interface is not initialized");
355
373
            return;
356
 
        }*/
 
374
        }
 
375
*/
357
376
    }
358
377
 
359
378
        // Clean request