Skip to content

Commit 28f05ef

Browse files
GeneratorTileMultiplication_F64
- Matches TileMultiplication_F64 again
1 parent a91eea4 commit 28f05ef

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

main/ejml-ddense/generate/org/ejml/dense/block/GeneratorTileMultiplication.java renamed to main/ejml-ddense/generate/org/ejml/dense/block/GeneratorTileMultiplication_F64.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import java.io.FileNotFoundException;
2424
import java.io.PrintStream;
2525

26-
public class GeneratorTileMultiplication {
26+
public class GeneratorTileMultiplication_F64 {
2727

2828
String className;
2929
PrintStream stream;
3030

31-
public GeneratorTileMultiplication( String className ) throws FileNotFoundException {
31+
public GeneratorTileMultiplication_F64( String className ) throws FileNotFoundException {
3232
this.className = className;
3333
stream = new PrintStream(className + ".java");
3434
}
@@ -81,8 +81,8 @@ private void print_mult( boolean hasAlpha, Operation opType ) {
8181
"// for( int i = 0; i < heightA; i++ ) {\n" +
8282
"// for( int k = 0; k < widthA; k++ ) {\n" +
8383
"// for( int j = 0; j < widthC; j++ ) {\n" +
84-
"// dataC[ i*widthC + j + indexC ] " + opString(opType) + " " + (hasAlpha ? "alpha * " : "") +
85-
"dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];\n" +
84+
"// dataC[ i*widthC + j + offsetC ] " + opString(opType) + " " + (hasAlpha ? "alpha * " : "") +
85+
"dataA[i*widthA + k + offsetA] * dataB[k*widthC + j + offsetB];\n" +
8686
"// }\n" +
8787
"// }\n" +
8888
"// }\n");
@@ -112,11 +112,11 @@ private void print_mult( boolean hasAlpha, Operation opType ) {
112112
stream.print(
113113
" int k = 0;\n" +
114114
" for (; k < kEnd4; k += 4) {\n" +
115-
" double a0 = " + alphaPrefix + "dataA[aRow + k ];\n" +
115+
" double a0 = " + alphaPrefix + "dataA[aRow + k];\n" +
116116
" double a1 = " + alphaPrefix + "dataA[aRow + k + 1];\n" +
117117
" double a2 = " + alphaPrefix + "dataA[aRow + k + 2];\n" +
118118
" double a3 = " + alphaPrefix + "dataA[aRow + k + 3];\n" +
119-
" final int b0 = offsetB + (k )*strideB;\n" +
119+
" final int b0 = offsetB + (k)*strideB;\n" +
120120
" final int b1 = offsetB + (k + 1)*strideB;\n" +
121121
" final int b2 = offsetB + (k + 2)*strideB;\n" +
122122
" final int b3 = offsetB + (k + 3)*strideB;\n" +
@@ -151,9 +151,9 @@ private void print_multTransA( boolean hasAlpha, Operation opType ) {
151151
stream.print(
152152
"// for( int i = 0; i < widthA; i++ ) {\n" +
153153
"// for( int k = 0; k < heightA; k++ ) {\n" +
154-
"// double valA = " + (hasAlpha ? "alpha*" : "") + "dataA[k*widthA + i + indexA];\n" +
154+
"// double valA = " + (hasAlpha ? "alpha*" : "") + "dataA[k*widthA + i + offsetA];\n" +
155155
"// for( int j = 0; j < widthC; j++ ) {\n" +
156-
"// dataC[ i*widthC + j + indexC ] " + opString(opType) + " valA * dataB[k*widthC + j + indexB];\n" +
156+
"// dataC[ i*widthC + j + offsetC ] " + opString(opType) + " valA * dataB[k*widthC + j + offsetB];\n" +
157157
"// }\n" +
158158
"// }\n" +
159159
"// }\n");
@@ -182,7 +182,7 @@ private void print_multTransA( boolean hasAlpha, Operation opType ) {
182182
" bIdx += strideB;\n" +
183183
" }\n" +
184184
" int cIdx = offsetC + i*strideC + j;\n" +
185-
" dataC[cIdx ] " + op + " s0;\n" +
185+
" dataC[cIdx] " + op + " s0;\n" +
186186
" dataC[cIdx + 1] " + op + " s1;\n" +
187187
" dataC[cIdx + 2] " + op + " s2;\n" +
188188
" dataC[cIdx + 3] " + op + " s3;\n" +
@@ -217,9 +217,9 @@ private void print_multTransB( boolean hasAlpha, Operation opType ) {
217217
"// for (int j = 0; j < widthC; j++) {\n" +
218218
"// double val = 0;\n" +
219219
"// for (int k = 0; k < widthA; k++) {\n" +
220-
"// val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];\n" +
220+
"// val += dataA[i*widthA + k + offsetA]*dataB[j*widthA + k + offsetB];\n" +
221221
"// }\n" +
222-
"// dataC[i*widthC + j + indexC] " + opString(opType) + " " + (hasAlpha ? "alpha*" : "") + "val;\n" +
222+
"// dataC[i*widthC + j + offsetC] " + opString(opType) + " " + (hasAlpha ? "alpha*" : "") + "val;\n" +
223223
"// }\n" +
224224
"// }\n");
225225
stream.println();
@@ -238,7 +238,7 @@ private void print_multTransB( boolean hasAlpha, Operation opType ) {
238238
" for (; j < jEnd4; j += 4) {\n" +
239239
" double s0 = 0.0, s1 = 0.0, s2 = 0.0, s3 = 0.0;\n" +
240240
" int a = aRow;\n" +
241-
" int b0 = offsetB + (j )*strideB;\n" +
241+
" int b0 = offsetB + (j)*strideB;\n" +
242242
" int b1 = offsetB + (j + 1)*strideB;\n" +
243243
" int b2 = offsetB + (j + 2)*strideB;\n" +
244244
" int b3 = offsetB + (j + 3)*strideB;\n" +
@@ -250,7 +250,7 @@ private void print_multTransB( boolean hasAlpha, Operation opType ) {
250250
" s3 += valA*dataB[b3++];\n" +
251251
" }\n" +
252252
" int cIdx = offsetC + i*strideC + j;\n" +
253-
" dataC[cIdx ] " + op + " " + alphaStore + "s0;\n" +
253+
" dataC[cIdx] " + op + " " + alphaStore + "s0;\n" +
254254
" dataC[cIdx + 1] " + op + " " + alphaStore + "s1;\n" +
255255
" dataC[cIdx + 2] " + op + " " + alphaStore + "s2;\n" +
256256
" dataC[cIdx + 3] " + op + " " + alphaStore + "s3;\n" +
@@ -296,12 +296,15 @@ private String funcName( Operation opType, boolean transA, boolean transB ) {
296296

297297
private void createHeader( boolean hasAlpha, Operation opType, boolean transA, boolean transB ) {
298298
printDoc(hasAlpha, opType, transA, transB);
299+
String name = funcName(opType, transA, transB);
300+
// continuation lines align under the first parameter, i.e. just past " public static void <name>( "
301+
String pad = " ".repeat(25 + name.length());
299302
String alphaParam = hasAlpha ? " double alpha," : "";
300303
stream.print(
301-
" public static void " + funcName(opType, transA, transB) + "(" + alphaParam + " final double[] dataA, final double[] dataB, final double[] dataC,\n" +
302-
" final int heightA, final int widthA, final int widthC,\n" +
303-
" int strideA, int strideB, int strideC,\n" +
304-
" int offsetA, int offsetB, int offsetC) {\n");
304+
" public static void " + name + "(" + alphaParam + " final double[] dataA, final double[] dataB, final double[] dataC,\n" +
305+
pad + "final int heightA, final int widthA, final int widthC,\n" +
306+
pad + "int strideA, int strideB, int strideC,\n" +
307+
pad + "int offsetA, int offsetB, int offsetC ) {\n");
305308
}
306309

307310
private void printDelegate( boolean hasAlpha, Operation opType, boolean transA, boolean transB ) {
@@ -310,10 +313,12 @@ private void printDelegate( boolean hasAlpha, Operation opType, boolean transA,
310313
String alphaParam = hasAlpha ? " double alpha," : "";
311314
String alphaArg = hasAlpha ? "alpha, " : "";
312315
String strideB = transB ? "widthA" : "widthC";
316+
// continuation lines align under the first parameter, i.e. just past " public static void <name>( "
317+
String pad = " ".repeat(25 + name.length());
313318
stream.print(
314319
" public static void " + name + "(" + alphaParam + " final double[] dataA, final double[] dataB, final double[] dataC,\n" +
315-
" final int heightA, final int widthA, final int widthC,\n" +
316-
" int offsetA, int offsetB, int offsetC) {\n" +
320+
pad + "final int heightA, final int widthA, final int widthC,\n" +
321+
pad + "int offsetA, int offsetB, int offsetC ) {\n" +
317322
" " + name + "(" + alphaArg + "dataA, dataB, dataC, heightA, widthA, widthC, widthA, " + strideB + ", widthC, offsetA, offsetB, offsetC);\n" +
318323
" }\n");
319324
}
@@ -346,7 +351,7 @@ private enum Operation {
346351
}
347352

348353
public static void main( String[] args ) throws FileNotFoundException {
349-
var app = new GeneratorTileMultiplication("InnerMultiplication_DDRB");
354+
var app = new GeneratorTileMultiplication_F64("TileMultiplication_F64");
350355
app.createClass();
351356
System.out.println("Done generating class");
352357
}

main/ejml-ddense/src/org/ejml/dense/block/TileMultiplication_F64.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
/// Matrix multiplication for the inner row major blocks, typically inside [DMatrixRBlock].
2424
///
25-
/// Generated by GeneratorTileMultiplication. Do not modify directly.
26-
@Generated("org.ejml.dense.block.GeneratorTileMultiplication")
25+
/// Generated by GeneratorTileMultiplication_F64. Do not modify directly.
26+
@Generated("org.ejml.dense.block.GeneratorTileMultiplication_F64")
2727
public class TileMultiplication_F64 {
2828

2929
/// C = C + A \* B

0 commit comments

Comments
 (0)