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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/lib/cl-target/main.c
ViewVC logotype

Diff of /branches/pure-cfg/src/lib/cl-target/main.c

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

revision 1326, Sun Jun 12 20:56:27 2011 UTC revision 1327, Sun Jun 12 20:56:49 2011 UTC
# Line 78  Line 78 
78          cl_int sts = CL_SUCCESS;          cl_int sts = CL_SUCCESS;
79    
80          /* Create the strand in-state and out-state buffers */          /* Create the strand in-state and out-state buffers */
81          cl_mem in_state_mem, out_state_mem;      cl_mem stateInMem, stateOutMem;
82    
83          in_state_mem = clCreateBuffer(wrld->context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,      stateInMem = clCreateBuffer (wrld->context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
84                                                                            wrld->strandSize, *(wrld->inState), &sts);                                                                            wrld->strandSize, *(wrld->inState), &sts);
   
85     if (sts != CL_SUCCESS) {     if (sts != CL_SUCCESS) {
86                  fprintf (stderr, "error creating OpenCL strand in-state buffer\n");                  fprintf (stderr, "error creating OpenCL strand in-state buffer\n");
87          exit(1);          exit(1);
88      }      }
89    
90          out_state_mem = clCreateBuffer(wrld->context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,      stateOutMem = clCreateBuffer (wrld->context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
91                                                                            wrld->strandSize, *(wrld->outState), &sts);                                                                            wrld->strandSize, *(wrld->outState), &sts);
   
92          if (sts != CL_SUCCESS) {          if (sts != CL_SUCCESS) {
93                  fprintf (stderr, "error creating OpenCL strand in-state buffer\n");                  fprintf (stderr, "error creating OpenCL strand in-state buffer\n");
94                  exit(1);                  exit(1);
95      }      }
96    
97          /* Set the in-state and out-state strand agruments */          /* Set the in-state and out-state strand agruments */
98     sts = clSetKernelArg(wrld->kernel,  argCount++, sizeof(cl_mem), &in_state_mem);      sts = clSetKernelArg (wrld->kernel,  argCount++, sizeof(cl_mem), &stateInMem);
   
99          if (sts != CL_SUCCESS) {          if (sts != CL_SUCCESS) {
100                  fprintf (stderr, "error Setting OpenCL strand in-state argument\n");                  fprintf (stderr, "error Setting OpenCL strand in-state argument\n");
101                  exit(1);                  exit(1);
102      }      }
103    
104        sts = clSetKernelArg (wrld->kernel, argCount++, sizeof(cl_mem), &stateOutMem);
         sts = clSetKernelArg(wrld->kernel, argCount++, sizeof(cl_mem), &out_state_mem);  
   
105          if (sts != CL_SUCCESS) {          if (sts != CL_SUCCESS) {
106                  fprintf (stderr, "error Setting OpenCL strand out-state argument\n");                  fprintf (stderr, "error Setting OpenCL strand out-state argument\n");
107                  exit(1);                  exit(1);
# Line 119  Line 114 
114          global_work_size[1] = wrld->size[1];          global_work_size[1] = wrld->size[1];
115          local_work_size[0] = 1;          local_work_size[0] = 1;
116          local_work_size[1] = 1;          local_work_size[1] = 1;
   
117          cl_int width = global_work_size[1];          cl_int width = global_work_size[1];
118    
119        sts = clSetKernelArg(wrld->kernel, argCount++, sizeof(cl_int), &width);        sts = clSetKernelArg(wrld->kernel, argCount++, sizeof(cl_int), &width);
   
120                  if (sts != CL_SUCCESS) {                  if (sts != CL_SUCCESS) {
121                          fprintf (stderr, "error Setting OpenCL width argument\n");                          fprintf (stderr, "error Setting OpenCL width argument\n");
122                          exit(1);                          exit(1);
123          }          }
124    
   
125                  Diderot_LoadGlobals(wrld->context, wrld->kernel, argCount);                  Diderot_LoadGlobals(wrld->context, wrld->kernel, argCount);
126    
127                  sts = clEnqueueNDRangeKernel(wrld->cmdQ, wrld->kernel, 2, NULL, global_work_size,                  sts = clEnqueueNDRangeKernel(wrld->cmdQ, wrld->kernel, 2, NULL, global_work_size,
128           local_work_size, 0, NULL, NULL);           local_work_size, 0, NULL, NULL);
   
   
129                  if (sts != CL_SUCCESS) {                  if (sts != CL_SUCCESS) {
130                          fprintf (stderr, "error in executing kernel code:%d\n",sts);                          fprintf (stderr, "error in executing kernel code:%d\n",sts);
131                          exit(1);                          exit(1);
# Line 143  Line 133 
133    
134                  clFinish(wrld->cmdQ);                  clFinish(wrld->cmdQ);
135    
136                  sts = clEnqueueReadBuffer(wrld->cmdQ, out_state_mem, CL_TRUE, 0, wrld->strandSize, wrld->outState, 0,          sts = clEnqueueReadBuffer(wrld->cmdQ, stateOutMem, CL_TRUE, 0, wrld->strandSize,
137                  NULL, NULL);              wrld->outState, 0, NULL, NULL);
138    
139                  if (sts != CL_SUCCESS) {                  if (sts != CL_SUCCESS) {
140                          fprintf (stderr, "error in reading back output code:%d\n",sts);                          fprintf (stderr, "error in reading back output code:%d\n",sts);
# Line 280  Line 270 
270      }      }
271    
272    // extract the kernel from the program    // extract the kernel from the program
273      cl_kernel kernel = clCreateKernel(prog, "Diderot_Kernel_Main", &sts);      cl_kernel kernel = clCreateKernel(prog, "Diderot_KernelMain", &sts);
274      if (sts != CL_SUCCESS) {      if (sts != CL_SUCCESS) {
275                  fprintf (stderr, "error getting kernel from program\n");                  fprintf (stderr, "error getting kernel from program\n");
276          return false;          return false;
# Line 294  Line 284 
284    
285      return true;      return true;
286  }  }
287    
288  // this should be the part of the scheduler  // this should be the part of the scheduler
289  void *Diderot_AllocStrand (Strand_t *strand)  void *Diderot_AllocStrand (Strand_t *strand)
290  {  {

Legend:
Removed from v.1326  
changed lines
  Added in v.1327

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