47 #ifdef HAVE_EPETRA_TEUCHOS
55 Epetra_View_(Source.Epetra_View_),
63 Epetra_View_(&Source) {
64 bool AutoTune =
false;
65 bool DeepCopy =
false;
66 string Matrix =
"general\0";
67 bool IsDiagNotStored =
false;
68 bool IsArrayZeroBased =
false;
70 bool AreIndicesSorted =
false;
71 bool AreIndicesRepeated =
false;
72 oski_inmatprop_t MatrixType = MAT_GENERAL;
73 oski_inmatprop_t Diagonal = MAT_DIAG_EXPLICIT;
74 oski_inmatprop_t ArrayBasis = INDEX_ONE_BASED;
75 oski_inmatprop_t SortedIndices = INDEX_UNSORTED;
76 oski_inmatprop_t RepeatedIndices = INDEX_REPEATED;
79 double* ValPtr = NULL;
82 DeepCopy = Teuchos::getParameter<bool>(List,
"deepcopy");
85 MatrixType = MAT_TRI_LOWER;
87 MatrixType = MAT_TRI_UPPER;
89 SortedIndices = INDEX_SORTED;
90 MyIndexBase = IndexBase();
92 ArrayBasis = INDEX_ZERO_BASED;
93 else if(MyIndexBase == 1)
94 ArrayBasis = INDEX_ONE_BASED;
96 std::cerr <<
"An OskiMatrix must be either zero or one based.\n";
100 RepeatedIndices = INDEX_UNIQUE;
103 Matrix = Teuchos::getParameter<string>(List,
"matrixtype");
104 if(Matrix ==
"general")
105 MatrixType = MAT_GENERAL;
106 else if(Matrix ==
"uppertri")
107 MatrixType = MAT_TRI_UPPER;
108 else if(Matrix ==
"lowertri")
109 MatrixType = MAT_TRI_LOWER;
110 else if(Matrix ==
"uppersymm")
111 MatrixType = MAT_SYMM_UPPER;
112 else if(Matrix ==
"lowersymm")
113 MatrixType = MAT_SYMM_LOWER;
114 else if(Matrix ==
"fullsymm")
115 MatrixType = MAT_SYMM_FULL;
116 else if(Matrix ==
"upperherm")
117 MatrixType = MAT_HERM_UPPER;
118 else if(Matrix ==
"lowerherm")
119 MatrixType = MAT_HERM_LOWER;
120 else if(Matrix ==
"fullherm")
121 MatrixType = MAT_HERM_FULL;
123 if(List.isParameter(
"diagstored"))
124 IsDiagNotStored = Teuchos::getParameter<bool>(List,
"diagstored");
125 if(List.isParameter(
"zerobased"))
126 IsArrayZeroBased = Teuchos::getParameter<bool>(List,
"zerobased");
127 if(List.isParameter(
"sorted"))
128 AreIndicesSorted = Teuchos::getParameter<bool>(List,
"sorted");
129 if(List.isParameter(
"unique"))
130 DeepCopy = Teuchos::getParameter<bool>(List,
"unique");
132 Diagonal = MAT_UNIT_DIAG_IMPLICIT;
134 ArrayBasis = INDEX_ZERO_BASED;
136 SortedIndices = INDEX_SORTED;
137 if(AreIndicesRepeated)
138 RepeatedIndices = INDEX_UNIQUE;
139 if(ExtractCrsDataPointers(RowPtr, IndPtr, ValPtr)) {
140 std::cerr <<
"Cannot wrap matrix as an Oski Matrix because at least one of FillComplete and Optimize Storage has not been called\n";
144 Copy_Created_ =
true;
145 A_tunable_ = oski_CreateMatCSR(RowPtr, IndPtr, ValPtr, Source.
NumMyRows(), Source.
NumMyCols(), COPY_INPUTMAT, 5, MatrixType, Diagonal, ArrayBasis, SortedIndices, RepeatedIndices);
148 Copy_Created_ =
false;
149 A_tunable_ = oski_CreateMatCSR(RowPtr, IndPtr, ValPtr, Source.
NumMyRows(), Source.
NumMyCols(), SHARE_INPUTMAT, 5, MatrixType, Diagonal, ArrayBasis, SortedIndices, RepeatedIndices);
155 std::cerr <<
"Destroy Matrix failed.\n";
164 for(
int i = 0; i < NumEntries; i++) {
165 ReturnVal = oski_SetMatEntry(
A_tunable_, MyRow, Indices[i], Values[i]);
175 std::cerr <<
"Error in ReplaceMyValues\n";
185 for(
int i = 0; i < NumEntries; i++) {
186 ReturnVal = oski_SetMatEntry(
A_tunable_, MyRow, Indices[i], oski_GetMatEntry(
A_tunable_, MyRow, Indices[i]));
196 std::cerr <<
"Error in SumIntoMyValues\n";
204 std::cerr <<
"Error in ExtractDiagonalCopy\n";
218 std::cerr <<
"Error in ReplaceDiagonalValues\n";
226 ReturnVal = this->
Multiply(TransA, x, y, 1.0, 0.0);
240 double* xp = (
double*) x.
Values();
241 double* yp = (
double*) y.
Values();
246 xp = (
double *) xcopy->
Values();
264 oski_vecview_t oskiX;
265 oski_vecview_t oskiY;
269 oskiX = oski_CreateVecView(xp,x.
MyLength(),1);
273 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
276 ReturnVal = oski_MatMult(
A_tunable_, OP_NORMAL, Alpha, oskiX, Beta, oskiY);
297 oski_vecview_t oskiX;
298 oski_vecview_t oskiY;
302 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
306 oskiX = oski_CreateVecView(xp,x.
MyLength(),1);
309 ReturnVal = oski_MatMult(
A_tunable_, OP_TRANS, Alpha, oskiX, Beta, oskiY);
319 std::cerr <<
"OskiVector multiply error\n";
328 ReturnVal = this->
Multiply(TransA, X, Y, 1.0, 0.0);
347 double** Xp = (
double**) X.
Pointers();
348 double** Yp = (
double**) Y.
Pointers();
377 oski_vecview_t oskiX;
378 oski_vecview_t oskiY;
382 oskiX = oski_CreateMultiVecView(*Xp,X.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDX);
386 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDY);
388 ReturnVal = oski_MatMult(
A_tunable_, OP_NORMAL, Alpha, oskiX, Beta, oskiY);
390 std::cerr <<
"OskiMultiVector multiply error\n";
414 oski_vecview_t oskiX;
415 oski_vecview_t oskiY;
419 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDY);
423 oskiX = oski_CreateMultiVecView(*Xp,X.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDX);
426 ReturnVal = oski_MatMult(
A_tunable_, OP_TRANS, Alpha, oskiX, Beta, oskiY);
428 std::cerr <<
"OskiMultiVector multiply error\n";
443 ReturnVal = this->
Solve(TransA, x, y, 1.0);
448 std::cout <<
"This function Epetra_OskiMatrix::Solve probably works in serial but has not been tested.\n It will not work in parallel.\n If you wish to use it feel free to comment out this line and the next return statement.\n However, correctness and performance are not guaranteed.\n";
453 bool xCreate =
false;
454 bool yCreate =
false;
468 ReturnVal = oski_MatTrisolve(
A_tunable_, OP_TRANS, Alpha, (*tCast).Oski_View());
470 ReturnVal = oski_MatTrisolve(
A_tunable_, OP_NORMAL, Alpha, (*tCast).Oski_View());
472 std::cerr <<
"OskiVector Solve error\n";
484 ReturnVal = this->
Solve(TransA, X, Y, 1.0);
489 std::cout <<
"This function Epetra_OskiMatrix::Solve probably works in serial but has not been tested.\n It will not work in parallel.\n If you wish to use it feel free to comment out this line and the next return statement.\n However, correctness and performance are not guaranteed.\n";
494 bool XCreate =
false;
495 bool YCreate =
false;
509 ReturnVal = oski_MatTrisolve(
A_tunable_, OP_TRANS, Alpha, (*TCast).Oski_View());
511 ReturnVal = oski_MatTrisolve(
A_tunable_, OP_NORMAL, Alpha, (*TCast).Oski_View());
513 std::cerr <<
"OskiMultiVector Solve error\n";
534 double* xp = (
double*) x.
Values();
535 double* xp2 = (
double*) x.
Values();
536 double* yp = (
double*) y.
Values();
539 tp = (
double*) t->
Values();
544 xp = (
double *) xcopy->
Values();
562 if(
Exporter() != 0 && (t) != NULL) {
566 oski_vecview_t oskiX=0;
567 oski_vecview_t oskiY=0;
568 oski_vecview_t oskiT=0;
572 oskiX = oski_CreateVecView(xp2,x.
MyLength(),1);
576 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
582 oskiT = oski_CreateVecView(tp,t->
MyLength(),1);
587 ReturnVal = oski_MatTransMatMult(
A_tunable_, OP_AT_A, Alpha, oskiX, Beta, oskiY, oskiT);
596 if(
Exporter() != 0 && (t != NULL)) {
606 if(this->
Comm().NumProc() == 1) {
607 oski_vecview_t oskiX=0;
608 oski_vecview_t oskiY=0;
609 oski_vecview_t oskiT=0;
611 oskiT = oski_CreateVecView(tp,t->
MyLength(),1);
612 oskiX = oski_CreateVecView(xp,x.
MyLength(),1);
613 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
614 ReturnVal = oski_MatTransMatMult(
A_tunable_, OP_A_AT, Alpha, oskiX, Beta, oskiY, oskiT);
621 ReturnVal = this->
Multiply(
false, x, tempResult, 1.0, 0.0);
622 int ReturnVal2 = this->
Multiply(
true, tempResult, y, Alpha, Beta);
623 if(ReturnVal < ReturnVal2)
624 ReturnVal = ReturnVal2;
627 ReturnVal = this->
Multiply(
false, x, *t, 1.0, 0.0);
628 int ReturnVal2 = this->
Multiply(
true,*t, y, Alpha, Beta);
629 if(ReturnVal < ReturnVal2)
630 ReturnVal = ReturnVal2;
660 double** Xp = (
double**) X.
Pointers();
661 double** Xp2 = (
double**) X.
Pointers();
662 double** Yp = (
double**) Y.
Pointers();
691 double** Xp2 = (
double**) X2->
Pointers();
703 oski_vecview_t oskiX=0;
704 oski_vecview_t oskiY=0;
705 oski_vecview_t oskiT=0;
709 oskiX = oski_CreateMultiVecView(*Xp2,X.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDX);
713 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDY);
719 oskiT = oski_CreateMultiVecView(*Tp,T->
MyLength(),NumVectors,LAYOUT_COLMAJ,LDT);
724 ReturnVal = oski_MatTransMatMult(
A_tunable_, OP_AT_A, Alpha, oskiX, Beta, oskiY, oskiT);
733 if(
Exporter() != 0 && (T != NULL)) {
743 if(this->
Comm().NumProc() == 1) {
744 oski_vecview_t oskiX=0;
745 oski_vecview_t oskiY=0;
746 oski_vecview_t oskiT=0;
748 oskiT = oski_CreateMultiVecView(*Tp,T->
MyLength(),NumVectors, LAYOUT_COLMAJ,LDT);
749 oskiX = oski_CreateMultiVecView(*Xp,X.
MyLength(),NumVectors, LAYOUT_COLMAJ,LDX);
750 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors, LAYOUT_COLMAJ,LDY);
751 ReturnVal = oski_MatTransMatMult(
A_tunable_, OP_A_AT, Alpha, oskiX, Beta, oskiY, oskiT);
757 ReturnVal = this->
Multiply(
false, X, TempResult, 1.0, 0.0);
758 int ReturnVal2 = this->
Multiply(
true, TempResult, Y, Alpha, Beta);
759 if(ReturnVal < ReturnVal2)
760 ReturnVal = ReturnVal2;
763 ReturnVal = this->
Multiply(
false, X, *T, 1.0, 0.0);
764 int ReturnVal2 = this->
Multiply(
true, *T, Y, Alpha, Beta);
765 if(ReturnVal < ReturnVal2)
766 ReturnVal = ReturnVal2;
793 double* xp = (
double*) x.
Values();
794 double* xp2 = (
double*) x.
Values();
795 double* wp = (
double*) w.
Values();
796 double* yp = (
double*) y.
Values();
798 double* zp = (
double*) z.
Values();
803 xp = (
double *) xcopy->
Values();
808 wp = (
double *) wcopy->
Values();
826 yp = (
double*) yp2->
Values();
833 oski_vecview_t oskiX=0;
834 oski_vecview_t oskiY=0;
835 oski_vecview_t oskiW=0;
836 oski_vecview_t oskiZ=0;
842 oskiX = oski_CreateVecView(xp2,x.
MyLength(),1);
843 oskiZ = oski_CreateVecView(zp,z.
MyLength(),1);
850 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
851 oskiW = oski_CreateVecView(wp,w.
MyLength(),1);
854 ReturnVal = oski_MatMultAndMatTransMult(
A_tunable_, Alpha, oskiX, Beta, oskiY, OP_TRANS, Omega, oskiW, Zeta, oskiZ);
883 yp = (
double*) yp2->
Values();
890 oski_vecview_t oskiX=0;
891 oski_vecview_t oskiY=0;
892 oski_vecview_t oskiW=0;
893 oski_vecview_t oskiZ=0;
899 oskiX = oski_CreateVecView(xp2,x.
MyLength(),1);
900 oskiW = oski_CreateVecView(wp,w.
MyLength(),1);
907 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
908 oskiZ = oski_CreateVecView(zp,z.
MyLength(),1);
911 ReturnVal = oski_MatMultAndMatTransMult(
A_tunable_, Alpha, oskiX, Beta, oskiY, OP_NORMAL, Omega, oskiW, Zeta, oskiZ);
926 std::cerr <<
"OskiVector multiply error\n";
948 double** Xp = (
double**) X.
Pointers();
949 double** Xp2 = (
double**) X.
Pointers();
950 double** Wp = (
double**) W.
Pointers();
951 double** Yp = (
double**) Y.
Pointers();
952 double** Zp = (
double**) Z.
Pointers();
969 Wp = (
double **) Wcopy->
Values();
982 double** Xp2 = (
double**) X2->
Pointers();
994 oski_vecview_t oskiX=0;
995 oski_vecview_t oskiY=0;
996 oski_vecview_t oskiW=0;
997 oski_vecview_t oskiZ=0;
1003 oskiX = oski_CreateMultiVecView(*Xp2,X.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDX);
1004 oskiZ = oski_CreateMultiVecView(*Zp,Z.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDZ);
1011 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDY);
1012 oskiW = oski_CreateMultiVecView(*Wp,W.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDW);
1015 ReturnVal = oski_MatMultAndMatTransMult(
A_tunable_, Alpha, oskiX, Beta, oskiY, OP_TRANS, Omega, oskiW, Zeta, oskiZ);
1049 oski_vecview_t oskiX=0;
1050 oski_vecview_t oskiY=0;
1051 oski_vecview_t oskiW=0;
1052 oski_vecview_t oskiZ=0;
1058 oskiX = oski_CreateMultiVecView(*Xp2,X.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDX);
1059 oskiW = oski_CreateMultiVecView(*Wp,W.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDW);
1066 oskiY = oski_CreateMultiVecView(*Yp,Y.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDY);
1067 oskiZ = oski_CreateMultiVecView(*Zp,Z.
MyLength(),NumVectors,LAYOUT_COLMAJ,LDZ);
1070 ReturnVal = oski_MatMultAndMatTransMult(
A_tunable_, Alpha, oskiX, Beta, oskiY, OP_NORMAL, Omega, oskiW, Zeta, oskiZ);
1093 double Beta)
const {
1095 std::cerr <<
"MatPowMultiply not implemented in oski-1.01h release.\n";
1103 double* xp = (
double*) x.
Values();
1104 double* yp = (
double*) y.
Values();
1105 double** Tp = (
double**) T.
Pointers();
1112 if(this->
Comm().NumProc() == 1) {
1113 oski_vecview_t oskiX=0;
1114 oski_vecview_t oskiY=0;
1115 oski_vecview_t oskiT=0;
1117 oskiT = oski_CreateMultiVecView(*Tp,T.
MyLength(),Power,LAYOUT_COLMAJ,LDT);
1118 oskiX = oski_CreateVecView(xp,x.
MyLength(),1);
1119 oskiY = oski_CreateVecView(yp,y.
MyLength(),1);
1122 ReturnVal = oski_MatPowMult(
A_tunable_, OP_TRANS, Power, Alpha, oskiX, Beta, oskiY, oskiT);
1124 ReturnVal = oski_MatPowMult(
A_tunable_, OP_NORMAL, Power, Alpha, oskiX, Beta, oskiY, oskiT);
1126 std::cerr <<
"OskiVector matpow multiply error\n";
1134 ReturnVal = this->
Multiply(
true, x, Tptr[1], 1.0, 0.0);
1135 for(
int i = 1; i < Power-1; i++)
1136 ReturnVal = this->
Multiply(
true, Tptr[i], Tptr[i+1], 1.0, 0.0);
1137 ReturnVal = this->
Multiply(
true, Tptr[Power-2], y, Alpha, Beta);
1140 ReturnVal = this->
Multiply(
false, x, Tptr[1], 1.0, 0.0);
1141 for(
int i = 1; i < Power-1; i++)
1142 ReturnVal = this->
Multiply(
false, Tptr[i], Tptr[i+1], 1.0, 0.0);
1143 ReturnVal = this->
Multiply(
false, Tptr[Power-2], y, Alpha, Beta);
1146 std::cerr <<
"OskiVector matpow multiply error\n";
1159 double Beta)
const {
1162 std::cerr <<
"MatPowMultiply not implemented in oski-1.01h release.\n";
1164 std::cerr <<
"mult\n";
1167 bool xCreate =
false;
1168 bool yCreate =
false;
1172 if (xCast == NULL) {
1176 if (yCast == NULL) {
1180 std::cerr <<
"mult\n";
1182 ReturnVal = oski_MatPowMult(
A_tunable_, OP_TRANS, Power, Alpha, (*xCast).Oski_View(), Beta, (*yCast).Oski_View(), NULL);
1184 ReturnVal = oski_MatPowMult(
A_tunable_, OP_NORMAL, Power, Alpha, (*xCast).Oski_View(), Beta, (*yCast).Oski_View(), NULL);
1185 std::cerr <<
"done\n";
1187 std::cerr <<
"OskiVector matpow multiply error\n";
1196 int* ArgArray = NULL;
1205 if(Teuchos::getParameter<bool>(List,
"randompattern"))
1206 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_RANDOM_PATTERN))
1207 std::cerr <<
"Error setting hint random pattern.\n";
1209 if(Teuchos::getParameter<bool>(List,
"correlatedpattern"))
1210 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_CORREL_PATTERN))
1211 std::cerr <<
"Error setting hint correlated pattern.\n";
1213 if(Teuchos::getParameter<bool>(List,
"symmetricpattern"))
1214 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_SYMM_PATTERN))
1215 std::cerr <<
"Error setting hint symmetric pattern.\n";
1217 if(Teuchos::getParameter<bool>(List,
"nonsymmetricpattern"))
1218 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_NONSYMM_PATTERN))
1219 std::cerr <<
"Error setting hint nonsymmetric pattern.\n";
1221 if(Teuchos::getParameter<bool>(List,
"alignedblocks"))
1223 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_ALIGNED_BLOCKS))
1224 std::cerr <<
"Error setting hint aligned blocks.\n";
1227 if(Teuchos::getParameter<bool>(List,
"unalignedblocks"))
1228 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_UNALIGNED_BLOCKS))
1229 std::cerr <<
"Error setting hint unaligned blocks.\n";
1231 if(Teuchos::getParameter<bool>(List,
"nodiags"))
1232 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_NO_DIAGS))
1233 std::cerr <<
"Error setting hint no diags.\n";
1235 if(Teuchos::getParameter<bool>(List,
"noblocks"))
1236 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_NO_BLOCKS))
1237 std::cerr <<
"Error setting hint no blocks.\n";
1239 if(Teuchos::getParameter<bool>(List,
"singleblocksize")) {
1240 ArgArray =
new int[2];
1243 ArgArray[0] = Teuchos::getParameter<int>(List,
"row");
1244 if(List.isParameter(
"col"))
1245 ArgArray[1] = Teuchos::getParameter<int>(List,
"col");
1246 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_SINGLE_BLOCKSIZE, ArgArray[0], ArgArray[1]))
1247 std::cerr <<
"Error setting hint single block size.\n";
1250 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_SINGLE_BLOCKSIZE))
1251 std::cerr <<
"Error setting hint single block size.\n";
1255 if(List.isParameter(
"multipleblocksize"))
1256 if(Teuchos::getParameter<bool>(List,
"multipleblocksize"))
1257 if(List.isParameter(
"blocks")) {
1258 Blocks = Teuchos::getParameter<int>(List,
"blocks");
1259 ArgArray =
new int[2*Blocks+1];
1260 ArgArray[0] = Blocks;
1261 for(
int i = 0; i < Blocks; i++) {
1262 sprintf(Number,
"%d", i+1);
1265 strcat(Row, Number);
1266 strcat(Col, Number);
1267 if(List.isParameter(Row))
1268 ArgArray[i*2 + 1] = Teuchos::getParameter<int>(List, Row);
1269 if(List.isParameter(Col))
1270 ArgArray[i*2 + 2] = Teuchos::getParameter<int>(List, Col);
1273 case 1 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES, ArgArray[0], ArgArray[1], ArgArray[2]))
1274 std::cerr <<
"Error setting hint multiple blocks.\n";
1276 case 2 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4]))
1277 std::cerr <<
"Error setting hint multiple blocks.\n";
1279 case 3 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4], ArgArray[5], ArgArray[6]))
1280 std::cerr <<
"Error setting hint multiple blocks.\n";
1282 case 4 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4], ArgArray[5], ArgArray[6], ArgArray[7], ArgArray[8]))
1283 std::cerr <<
"Error setting hint multiple blocks.\n";
1285 case 5 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4], ArgArray[5], ArgArray[6], ArgArray[7], ArgArray[8], ArgArray[9], ArgArray[10]))
1286 std::cerr <<
"Error setting hint multiple blocks.\n";
1288 default :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES))
1289 std::cerr <<
"Error setting hint multiple blocks.\n";
1296 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_MULTIPLE_BLOCKSIZES))
1297 std::cerr <<
"Error setting hint multiple blocks.\n";
1298 if(List.isParameter(
"diags"))
1299 if(Teuchos::getParameter<bool>(List,
"diags"))
1300 if(List.isParameter(
"numdiags")) {
1301 Diags = Teuchos::getParameter<int>(List,
"numdiags");
1302 ArgArray =
new int[Diags+1];
1303 ArgArray[0] = Diags;
1304 for(
int i = 0; i < Diags; i++) {
1305 sprintf(Number,
"%d", i + 1);
1306 strcpy(Diag,
"diag");
1307 strcat(Diag, Number);
1308 if(List.isParameter(Diag))
1309 ArgArray[i + 1] = Teuchos::getParameter<int>(List, Diag);
1312 case 1 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0], ArgArray[1]))
1313 std::cerr <<
"Error setting hint diags\n";
1315 case 2 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0], ArgArray[1], ArgArray[2]))
1316 std::cerr <<
"Error setting hint diags\n";
1318 case 3 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3]))
1319 std::cerr <<
"Error setting hint diags\n";
1321 case 4 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4]))
1322 std::cerr <<
"Error setting hint diags\n";
1324 case 5 :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0], ArgArray[1], ArgArray[2], ArgArray[3], ArgArray[4], ArgArray[5]))
1325 std::cerr <<
"Error setting hint diags\n";
1327 default :
if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS, ArgArray[0]))
1328 std::cerr <<
"Error setting hint diags\n";
1335 if(ReturnVal = oski_SetHint(
A_tunable_, HINT_DIAGS))
1336 std::cerr <<
"Error setting hint digs.\n";
1349 oski_vecview_t InView = NULL;
1350 oski_vecview_t OutView = NULL;
1354 if(Teuchos::getParameter<bool>(List,
"tune"))
1355 NumCalls = ALWAYS_TUNE;
1357 if(Teuchos::getParameter<bool>(List,
"tuneaggressive"))
1358 NumCalls = ALWAYS_TUNE_AGGRESSIVELY;
1360 if(Teuchos::getParameter<bool>(List,
"symminvec"))
1361 InView = SYMBOLIC_VEC;
1363 if(Teuchos::getParameter<bool>(List,
"symminmultivec"))
1364 InView = SYMBOLIC_MULTIVEC;
1366 if(Teuchos::getParameter<bool>(List,
"symmoutvec"))
1367 OutView = SYMBOLIC_VEC;
1369 if(Teuchos::getParameter<bool>(List,
"symmoutmultivec"))
1370 OutView = SYMBOLIC_MULTIVEC;
1373 InView = SYMBOLIC_VEC;
1375 InView = SYMBOLIC_MULTIVEC;
1377 OutView = SYMBOLIC_VEC;
1379 OutView = SYMBOLIC_MULTIVEC;
1382 ReturnVal = oski_SetHintMatMult(
A_tunable_, OP_TRANS, Alpha, InView, Beta, OutView, NumCalls);
1384 ReturnVal = oski_SetHintMatMult(
A_tunable_, OP_NORMAL, Alpha, InView, Beta, OutView, NumCalls);
1386 std::cerr <<
"Set hint multivector multiply error\n";
1396 oski_vecview_t VecView = NULL;
1399 if(Teuchos::getParameter<bool>(List,
"tune"))
1400 NumCalls = ALWAYS_TUNE;
1402 if(Teuchos::getParameter<bool>(List,
"tuneaggressive"))
1403 NumCalls = ALWAYS_TUNE_AGGRESSIVELY;
1405 if(Teuchos::getParameter<bool>(List,
"symmvec"))
1406 VecView = SYMBOLIC_VEC;
1408 if(Teuchos::getParameter<bool>(List,
"symmmultivec"))
1409 VecView = SYMBOLIC_MULTIVEC;
1412 VecView = SYMBOLIC_VEC;
1414 VecView = SYMBOLIC_MULTIVEC;
1417 ReturnVal = oski_SetHintMatTrisolve(
A_tunable_, OP_TRANS, Alpha, VecView, NumCalls);
1419 ReturnVal = oski_SetHintMatTrisolve(
A_tunable_, OP_NORMAL, Alpha, VecView, NumCalls);
1421 std::cerr <<
"Set hint solve error\n";
1434 oski_vecview_t InView = NULL;
1435 oski_vecview_t OutView = NULL;
1436 oski_vecview_t IntermediateView = NULL;
1439 if(&Intermediate != NULL)
1440 IntermediateView = Intermediate.
Oski_View();
1442 if(Teuchos::getParameter<bool>(List,
"tune"))
1443 NumCalls = ALWAYS_TUNE;
1445 if(Teuchos::getParameter<bool>(List,
"tuneaggressive"))
1446 NumCalls = ALWAYS_TUNE_AGGRESSIVELY;
1448 if(Teuchos::getParameter<bool>(List,
"symminvec"))
1449 InView = SYMBOLIC_VEC;
1451 if(Teuchos::getParameter<bool>(List,
"symminmultivec"))
1452 InView = SYMBOLIC_MULTIVEC;
1454 if(Teuchos::getParameter<bool>(List,
"symmoutvec"))
1455 OutView = SYMBOLIC_VEC;
1457 if(Teuchos::getParameter<bool>(List,
"symmoutmultivec"))
1458 OutView = SYMBOLIC_MULTIVEC;
1460 if(Teuchos::getParameter<bool>(List,
"symmintervec"))
1461 IntermediateView = SYMBOLIC_VEC;
1463 if(Teuchos::getParameter<bool>(List,
"symmintermultivec"))
1464 IntermediateView = SYMBOLIC_MULTIVEC;
1466 if(Teuchos::getParameter<bool>(List,
"invalidinter"))
1467 IntermediateView = NULL;
1470 InView = SYMBOLIC_VEC;
1472 InView = SYMBOLIC_MULTIVEC;
1474 OutView = SYMBOLIC_VEC;
1476 OutView = SYMBOLIC_MULTIVEC;
1478 IntermediateView = SYMBOLIC_VEC;
1480 IntermediateView = SYMBOLIC_MULTIVEC;
1483 ReturnVal = oski_SetHintMatTransMatMult(
A_tunable_, OP_AT_A, Alpha, InView, Beta, OutView, IntermediateView, NumCalls);
1485 ReturnVal = oski_SetHintMatTransMatMult(
A_tunable_, OP_A_AT, Alpha, InView, Beta, OutView, IntermediateView, NumCalls);
1487 std::cerr <<
"Set hint mattransmat multiply error\n";
1503 oski_vecview_t InView = NULL;
1504 oski_vecview_t OutView = NULL;
1505 oski_vecview_t InView2 = NULL;
1506 oski_vecview_t OutView2 = NULL;
1512 if(Teuchos::getParameter<bool>(List,
"tune"))
1513 NumCalls = ALWAYS_TUNE;
1515 if(Teuchos::getParameter<bool>(List,
"tuneaggressive"))
1516 NumCalls = ALWAYS_TUNE_AGGRESSIVELY;
1518 if(Teuchos::getParameter<bool>(List,
"symminvec"))
1519 InView = SYMBOLIC_VEC;
1521 if(Teuchos::getParameter<bool>(List,
"symminmultivec"))
1522 InView = SYMBOLIC_MULTIVEC;
1524 if(Teuchos::getParameter<bool>(List,
"symmoutvec"))
1525 OutView = SYMBOLIC_VEC;
1527 if(Teuchos::getParameter<bool>(List,
"symmoutmultivec"))
1528 OutView = SYMBOLIC_MULTIVEC;
1530 if(Teuchos::getParameter<bool>(List,
"symminvec2"))
1531 InView2 = SYMBOLIC_VEC;
1533 if(Teuchos::getParameter<bool>(List,
"symminmultivec2"))
1534 InView2 = SYMBOLIC_MULTIVEC;
1536 if(Teuchos::getParameter<bool>(List,
"symmoutvec2"))
1537 OutView2 = SYMBOLIC_VEC;
1539 if(Teuchos::getParameter<bool>(List,
"symmoutmultivec2"))
1540 OutView2 = SYMBOLIC_MULTIVEC;
1543 InView = SYMBOLIC_VEC;
1545 InView = SYMBOLIC_MULTIVEC;
1547 OutView = SYMBOLIC_VEC;
1549 OutView = SYMBOLIC_MULTIVEC;
1551 InView2 = SYMBOLIC_VEC;
1553 InView2 = SYMBOLIC_MULTIVEC;
1555 OutView2 = SYMBOLIC_VEC;
1557 OutView2 = SYMBOLIC_MULTIVEC;
1560 ReturnVal = oski_SetHintMatMultAndMatTransMult(
A_tunable_, Alpha, InView, Beta, OutView, OP_TRANS, Omega, InView2, Zeta, OutView2, NumCalls);
1562 ReturnVal = oski_SetHintMatMultAndMatTransMult(
A_tunable_, Alpha, InView, Beta, OutView, OP_NORMAL, Omega, InView2, Zeta, OutView2, NumCalls);
1564 std::cerr <<
"Set hint multivector multiply and mattransmultiply error\n";
1578 oski_vecview_t InView = NULL;
1579 oski_vecview_t OutView = NULL;
1580 oski_vecview_t IntermediateView = NULL;
1583 if(&Intermediate != NULL)
1584 IntermediateView = Intermediate.
Oski_View();
1586 if(Teuchos::getParameter<bool>(List,
"tune"))
1587 NumCalls = ALWAYS_TUNE;
1589 if(Teuchos::getParameter<bool>(List,
"tuneaggressive"))
1590 NumCalls = ALWAYS_TUNE_AGGRESSIVELY;
1592 if(Teuchos::getParameter<bool>(List,
"symminvec"))
1593 InView = SYMBOLIC_VEC;
1595 if(Teuchos::getParameter<bool>(List,
"symminmultivec"))
1596 InView = SYMBOLIC_MULTIVEC;
1598 if(Teuchos::getParameter<bool>(List,
"symmoutvec"))
1599 OutView = SYMBOLIC_VEC;
1601 if(Teuchos::getParameter<bool>(List,
"symmoutmultivec"))
1602 OutView = SYMBOLIC_MULTIVEC;
1604 if(Teuchos::getParameter<bool>(List,
"symmintermultivec"))
1605 IntermediateView = SYMBOLIC_MULTIVEC;
1607 if(Teuchos::getParameter<bool>(List,
"invalidinter"))
1608 IntermediateView = NULL;
1611 InView = SYMBOLIC_VEC;
1613 InView = SYMBOLIC_MULTIVEC;
1615 OutView = SYMBOLIC_VEC;
1617 OutView = SYMBOLIC_MULTIVEC;
1619 IntermediateView = SYMBOLIC_VEC;
1621 IntermediateView = SYMBOLIC_MULTIVEC;
1624 ReturnVal = oski_SetHintMatPowMult(
A_tunable_, OP_TRANS, Power, Alpha, InView, Beta, OutView, IntermediateView, NumCalls);
1626 ReturnVal = oski_SetHintMatPowMult(
A_tunable_, OP_NORMAL, Power, Alpha, InView, Beta, OutView, IntermediateView, NumCalls);
1628 std::cerr <<
"Set hint matpow multiply error\n";
1649 Transformed = &Temp;
1651 return *Transformed;
1669 char* ReturnVal = NULL;
1670 ReturnVal = oski_GetMatTransforms(
A_tunable_);
1671 if(ReturnVal == NULL)
1672 std::cerr <<
"Error in GetMatrixTransforms\n";
1678 ReturnVal = oski_ApplyMatTransforms(
A_tunable_, Transforms);
1680 std::cerr <<
"Error in ApplyMatrixTransforms\n";
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int MatTransMatMultiply(bool ATA, const Epetra_Vector &x, Epetra_Vector &y, Epetra_Vector *t, double Alpha=1.0, double Beta=0.0) const
Performs two matrix vector multiplies of y = Alpha*this^TransA*this*x + Beta*y or y = Alpha*this*this...
const Epetra_BlockMap & RangeMap() const
Returns the RangeMap associated with this graph.
bool DistributedGlobal() const
Returns true if this multi-vector is distributed global, i.e., not local replicated.
bool DistributedGlobal() const
Returns true if map is defined across more than one processor.
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
int IsMatrixTransformed() const
Returns 1 if the matrix has been reordered by tuning, and 0 if it has not been.
Epetra_OskiPermutation: A class for storing the permutation performed on a Epetra_OskiMatrix.
Epetra_OskiMultiVector: A class for constructing and using dense Oski multi-vectors on a single proce...
const Epetra_OskiPermutation & ViewRowPermutation() const
Returns a read only row/left permutation of the Matrix.
int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
int SetHintMatTransMatMultiply(bool ATA, double Alpha, const Epetra_OskiMultiVector &InVec, double Beta, const Epetra_OskiMultiVector &OutVec, const Epetra_OskiMultiVector &Intermediate, int NumCalls, const Teuchos::ParameterList &List)
Workload hints for computing a two matrix-vector multiplies that are composed used by OskiTuneMat to ...
int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
Epetra_OskiVector: A class for constructing and using dense OSKI vectors on a single processor or a s...
char * GetMatrixTransforms() const
Returns a string holding the transformations performed on the matrix when it was tuned.
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
void UpdateExportVector(int NumVectors) const
double ** Pointers() const
Get pointer to individual vector pointers.
#define EPETRA_CHK_ERR(a)
void ReplacePermutation(const oski_perm_t &InPerm)
Stores a permutation in the data structure.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
void UpdateImportVector(int NumVectors) const
const Epetra_BlockMap & DomainMap() const
Returns the DomainMap associated with this graph.
oski_vecview_t Oski_View() const
Returns the Oski portion of the Multi-Vector.
int NumVectors() const
Returns the number of vectors in the multi-vector.
const Epetra_CrsMatrix * Epetra_View_
long long NumGlobalNonzeros64() const
int ReplaceDiagonalValues(const Epetra_OskiVector &Diagonal)
Replaces diagonal values of the matrix with those in the user-provided vector.
bool isParameter(const std::string &name) const
int NumMyCols() const
Returns the number of entries in the set of column-indices that appear on this processor.
Epetra_OskiMatrix: A class for constructing and using OSKI Matrices within Epetra. For information on known issues with OSKI see the detailed description.
Epetra_MultiVector * ExportVector_
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
int SetHintMultiply(bool TransA, double Alpha, const Epetra_OskiMultiVector &InVec, double Beta, const Epetra_OskiMultiVector &OutVec, int NumCalls, const Teuchos::ParameterList &List)
Workload hints for computing a matrix-vector multiply used by OskiTuneMat to optimize the data struct...
int MatPowMultiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y, Epetra_MultiVector &T, int Power=2, double Alpha=1.0, double Beta=0.0) const
Performs a matrix vector multiply of y = Alpha*(this^TransA)^Power*x + Beta*y. This is not implemente...
const Epetra_Import * Importer() const
Returns the Epetra_Import object that contains the import operations for distributed operations...
int TuneMatrix()
Tunes the matrix multiply if its deemed profitable.
int MultiplyAndMatTransMultiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y, const Epetra_Vector &w, Epetra_Vector &z, double Alpha=1.0, double Beta=0.0, double Omega=1.0, double Zeta=0.0) const
Performs the two matrix vector multiplies of y = Alpha*this*x + Beta*y and z = Omega*this^TransA*w + ...
Epetra_OskiMatrix(const Epetra_OskiMatrix &Source)
Copy constructor.
int SetHintMultiplyAndMatTransMultiply(bool TransA, double Alpha, const Epetra_OskiMultiVector &InVec, double Beta, const Epetra_OskiMultiVector &OutVec, double Omega, const Epetra_OskiMultiVector &InVec2, double Zeta, const Epetra_OskiMultiVector &OutVec2, int NumCalls, const Teuchos::ParameterList &List)
Workload hints for computing two matrix-vector multiplies used by OskiTuneMat to optimize the data st...
int Solve(bool Upper, bool TransA, bool UnitDiagonal, const Epetra_Vector &x, Epetra_Vector &y) const
Performs a triangular solve of y = (this^TransA)^-1*x where this is a triangular matrix.
int SetHint(const Teuchos::ParameterList &List)
Stores the hints in List in the matrix structure.
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
virtual ~Epetra_OskiMatrix()
Destructor.
int SetHintSolve(bool TransA, double Alpha, const Epetra_OskiMultiVector &Vector, int NumCalls, const Teuchos::ParameterList &List)
Workload hints for computing a triangular solve used by OskiTuneMat to optimize the data structure st...
const Epetra_Export * Exporter() const
Returns the Epetra_Export object that contains the export operations for distributed operations...
int SumIntoMyValues(int MyRow, int NumEntries, double *Values, int *Indices)
Add this list of entries to existing values for a given local row of the matrix. WARNING: this could ...
int Stride() const
Returns the stride between vectors in the multi-vector (only meaningful if ConstantStride() is true)...
const Epetra_OskiPermutation & ViewColumnPermutation() const
Returns a read only column/right permutation of the Matrix.
bool ConstantStride() const
Returns true if this multi-vector has constant stride between vectors.
int SetHintPowMultiply(bool TransA, double Alpha, const Epetra_OskiMultiVector &InVec, double Beta, const Epetra_OskiMultiVector &OutVec, const Epetra_OskiMultiVector &Intermediate, int Power, int NumCalls, const Teuchos::ParameterList &List)
Workload hints for computing a matrix-vector multiply performed Power times used by OskiTuneMat to op...
double * Values() const
Get pointer to MultiVector values.
const Epetra_Vector * Epetra_View() const
Returns a view to the Epetra Object.
virtual int NumProc() const =0
Returns total number of processes.
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Performs a matrix vector multiply of y = this^TransA*x.
int ReplaceMyValues(int MyRow, int NumEntries, double *Values, int *Indices)
Replace current values with this list of entries for a given local row of the matrix. Warning this could be expensive.
const Epetra_CrsGraph & Graph() const
Returns a reference to the Epetra_CrsGraph object associated with this matrix.
int ApplyMatrixTransforms(const char *Transforms)
Replaces the current data structure of the matrix with the one specified in Transforms.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
Epetra_MultiVector * ImportVector_
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
void UpdateFlops(int Flops_in) const
Increment Flop count for this object.
const Epetra_OskiMatrix & ViewTransformedMat() const
Returns the transformed version of InMat if InMat has been transformed. If InMat has not been transfo...
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.