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

SCM Repository

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

View of /branches/lamont/src/compiler/codegen/target-util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2081 - (download) (annotate)
Mon Nov 5 23:26:06 2012 UTC (6 years, 11 months ago) by lamonts
File size: 2389 byte(s)
Creating new developmented branch based on vis12
(* target-util.sml
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Utility support for target selection, etc.
 *)

structure TargetUtil =
  struct

    datatype target
      = TARGET_C		(* C code *)
      | TARGET_CL		(* C + OpenCL *)
      | TARGET_CUDA		(* C + CUDA *)

  (* the target descriptor collects together the information specified on the Diderot
   * compiler's command-line.
   *)
    type target_desc = {
	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 : 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 *)
      }

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

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

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

  end

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