/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 dict_hw/src/dict_hw_test.cpp

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-25 23:10:35 UTC
  • Revision ID: csa@dside.dyndns.org-20100425231035-ggdq59911gurvsu3
Preloading of images

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
typedef enum {
27
27
    OPT_DEFAULT_FFT = 250,
28
28
    OPT_SINGLE_MODE = 251,
 
29
    OPT_NO_PRELOAD = 252,
 
30
    OPT_MULTIPASS = 253,
29
31
    OPT_MATLAB = 'm',
30
32
    OPT_HELP = 'h'
31
33
} Options;
34
36
    {"matlab",                  no_argument, 0, OPT_MATLAB },
35
37
    {"default-fft",             no_argument, 0, OPT_DEFAULT_FFT },
36
38
    {"no-threads",              no_argument, 0, OPT_SINGLE_MODE },
 
39
    {"no-preload",              no_argument, 0, OPT_NO_PRELOAD },
 
40
    {"multipass",               no_argument, 0, OPT_MULTIPASS },
37
41
    {"help",                    no_argument, 0, OPT_HELP },
38
42
    { 0, 0, 0, 0 }
39
43
};
40
44
 
41
45
void Usage(int argc, char *argv[]) {
42
46
    printf(
43
 
" %s [options] [mode] <directory> [maximages]\n"
44
 
"  Modes:\n"
 
47
" %s [options] <directory> [maximages]\n"
 
48
"  Options:\n"
45
49
"       --matlab        - Matlab mode (transposed data ordering)\n"
46
50
"       --default-fft   - Do not optimize FFT size\n"
47
 
"       --no-threads    - Single GPU mode\n"
 
51
"       --no-threads    - Disables threading, results in a single GPU mode\n"
 
52
"       --no-preload    - Disables image preloading in multi-threaded mode\n"
 
53
"       --multipass     - In multipass mode the caching is always used at the\n"
 
54
"                         expense of the repeated image reading\n"
48
55
"       --help          - Help message\n"
49
56
"\n\n", argv[0]);
50
57
}
153
160
 
154
161
    int default_fft = 0;
155
162
    int single_mode = 0;
 
163
    int preload = 1;
 
164
 
 
165
    int multipass;
156
166
    
157
167
    int option_index = 0;
158
168
    unsigned char c;
168
178
            break;
169
179
            case OPT_SINGLE_MODE:
170
180
                single_mode = 1;
 
181
                preload = 0;
 
182
            break;
 
183
            case OPT_NO_PRELOAD:
 
184
                preload = 0;
 
185
            break;
 
186
            case OPT_MULTIPASS:
 
187
                multipass = 1;
171
188
            break;
172
189
            case OPT_HELP:
173
190
                Usage(argc, argv);
243
260
    allocimg = i;
244
261
    if ((!maximg)||(maximg > i)) maximg = i;
245
262
    
246
 
    qsort(images, allocimg, sizeof(char*), (int (*)(const void*, const void*))compare);
247
 
    
248
263
    if (maximg < 2) {
249
264
        printf("At least two images are required\n");
250
265
        exit(-1);
251
266
    }
252
267
 
 
268
    qsort(images, allocimg, sizeof(char*), (int (*)(const void*, const void*))compare);
 
269
 
253
270
    int ncp = xsize;
254
271
    
255
272
    DICTContext ps = dictCreateContext();
332
349
#endif /* DICT_HW_MEASURE_TIMINGS */
333
350
 
334
351
 
335
 
    for (i = 1; i < maximg; i++) {
 
352
    gchar *next = NULL;
 
353
 
 
354
    name = g_strdup_printf("%s/images/%s", argv[optind], images[1]);
 
355
    if (!g_file_test(name, G_FILE_TEST_IS_REGULAR)) {
 
356
        g_free(name);
 
357
        printf("%s is not a regular file\n", images[1]);
 
358
        exit(-1);
 
359
    }
 
360
    
 
361
    for (i = 1; i < maximg; i++, name = next) {
336
362
#ifndef DICT_HW_MEASURE_TIMINGS
337
363
        printf("%s\n", images[i]);
338
364
#endif /* !DICT_HW_MEASURE_TIMINGS */
 
365
 
 
366
 
 
367
        if ((i + 1) < maximg) {
 
368
            next = g_strdup_printf("%s/images/%s", argv[optind], images[i + 1]);
 
369
            if (!g_file_test(next, G_FILE_TEST_IS_REGULAR)) {
 
370
                g_free(next);
 
371
                g_free(name);
 
372
                printf("%s is not a regular file\n", images[i + 1]);
 
373
                exit(-1);
 
374
            }
 
375
            
 
376
            if (preload) {
 
377
                dictPreloadImageFile(ps, next);
 
378
            }
 
379
        }
339
380
        
340
 
        name = g_strdup_printf("%s/images/%s", argv[optind], images[i]);
341
 
        if (!g_file_test(name, G_FILE_TEST_IS_REGULAR)) {
342
 
            g_free(name);
343
 
            printf("%s is not a regular file\n", images[0]);
344
 
            exit(-1);
345
 
        }
346
 
 
347
381
#ifdef DICT_HW_MEASURE_TIMINGS
348
382
        gettimeofday(&tv3, NULL);
349
383
#endif /* DICT_HW_MEASURE_TIMINGS */
352
386
        gettimeofday(&tv2, NULL);
353
387
        time[5] += (tv2.tv_sec - tv3.tv_sec) * 1000000 + (tv2.tv_usec - tv3.tv_usec);
354
388
#endif /* DICT_HW_MEASURE_TIMINGS */
 
389
        
355
390
        g_free(name);
356
391
 
357
392
        if (err) {
358
393
            printf("failed to load image %s\n", images[0]);
359
394
            exit(-1);
360
395
        }
 
396
        
361
397
 
362
398
        if (matlab_mode) {
363
399
            float *out = res + ncp * (i - 1);