Program: 20407
Project: 20407
Buggy source:
/** 
 * Finds number of transactions supporting a given set.
 * @param candidateSet set to be tested
 * @return number of transactions supporting given set.
 */
public int getSupport(char[] candidateSet){
  candSetPointer=Pointer.to(candidateSet);
  candSetMem=clCreateBuffer(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,Sizeof.cl_short * data.getNumberOfAttributesClusters(),candSetPointer,null);
  transCharMapMem=clCreateBuffer(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,Sizeof.cl_short * transCharMap.length,transCharMapPointer,null);
  tmpMapMem=clCreateBuffer(context,CL_MEM_READ_WRITE,Sizeof.cl_short * transCharMap.length,tmpMapPointer,null);
  clSetKernelArg(kernel1,0,Sizeof.cl_mem,Pointer.to(transCharMapMem));
  clSetKernelArg(kernel1,1,Sizeof.cl_mem,Pointer.to(candSetMem));
  clSetKernelArg(kernel1,2,Sizeof.cl_mem,Pointer.to(tmpMapMem));
  global_work_size[0]=transCharMap.length / 4;
  local_work_size[0]=data.getNumberOfAttributesClusters() / 4;
  clEnqueueNDRangeKernel(commandQueue,kernel1,1,null,global_work_size,local_work_size,0,null,null);
  outSuppLongArray=new long[data.getNumberOfTransactions()];
  outSuppLongArrayPointer=Pointer.to(outSuppLongArray);
  outSuppLongArrayMem=clCreateBuffer(context,CL_MEM_WRITE_ONLY,Sizeof.cl_ulong * data.getNumberOfTransactions(),null,null);
  clSetKernelArg(kernel2,0,Sizeof.cl_mem,Pointer.to(tmpMapMem));
  clSetKernelArg(kernel2,1,Sizeof.cl_mem,Pointer.to(outSuppLongArrayMem));
  global_work_size[0]=data.getNumberOfTransactions();
  local_work_size[0]=1;
  clEnqueueNDRangeKernel(commandQueue,kernel2,1,null,global_work_size,local_work_size,0,null,null);
  clEnqueueReadBuffer(commandQueue,outSuppLongArrayMem,CL_TRUE,0,data.getNumberOfTransactions() * Sizeof.cl_ulong,outSuppLongArrayPointer,0,null,null);
  clFinish(commandQueue);
  int supp=0;
  for (int i=0; i < outSuppLongArray.length; i++) {
    if (outSuppLongArray[i] == 0)     supp++;
  }
  clReleaseMemObject(candSetMem);
  clReleaseMemObject(tmpMapMem);
  clReleaseMemObject(transCharMapMem);
  clReleaseMemObject(outSuppLongArrayMem);
  return supp;
}

Fixed version (ground truth):
/** 
 * Finds number of transactions supporting a given set.
 * @param candidateSet set to be tested
 * @return number of transactions supporting given set.
 */
public int getSupport(char[] candidateSet){
  candSetPointer=Pointer.to(candidateSet);
  candSetMem=clCreateBuffer(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,Sizeof.cl_short * data.getNumberOfAttributesClusters(),candSetPointer,null);
  transCharMapMem=clCreateBuffer(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,Sizeof.cl_short * transCharMap.length,transCharMapPointer,null);
  tmpMapMem=clCreateBuffer(context,CL_MEM_WRITE_ONLY,Sizeof.cl_short * transCharMap.length,null,null);
  clSetKernelArg(kernel1,0,Sizeof.cl_mem,Pointer.to(transCharMapMem));
  clSetKernelArg(kernel1,1,Sizeof.cl_mem,Pointer.to(candSetMem));
  clSetKernelArg(kernel1,2,Sizeof.cl_mem,Pointer.to(tmpMapMem));
  global_work_size[0]=transCharMap.length / 4;
  local_work_size[0]=data.getNumberOfAttributesClusters() / 4;
  clEnqueueNDRangeKernel(commandQueue,kernel1,1,null,global_work_size,local_work_size,0,null,null);
  outSuppLongArray=new long[data.getNumberOfTransactions()];
  outSuppLongArrayPointer=Pointer.to(outSuppLongArray);
  outSuppLongArrayMem=clCreateBuffer(context,CL_MEM_WRITE_ONLY,Sizeof.cl_ulong * data.getNumberOfTransactions(),null,null);
  clSetKernelArg(kernel2,0,Sizeof.cl_mem,Pointer.to(tmpMapMem));
  clSetKernelArg(kernel2,1,Sizeof.cl_mem,Pointer.to(outSuppLongArrayMem));
  global_work_size[0]=data.getNumberOfTransactions();
  local_work_size[0]=1;
  clEnqueueNDRangeKernel(commandQueue,kernel2,1,null,global_work_size,local_work_size,0,null,null);
  clEnqueueReadBuffer(commandQueue,outSuppLongArrayMem,CL_TRUE,0,data.getNumberOfTransactions() * Sizeof.cl_ulong,outSuppLongArrayPointer,0,null,null);
  clFinish(commandQueue);
  int supp=0;
  for (int i=0; i < outSuppLongArray.length; i++) {
    if (outSuppLongArray[i] == 0)     supp++;
  }
  clReleaseMemObject(candSetMem);
  clReleaseMemObject(tmpMapMem);
  clReleaseMemObject(transCharMapMem);
  clReleaseMemObject(outSuppLongArrayMem);
  return supp;
}