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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/codegen/properties.sml
ViewVC logotype

View of /branches/vis12/src/compiler/codegen/properties.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2435 - (download) (annotate)
Sat Sep 21 14:36:39 2013 UTC (5 years, 10 months ago) by jhr
File size: 3731 byte(s)
  Modify compiler to dynamically determine the intall location of the Diderot
  libraries and include files.  This feature will allow the diderot compiler
  to be installed in places other than where it is built.
(* properties.sml
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Properties, including the target description, that affect code generation.
 *)

structure Properties =
  struct

    type props = {
      (* properties from the target description *)
	srcFile : string,		(* source filename *)
	outDir : string,		(* directory to put output *)
	outBase : string,		(* basename for output or name of executable *)
	exec : bool,			(* generate standalone executable? *)
	snapshot : bool,		(* generate functions to get snapshot *)
	target : TargetUtil.target,	(* target platform *)
	namespace : string,		(* optional namespace prefix *)
	parallel : bool,		(* parallel components *)
	double : bool,			(* true for double-precision candidates *)
	longint : bool,			(* true for 64-bit integers (not currently used) *)
	debug : bool,			(* true if debugging of the target is enabled *)
	bsp : bool,			(* true if BSP style execution should always be used *)
      (* properties from analysing the program *)
	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 *)
      }

  (* create the property record from the target description and program properties *)
    fun mkProps (tgt : TargetUtil.target_desc, props : StrandUtil.program_prop list) = {
	    srcFile = #srcFile tgt,
	    outDir = #outDir tgt,
	    outBase = #outBase tgt,
	    exec = #exec tgt,
	    snapshot = #snapshot tgt,
	    target = #target tgt,
	    namespace = #namespace tgt,
	    parallel = #parallel tgt,
	    double = #double tgt,
	    longint = #longint tgt,
	    debug = #debug tgt,
	    bsp = #bsp tgt,
	    hasDie = StrandUtil.hasProp StrandUtil.StrandsMayDie props,
	    hasNew = StrandUtil.hasProp StrandUtil.NewStrands props,
	    hasCom = StrandUtil.hasProp StrandUtil.StrandCommunication props,
	    hasReduce = StrandUtil.hasProp StrandUtil.GlobalReduce props
	  }

  (* returns false if BSP style execution should always be used;
   * this property can be set on the command line, but
   * also holds when program has communication, etc.
   *)
    fun noBSP (p : props) = not(#bsp p orelse #hasCom p orelse #hasReduce p)

  (* return true if we need to keep two copies of the state: in and out. *)
    fun dualState (p : props) = (#hasCom p)

  (* convert a target specification to the name of the runtime library *)
    fun runtimeName (props : props) = let
	  val l = if #debug props then ["-debug.o"] else [".o"]
	  val l = if #parallel props then "-par"::l else l
	  val p = if #double props then "-d" else "-f"
	  val t = (case #target props
		 of TargetUtil.TARGET_C => "-c"
		  | TargetUtil.TARGET_CL => "-cl"
		  | TargetUtil.TARGET_CUDA => "-cuda"
		(* end case *))
	  in
	    OS.Path.concat(
	      Paths.diderotLib(),
	      String.concat("diderot-rt" :: t :: p :: l))
	  end

  (* return the CPP floating-point precision definition for the target *)
    fun floatPrecisionDef (p : props) = if #double p
	  then "DIDEROT_DOUBLE_PRECISION"
	  else "DIDEROT_SINGLE_PRECISION"

  (* return the CPP integer precision definition for the target *)
    fun intPrecisionDef (p : props) = if #longint p
	  then "DIDEROT_LONGINT"
	  else "DIDEROT_INT"

  (* return the CPP target definition for the target *)
    fun targetDef (p : props) = (case #target p
	   of TargetUtil.TARGET_C => if #parallel p
		then "DIDEROT_TARGET_PARALLEL"
		else "DIDEROT_TARGET_C"
	    | TargetUtil.TARGET_CL => "DIDEROT_TARGET_CL"
	    | TargetUtil.TARGET_CUDA => "DIDEROT_TARGET_CUDA"
	  (* end case *))

  end

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