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

SCM Repository

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

Diff of /branches/vis12-cl/src/compiler/cl-target/cl-target.sml

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

revision 3117, Sun Mar 22 08:30:03 2015 UTC revision 3118, Mon Mar 23 18:05:45 2015 UTC
# Line 526  Line 526 
526                end                end
527    
528        (* generate the C struct declaration for the world representation *)        (* generate the C struct declaration for the world representation *)
529          fun genWorldStruct (Prog{props, globals, kernels, ...}) = let          fun genWorldStruct (Prog{props, globals, inputs, kernels, ...}) = let
530                  val clMemTy = CL.T_Named "cl_mem"
531                (* program-independent fields, which should match the layout of the
532                 * OCLWorldPrefix_t type.
533                 *)
534                val extras = [                val extras = [
535                          (CL.T_Named "cl_context", "context"),
536                          (CL.T_Named "cl_command_queue", "cmdQ"),
537                          (CL.T_Named "cl_program", "prog"),
538                          (ON.sizesTy props, "oclSizes"),
539                        (CL.uint32, "nWorkers"),                        (CL.uint32, "nWorkers"),
540                        (CL.T_Ptr(CL.T_Named "Diderot_DeviceInfo_t"), "device"),                        (CL.T_Ptr(CL.T_Named "Diderot_DeviceInfo_t"), "device"),
541                        (CL.T_Named "cl_int", "gpuDevId"),                        (CL.T_Named "cl_int", "gpuDevId"),
542                        (CL.T_Ptr(CL.T_Named "Diderot_OCLInfo_t"), "oclInfo")                        (CL.T_Ptr(CL.T_Named "Diderot_OCLInfo_t"), "oclInfo")
543                      ]                      ]
544                val extras = if #exec props orelse not(#hasInputs props)              (* the remaining fields are program dependent *)
                     then extras  
                     else (CL.T_Named(CN.definedInpTyName props), "definedInp") :: extras  
               val extras = (ON.sizesTy props, "oclSizes") :: extras  
             (* OpenCL execution context *)  
               val extras =  
                     (CL.T_Named "cl_context", "context") ::  
                     (CL.T_Named "cl_command_queue", "cmdQ") ::  
                     (CL.T_Named "cl_program", "prog") :: extras  
545              (* add fields for GPU memory objects *)              (* add fields for GPU memory objects *)
546                val extras =                val extras =
547                      (CL.T_Named "cl_mem", "schedBuf") ::                      (clMemTy, "schedBuf") ::
548                      (CL.T_Named "cl_mem", "globalsBuf") ::                      (clMemTy, "stateBuf") ::
549                      (CL.T_Named "cl_mem", "stateBuf") ::                      (clMemTy, "statusBuf") :: extras
550                      (CL.T_Named "cl_mem", "statusBuf") :: extras                val extras = if #hasGlobals props
551                      then (clMemTy, "globalsBuf") :: extras
552                      else extras
553                (* get extra fields for image buffers and initialization kernels *)
554                  val (imageBufs, imageKerns) = GenInputs.getBuffersAndKernels (!inputs)
555                (* add fields for the image buffers *)
556                  val extras = List.foldr (fn (b, extras) => (clMemTy, b)::extras) extras imageBufs
557              (* add a field for each kernel *)              (* add a field for each kernel *)
558                val extras = let                val extras = let
559                      fun kField (k, extras) = (CL.T_Named "cl_kernel", k) :: extras                      fun kField (k, extras) = (CL.T_Named "cl_kernel", k) :: extras
560                      in                      in
561                        List.foldl kField extras (!kernels)                        List.foldl kField extras (List.revAppend(imageKerns, !kernels))
562                      end                      end
563                  val extras = if #exec props orelse not(#hasInputs props)
564                        then extras
565                        else (CL.T_Named(CN.definedInpTyName props), "definedInp") :: extras
566                in                in
567                  World.genStruct (props, List.rev extras)                  World.genStruct (props, List.rev extras)
568                end                end
# Line 648  Line 657 
657                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_INPUTS\n"])                    then ppDecl (CL.D_Verbatim ["#define DIDEROT_NO_INPUTS\n"])
658                    else ();                    else ();
659                (* generate the host-side type definitions *)                (* generate the host-side type definitions *)
                 ppDecl (CL.verbatimDcl [CSizesFrag.text] substitutions);  
660                  List.app ppDecl (GenInputs.genDefinedInpStruct (props, !inputs));                  List.app ppDecl (GenInputs.genDefinedInpStruct (props, !inputs));
661    (* FIXME: world structure needs extra fields for image buffers and initialization kernels *)
662                  ppDecl (genWorldStruct prog);                  ppDecl (genWorldStruct prog);
663                  List.app ppDecl (GenInputs.genInputsStruct (props, !inputs));                  List.app ppDecl (GenInputs.genInputsStruct (props, !inputs));
664                (* support code for OpenCL *)                (* support code for OpenCL *)

Legend:
Removed from v.3117  
changed lines
  Added in v.3118

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