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

SCM Repository

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

Diff of /branches/vis12/src/compiler/c-target/gen-output.sml

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

revision 1709, Fri Mar 9 14:02:43 2012 UTC revision 1710, Fri Mar 9 15:08:12 2012 UTC
# Line 3  Line 3 
3   * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * Generate strand output functions   * Generate strand output functions.  There are four cases that we handle:
7     *
8     *      grid, fixed-size elements:
9     *              nrrd has object dimensions followed by axes
10     *
11     *      collection, fixed-size elements
12     *              nrrd has object dims followed by a single axis
13     *
14     *      grid, dynamic-size elements
15     *              lengths nrrd has size 2 for objects (offset, length) followed by axes
16     *              data nrrd has object dimensions followed by a single axis
17     *
18     *      collection, dynamic-size elements
19     *              lengths nrrd has size 2 for objects (offset, length) followed by a single axis
20     *              data nrrd has object dimensions followed by a single axis
21     *
22     * TODO: copy code for collection of fixed-size elements
23   *)   *)
24    
25  structure GenOutput : sig  structure GenOutput : sig
# Line 25  Line 41 
41              mapf (0, l, [])              mapf (0, l, [])
42            end            end
43    
 (* cases:  
  *      grid, fixed-size elements:  
  *              nrrd has object dimensions followed by axes  
  *      collection, fixed-size elements  
  *              nrrd has object dims followed by a single axis  
  *      grid, dynamic-size elements  
  *              lengths nrrd has size 2 for objects (offset, length) followed by axes  
  *              data nrrd has object dimensions followed by a single axis  
  *      collection, dynamic-size elements  
  *              lengths nrrd has size 2 for objects (offset, length) followed by a single axis  
  *              data nrrd has object dimensions followed by a single axis  
  *)  
   
44      val nrrdPtrTy = CL.T_Ptr(CL.T_Named "Nrrd")      val nrrdPtrTy = CL.T_Ptr(CL.T_Named "Nrrd")
45      val sizeTy = CL.T_Named "size_t"      val sizeTy = CL.T_Named "size_t"
46    
# Line 65  Line 68 
68      val wrldV = CL.mkVar "wrld"      val wrldV = CL.mkVar "wrld"
69      val sizesV = CL.mkVar "sizes"      val sizesV = CL.mkVar "sizes"
70      val iV = CL.mkVar "i"      val iV = CL.mkVar "i"
71        val nV = CL.mkVar "n"
72      val pV = CL.mkVar "p"      val pV = CL.mkVar "p"
73        val offsetV = CL.mkVar "offset"
74      val dataV = CL.mkVar "data"      val dataV = CL.mkVar "data"
75      val lengthsV = CL.mkVar "lengths"      val lengthsV = CL.mkVar "lengths"
76      val numStableV = CL.mkVar "numStable"      val numStableV = CL.mkVar "numStable"
# Line 156  Line 161 
161                          nElemsInit, forStrands cntElems                          nElemsInit, forStrands cntElems
162                        ]                        ]
163                      else [                      else [
164                          CL.mkComment["count number of elements and stable strands"],                          CL.mkComment["count number of output elements and stable strands"],
165                          CL.mkAssign(numStableV, CL.mkInt 0), nElemsInit,                          CL.mkAssign(numStableV, CL.mkInt 0), nElemsInit,
166                          forStrands(ifStable(CL.mkBlock[cntElems, CL.S_Exp(CL.mkPostOp(numStableV, CL.^++))]))                          forStrands(ifStable(CL.mkBlock[cntElems, CL.S_Exp(CL.mkPostOp(numStableV, CL.^++))]))
167                        ]                        ]
# Line 188  Line 193 
193                  end                  end
194          (* generate the lengths copy code *)          (* generate the lengths copy code *)
195            val copyLengths = let            val copyLengths = let
196                    val pInit = CL.mkAssign(pV,
197                          CL.mkCast(CL.T_Ptr(CL.uint32), CL.mkIndirect(lengthsV, "data")))
198                    val offsetDecl = CL.mkDecl(CL.uint32, "offset", SOME(CL.I_Exp(CL.mkInt 0)))
199                    val copyBlk = CL.mkBlock[
200                            CL.mkDecl(CL.uint32, "n", SOME(CL.I_Exp(seqLength(stateVar name)))),
201                            CL.mkAssign(CL.mkPostOp(pV, CL.^++), offsetV),
202                            CL.mkAssign(CL.mkPostOp(pV, CL.^++), nV),
203                            CL.S_Exp(CL.mkAssignOp(offsetV, CL.+=, nV))
204                          ]
205                    val copyStm = if isArray
206                          then copyBlk
207                          else ifStable copyBlk
208                  in                  in
209                    []                    [pInit, offsetDecl, copyStm]
210                  end                  end
211          (* generate the data copy code *)          (* generate the data copy code *)
212            val copyData = let            val copyData = let
213                    val pInit = CL.mkAssign(pV, CL.mkCast(CL.charPtr, CL.mkIndirect(dataV, "data")))
214                    val copyStm = CL.mkAssign(pV, seqCopy(
215                          CL.mkBinOp(mkInt nElems, CL.#*, CL.mkSizeof(elemCTy)), pV, stateVar name))
216                    val copyStm = if isArray
217                          then copyStm
218                          else ifStable copyStm
219                  in                  in
220                    []                    [pInit, forStrands copyStm]
221                  end                  end
222          (* the function body *)          (* the function body *)
223            val stms =            val stms =

Legend:
Removed from v.1709  
changed lines
  Added in v.1710

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