<commit_before>#include "itkOpenCLFDKBackProjectionImageFilter.h"

#include <itkImageRegionConstIterator.h>
#include <itkImageRegionIteratorWithIndex.h>
#include <itkLinearInterpolateImageFunction.h>
#include <itkMacro.h>
#include "itkOpenCLUtilities.h"

namespace itk
{

OpenCLFDKBackProjectionImageFilter
::OpenCLFDKBackProjectionImageFilter()
{
}

void
OpenCLFDKBackProjectionImageFilter
::InitDevice()
{
  // OpenCL init (platform, device, context and command queue)
  std::vector<cl_platform_id> platforms = GetListOfOpenCLPlatforms();
  std::vector<cl_device_id>   devices = GetListOfOpenCLDevices(platforms[0]);
  cl_context_properties       properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[0], 0};

  cl_int error;
  m_Context = clCreateContext(properties, devices.size(), &(devices[0]), NULL, NULL, &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL context, error code: " << error);

  m_CommandQueue = clCreateCommandQueue(m_Context, devices[0], CL_QUEUE_PROFILING_ENABLE, &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL command queue, error code: " << error);

  // OpenCL memory allocation
  m_DeviceMatrix = clCreateBuffer(m_Context,
                                  CL_MEM_READ_ONLY,
                                  sizeof(cl_float) * 12,
                                  NULL,
                                  &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL matrix buffer, error code: " << error);

  size_t volBytes = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels() * sizeof(float);
  m_DeviceVolume = clCreateBuffer(m_Context,
                                  CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
                                  volBytes,
                                  (void*)this->GetInput()->GetBufferPointer(),
                                  &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL volume buffer, error code: " << error);

  cl_image_format projFormat;
  projFormat.image_channel_order = CL_INTENSITY;
  projFormat.image_channel_data_type = CL_FLOAT;
  m_DeviceProjection =  clCreateImage2D(m_Context,
                                        CL_MEM_READ_ONLY,
                                        &projFormat,
                                        this->GetInput(1)->GetRequestedRegion().GetSize()[0],
                                        this->GetInput(1)->GetRequestedRegion().GetSize()[1],
                                        0,
                                        NULL,
                                        &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL projection image, error code: " << error);

  CreateAndBuildOpenCLProgramFromSourceFile("itkOpenCLFDKBackProjectionImageFilter.cl",
                                            m_Context, m_Program);

  m_Kernel = clCreateKernel(m_Program, "OpenCLFDKBackProjectionImageFilterKernel", &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL kernel, error code: " << error);

  // Set kernel parameters
  cl_uint4 volumeDim;
  volumeDim.x = this->GetOutput()->GetRequestedRegion().GetSize()[0];
  volumeDim.y = this->GetOutput()->GetRequestedRegion().GetSize()[1];
  volumeDim.z = this->GetOutput()->GetRequestedRegion().GetSize()[2];
  volumeDim.w = 1;
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 0, sizeof(cl_mem), &m_DeviceVolume) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 1, sizeof(cl_mem), &m_DeviceMatrix) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 2, sizeof(cl_mem), &m_DeviceProjection) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 3, sizeof(cl_uint4), &volumeDim) );
}

void<commit_msg>Solved compatibility issue with INTEL OpenCL for Windows<commit_after>#include "itkOpenCLFDKBackProjectionImageFilter.h"

#include <itkImageRegionConstIterator.h>
#include <itkImageRegionIteratorWithIndex.h>
#include <itkLinearInterpolateImageFunction.h>
#include <itkMacro.h>
#include "itkOpenCLUtilities.h"

namespace itk
{

OpenCLFDKBackProjectionImageFilter
::OpenCLFDKBackProjectionImageFilter()
{
}

void
OpenCLFDKBackProjectionImageFilter
::InitDevice()
{
  // OpenCL init (platform, device, context and command queue)
  std::vector<cl_platform_id> platforms = GetListOfOpenCLPlatforms();
  std::vector<cl_device_id>   devices = GetListOfOpenCLDevices(platforms[0]);
  cl_context_properties       properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[0], 0};

  cl_int error;
  m_Context = clCreateContext(properties, devices.size(), &(devices[0]), NULL, NULL, &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL context, error code: " << error);

  m_CommandQueue = clCreateCommandQueue(m_Context, devices[0], CL_QUEUE_PROFILING_ENABLE, &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL command queue, error code: " << error);

  // OpenCL memory allocation
  m_DeviceMatrix = clCreateBuffer(m_Context,
                                  CL_MEM_READ_ONLY,
                                  sizeof(cl_float) * 12,
                                  NULL,
                                  &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL matrix buffer, error code: " << error);

  size_t volBytes = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels() * sizeof(float);
  m_DeviceVolume = clCreateBuffer(m_Context,
                                  CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
                                  volBytes,
                                  (void*)this->GetInput()->GetBufferPointer(),
                                  &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL volume buffer, error code: " << error);

  cl_image_format projFormat;
  projFormat.image_channel_order = CL_INTENSITY;
  projFormat.image_channel_data_type = CL_FLOAT;
  m_DeviceProjection =  clCreateImage2D(m_Context,
                                        CL_MEM_READ_ONLY,
                                        &projFormat,
                                        this->GetInput(1)->GetRequestedRegion().GetSize()[0],
                                        this->GetInput(1)->GetRequestedRegion().GetSize()[1],
                                        0,
                                        NULL,
                                        &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not allocate OpenCL projection image, error code: " << error);

  CreateAndBuildOpenCLProgramFromSourceFile("itkOpenCLFDKBackProjectionImageFilter.cl",
                                            m_Context, m_Program);

  m_Kernel = clCreateKernel(m_Program, "OpenCLFDKBackProjectionImageFilterKernel", &error);
  if(error != CL_SUCCESS)
    itkExceptionMacro(<< "Could not create OpenCL kernel, error code: " << error);

  // Set kernel parameters
  cl_uint4 volumeDim;
  volumeDim.s[0] = this->GetOutput()->GetRequestedRegion().GetSize()[0];
  volumeDim.s[1] = this->GetOutput()->GetRequestedRegion().GetSize()[1];
  volumeDim.s[2] = this->GetOutput()->GetRequestedRegion().GetSize()[2];
  volumeDim.s[3] = 1;
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 0, sizeof(cl_mem), &m_DeviceVolume) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 1, sizeof(cl_mem), &m_DeviceMatrix) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 2, sizeof(cl_mem), &m_DeviceProjection) );
  OPENCL_CHECK_ERROR( clSetKernelArg(m_Kernel, 3, sizeof(cl_uint4), &volumeDim) );
}

void
{'fraction_non_alphanumeric': 0.10760570755334468, 'fraction_numerical': 0.006545359340227779, 'mean_word_length': 2.823823823823824, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1874208', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2200, 'n_words': 404}