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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/codegen/target-spec.sml
ViewVC logotype

View of /branches/vis15/src/compiler/codegen/target-spec.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3812 - (download) (annotate)
Wed May 4 13:16:31 2016 UTC (3 years ago) by jhr
File size: 5478 byte(s)
  working on merge
(* target-spec.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

structure TargetSpec =
  struct

    datatype platform = datatype TargetOptions.platform

    type t = {
      (* properties from the command line *)
        diderotc : string,              (* the diderotc command used to invoke this compiler *)
        argv : string list,             (* command-line arguments used to invoke this compiler *)
        version : string,               (* version message string for this compiler *)
        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 snapshots? *)
        platform : platform,     	(* target platform *)
        namespace : string,             (* optional namespace prefix *)
        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 *)
        hasGlobals : bool,              (* true if the program has global variables *)
        hasInputs : bool,               (* true if the program has input variables *)
        isArray : bool,                 (* true for programs that use a fixed array of strands *)
        hasDynSeq : bool,               (* true for programs that have create dynamic sequences;
                                         * this does not include programs that just load sequences
                                         * from nrrd files. *)
        hasStabilize : bool,            (* true for programs with user-defined stabilize methods *)
        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 mk (tgt : TargetOptions.t, props : Properties.t list) : t = {
            diderotc = CommandLine.name(),
            argv = CommandLine.arguments(),
            version = Version.message,
            srcFile = #srcFile tgt,
            outDir = #outDir tgt,
            outBase = #outBase tgt,
            exec = #exec tgt,
            snapshot = #snapshot tgt,
            platform = #platform tgt,
            namespace = #namespace tgt,
            double = #double tgt,
            longint = #longint tgt,
            debug = #debug tgt,
            bsp = #bsp tgt,
            hasGlobals = Properties.hasProp Properties.HasGlobals props,
            hasInputs = Properties.hasProp Properties.HasInputs props,
            isArray = Properties.hasProp Properties.StrandArray props,
            hasDynSeq = Properties.hasProp Properties.DynamicSeq props,
            hasStabilize = Properties.hasProp Properties.HasStabilizeMethod props,
            hasDie = Properties.hasProp Properties.StrandsMayDie props,
            hasNew = Properties.hasProp Properties.NewStrands props,
            hasCom = Properties.hasProp Properties.StrandCommunication props,
            hasReduce = Properties.hasProp Properties.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 the program has communication, etc.
   *)
    fun noBSP (p : t) = not(#bsp p orelse #hasCom p orelse #hasReduce p)

  (* returns true if the program does not use inter-strand communication *)
    fun noComm (p : t) = not(#hasCom p)

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

  (* convert a target specification to the name of the runtime library *)
    fun runtimeName (spec : t) = let
          val l = if #debug spec then ["-debug.o"] else [".o"]
          val p = if #double spec then "-d" else "-f"
          val t = (case #platform spec
                 of SEQUENTIAL => "-seq"
		  | PARALLEL => "-par"
                  | OPENCL => "-cl"
                  | 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 : t) = if #double p
          then "DIDEROT_DOUBLE_PRECISION"
          else "DIDEROT_SINGLE_PRECISION"

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

  (* return the CPP target definition for the target *)
    fun targetDef (p : t) = "DIDEROT_TARGET_" ^ TargetOptions.platformToString (#platform p)

  end

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