@@ -133,17 +133,24 @@ function demo() {
133
133
} ,
134
134
resetSchedule : function ( ) {
135
135
model . schedule = [ ] ;
136
+
137
+ model . cancelReq ( ) ;
138
+ model . setOutput ( "" , "" , "" , "" ) ;
136
139
model . updateScheduleView ( ) ;
137
140
} ,
138
141
addScheduleRow : function ( ) {
139
142
model . schedule . push ( { command : "" , parameters : [ ] } ) ;
143
+
140
144
model . updateScheduleView ( ) ;
141
145
} ,
142
146
deleteScheduleRow : function ( row ) {
147
+ var isNop = ( model . schedule [ row ] . command === "" ) ;
143
148
model . schedule . splice ( row , 1 ) ;
144
149
145
- model . cancelReq ( ) ;
146
- model . setOutput ( "" , "" , "" , "" ) ;
150
+ if ( ! isNop ) {
151
+ model . cancelReq ( ) ;
152
+ model . setOutput ( "" , "" , "" , "" ) ;
153
+ }
147
154
model . updateScheduleView ( ) ;
148
155
} ,
149
156
swapScheduleRows : function ( row1 , row2 ) {
@@ -161,12 +168,23 @@ function demo() {
161
168
var parameterInfo = scheduleCommands [ command ] [ i ] ;
162
169
var defaultValue = "" ;
163
170
164
- if ( parameterInfo [ 0 ] === "default" || parameterInfo [ 0 ] === "predefined dropdown" ) {
171
+ if ( parameterInfo [ 0 ] === "default" ||
172
+ parameterInfo [ 0 ] === "predefined dropdown" ) {
165
173
defaultValue = parameterInfo [ 1 ] ;
174
+ } else if ( parameterInfo [ 0 ] === "result dropdown" ) {
175
+ for ( var access in model . input . tensorOrders ) {
176
+ if ( model . input . tensorOrders [ access ] > 0
177
+ && model . input . expression . indexOf ( access ) <= model . input . expression . indexOf ( "=" ) ) {
178
+ defaultValue += access ;
179
+ break ;
180
+ }
181
+ }
166
182
}
167
183
model . schedule [ row ] . parameters . push ( defaultValue ) ;
168
184
}
169
185
186
+ model . cancelReq ( ) ;
187
+ model . setOutput ( "" , "" , "" , "" ) ;
170
188
model . updateScheduleView ( ) ;
171
189
} ,
172
190
addScheduleParameter : function ( row , index , value ) {
@@ -616,13 +634,13 @@ function demo() {
616
634
2 : [ "default" , "" ] ,
617
635
3 : [ "text" ]
618
636
} ,
619
- // divide: {
620
- // parameters: ["Divided IndexVar", "Outer IndexVar", "Inner IndexVar", "Divide Factor"],
621
- // 0: ["index dropdown", [1, "0"], [2, "1"]],
622
- // 1: ["default", ""],
623
- // 2: ["default", ""],
624
- // 3: ["text"]
625
- // },
637
+ divide : {
638
+ parameters : [ "Divided IndexVar" , "Outer IndexVar" , "Inner IndexVar" , "Divide Factor" ] ,
639
+ 0 : [ "index dropdown" , [ 1 , "0" ] , [ 2 , "1" ] ] ,
640
+ 1 : [ "default" , "" ] ,
641
+ 2 : [ "default" , "" ] ,
642
+ 3 : [ "text" ]
643
+ } ,
626
644
precompute : {
627
645
parameters : [ "Precomputed Expr" , "Original IndexVar" , "Workspace IndexVar" ] ,
628
646
0 : [ "long text" ] ,
@@ -653,6 +671,12 @@ function demo() {
653
671
"GPU Thread" , "GPU Block" , "GPU Warp" ] ,
654
672
2 : [ "predefined dropdown" , "No Races" ,
655
673
"Ignore Races" , "No Races" , "Atomics" , "Temporary" , "Parallel Reduction" ]
674
+ } ,
675
+ assemble : {
676
+ parameters : [ "Result Tensor" , "Assembly Strategy" ] ,
677
+ 0 : [ "result dropdown" ] ,
678
+ 1 : [ "predefined dropdown" , "Insert" ,
679
+ "Insert" , "Append" ]
656
680
}
657
681
} ;
658
682
@@ -734,6 +758,26 @@ function demo() {
734
758
return parameter ;
735
759
}
736
760
761
+ // a dropdown where user can choose from result tensors
762
+ function resultDropdown ( parameterName , inputId , input ) {
763
+ var parameter = "" ;
764
+ var defaultParam = "" ;
765
+ for ( var access in model . input . tensorOrders ) {
766
+ if ( model . input . tensorOrders [ access ] > 0
767
+ && model . input . expression . indexOf ( access ) <= model . input . expression . indexOf ( "=" ) ) {
768
+ parameter += "<li><a>" ;
769
+ parameter += access ;
770
+ parameter += "</a></li>" ;
771
+ if ( defaultParam === "" ) {
772
+ defaultParam += access ;
773
+ }
774
+ }
775
+ }
776
+ parameter = dropdown ( parameterName , inputId , input , defaultParam )
777
+ + parameter + "</ul></div></li>" ;
778
+ return parameter ;
779
+ }
780
+
737
781
// a dropdown where user can choose from a set of predefined options
738
782
function predefinedDropdown ( parameterName , inputId , input , options ) {
739
783
var parameter = dropdown ( parameterName , inputId , input , options [ 0 ] , false , "160px" ) ;
@@ -763,6 +807,9 @@ function demo() {
763
807
case "access dropdown" :
764
808
parameters += accessDropdown ( parameterName , inputId , input ) ;
765
809
break ;
810
+ case "result dropdown" :
811
+ parameters += resultDropdown ( parameterName , inputId , input ) ;
812
+ break ;
766
813
case "predefined dropdown" :
767
814
parameters += predefinedDropdown ( parameterName , inputId , input , parameterInfo . slice ( 1 ) ) ;
768
815
break ;
@@ -858,7 +905,7 @@ function demo() {
858
905
var row = rowId . substring ( ( "schedule" ) . length ) ;
859
906
860
907
$ ( "#" + rowId ) . val ( command ) ;
861
- model . addScheduleCommand ( row , command , ) ;
908
+ model . addScheduleCommand ( row , command ) ;
862
909
} ) ;
863
910
864
911
$ ( ".schedule-input input" ) . on ( "change" , function ( e ) {
@@ -989,7 +1036,7 @@ function demo() {
989
1036
var getKernel = function ( ) {
990
1037
model . setOutput ( "" , "" , "" , "" ) ;
991
1038
992
- var command = model . input . expression . replace ( / / g, "" ) ;
1039
+ var command = "\"" + model . input . expression . replace ( / / g, "" ) + "\"" ;
993
1040
994
1041
var formats = "" ;
995
1042
for ( t in model . input . tensorOrders ) {
@@ -1022,7 +1069,7 @@ function demo() {
1022
1069
var scheduleCommand = model . schedule [ i ] [ "command" ] ;
1023
1070
if ( ! scheduleCommand ) { continue ; }
1024
1071
1025
- command += " -s=" + scheduleCommand + "(" ;
1072
+ command += " -s=\" " + scheduleCommand + "(" ;
1026
1073
schedule += ( ( schedule === "" ) ? "" : ";" ) + scheduleCommand + ":" ;
1027
1074
1028
1075
for ( var param of model . schedule [ i ] [ "parameters" ] ) {
@@ -1038,7 +1085,7 @@ function demo() {
1038
1085
}
1039
1086
1040
1087
command = command . substring ( 0 , command . length - 1 ) ;
1041
- command += ")" ;
1088
+ command += ")\" " ;
1042
1089
schedule = schedule . substring ( 0 , schedule . length - 1 ) ;
1043
1090
}
1044
1091
@@ -1086,7 +1133,15 @@ function demo() {
1086
1133
x : { name : "Dense array" , levels : { formats : [ "d" ] , ordering : [ 0 ] } }
1087
1134
}
1088
1135
} ,
1089
- add : { name : "Sparse matrix addition" ,
1136
+ spgemm : { name : "SpGEMM" ,
1137
+ code : "A(i,j) = B(i,k) * C(k,j)" ,
1138
+ formats : {
1139
+ A : { name : "CSR" , levels : { formats : [ "d" , "s" ] , ordering : [ 0 , 1 ] } } ,
1140
+ B : { name : "CSR" , levels : { formats : [ "d" , "s" ] , ordering : [ 0 , 1 ] } } ,
1141
+ C : { name : "CSR" , levels : { formats : [ "d" , "s" ] , ordering : [ 0 , 1 ] } } ,
1142
+ }
1143
+ } ,
1144
+ spadd : { name : "Sparse matrix addition" ,
1090
1145
code : "A(i,j) = B(i,j) + C(i,j)" ,
1091
1146
formats : {
1092
1147
A : { name : "CSR" , levels : { formats : [ "d" , "s" ] , ordering : [ 0 , 1 ] } } ,
@@ -1186,9 +1241,10 @@ function demo() {
1186
1241
}
1187
1242
model . setInput ( code ) ;
1188
1243
1189
- var schedule = default_CPU_schedules [ e ] ;
1190
- model . setExampleSchedule ( ( schedule . length > 0 ) ? e : "" ) ;
1191
- model . setSchedule ( schedule ) ;
1244
+ var cpuSchedule = default_CPU_schedules [ e ] ;
1245
+ var gpuSchedule = default_GPU_schedules [ e ] ;
1246
+ model . setExampleSchedule ( ( gpuSchedule . length > 0 ) ? e : "" ) ;
1247
+ model . setSchedule ( cpuSchedule ) ;
1192
1248
} ;
1193
1249
$ ( "#example_" + e ) . click ( setExample ) ;
1194
1250
0 commit comments