# HG changeset patch # User Mike Pavone # Date 1286932504 0 # Node ID 25a205094f9bf0f2f7d510fd11e465c2f3b7006b # Parent 336da6ce8174c5bc50bee64517586ea6dfeb8f2b More performance optimizations diff -r 336da6ce8174 -r 25a205094f9b cbackend.rhope --- a/cbackend.rhope Wed Oct 06 23:48:32 2010 +0000 +++ b/cbackend.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -1613,7 +1613,7 @@ for (idx = 0; idx < END; ++idx) { if(profile_counts[idx]) - printf(\"Func: %d\tCount: %llu\tTime: %llu\tAvg: %f\tSelf: %llu\tAvg: %f\n\", idx, profile_counts[idx], profile_totals[idx], ((double)profile_totals[idx])/((double)profile_counts[idx]), profile_selftotals[idx], ((double)profile_selftotals[idx])/((double)profile_counts[idx])); + printf(\"Func: %d\tCount: %llu\tTime: %llu\tAvg: %f\tSelf: %llu\tAvg: %f\\n\", idx, profile_counts[idx], profile_totals[idx], ((double)profile_totals[idx])/((double)profile_counts[idx]), profile_selftotals[idx], ((double)profile_selftotals[idx])/((double)profile_counts[idx])); } #endif if (!numret) diff -r 336da6ce8174 -r 25a205094f9b compile --- a/compile Wed Oct 06 23:48:32 2010 +0000 +++ b/compile Wed Oct 13 01:15:04 2010 +0000 @@ -4,7 +4,7 @@ rm "$1.c" fi -./rhope -t 1 parser_old.rhope $1 +./rhope -t 1 compile_old.rhope $1 if test ! -f "$1.c"; then echo "Compilation to C failed" diff -r 336da6ce8174 -r 25a205094f9b compile_old.rhope --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compile_old.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -0,0 +1,29 @@ +Import parser_old.rhope + +Main[args] +{ + fname <- [args]Index[1] + { + file <- >, ["Check Worker Literals"]Set Input[1, ~]] ] + { Print["Compiling"] } + } + compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]] + { Print["Compiled program to backend"] } + outfile <- >, Check Worker Literals[?, ~]] ] + { Print["Compiling"] } + } + compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]] + { Print["Compiled program to backend"] } + outfile <- [File[ [fname]Append[".c"] ]]Truncate + [[compiled]Text]Write to File[outfile] + { Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] } + } + }{ + Print["You must provide a file name to compile"] + } +} + diff -r 336da6ce8174 -r 25a205094f9b file.rhope --- a/file.rhope Wed Oct 06 23:48:32 2010 +0000 +++ b/file.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -219,12 +219,28 @@ Write@File Write[file,data(Array):out,err] { - err <- If[write[[file]Descriptor >>, data, Int64[[data]Length >>]]] {} + err <- If[[write[[file]Descriptor >>, data, Int64[[data]Length >>]]]<[0i32]] {} { out <- file } } +Write to File@String[str,file:out,err] +{ + out,err <- [file]Write[[str]Buffer >>] +} + +Write to File@String Slice[str,file:out,err] +{ + out,err <- [[str]Flatten]Write to File[file] +} + +Write to File@String Cat[str,file:out,err] +{ + ,err <- [[str]Left >>]Write to File[file] + { out,err <- [[str]Right >>]Write to File[~] } +} + Close@File Write[file:out] { fsync[[file]Descriptor >>] diff -r 336da6ce8174 -r 25a205094f9b nworker_c.rhope --- a/nworker_c.rhope Wed Oct 06 23:48:32 2010 +0000 +++ b/nworker_c.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -32,7 +32,18 @@ { If[[Blueprint Of[cond]] = [Condition Set()]] { - out <- [set]Subsets <<[ [[set]Subsets>>]Set[[cond]To String, cond] ] + If[[[set]Condition Type >>]=[[cond]Condition Type >>]] + { + out <- [[set]Variables <<[ Combine[[set]Variables >>, [cond]Variables >>] ] + ]Subsets <<[ Combine[[set]Subsets >>, [cond]Subsets >>] ] + }{ + [cond]Empty? + { + out <- [set]Subsets <<[ [[set]Subsets>>]Set[[cond]To String, cond] ] + }{ + out <- set + } + } }{ out <- [set]Variables <<[ [[set]Variables >>]Set[cond, Yes] ] } @@ -72,47 +83,17 @@ Empty?@Condition Set[set:not empty,empty] { - Print["Empty?@Condition Set"] [[set]Variables >>]First { not empty <- Yes }{ - ,empty <- [[set]Subsets >>]First Non-empty Set + ,empty <- [[set]Subsets >>]First { not empty <- Yes } } } -_First Non-empty Set[setlist,index:out,none] -{ - current <- [setlist]Index[index] - [[current]Variables >>]First - { - out <- index - }{ - ,trynext <- [[current]Subsets >>]First Non-empty Set - { - out <- index - } - } - Val[trynext] - { - ,none <- [setlist]Next[index] - { - out,none <- _First Non-empty Set[setlist, ~] - } - } -} - -First Non-empty Set[setlist:index,none] -{ - ,none <- [setlist]First - { - index,none <- _First Non-empty Set[setlist,~] - } -} - For Backend@Condition Set[set:out,none] { firstvar <- [[set]Variables >>]First @@ -125,7 +106,7 @@ } out <- Fold[_For Backend Subset[?, ?, [set]Condition Type >>], vars, [set]Subsets >>] }{ - [[set]Subsets >>]First Non-empty Set + [[set]Subsets >>]First { firstsub <- [[[set]Subsets >>]Index[~]]For Backend [[set]Subsets >>]Next[~] @@ -714,7 +695,7 @@ If[[[node]Type >>] = ["input"]] { input name <- [[worker]Inputs >>]Index[ [node]Data >> ] - [conditions]For Backend + [conditions]Empty? { out <- AddRef[Result Var Name[[noderef]IO Num >>, [noderef]Index >>]] }{ @@ -723,7 +704,7 @@ }{ If[[[node]Type >>] = ["const"]] { - [conditions]For Backend + [conditions]Empty? { out <- AddRef[Result Var Name[[noderef]IO Num >>, [noderef]Index >>]] }{ @@ -1031,7 +1012,7 @@ { [("const","input")]Find[=[[node]Type >>, ?]] { - [[node]Conditions >>]For Backend + [[node]Conditions >>]Empty? { out <- Result Var[vars, 0, index] }{ diff -r 336da6ce8174 -r 25a205094f9b parser_old.rhope --- a/parser_old.rhope Wed Oct 06 23:48:32 2010 +0000 +++ b/parser_old.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -1652,6 +1652,7 @@ } +/* Main[args] { fname <- [args]Index[1] @@ -1678,3 +1679,5 @@ REPL[New@Parser[]] } } +*/ + diff -r 336da6ce8174 -r 25a205094f9b parser_old_c.rhope --- a/parser_old_c.rhope Wed Oct 06 23:48:32 2010 +0000 +++ b/parser_old_c.rhope Wed Oct 13 01:15:04 2010 +0000 @@ -1578,7 +1578,7 @@ out <- Fold[Add If Store[?, ?, params], stores, [node]Assignments >>] } - +/* Main[args] { fname <- [args]Index[1] @@ -1605,3 +1605,5 @@ Print["You must provide a file name to compile"] } } +*/ +