Skip to content

Commit 9665ba6

Browse files
Merge pull request #8 from jwshi21/master
expand format selection options
2 parents ec37fdc + 3242bad commit 9665ba6

13 files changed

+677
-100
lines changed

codegen.html

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@
88
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
99
<link rel="stylesheet" href="stylesheets/style.css">
1010
<link rel="stylesheet" href="stylesheets/getmdl-select.min.css">
11+
<link rel="stylesheet" href="stylesheets/bootstrap-dropdown.css">
12+
<link rel="stylesheet" href="stylesheets/dropdown.css">
1113
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
1214
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
1315
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
1416
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/styles/default.min.css">
1517
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/highlight.min.js"></script>
16-
<!--<script src="javascripts/demo.min.js"></script>-->
18+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js">
19+
</script>
1720
<script src="javascripts/getmdl-select.min.js"></script>
1821
<script src="javascripts/jquery.ui.touch-punch.min.js"></script>
1922
<script src="javascripts/FileSaver.min.js"></script>
2023
<script src="javascripts/parser.js"></script>
2124
<script src="javascripts/demo.js"></script>
25+
<script type="text/x-mathjax-config">
26+
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
27+
</script>
28+
<script type="text/javascript"
29+
src="http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
30+
</script>
2231
</head>
2332
<body>
2433
<!-- Always shows a header, even in smaller screens. -->
@@ -76,14 +85,43 @@ <h6 style="margin-bottom: 0px; margin-top: 18px">Input a tensor algebra expressi
7685
<table class="mdl-data-table mdl-js-data-table" style="width: 100%; margin-bottom: 8px">
7786
<thead>
7887
<tr>
79-
<th class="mdl-data-table__cell--non-numeric" width="100"><div align="center" style="position:relative; top:-1px"><big>Tensor</big></div></th>
80-
<th class="mdl-data-table__cell--non-numeric" style="padding-left: 7px">
88+
<th class="mdl-data-table__cell--non-numeric" width="100">
89+
<div align="center" style="position:relative"><big>Tensor</big></div></th>
90+
<th class="mdl-data-table__cell--non-numeric" width="175px"
91+
style="padding-left: 0px">
8192
<div style="display:inline"><big>Format&nbsp;</big></div>
82-
<div style="display:inline">(reorder dimensions by dragging the drop-down menus)</div>
93+
</th>
94+
<th class="mdl-data-table__cell--non-numeric" style="padding-left: 7px">
95+
<div style="display:inline"><big>Level Formats&nbsp;</big></div>
96+
<div style="display:inline; margin-right:10px">(reorder dimensions by dragging the drop-down menus)</div>
97+
<div style="display:inline; vertical-align: middle">
98+
<button id="btnHelp" class="help-btn mdl-button mdl-js-button mdl-button--icon">
99+
<i class="material-icons" style="font-size:20px">help_outline</i>
100+
</button>
101+
<div id="helpMenu" class="help-menu mdl-menu mdl-js-menu mdl-js-ripple-effect" for="btnHelp">
102+
<p>
103+
<strong>Dense</strong> levels store the size of the dimension $(N)$ and encode the coordinates in the interval $[0, N)$.
104+
<img src="images/dense-arrays.jpg" class="centered-img" style="height: 25px; padding-top:10px">
105+
</p>
106+
<p>
107+
<strong>Sparse</strong> levels store coordinates in a segment of the $\texttt{crd}$ array, with segment bounds stored in the $\texttt{pos}$ array.
108+
<img src="images/compressed-arrays.jpg" class="centered-img" style="height: 50px; padding-top:10px">
109+
</p>
110+
<p>
111+
<strong>Singleton</strong> levels store individual coordinates (with no siblings) in the $\texttt{crd}$ array.
112+
<img src="images/singleton-arrays.jpg" class="centered-img" style="height: 25px; padding-top:10px">
113+
</p>
114+
<p>
115+
A level is <strong>unique (U)</strong> if no collection of coordinates that share the same ancestors contains duplicates, and it is <strong>not unique (&not;U)</strong> otherwise.
116+
</p>
117+
<p style="margin-bottom: 0"> More info on taco's tensor formats can be found <a href="http://tensor-compiler.org/chou-oopsla18-taco-formats.pdf">here</a>.</p>
118+
</div>
119+
</div>
83120
</th>
84121
</tr>
85122
</thead>
86-
<tbody id="listTensors"></tbody>
123+
<tbody id="listTensors">
124+
</tbody>
87125
</table>
88126
</div>
89127
<div class="mdl-layout-spacer"></div>
@@ -148,6 +186,5 @@ <h6 style="margin-bottom: 0px; margin-top: 18px">Input a tensor algebra expressi
148186
</div>
149187
</main>
150188
</div>
151-
152189
</body>
153190
</html>

examples/spmv_assembly.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
// Generated by the Tensor Algebra Compiler (tensor-compiler.org)
2-
allocate y_vals[y1_size]
2+
// taco "y(i)=A(i,j)*x(j)" -f=y:d:0 -f=A:ds:0,1 -f=x:d:0 -write-source=taco_kernel.c -write-compute=taco_compute.c -write-assembly=taco_assembly.c
3+
4+
int assemble(taco_tensor_t *y, taco_tensor_t *A, taco_tensor_t *x) {
5+
int y1_dimension = (int)(y->dimensions[0]);
6+
double* restrict y_vals = (double*)(y->vals);
7+
8+
y_vals = (double*)malloc(sizeof(double) * y1_dimension);
9+
10+
y->vals = (uint8_t*)y_vals;
11+
return 0;
12+
}

examples/spmv_compute.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
// Generated by the Tensor Algebra Compiler (tensor-compiler.org)
2-
for (int32_t iA = 0; iA < A1_size; iA++) {
3-
double tj = 0;
4-
for (int32_t pA2 = A2_pos[iA]; pA2 < A2_pos[iA + 1]; pA2++) {
5-
int32_t jA = A2_idx[pA2];
6-
tj += A_vals[pA2] * x_vals[jA];
2+
// taco "y(i)=A(i,j)*x(j)" -f=y:d:0 -f=A:ds:0,1 -f=x:d:0 -write-source=taco_kernel.c -write-compute=taco_compute.c -write-assembly=taco_assembly.c
3+
4+
int compute(taco_tensor_t *y, taco_tensor_t *A, taco_tensor_t *x) {
5+
int y1_dimension = (int)(y->dimensions[0]);
6+
double* restrict y_vals = (double*)(y->vals);
7+
int A1_dimension = (int)(A->dimensions[0]);
8+
int* restrict A2_pos = (int*)(A->indices[1][0]);
9+
int* restrict A2_crd = (int*)(A->indices[1][1]);
10+
double* restrict A_vals = (double*)(A->vals);
11+
int x1_dimension = (int)(x->dimensions[0]);
12+
double* restrict x_vals = (double*)(x->vals);
13+
14+
#pragma omp parallel for schedule(static)
15+
for (int32_t py = 0; py < y1_dimension; py++) {
16+
y_vals[py] = 0.0;
717
}
8-
y_vals[iA] = tj;
18+
19+
#pragma omp parallel for schedule(runtime)
20+
for (int32_t i = 0; i < A1_dimension; i++) {
21+
for (int32_t jA = A2_pos[i]; jA < A2_pos[(i + 1)]; jA++) {
22+
int32_t j = A2_crd[jA];
23+
y_vals[i] = y_vals[i] + A_vals[jA] * x_vals[j];
24+
}
25+
}
26+
return 0;
927
}

0 commit comments

Comments
 (0)