/perf/fdk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/perf/fdk

« back to all changes in this revision

Viewing changes to test.c

  • Committer: Suren A. Chilingaryan
  • Date: 2017-02-09 00:44:25 UTC
  • Revision ID: csa@suren.me-20170209004425-4dt67qhxz9ibdehy
Intel compiler

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include <stdio.h>
5
5
#include <stdlib.h>
6
6
#include <malloc.h>
 
7
#include <errno.h>
7
8
#include <sys/time.h>
 
9
#include <ctype.h>
 
10
#include <stdarg.h>
8
11
 
9
12
#include <math.h>
10
13
#include <pthread.h>
12
15
#include <string.h>
13
16
#include <limits.h>
14
17
 
 
18
#include <getopt.h>
 
19
 
15
20
#include "process.h"
16
21
 
17
 
void main() {
 
22
extern int counter;
 
23
 
 
24
 
 
25
enum {
 
26
    OPT_SLICE = 's',
 
27
    OPT_HELP
 
28
};
 
29
 
 
30
static struct option long_options[] = {
 
31
    {"help",                    no_argument,            0, OPT_HELP },
 
32
    {"slice",                   required_argument,      0, OPT_SLICE },
 
33
    { 0, 0, 0, 0 }
 
34
};
 
35
 
 
36
static void Usage(int argc, char *argv[], const char *format, ...) {
 
37
    if (format) {
 
38
        va_list ap;
 
39
 
 
40
        va_start(ap, format);
 
41
        printf("Error %i: ", errno);
 
42
        vprintf(format, ap);
 
43
        printf("\n");
 
44
        va_end(ap);
 
45
 
 
46
        printf("\n");
 
47
    }
 
48
 
 
49
    printf(
 
50
"Usage:\n"
 
51
" %s [options]\n"
 
52
"\n"
 
53
"Options:\n"
 
54
" -s [slice]            - slice number\n"
 
55
"\n\n",
 
56
argv[0]);
 
57
 
 
58
    exit(0);
 
59
}
 
60
 
 
61
 
 
62
static int isnumber(const char *str) {
 
63
    int i = 0;
 
64
    for (i = 0; str[i]; i++)
 
65
        if (!isdigit(str[i])) return 0;
 
66
    return 1;
 
67
}
 
68
 
 
69
 
 
70
void main(int argc, char *argv[]) {
18
71
 
19
72
    int n_threads = 1;
20
73
    int alignment = 256;
55
108
    }
56
109
 
57
110
    for (i = 0; i < n_elements; i++) {
58
 
        slice_coord_z[i] = (i + 1) - (n_elements + 1.)/2;
 
111
        slice_coord_z[i] = (pixel_size / 16) * ((i + 1) - (n_elements + 1.) / 2);
59
112
        for (j = 0; j < n_elements; j++) {
60
113
            slice_x[i * n_elements + j] = (pixel_size / 16) * ((i + 1) - (n_elements + 1.)/2);
61
114
            slice_y[i * n_elements + j] = (pixel_size / 16) * ((n_elements - j) - (n_elements + 1.)/2);
73
126
 
74
127
        /* fill tread_info structure and create threads */
75
128
 
 
129
 
 
130
    counter = n_elements / 2;
 
131
 
 
132
    unsigned char c;
 
133
    while ((c = getopt_long(argc, argv, "s:", long_options, NULL)) != (unsigned char)-1) {
 
134
        extern int optind;
 
135
        switch (c) {
 
136
         case OPT_HELP:
 
137
            Usage(argc, argv, NULL);
 
138
            break;
 
139
         case OPT_SLICE:
 
140
            if ((!isnumber(optarg))||(sscanf(optarg, "%i", &counter) != 1)||(counter < 0)||(counter >= n_elements)) {
 
141
                Usage(argc, argv, "Invalid slice is specified (%s)", optarg);
 
142
            }
 
143
            break;
 
144
         default:
 
145
            Usage(argc, argv,  "Unknown option (%s) with argument (%s)", optarg?argv[optind-2]:argv[optind-1], optarg?optarg:"(null)");
 
146
        }
 
147
    }
 
148
 
 
149
 
76
150
    gettimeofday(&start, NULL);
77
151
 
78
152
    for (tnum = 0; tnum < n_threads; tnum++)
97
171
        t_info[tnum].slice_y = slice_y; 
98
172
        t_info[tnum].slice_coord_z = slice_coord_z;
99
173
        t_info[tnum].out_volume = out_volume;
 
174
        t_info[tnum].slices_per_iter = n_elements;
100
175
 
101
176
        if (n_threads > 1) {
102
177
            m = pthread_create(&t_info[tnum].thread_id, NULL, &process, &t_info[tnum]);
127
202
 
128
203
    gettimeofday(&end, NULL);
129
204
    duration = (end.tv_sec - start.tv_sec) * 1000000 + end.tv_usec - start.tv_usec;
130
 
    printf("Time: %2u:%2u:%2u (%6u)", duration/3600000000, (duration%3600000000)/60000000, (duration%60000000)/1000000, (duration%1000000)); 
 
205
    printf("Time: %2u:%2u:%2u (%6u)\n", duration/3600000000, (duration%3600000000)/60000000, (duration%60000000)/1000000, (duration%1000000)); 
131
206
 
132
207
 
133
208
    free(t_info);