Changes between Version 13 and Version 14 of OpenCLTransformation


Ignore:
Timestamp:
08/06/14 15:12:56 (12 years ago)
Author:
fuufusuu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OpenCLTransformation

    v13 v14  
    11== OpenCL/CIVL structs ==
    2 * 'args' : a struct containing all of the variables that will be passed into a kernel. Uses an array of void pointers. Size determined by number of parameters.
     2* 'args' : a struct containing all of the variables that will be passed into a kernel. Uses an array of void pointers. Size determined by number of parameters. Has an array of ints as a flag for whether a method used malloc or not, used in clReleaseKernel
    33{{{
    44typedef struct
    55{
    66  void * param[3];
     7  int mallocflag[numArgs];
    78}args;
    89}}}
     
    2324
    2425
    25 ===Methods===
     26== Methods and equivalents ==
     27
     28* 'clCreateKernel': takes in the specified args struct and the name of the method, and returns a kernel.
     29
     30{{{
     31cl_kernel clCreateKernel(args * argument, char * function)
     32{
     33  cl_kernel kernel;
     34  kernel.arguments = argument;
     35  kernel.method = function;
     36 
     37  for(int j = 0; j < numArgs; j++)
     38  {
     39    ((args*)kernel.arguments)->mallocflag[j] = 0;
     40  }
     41 
     42  return kernel;
     43}
     44}}}
     45
     46* 'clReleaseKernel' : a convenient way to free the variables in each kernel's arguments without memory leaks or freeing a space already freed.
     47
     48{{{
     49void clReleaseKernel(cl_kernel kernel)
     50{
     51  for (int i = 0; i < numArgs; i++)
     52  {
     53    printf("I am argument %d with value %d\n", i, ((args*)kernel.arguments)->mallocflag[i]);
     54    if (((args*)kernel.arguments)->mallocflag[i] == 1)
     55    {
     56      printf("and I pass the flag check\n");
     57      free(((args*)kernel.arguments)->param[i]);
     58    }
     59  }
     60}
     61}}}
     62
    2663input = clCreateBuffer(context,  CL_MEM_READ_ONLY,  sizeof(float) * count, NULL, NULL);
    2764