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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/c-target/c-target.sml
ViewVC logotype

Diff of /branches/lamont/src/compiler/c-target/c-target.sml

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

revision 2121, Thu Feb 7 13:53:52 2013 UTC revision 2122, Thu Feb 7 18:41:18 2013 UTC
# Line 375  Line 375 
375        (***** OUTPUT *****)        (***** OUTPUT *****)
376    
377        (* create the target-specific substitution list *)        (* create the target-specific substitution list *)
378          fun mkSubs (tgt : target_desc, hasCom, gridIs2D,strandSize, Strand{name, tyName, ...}) = let          fun mkSubs (tgt : target_desc, hasCom, hasReduce, gridIs2D,strandSize, Strand{name, tyName, ...}) = let
379             val construct2D = "\nconstructGrid2D(wrld->inState, &wrld->gridCtx);"
380             val construct3D =  "\nconstructGrid3D(wrld->inState, &wrld->gridCtx);"
381           val grid3DInit = concat["wrld->gridCtx.gridSize[0] = wrld->gridCtx.gridSize[1] = wrld->gridCtx.gridSize[2] = pow(wrld->numStrands,1.0f/3.0f);\n",           val grid3DInit = concat["wrld->gridCtx.gridSize[0] = wrld->gridCtx.gridSize[1] = wrld->gridCtx.gridSize[2] = pow(wrld->numStrands,1.0f/3.0f);\n",
382                                  "wrld->gridCtx.cellSize[0] = wrld->gridCtx.cellSize[1] = wrld->gridCtx.gridSize[2]= ", strandSize, ";\n",                                  "wrld->gridCtx.cellSize[0] = wrld->gridCtx.cellSize[1] = wrld->gridCtx.gridSize[2]= ", strandSize, ";\n",
383                                  "wrld->gridCtx.numberOfStrands = wrld->numStrands;\n",                                  "wrld->gridCtx.numberOfStrands = wrld->numStrands;\n",
384                                  "\nconstructGrid3D(wrld->inState, &wrld->gridCtx);"]                                  construct3D]
385    
386           val grid2DInit = concat["wrld->gridCtx.gridSize[0] = wrld->gridCtx.gridSize[1] = pow(wrld->numStrands,1.0f/3.0f);\n",           val grid2DInit = concat["wrld->gridCtx.gridSize[0] = wrld->gridCtx.gridSize[1] = pow(wrld->numStrands,1.0f/3.0f);\n",
387                                  "wrld->gridCtx.cellSize[0] = wrld->gridCtx.cellSize[1] = ", strandSize, ";\n",                                  "wrld->gridCtx.cellSize[0] = wrld->gridCtx.cellSize[1] = ", strandSize, ";\n",
388                                  "wrld->gridCtx.numberOfStrands = wrld->numStrands;\n",                                  "wrld->gridCtx.numberOfStrands = wrld->numStrands;\n",
389                                  "\nconstructGrid2D(wrld->inState, &wrld->gridCtx);"]                                   construct2D]
390    
391             val globalReduce = concat[#namespace tgt," Global_Reduction(wrld,glob,wrld->inState);"]
392          in          in
393           [           [
394                  ("CFILE",       OS.Path.joinBaseExt{base= #outBase tgt, ext= SOME "c"}),                  ("CFILE",       OS.Path.joinBaseExt{base= #outBase tgt, ext= SOME "c"}),
# Line 392  Line 396 
396                  ("PREFIX",      #namespace tgt),                  ("PREFIX",      #namespace tgt),
397                  ("SRCFILE",     #srcFile tgt),                  ("SRCFILE",     #srcFile tgt),
398                  ("STRAND",      name),                  ("STRAND",      name),
399            ("GLOBAL_REDUCE", if hasReduce then globalReduce else ""),
400            ("REBUILD_GRID", if hasCom then (if gridIs2D then construct2D  else construct3D) else ""),
401          ("GRID_D", if gridIs2D then "2" else "3"),          ("GRID_D", if gridIs2D then "2" else "3"),
402          ("BUILD_GRID", if hasCom then (if gridIs2D then grid2DInit else grid3DInit) else ""),          ("BUILD_GRID", if hasCom then (if gridIs2D then grid2DInit else grid3DInit) else ""),
403          ("PASS_GRID",  if hasCom then ",wrld->inState,&wrld->gridCtx" else ""),          ("PASS_GRID",  if hasCom then ",wrld->inState,&wrld->gridCtx" else ""),
# Line 501  Line 507 
507                val needsBarrier = #bsp tgt orelse hasCom orelse hasReduce                val needsBarrier = #bsp tgt orelse hasCom orelse hasReduce
508                val [strand as Strand{name, tyName, state, output, ...}] = AtomTable.listItems strands                val [strand as Strand{name, tyName, state, output, ...}] = AtomTable.listItems strands
509                val outputs = GenOutput.gen (tgt, !nAxes) [output]                val outputs = GenOutput.gen (tgt, !nAxes) [output]
510                val substitutions = mkSubs (tgt,hasCom,gridIs2D,strandSize,strand)                val substitutions = mkSubs (tgt,hasCom,hasReduce,gridIs2D,strandSize,strand)
511              (* output to C file *)              (* output to C file *)
512                val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}                val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
513                val outS = TextIO.openOut fileName                val outS = TextIO.openOut fileName
# Line 521  Line 527 
527                  List.app ppDecl (GenInputs.genInputFuns(tgt, !inputs));                  List.app ppDecl (GenInputs.genInputFuns(tgt, !inputs));
528                  List.app ppDecl (List.rev (!topDecls));                  List.app ppDecl (List.rev (!topDecls));
529                  List.app ppDecl (genStrand strand);                  List.app ppDecl (genStrand strand);
530                  ppDecl(!globalReduce);                  if hasReduce then
531                  ppDecl (CL.verbatim [ReductionFrag.text] substitutions);                  (ppDecl(!globalReduce);
532                    ppDecl (CL.verbatim [ReductionFrag.text] substitutions))
533                    else
534                        ();
535    
536                if(hasCom)                if(hasCom)
537                then (if(gridIs2D)then ppDecl (CL.verbatim [Grid2DFrag.text] substitutions)                then (if(gridIs2D)then ppDecl (CL.verbatim [Grid2DFrag.text] substitutions)
# Line 582  Line 591 
591                      ("DIDEROT_FLOAT_PRECISION", TargetUtil.floatPrecisionDef tgt) ::                      ("DIDEROT_FLOAT_PRECISION", TargetUtil.floatPrecisionDef tgt) ::
592                      ("DIDEROT_INT_PRECISION", TargetUtil.intPrecisionDef tgt) ::                      ("DIDEROT_INT_PRECISION", TargetUtil.intPrecisionDef tgt) ::
593                      ("DIDEROT_TARGET", TargetUtil.targetDef tgt) ::                      ("DIDEROT_TARGET", TargetUtil.targetDef tgt) ::
594                      mkSubs (tgt, hasCom,gridIs2D,strandSize,strand)                      mkSubs (tgt, hasCom,hasReduce,gridIs2D,strandSize,strand)
595                val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}                val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
596                val outS = TextIO.openOut fileName                val outS = TextIO.openOut fileName
597                val ppStrm = PrintAsC.new outS                val ppStrm = PrintAsC.new outS
# Line 601  Line 610 
610                  List.app ppDecl (List.rev (!topDecls));                  List.app ppDecl (List.rev (!topDecls));
611                  List.app ppDecl (GenInputs.genExecInputFuns (tgt, !inputs));                  List.app ppDecl (GenInputs.genExecInputFuns (tgt, !inputs));
612                  List.app ppDecl (genStrand strand);                  List.app ppDecl (genStrand strand);
613                  ppDecl(!globalReduce);                  if hasReduce then
614                  ppDecl (CL.verbatim [ReductionFrag.text] substitutions);                  (ppDecl(!globalReduce);
615                    ppDecl (CL.verbatim [ReductionFrag.text] substitutions))
616                    else
617                        ();
618    
619        if(hasCom)        if(hasCom)
620                then (if(gridIs2D)then ppDecl (CL.verbatim [Grid2DFrag.text] substitutions)                then (if(gridIs2D)then ppDecl (CL.verbatim [Grid2DFrag.text] substitutions)

Legend:
Removed from v.2121  
changed lines
  Added in v.2122

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