@@ -50,6 +50,7 @@ CollectionOptimisation::CollectionOptimisation(
50
50
{
51
51
int i;
52
52
map<ElmtOrder, ImplementationType> defaults;
53
+ map<ElmtOrder, ImplementationType> defaultsPhysDeriv;
53
54
map<ElmtOrder, ImplementationType>::iterator it;
54
55
bool verbose = (pSession.get ()) &&
55
56
(pSession->DefinesCmdLineArgument (" verbose" )) &&
@@ -58,7 +59,7 @@ CollectionOptimisation::CollectionOptimisation(
58
59
m_setByXml = false ;
59
60
m_autotune = false ;
60
61
m_maxCollSize = 0 ;
61
- m_defaultType = defaultType == eNoImpType ? eNoCollection : defaultType;
62
+ m_defaultType = defaultType == eNoImpType ? eIterPerExp : defaultType;
62
63
63
64
map<string, LibUtilities::ShapeType> elTypes;
64
65
map<string, LibUtilities::ShapeType>::iterator it2;
@@ -73,14 +74,38 @@ CollectionOptimisation::CollectionOptimisation(
73
74
// Set defaults for all element types.
74
75
for (it2 = elTypes.begin (); it2 != elTypes.end (); ++it2)
75
76
{
76
- defaults[ElmtOrder (it2->second , -1 )] = m_defaultType;
77
+ defaults [ElmtOrder (it2->second , -1 )] = m_defaultType;
78
+ defaultsPhysDeriv [ElmtOrder (it2->second , -1 )] = m_defaultType;
79
+ }
80
+
81
+ if (defaultType == eNoImpType)
82
+ {
83
+ for (it2 = elTypes.begin (); it2 != elTypes.end (); ++it2)
84
+ {
85
+ defaultsPhysDeriv [ElmtOrder (it2->second , -1 )] = eNoCollection;
86
+ for (int i = 1 ; i < 5 ; ++i)
87
+ {
88
+ defaults[ElmtOrder (it2->second , i)] = eStdMat;
89
+ }
90
+ for (int i = 1 ; i < 3 ; ++i)
91
+ {
92
+ defaultsPhysDeriv[ElmtOrder (it2->second , i)] = eSumFac;
93
+ }
94
+ }
77
95
}
78
96
79
97
map<string, OperatorType> opTypes;
80
98
for (i = 0 ; i < SIZE_OperatorType; ++i)
81
99
{
82
100
opTypes[OperatorTypeMap[i]] = (OperatorType)i;
83
- m_global[(OperatorType)i] = defaults;
101
+ switch ((OperatorType)i)
102
+ {
103
+ case ePhysDeriv:
104
+ m_global[(OperatorType)i] = defaultsPhysDeriv;
105
+ break ;
106
+ default :
107
+ m_global[(OperatorType)i] = defaults;
108
+ }
84
109
}
85
110
86
111
map<string, ImplementationType> impTypes;
@@ -98,17 +123,23 @@ CollectionOptimisation::CollectionOptimisation(
98
123
99
124
TiXmlElement *xmlCol = master->FirstChildElement (" COLLECTIONS" );
100
125
126
+ // Check if user has specified some options
101
127
if (xmlCol)
102
128
{
129
+ // Set the maxsize and default implementation type if provided
103
130
const char *maxSize = xmlCol->Attribute (" MAXSIZE" );
104
131
m_maxCollSize = (maxSize ? atoi (maxSize) : 0 );
105
132
106
133
const char *defaultImpl = xmlCol->Attribute (" DEFAULT" );
107
134
m_defaultType = defaultType;
135
+
136
+ // If user has specified a default impl type, autotuning
137
+ // and set this default across all operators.
108
138
if (defaultType == eNoImpType && defaultImpl)
109
139
{
110
140
const std::string collinfo = string (defaultImpl);
111
141
m_autotune = boost::iequals (collinfo, " auto" );
142
+
112
143
if (!m_autotune)
113
144
{
114
145
for (i = 1 ; i < Collections::SIZE_ImplementationType; ++i)
@@ -122,7 +153,7 @@ CollectionOptimisation::CollectionOptimisation(
122
153
}
123
154
124
155
ASSERTL0 (i != Collections::SIZE_ImplementationType,
125
- " Unknown default collection scheme: " +collinfo);
156
+ " Unknown default collection scheme: " +collinfo);
126
157
127
158
// Override default types
128
159
for (it2 = elTypes.begin (); it2 != elTypes.end (); ++it2)
@@ -137,6 +168,7 @@ CollectionOptimisation::CollectionOptimisation(
137
168
}
138
169
}
139
170
171
+ // Now process operator-specific implementation selections
140
172
TiXmlElement *elmt = xmlCol->FirstChildElement ();
141
173
while (elmt)
142
174
{
@@ -323,7 +355,23 @@ OperatorImpMap CollectionOptimisation::SetWithTimings(
323
355
CollectionVector coll;
324
356
for (int imp = 1 ; imp < SIZE_ImplementationType; ++imp)
325
357
{
326
- OperatorImpMap impTypes = SetFixedImpType ((ImplementationType) imp);
358
+ ImplementationType impType = (ImplementationType)imp;
359
+ OperatorImpMap impTypes;
360
+ for (int i = 0 ; i < SIZE_OperatorType; ++i)
361
+ {
362
+ OperatorType opType = (OperatorType)i;
363
+ OperatorKey opKey (pCollExp[0 ]->DetShapeType (), opType, impType,
364
+ pCollExp[0 ]->IsNodalNonTensorialExp ());
365
+
366
+ if (GetOperatorFactory ().ModuleExists (opKey))
367
+ {
368
+ impTypes[opType] = impType;
369
+ }
370
+ else
371
+ {
372
+ cout << " Note: Implementation does not exist: " << opKey << endl;
373
+ }
374
+ }
327
375
328
376
Collection collloc (pCollExp,impTypes);
329
377
coll.push_back (collloc);
@@ -357,17 +405,24 @@ OperatorImpMap CollectionOptimisation::SetWithTimings(
357
405
// call collection implementation in thorugh ExpList.
358
406
for (int imp = 0 ; imp < coll.size (); ++imp)
359
407
{
360
- t.Start ();
361
- for (int n = 0 ; n < Ntest[i]; ++n)
408
+ if (coll[imp].HasOperator (OpType))
362
409
{
363
- coll[imp].ApplyOperator (OpType,
410
+ t.Start ();
411
+ for (int n = 0 ; n < Ntest[i]; ++n)
412
+ {
413
+ coll[imp].ApplyOperator (OpType,
364
414
inarray,
365
415
outarray1,
366
416
outarray2,
367
417
outarray3);
418
+ }
419
+ t.Stop ();
420
+ timing[imp] = t.TimePerTest (Ntest[i]);
421
+ }
422
+ else
423
+ {
424
+ timing[imp] = 1000.0 ;
368
425
}
369
- t.Stop ();
370
- timing[imp] = t.TimePerTest (Ntest[i]);
371
426
}
372
427
// determine optimal implementation. Note +1 to
373
428
// remove NoImplementationType flag
@@ -379,7 +434,14 @@ OperatorImpMap CollectionOptimisation::SetWithTimings(
379
434
<< ImplementationTypeMap[minImp] << " \t (" ;
380
435
for (int j = 0 ; j < coll.size (); ++j)
381
436
{
382
- cout << timing[j] ;
437
+ if (timing[j] > 999.0 )
438
+ {
439
+ cout << " -" ;
440
+ }
441
+ else
442
+ {
443
+ cout << timing[j] ;
444
+ }
383
445
if (j != coll.size ()-1 )
384
446
{
385
447
cout <<" , " ;
0 commit comments