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

SCM Repository

[diderot] View of /branches/lamont/src/compiler/common/strand-util.sml
ViewVC logotype

View of /branches/lamont/src/compiler/common/strand-util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (download) (annotate)
Wed Feb 26 14:22:24 2014 UTC (7 years, 3 months ago) by lamonts
File size: 1930 byte(s)
Fixed global reduction block
(* strand-util.sml
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Utility definitions for strands.
 *)

structure StrandUtil =
  struct

  (* method names *)
    datatype method_name
      = Update
      | Stabilize

    fun nameToString Update = "Update"
      | nameToString Stabilize = "Stabilize"

  (* program properties *)
    datatype program_prop
      = StrandsMayDie                   (* present if strands may die *)
      | NewStrands                      (* present if new strands may be created dynamically *)
	  | StrandCommunication 			    (* present if strands read the state of other strands and supplies the dimension for communication *)	
      | SpatialComDim of int            (* present if spatial communication is present and stores the dimension *)
      | GlobalCommunication             (* present if there is global communication *)
      | GlobalReduce                    (* present if there is a global readuction *) 
 
    fun propToString StrandsMayDie = "StrandsMayDie"
      | propToString NewStrands = "NewStrands"
	  | propToString StrandCommunication = "StrandCommunication"
      | propToString (SpatialComDim d) = concat["Spatial Communication Dimension:",Int.toString(d),"D"]
      | propToString GlobalCommunication = "GlobalCommunication"
      | propToString GlobalReduce = "GlobalReduce"

    fun propsToString [] = "none"
      | propsToString [p] = propToString p 
      | propsToString (p::props) = String.concat(
          propToString p
            :: List.foldr (fn (p, l) => "," :: propToString p :: l) [] props)

    fun hasProp (prop : program_prop) = List.exists (fn p => prop = p)

	fun spatialDim props = let  
		  fun hasDim (SpatialComDim _) = true 
			| hasDim _ = false 
		in 
		  (case (List.find hasDim props)
			of SOME(SpatialComDim d) => d 
			 | _ => 0
		   (* end of case *)) 
		  end 

  end

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