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 4366, Fri Aug 5 19:19:15 2016 UTC revision 4367, Fri Aug 5 21:34:40 2016 UTC
# Line 62  Line 62 
62              ("STRANDTY",                Atom.toString name ^ "_strand"),              ("STRANDTY",                Atom.toString name ^ "_strand"),
63              ("IS_GRID",                 Bool.toString(#isGrid spec)),              ("IS_GRID",                 Bool.toString(#isGrid spec)),
64              ("NUM_AXES",                Int.toString(Option.getOpt(Create.gridDim create, 1))),              ("NUM_AXES",                Int.toString(Option.getOpt(Create.gridDim create, 1))),
65                ("SPATIAL_DIM",             "2"), (* FIXME: get this from the program *)
66              ("DIDEROTC_CMD",            #diderotc spec),              ("DIDEROTC_CMD",            #diderotc spec),
67              ("DIDEROTC_ARGV",           String.concatWith " " (#argv spec)),              ("DIDEROTC_ARGV",           String.concatWith " " (#argv spec)),
68              ("DIDEROTC_VERSION",        #version spec),              ("DIDEROTC_VERSION",        #version spec),
# Line 173  Line 174 
174              end              end
175            else [TargetSpec.runtimeLibName spec]            else [TargetSpec.runtimeLibName spec]
176    
177      (* generate defines that control specialization of the code for various features (e.g.,
178       * parallelism, global updates, ...
179       *)
180        fun outputDefines (outS, spec, substitutions) = let
181              val ppDecl = Out.decl outS
182              fun pp (true, dcl) = ppDecl (CL.D_Verbatim [dcl])
183                | pp _ = ()
184              in
185                if (TargetSpec.isParallel spec)
186                  then ppDecl (CL.verbatimDcl [CPUFragments.parallelExtras] substitutions)
187                  else ();
188                pp (TargetSpec.dualState spec, "#define DIDEROT_DUAL_STATE\n");
189                pp (not(#hasGlobals spec), "#define DIDEROT_NO_GLOBALS\n");
190                pp (not(#hasInputs spec), "#define DIDEROT_NO_INPUTS\n");
191                pp (#hasCom spec, "#define DIDEROT_HAS_STRAND_COMMUNICATION\n");
192                pp (#hasGlobalUpdate spec, "#define DIDEROT_HAS_GLOBAL_UPDATE\n")
193              end
194    
195    (* generate source code that is common to both libraries and standalone executables *)    (* generate source code that is common to both libraries and standalone executables *)
196      fun outputSrc (outS, env, spec, prog, strand, substitutions, genInputCode) = let      fun outputSrc (outS, env, spec, prog, strand, substitutions, genInputCode) = let
197            val IR.Program{consts, inputs, globals, funcs, globInit, create, init, update, ...} = prog            val IR.Program{consts, inputs, globals, funcs, globInit, create, init, update, ...} = prog
# Line 182  Line 201 
201            val {structDef, methods} = GenStrand.gen (env, strand)            val {structDef, methods} = GenStrand.gen (env, strand)
202            val outputs = OutputUtil.gatherOutputs prog            val outputs = OutputUtil.gatherOutputs prog
203            in            in
             if (TargetSpec.isParallel spec)  
               then ppDecl (CL.verbatimDcl [CPUFragments.parallelExtras] substitutions)  
               else ();  
             if TargetSpec.dualState spec  
               then ppDecl (CL.D_Verbatim ["#define DIDEROT_DUAL_STATE\n"])  
               else ();  
             if not(#hasGlobals spec)  
               then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_GLOBALS\n"])  
               else ();  
             if not(#hasInputs spec)  
               then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_INPUTS\n"])  
               else ();  
             if #hasCom spec  
               then ppDecl (CL.D_Verbatim [  
                   "#define DIDEROT_HAS_GLOBAL_UPDATE\n",  
                   "#define DIDEROT_HAS_STRAND_COMMUNICATION\n"  
                 ])  
             else if #hasGlobalUpdate spec  
               then ppDecl (CL.D_Verbatim ["#define DIDEROT_HAS_GLOBAL_UPDATE\n"])  
               else ();  
204              List.app ppDecl (genGlobalStruct (env, consts, inputs, globals));              List.app ppDecl (genGlobalStruct (env, consts, inputs, globals));
205              ppDecl structDef;              ppDecl structDef;
206              ppDecl (GenWorld.genStruct(env, strandName, Option.getOpt(dim, 1)));              ppDecl (GenWorld.genStruct(env, strandName, Option.getOpt(dim, 1)));
# Line 231  Line 230 
230            val {preWorld, postWorld} = GenTysAndOps.gen (env, CollectInfo.collect prog)            val {preWorld, postWorld} = GenTysAndOps.gen (env, CollectInfo.collect prog)
231            in            in
232              ppDecl (CL.verbatimDcl [CxxFragments.execHead] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.execHead] substitutions);
233                outputDefines (outS, spec, substitutions);
234                ppDecl (CL.verbatimDcl [CxxFragments.execIncl] substitutions);
235              List.app ppDecl preWorld;              List.app ppDecl preWorld;
236              ppDecl (CL.verbatimDcl [CxxFragments.namespaceOpen] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.namespaceOpen] substitutions);
237              ppDecl (CL.verbatimDcl [CxxFragments.nrrdSaveHelper] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.nrrdSaveHelper] substitutions);
# Line 270  Line 271 
271                  outputs = outputs                  outputs = outputs
272                };                };
273              ppDecl (CL.verbatimDcl [CxxFragments.libCXXHead] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.libCXXHead] substitutions);
274                outputDefines (outS, spec, substitutions);
275                ppDecl (CL.verbatimDcl [CxxFragments.libCXXIncl] substitutions);
276              List.app ppDecl preWorld;              List.app ppDecl preWorld;
277              ppDecl (CL.verbatimDcl [CxxFragments.namespaceOpen] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.namespaceOpen] substitutions);
278              ppDecl (CL.verbatimDcl [CxxFragments.nrrdSaveHelper] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.nrrdSaveHelper] substitutions);

Legend:
Removed from v.4366  
changed lines
  Added in v.4367

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