Mercurial > repos > rhope
comparison nworker.rhope @ 110:336da6ce8174
Merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 06 Oct 2010 23:48:32 +0000 |
parents | 43cc42df26cc |
children |
comparison
equal
deleted
inserted
replaced
109:b7df624895b2 | 110:336da6ce8174 |
---|---|
490 Add Input@NWorker[worker,name,number:out,node index] | 490 Add Input@NWorker[worker,name,number:out,node index] |
491 { | 491 { |
492 out,node index <- [worker]Add Typed Input[name,number,Type Instance["Any Type"]] | 492 out,node index <- [worker]Add Typed Input[name,number,Type Instance["Any Type"]] |
493 } | 493 } |
494 | 494 |
495 Add Anon Input@NWorker[worker,number:out] | |
496 { | |
497 If[[number]>[Length[[worker]Inputs >>]]] | |
498 { | |
499 prepped <- [worker]Add Anon Input[[number]-[1]] | |
500 }{ | |
501 prepped <- Val[worker] | |
502 } | |
503 out <- out <- [[prepped]Inputs <<[[[prepped]Inputs >>]Set[number,[" unnamed"]Append[number]]] | |
504 ]Input Types <<[[[prepped]Input Types >>]Set[number,Type Instance["Any Type"]]] | |
505 } | |
506 | |
495 Add Typed Input@NWorker[worker,name,number,type:out,node index] | 507 Add Typed Input@NWorker[worker,name,number,type:out,node index] |
496 { | 508 { |
497 ,node index <- [worker]Add Node["input",number,0,1] | 509 If[[number]>[Length[[worker]Inputs >>]]] |
510 { | |
511 prepped <- [worker]Add Anon Input[[number]-[1]] | |
512 }{ | |
513 prepped <- Val[worker] | |
514 } | |
515 ,node index <- [prepped]Add Node["input",number,0,1] | |
498 { | 516 { |
499 out <- [[~]Inputs <<[[[~]Inputs >>]Set[number,name]] | 517 out <- [[~]Inputs <<[[[~]Inputs >>]Set[number,name]] |
500 ]Input Types <<[[[~]Input Types >>]Set[number,type]] | 518 ]Input Types <<[[[~]Input Types >>]Set[number,type]] |
501 } | 519 } |
502 } | 520 } |
871 constname <- Const Name[[node]Data >>, node index, [worker]Name >>] | 889 constname <- Const Name[[node]Data >>, node index, [worker]Name >>] |
872 withconst <- [func]Register Constant[constname, [node]Data >>] | 890 withconst <- [func]Register Constant[constname, [node]Data >>] |
873 [conditions]For Backend | 891 [conditions]For Backend |
874 { | 892 { |
875 stream <- [[withconst]Instruction Stream | 893 stream <- [[withconst]Instruction Stream |
876 ]Move[Constant[constname], [[["__result_"]Append[node index]]Append["_"]]Append[0]] | 894 ]Move[Strip Addref[Constant[constname]], [[["__result_"]Append[node index]]Append["_"]]Append[0]] |
877 nfunc <- [withconst]Do If[~, stream] | 895 nfunc <- [withconst]Do If[~, stream] |
878 }{ | 896 }{ |
879 nfunc <- Val[withconst] | 897 nfunc <- Val[withconst] |
880 } | 898 } |
881 }{ | 899 }{ |
941 } | 959 } |
942 } | 960 } |
943 | 961 |
944 Release Var@NWorker[worker,func,name:out] | 962 Release Var@NWorker[worker,func,name:out] |
945 { | 963 { |
946 //_result_index_ionum | 964 //__result_index_ionum |
947 Print[["Release Var@NWorker: "]Append[name]] | |
948 parts <- [name]Split["_"] | 965 parts <- [name]Split["_"] |
949 index <- <String@Whole Number[ [parts]Index[3] ] | 966 index <- <String@Whole Number[ [parts]Index[3] ] |
950 io num <- <String@Whole Number[ [parts]Index[4] ] | 967 io num <- <String@Whole Number[ [parts]Index[4] ] |
951 node <- [[worker]Nodes >>]Index[index] | 968 node <- [[worker]Nodes >>]Index[index] |
952 dests <- [[node]Wires From >>]Index[io num] {} | 969 dests <- [[node]Wires From >>]Index[io num] {} |
953 { | 970 { |
954 Print["oops"] | 971 Print["oops"] |
955 { Pretty Print[node, ""] | 972 { Pretty Print[node, ""] |
956 { Pretty Print[parts, ""]}} } | 973 { Pretty Print[parts, ""]}} } |
957 If[[[dests]Length] = [1]] | 974 ,normal <- If[[[dests]Length] = [1]] |
958 { | 975 { |
959 Print["Single dest, maybe release"] | 976 dest ionum <- [[dests]Index[0]]IO Num >> |
960 { Print[["Dest index: "]Append[dest index]] } | 977 If[[[[dests]Index[0]]IO Num >>]=[-1]] |
961 dest index <- [[dests]Index[0]]Index >> | 978 { |
962 dest node <- [[worker]Nodes >>]Index[dest index] | 979 normal <- Yes |
963 { Print["got dest node"] } | 980 }{ |
981 dest index <- [[dests]Index[0]]Index >> | |
982 dest node <- [[worker]Nodes >>]Index[dest index] | |
964 | 983 |
965 [[dest node]Conditions >>]For Backend | 984 [[dest node]Conditions >>]For Backend |
966 { | 985 { |
967 Print["dest has conditions"] | 986 out <- [func]Do If[AndCond[NotCond[~], name], [[func]Instruction Stream]Release[name]] |
968 out <- [func]Do If[AndCond[NotCond[~], name], [[func]Instruction Stream]Release[name]] | 987 }{ |
969 { Print["got output"] } | 988 out <- func |
970 }{ | 989 } |
971 Print["No conditions on dest, no release needed"] | 990 } |
972 out <- func | 991 } |
973 } | 992 |
974 }{ | 993 Val[normal] |
975 Print["Multiple (or zero) dests, definitely release"] | 994 { |
976 do if <- If[[[node]Outputs >>] > [1]] {} | 995 do if <- If[[[node]Outputs >>] > [1]] {} |
977 { | 996 { |
978 do if <- [[node]Conditions >>]Empty? {} | 997 do if <- [[node]Conditions >>]Empty? {} |
979 { | 998 { |
980 out <- [func]Release[name] | 999 out <- [func]Release[name] |
1074 ]Get Raw Pointer[name, raw] | 1093 ]Get Raw Pointer[name, raw] |
1075 } | 1094 } |
1076 }{ | 1095 }{ |
1077 out <- Val[copied] | 1096 out <- Val[copied] |
1078 } | 1097 } |
1098 } | |
1099 } | |
1100 | |
1101 Release Raw Inputs[func,input type,index,inputs,outputs:out] | |
1102 { | |
1103 If[[[input type]Variant >>] = ["Raw Pointer"]] | |
1104 { | |
1105 name <- [inputs]Index[index] | |
1106 If[[input type]Mutable? >>] | |
1107 { | |
1108 [outputs]Find[[inputs]Index[index]] | |
1109 { | |
1110 out <- func | |
1111 }{ | |
1112 out <- [func]Release[name] | |
1113 } | |
1114 }{ | |
1115 out <- [func]Release[name] | |
1116 } | |
1117 }{ | |
1118 out <- func | |
1079 } | 1119 } |
1080 } | 1120 } |
1081 | 1121 |
1082 FParams[input:out] | 1122 FParams[input:out] |
1083 { | 1123 { |
1159 rfunc <- Val[ifunc] | 1199 rfunc <- Val[ifunc] |
1160 } | 1200 } |
1161 | 1201 |
1162 Fold[["FInputs"]Set Input[3, [worker]Inputs >>], rfunc, [worker]Input Types >>] | 1202 Fold[["FInputs"]Set Input[3, [worker]Inputs >>], rfunc, [worker]Input Types >>] |
1163 { [~]Call Foreign[name, [worker]Convention >>, Map[Zip[[worker]Inputs >>, [worker]Input Types >>], "FParams"], rparam] | 1203 { [~]Call Foreign[name, [worker]Convention >>, Map[Zip[[worker]Inputs >>, [worker]Input Types >>], "FParams"], rparam] |
1204 { Fold[[["Release Raw Inputs"]Set Input[3, [worker]Inputs >>]]Set Input[4, [worker]Outputs >>], ~, [worker]Input Types >>] | |
1164 { Fold[[[["Save Foreign Result"]Set Input[3, [worker]Output Types >>]]Set Input[4, [worker]Inputs >>]]Set Input[5, [worker]Input Types >>], ~, [worker]Outputs >>] | 1205 { Fold[[[["Save Foreign Result"]Set Input[3, [worker]Output Types >>]]Set Input[4, [worker]Inputs >>]]Set Input[5, [worker]Input Types >>], ~, [worker]Outputs >>] |
1165 { out <- [program]Store Function[~] }}} | 1206 { out <- [program]Store Function[~] }}}} |
1166 } | 1207 } |
1167 | 1208 |
1168 Compile Worker@NWorker[worker,program,name:out] | 1209 Compile Worker@NWorker[worker,program,name:out] |
1169 { | 1210 { |
1170 If[[worker]Builtin? >>] | 1211 If[[worker]Builtin? >>] |