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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/cl-target/cl-target.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/cl-target/cl-target.sml

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

revision 1629, Sat Nov 12 18:50:23 2011 UTC revision 1630, Sun Nov 13 19:05:36 2011 UTC
# Line 575  Line 575 
575                genKeneralGlobalParams(rest, concat[line, "__global void *", RN.addBufferSuffixData name, ","])                genKeneralGlobalParams(rest, concat[line, "__global void *", RN.addBufferSuffixData name, ","])
576    
577          fun genUpdateMethod (Strand{name, tyName, state,...},imgGlobals) = let          fun genUpdateMethod (Strand{name, tyName, state,...},imgGlobals) = let
578    (* FIXME: read the file using TextIO.inputAll *)
579                fun readPlaceholders () = let                fun readPlaceholders () = let
580                      val infile = concat[Paths.diderotSrc, "/lib/cl-target/cl-kernels/update_cl.in"]                      val infile = concat[Paths.diderotSrc, "/lib/cl-target/cl-kernels/update_cl.in"]
581                      val ins = TextIO.openIn infile                      val ins = TextIO.openIn infile
# Line 791  Line 792 
792                end                end
793    
794          fun genSrc (baseName, prog) = let          fun genSrc (baseName, prog) = let
795                val Prog{name,double,globals, topDecls, strands, initially, imgGlobals, numDims,outFn, ...} = prog                val Prog{
796                          name, double, globals, topDecls, strands, initially,
797                          imgGlobals, numDims,outFn, ...
798                        } = prog
799                val clFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "cl"}                val clFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "cl"}
800                val cFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}                val cFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
801                val clOutS = TextIO.openOut clFileName                val clOutS = TextIO.openOut clFileName
# Line 805  Line 809 
809                val [strand as Strand{name, tyName, code, init_code, ...}] = strands                val [strand as Strand{name, tyName, code, init_code, ...}] = strands
810                in                in
811                (* Generate the OpenCl file *)                (* Generate the OpenCl file *)
812                  clppDecl (CL.D_Verbatim([                  clppDecl (CL.D_Verbatim[
813                                    (* if the target supports OpenCL 1.1, then 32-bit atomics are part of the core. *)                                    (* if the target supports OpenCL 1.1, then 32-bit atomics are part of the core. *)
814                                          "#if (DIDEROT_CL_VERSION == 100)",                      "#if (DIDEROT_CL_VERSION == 100)\n",
815                      "#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable",                      "#  pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable\n",
816                      "#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable",                      "#  pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable\n",
817                                          "#endif",                      "#endif\n",
818                      if double                      if double
819                        then "#define DIDEROT_DOUBLE_PRECISION"                        then "#define DIDEROT_DOUBLE_PRECISION\n"
820                        else "#define DIDEROT_SINGLE_PRECISION",                        else "#define DIDEROT_SINGLE_PRECISION\n",
821                      "#define DIDEROT_TARGET_CL",                      "#define DIDEROT_INT\n",
822                      "#include \"Diderot/cl-diderot.h\""                      "#define DIDEROT_TARGET_CL\n",
823                    ]));                      "#include \"Diderot/cl-diderot.h\"\n"
824                      ]);
825                  clppDecl (genGlobalStruct (#gpuTy, !globals, RN.globalsTy));                  clppDecl (genGlobalStruct (#gpuTy, !globals, RN.globalsTy));
826                  clppDecl (genImageDataStruct(!imgGlobals,RN.imageDataType));                  clppDecl (genImageDataStruct(!imgGlobals,RN.imageDataType));
827                  clppDecl (genStrandTyDef(#gpuTy, strand,tyName));                  clppDecl (genStrandTyDef(#gpuTy, strand,tyName));
# Line 827  Line 832 
832                (* Generate the Host C file *)                (* Generate the Host C file *)
833                  cppDecl (CL.D_Verbatim[                  cppDecl (CL.D_Verbatim[
834                            if double                            if double
835                              then "#define DIDEROT_DOUBLE_PRECISION"                        then "#define DIDEROT_DOUBLE_PRECISION\n"
836                              else "#define DIDEROT_SINGLE_PRECISION",                        else "#define DIDEROT_SINGLE_PRECISION\n",
837                            "#define DIDEROT_INT",                      "#define DIDEROT_INT\n",
838                            "#define DIDEROT_TARGET_CL",                      "#define DIDEROT_TARGET_CL\n",
839                            "#include \"Diderot/diderot.h\""                      "#include \"Diderot/diderot.h\"\n"
840                          ]);                          ]);
841                  cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",                  cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",
842                    SOME(CL.I_Exp(CL.mkStr progName))));                    SOME(CL.I_Exp(CL.mkStr progName))));

Legend:
Removed from v.1629  
changed lines
  Added in v.1630

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