File: select.c

package info (click to toggle)
paraview 5.1.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 221,108 kB
  • ctags: 236,092
  • sloc: cpp: 2,416,026; ansic: 190,891; python: 99,856; xml: 81,001; tcl: 46,915; yacc: 5,039; java: 4,413; perl: 3,108; sh: 1,974; lex: 1,926; f90: 748; asm: 471; pascal: 228; makefile: 198; objc: 83; fortran: 31
file content (236 lines) | stat: -rw-r--r-- 9,371 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* -*- c -*- *******************************************************/
/*
 * Copyright (C) 2010 Sandia Corporation
 * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
 * the U.S. Government retains certain rights in this software.
 *
 * This source code is released under the New BSD License.
 */

#include <IceTDevStrategySelect.h>

#include <IceT.h>
#include <IceTDevDiagnostics.h>
#include <IceTDevImage.h>
#include <IceTDevState.h>

/* Declaration of strategy compose functions. */
extern IceTImage icetDirectCompose(void);
extern IceTImage icetSequentialCompose(void);
extern IceTImage icetSplitCompose(void);
extern IceTImage icetReduceCompose(void);
extern IceTImage icetVtreeCompose(void);

/* Declaration of single image strategy compose functions. */
extern void icetAutomaticCompose(const IceTInt *compose_group,
                                 IceTInt group_size,
                                 IceTInt image_dest,
                                 IceTSparseImage input_image,
                                 IceTSparseImage *result_image,
                                 IceTSizeType *piece_offset);
extern void icetBswapCompose(const IceTInt *compose_group,
                             IceTInt group_size,
                             IceTInt image_dest,
                             IceTSparseImage input_image,
                             IceTSparseImage *result_image,
                             IceTSizeType *piece_offset);
void icetBswapFoldingCompose(const IceTInt *compose_group,
                             IceTInt group_size,
                             IceTInt image_dest,
                             IceTSparseImage input_image,
                             IceTSparseImage *result_image,
                             IceTSizeType *piece_offset);
extern void icetTreeCompose(const IceTInt *compose_group,
                            IceTInt group_size,
                            IceTInt image_dest,
                            IceTSparseImage input_image,
                            IceTSparseImage *result_image,
                            IceTSizeType *piece_offset);
extern void icetRadixkCompose(const IceTInt *compose_group,
                              IceTInt group_size,
                              IceTInt image_dest,
                              IceTSparseImage input_image,
                              IceTSparseImage *result_image,
                              IceTSizeType *piece_offset);
extern void icetRadixkrCompose(const IceTInt *compose_group,
                               IceTInt group_size,
                               IceTInt image_dest,
                               IceTSparseImage input_image,
                               IceTSparseImage *result_image,
                               IceTSizeType *piece_offset);

/*==================================================================*/

IceTBoolean icetStrategyValid(IceTEnum strategy)
{
    switch (strategy) {
      case ICET_STRATEGY_DIRECT:
      case ICET_STRATEGY_SEQUENTIAL:
      case ICET_STRATEGY_SPLIT:
      case ICET_STRATEGY_REDUCE:
      case ICET_STRATEGY_VTREE:
          return ICET_TRUE;
      default:
          return ICET_FALSE;
    }
}

const char *icetStrategyNameFromEnum(IceTEnum strategy)
{
    switch (strategy) {
      case ICET_STRATEGY_DIRECT:        return "Direct";
      case ICET_STRATEGY_SEQUENTIAL:    return "Sequential";
      case ICET_STRATEGY_SPLIT:         return "Split";
      case ICET_STRATEGY_REDUCE:        return "Reduce";
      case ICET_STRATEGY_VTREE:         return "Virtual Tree";
      case ICET_STRATEGY_UNDEFINED:
          icetRaiseError("Strategy not defined. "
                         "Use icetStrategy to set the strategy.",
                         ICET_INVALID_ENUM);
          return "<Not Set>";
      default:
          icetRaiseError("Invalid strategy.", ICET_INVALID_ENUM);
          return "<Invalid>";
    }
}

IceTBoolean icetStrategySupportsOrdering(IceTEnum strategy)
{
    switch (strategy) {
      case ICET_STRATEGY_DIRECT:        return ICET_TRUE;
      case ICET_STRATEGY_SEQUENTIAL:    return ICET_TRUE;
      case ICET_STRATEGY_SPLIT:         return ICET_FALSE;
      case ICET_STRATEGY_REDUCE:        return ICET_TRUE;
      case ICET_STRATEGY_VTREE:         return ICET_FALSE;
      case ICET_STRATEGY_UNDEFINED:
          icetRaiseError("Strategy not defined. "
                         "Use icetStrategy to set the strategy.",
                         ICET_INVALID_ENUM);
          return ICET_FALSE;
      default:
          icetRaiseError("Invalid strategy.", ICET_INVALID_ENUM);
          return ICET_FALSE;
    }
}

IceTImage icetInvokeStrategy(IceTEnum strategy)
{
    icetRaiseDebug1("Invoking strategy %s",
                    icetStrategyNameFromEnum(strategy));

    switch (strategy) {
      case ICET_STRATEGY_DIRECT:        return icetDirectCompose();
      case ICET_STRATEGY_SEQUENTIAL:    return icetSequentialCompose();
      case ICET_STRATEGY_SPLIT:         return icetSplitCompose();
      case ICET_STRATEGY_REDUCE:        return icetReduceCompose();
      case ICET_STRATEGY_VTREE:         return icetVtreeCompose();
      case ICET_STRATEGY_UNDEFINED:
          icetRaiseError("Strategy not defined. "
                         "Use icetStrategy to set the strategy.",
                         ICET_INVALID_ENUM);
          return icetImageNull();
      default:
          icetRaiseError("Invalid strategy.", ICET_INVALID_ENUM);
          return icetImageNull();
    }
}

/*==================================================================*/

IceTBoolean icetSingleImageStrategyValid(IceTEnum strategy)
{
    switch(strategy) {
      case ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC:
      case ICET_SINGLE_IMAGE_STRATEGY_BSWAP:
      case ICET_SINGLE_IMAGE_STRATEGY_TREE:
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXK:
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXKR:
      case ICET_SINGLE_IMAGE_STRATEGY_BSWAP_FOLDING:
          return ICET_TRUE;
      default:
          return ICET_FALSE;
    }
}

const char *icetSingleImageStrategyNameFromEnum(IceTEnum strategy)
{
    switch(strategy) {
      case ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC:        return "Automatic";
      case ICET_SINGLE_IMAGE_STRATEGY_BSWAP:            return "Binary Swap";
      case ICET_SINGLE_IMAGE_STRATEGY_TREE:             return "Binary Tree";
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXK:           return "Radix-k";
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXKR:          return "Radix-kr";
      case ICET_SINGLE_IMAGE_STRATEGY_BSWAP_FOLDING:    return "Folded Binary Swap";
      default:
          icetRaiseError("Invalid single image strategy.", ICET_INVALID_ENUM);
          return "<Invalid>";
    }
}

void icetInvokeSingleImageStrategy(IceTEnum strategy,
                                   const IceTInt *compose_group,
                                   IceTInt group_size,
                                   IceTInt image_dest,
                                   IceTSparseImage input_image,
                                   IceTSparseImage *result_image,
                                   IceTSizeType *piece_offset)
{
    icetRaiseDebug1("Invoking single image strategy %s",
                    icetSingleImageStrategyNameFromEnum(strategy));

    switch(strategy) {
      case ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC:
          icetAutomaticCompose(compose_group,
                               group_size,
                               image_dest,
                               input_image,
                               result_image,
                               piece_offset);
          break;
      case ICET_SINGLE_IMAGE_STRATEGY_BSWAP:
          icetBswapCompose(compose_group,
                           group_size,
                           image_dest,
                           input_image,
                           result_image,
                           piece_offset);
          break;
      case ICET_SINGLE_IMAGE_STRATEGY_TREE:
          icetTreeCompose(compose_group,
                          group_size,
                          image_dest,
                          input_image,
                          result_image,
                          piece_offset);
          break;
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXK:
          icetRadixkCompose(compose_group,
                            group_size,
                            image_dest,
                            input_image,
                            result_image,
                            piece_offset);
          break;
      case ICET_SINGLE_IMAGE_STRATEGY_RADIXKR:
          icetRadixkrCompose(compose_group,
                             group_size,
                             image_dest,
                             input_image,
                             result_image,
                             piece_offset);
          break;
    case ICET_SINGLE_IMAGE_STRATEGY_BSWAP_FOLDING:
        icetBswapFoldingCompose(compose_group,
                                group_size,
                                image_dest,
                                input_image,
                                result_image,
                                piece_offset);
        break;
      default:
          icetRaiseError("Invalid single image strategy.", ICET_INVALID_ENUM);
          break;
    }

    icetStateCheckMemory();
}