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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/cl-target/cl-target.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/cl-target/cl-target.sml

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

revision 2077, Mon Nov 5 11:51:35 2012 UTC revision 2082, Tue Nov 6 22:54:10 2012 UTC
# Line 14  Line 14 
14      structure RN = RuntimeNames      structure RN = RuntimeNames
15      structure N = CNames      structure N = CNames
16      structure ToCL = TreeToCL      structure ToCL = TreeToCL
     structure SU = StrandUtil  
17      structure HF = CLHeaderFrag      structure HF = CLHeaderFrag
18      structure SF = CLSchedFrag      structure SF = CLSchedFrag
19    
# Line 120  Line 119 
119                  | _ => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))                  | _ => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
120                (* end case *))                (* end case *))
121        (* translate a strand state variable that occurs in an l-value context *)        (* translate a strand state variable that occurs in an l-value context *)
122          fun lvalueStateVar (IL.SV{name, ...}) = lvalueSV name          fun lvalueStateVar (_, IL.SV{name, ...}) = lvalueSV name
123        (* translate a strand state variable that occurs in an r-value context *)        (* translate a strand state variable that occurs in an r-value context *)
124          fun rvalueStateVar (IL.SV{name, ...}) = rvalueSV name          fun rvalueStateVar (_, IL.SV{name, ...}) = rvalueSV name
125        end        end
126    
127      structure ToC = TreeToCFn (TrCVar)      structure ToC = TreeToCFn (TrCVar)
# Line 165  Line 164 
164        }        }
165    
166      datatype program = Prog of {      datatype program = Prog of {
167          tgt : TargetUtil.target_desc,   (* info about target *)          props : Properties.props,
         hasDie : bool,                  (* true for programs that have "die" *)  
         hasNew : bool,                  (* true for programs that have "new" *)  
         hasCom : bool,                  (* true for programs that have strand communication *)  
         hasReduce : bool,               (* true for programs that have global reduce *)  
168          globals : mirror_var list ref,          globals : mirror_var list ref,
169          topDecls : CL.decl list ref,          topDecls : CL.decl list ref,
170          strands : strand AtomTable.hash_table,          strands : strand AtomTable.hash_table,
# Line 353  Line 348 
348                RN.initTargetSpec (#double tgt);                RN.initTargetSpec (#double tgt);
349                CNames.initTargetSpec {double = #double tgt, long = false};                CNames.initTargetSpec {double = #double tgt, long = false};
350                Prog{                Prog{
351                    tgt = tgt,                    props = Properties.mkProps (tgt, props),
                   hasDie = SU.hasProp SU.StrandsMayDie props,  
                   hasNew = SU.hasProp SU.NewStrands props,  
                   hasCom = SU.hasProp SU.StrandCommunication props,  
                   hasReduce = SU.hasProp SU.GlobalReduce props,  
352                    globals = ref [],                    globals = ref [],
353                    topDecls = ref [],                    topDecls = ref [],
354                    strands = AtomTable.mkTable (16, Fail "strand table"),                    strands = AtomTable.mkTable (16, Fail "strand table"),
# Line 400  Line 391 
391                  topDecls := shutdownFn :: initFn :: initHelperFn :: !topDecls                  topDecls := shutdownFn :: initFn :: initHelperFn :: !topDecls
392                end                end
393        (* register the global destruction part of a program *)        (* register the global destruction part of a program *)
394          fun free (Prog{tgt, topDecls, ...}, free) = let          fun free (Prog{props, topDecls, ...}, free) = let
395                val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy tgt))                val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy props))
396                val globTy = CL.T_Ptr(CL.T_Named(N.globalTy tgt))                val globTy = CL.T_Ptr(CL.T_Named(N.globalTy props))
397                val free = CL.mkBlock(                val free = CL.mkBlock(
398                      CL.mkDeclInit(globTy, "glob", CL.mkIndirect(CL.mkVar "wrld", "globals")) ::                      CL.mkDeclInit(globTy, "glob", CL.mkIndirect(CL.mkVar "wrld", "globals")) ::
399                      CL.unBlock free @ [CL.mkReturn(SOME(CL.mkVar "false"))])                      CL.unBlock free @ [CL.mkReturn(SOME(CL.mkVar "false"))])
# Line 416  Line 407 
407    
408        (* create and register the initially function for a program *)        (* create and register the initially function for a program *)
409          fun initially {          fun initially {
410                prog = Prog{tgt, strands, initially, numDims, ...},                prog = Prog{props, strands, initially, numDims, ...},
411                isArray : bool,                isArray : bool,
412                iterPrefix : stm list,                iterPrefix : stm list,
413                iters : (var * exp * exp) list,                iters : (var * exp * exp) list,
# Line 426  Line 417 
417              } = let              } = let
418                val name = Atom.toString strand                val name = Atom.toString strand
419                val nDims = List.length iters                val nDims = List.length iters
420                val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy tgt))                val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy props))
421                fun mapi f xs = let                fun mapi f xs = let
422                      fun mapf (_, []) = []                      fun mapf (_, []) = []
423                        | mapf (i, x::xs) = f(i, x) :: mapf(i+1, xs)                        | mapf (i, x::xs) = f(i, x) :: mapf(i+1, xs)
# Line 484  Line 475 
475                      allocCode @                      allocCode @
476                      iterCode @                      iterCode @
477                      [CL.mkReturn(SOME(CL.mkVar "wrld"))])                      [CL.mkReturn(SOME(CL.mkVar "wrld"))])
478                val initFn = CL.D_Func([], worldTy, N.initially tgt, [], body)                val initFn = CL.D_Func([], worldTy, N.initially props, [], body)
479                in                in
480                  numDims := nDims;                  numDims := nDims;
481                  initially := initFn                  initially := initFn
# Line 787  Line 778 
778    
779          fun genSrc (baseName, prog) = let          fun genSrc (baseName, prog) = let
780                val Prog{                val Prog{
781                        tgt,                        props,
782                        globals, topDecls, strands, initially,                        globals, topDecls, strands, initially,
783                        imgGlobals, numDims,outFn, ...                        imgGlobals, numDims,outFn, ...
784                      } = prog                      } = prog
# Line 807  Line 798 
798                  clppDecl (CL.verbatim [HF.text] [                  clppDecl (CL.verbatim [HF.text] [
799                      ("OUTFILE", clFileName),                      ("OUTFILE", clFileName),
800                      ("SRCFILE", OS.Path.joinBaseExt{base=baseName, ext=SOME "diderot"}),                      ("SRCFILE", OS.Path.joinBaseExt{base=baseName, ext=SOME "diderot"}),
801                      ("DIDEROT_FLOAT_PRECISION", TargetUtil.floatPrecisionDef tgt),                      ("DIDEROT_FLOAT_PRECISION", Properties.floatPrecisionDef props),
802                      ("DIDEROT_INT_PRECISION", TargetUtil.intPrecisionDef tgt)                      ("DIDEROT_INT_PRECISION", Properties.intPrecisionDef props)
803                    ]);                    ]);
804                (* if there are no globals, then define a dummy type *)                (* if there are no globals, then define a dummy type *)
805                  if List.null(!globals)                  if List.null(!globals)
# Line 830  Line 821 
821                  clppDecl (genUpdateMethod(strand, globals, imgGlobals));                  clppDecl (genUpdateMethod(strand, globals, imgGlobals));
822                (* Generate the Host C file *)                (* Generate the Host C file *)
823                  cppDecl (CL.D_Verbatim[                  cppDecl (CL.D_Verbatim[
824                      concat["#define " ^ TargetUtil.floatPrecisionDef tgt, "\n"],                      concat["#define " ^ Properties.floatPrecisionDef props, "\n"],
825                      concat["#define " ^ TargetUtil.intPrecisionDef tgt, "\n"],                      concat["#define " ^ Properties.intPrecisionDef props, "\n"],
826                      concat["#define " ^ TargetUtil.targetDef tgt, "\n"],                      concat["#define " ^ Properties.targetDef props, "\n"],
827                      "#include \"Diderot/diderot.h\"\n"                      "#include \"Diderot/diderot.h\"\n"
828                    ]);                    ]);
829                  case !globals                  case !globals
# Line 840  Line 831 
831                    | _ => ()                    | _ => ()
832                  (* end case *);                  (* end case *);
833                  cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",                  cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",
834                    SOME(CL.I_Exp(CL.mkStr(#srcFile tgt)))));                    SOME(CL.I_Exp(CL.mkStr(#srcFile props)))));
835                  cppDecl (genGlobalStruct (#hostTy, !globals, RN.globalsTy));                  cppDecl (genGlobalStruct (#hostTy, !globals, RN.globalsTy));
836                  cppDecl (genGlobalStruct (#shadowTy, !globals, RN.shadowGlobalsTy));                  cppDecl (genGlobalStruct (#shadowTy, !globals, RN.shadowGlobalsTy));
837  (* FIXME: does this really need to be a global? *)  (* FIXME: does this really need to be a global? *)
# Line 863  Line 854 
854                end                end
855    
856        (* output the code to the filesystem.  The string is the basename of the source file *)        (* output the code to the filesystem.  The string is the basename of the source file *)
857          fun generate (prog as Prog{tgt, ...}) = let          fun generate (prog as Prog{props, ...}) = let
858                val {outDir, outBase, exec, double, parallel, debug, ...} = tgt                val {outDir, outBase, exec, double, parallel, debug, ...} = props
859                fun condCons (true, x, xs) = x::xs                fun condCons (true, x, xs) = x::xs
860                  | condCons (false, _, xs) = xs                  | condCons (false, _, xs) = xs
861              (* generate the C compiler flags *)              (* generate the C compiler flags *)
# Line 879  Line 870 
870                val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])                val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])
871                val extraLibs = Paths.teemLinkFlags @  #base Paths.extraLibs :: extraLibs                val extraLibs = Paths.teemLinkFlags @  #base Paths.extraLibs :: extraLibs
872                     val extraLibs =  #cl Paths.extraLibs :: extraLibs                     val extraLibs =  #cl Paths.extraLibs :: extraLibs
873                val rtLib = TargetUtil.runtimeName tgt                val rtLib = Properties.runtimeName props
874                val ldOpts = rtLib :: extraLibs                val ldOpts = rtLib :: extraLibs
875                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}
876                in                in

Legend:
Removed from v.2077  
changed lines
  Added in v.2082

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