Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/target-cpu/gen.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/target-cpu/gen.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3908, Tue May 24 14:33:23 2016 UTC revision 3912, Wed May 25 14:53:50 2016 UTC
# Line 61  Line 61 
61            CL.verbatimDcl [if (TargetSpec.isParallel spec) then parFrag else seqFrag] subs            CL.verbatimDcl [if (TargetSpec.isParallel spec) then parFrag else seqFrag] subs
62    
63      fun runFrag (false, spec, subs) =      fun runFrag (false, spec, subs) =
64            verbFrag (spec, ParRunFrag.text, SeqRunFrag.text, subs)            verbFrag (spec, Fragments.parallelRun, Fragments.sequentialRun, subs)
65        | runFrag (true, spec, subs) =        | runFrag (true, spec, subs) =
66            verbFrag (spec, ParRunNoBSPFrag.text, SeqRunNoBSPFrag.text, subs)            verbFrag (spec, Fragments.parallelRunNoBSP, Fragments.sequentialRunNoBSP, subs)
67    
68      fun compile (spec : TargetSpec.t, basename) = let      fun compile (spec : TargetSpec.t, basename) = let
69          (* generate the C compiler flags *)          (* generate the C compiler flags *)
# Line 87  Line 87 
87              end              end
88            else [TargetSpec.runtimeLibName spec]            else [TargetSpec.runtimeLibName spec]
89    
90  (********************  
91        (* generate source code that is common to both libraries and standalone executables *)        (* generate source code that is common to both libraries and standalone executables *)
92          fun outputSrc (out, prog, strand, substitutions, genInputCode) = let      fun outputSrc (outS, spec, prog, strand, substitutions, genInputCode) = ()
93                val Prog{props, globals, topDecls, nAxes, initially, ...} = prog  (*
94        fun outputSrc (outS, spec, prog, strand, substitutions, genInputCode) = let
95              val IR.Program{globals, create, ...} = prog
96              (* does the program require barrier synchronization to implement BSP semantics? *)              (* does the program require barrier synchronization to implement BSP semantics? *)
97                val noBSP = Properties.noBSP props            val noBSP = TargetSpec.noBSP spec
98                val Strand{output, ...} = strand                val Strand{output, ...} = strand
99                val outputs = GenOutput.gen (props, !nAxes) output                val outputs = GenOutput.gen (props, !nAxes) output
100                fun ppDecl dcl = PrintAsC.output(#ppStrm out, dcl)            fun ppDecl dcl = Out.decl outS
101                in                in
102                  if (TargetSpec.isParallel spec)                  if (TargetSpec.isParallel spec)
103                    then ppDecl (CL.verbatimDcl [CHeadParExtraFrag.text] substitutions)                    then ppDecl (CL.verbatimDcl [CHeadParExtraFrag.text] substitutions)
104                    else ();                    else ();
105                  if Properties.dualState props              if TargetSpec.dualState spec
106                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_DUAL_STATE\n"])                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_DUAL_STATE\n"])
107                    else ();                    else ();
108                  if not(#hasGlobals props)              if not(#hasGlobals spec)
109                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_GLOBALS\n"])                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_GLOBALS\n"])
110                    else ();                    else ();
111                  if not(#hasInputs props)              if not(#hasInputs spec)
112                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_INPUTS\n"])                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_INPUTS\n"])
113                    else ();                    else ();
114                  List.app ppDecl (genGlobalStruct (props, !globals));                  List.app ppDecl (genGlobalStruct (props, !globals));
# Line 122  Line 124 
124                  ppDecl (runFrag (noBSP, props, substitutions));                  ppDecl (runFrag (noBSP, props, substitutions));
125                  ppDecl (CL.verbatimDcl [ShutdownFrag.text] substitutions)                  ppDecl (CL.verbatimDcl [ShutdownFrag.text] substitutions)
126                end                end
127    *)
128    
129    (********************
130          fun outputLibSrc (baseName, prog as Prog{props, inputs, strands, ...}) = let          fun outputLibSrc (baseName, prog as Prog{props, inputs, strands, ...}) = let
131                val [strand] = AtomTable.listItems strands                val [strand] = AtomTable.listItems strands
132                val substitutions = mkSubs (props, strand)                val substitutions = mkSubs (props, strand)
# Line 161  Line 165 
165  ********************)  ********************)
166    
167      fun exec (spec : TargetSpec.t, prog) = let      fun exec (spec : TargetSpec.t, prog) = let
168            val IR.Program{            val IR.Program{inputs, strand, ...} = prog
                   props, target, consts, inputs, constInit,  
                   globals, globalInit, strand, create, update  
                 } = prog  
           val {outDir, outBase, exec, double, debug, ...} = spec  
169            val env = mkEnv spec            val env = mkEnv spec
170            val baseName = OS.Path.joinDirFile{dir = #outDir spec, file = #outBase spec}            val baseName = OS.Path.joinDirFile{dir = #outDir spec, file = #outBase spec}
171            val substitutions = mkSubs (spec, strand)            val substitutions = mkSubs (spec, strand)
# Line 174  Line 174 
174            val ppDecl = Out.decl outS            val ppDecl = Out.decl outS
175            val fragment = Out.fragment substitutions outS            val fragment = Out.fragment substitutions outS
176            in            in
177              ppDecl (CL.verbatimDcl [ExecHdrFrag.text] substitutions);              GenExecUtil.execHead (outS, substitutions);
178              ppDecl (CL.verbatimDcl [NrrdSaveHelperFrag.text] substitutions);              outputSrc (outS, spec, prog, strand, substitutions,
             outputSrc (outS, prog, strand, substitutions,  
179                fn () => (                fn () => (
180                  GenInputs.genInputsStruct (env, inputs) @                  GenInputs.genInputsStruct (env, inputs) @
181                  GenInputs.genExecInputFuns (env, inputs) @                  GenInputs.genExecInputFuns (env, prog) @
182                  OutputUtil.genRegisterOutputOpts output));                  OutputUtil.genRegisterOutputOpts (env, OutputUtil.gatherOutputs prog)));
183              ppDecl (verbFrag (spec, ParMainFrag.text, SeqMainFrag.text, substitutions));              ppDecl (verbFrag (spec, Fragments.parallelMain, Fragments.sequentialMain, substitutions));
184                GenExecUtil.execFoot outS;
185              Out.closeOut outS;              Out.closeOut outS;
186              compile (spec, baseName);              compile (spec, baseName);
187              RunCC.linkExec (baseName, ldFlags spec)              RunCC.linkExec (baseName, ldFlags spec)

Legend:
Removed from v.3908  
changed lines
  Added in v.3912

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0