|
@@ -42,20 +42,23 @@
|
|
//========================================================================================================================================================================================================200
|
|
//========================================================================================================================================================================================================200
|
|
|
|
|
|
void
|
|
void
|
|
-kernel_gpu_opencl_wrapper( fp* image, // input image
|
|
|
|
- int Nr, // IMAGE nbr of rows
|
|
|
|
- int Nc, // IMAGE nbr of cols
|
|
|
|
- long Ne, // IMAGE nbr of elem
|
|
|
|
- int niter, // nbr of iterations
|
|
|
|
- fp lambda, // update step size
|
|
|
|
- long NeROI, // ROI nbr of elements
|
|
|
|
- int* iN,
|
|
|
|
- int* iS,
|
|
|
|
- int* jE,
|
|
|
|
- int* jW,
|
|
|
|
- int iter, // primary loop
|
|
|
|
- int mem_size_i,
|
|
|
|
- int mem_size_j)
|
|
|
|
|
|
+kernel_gpu_opencl_wrapper(fp* image, // input image
|
|
|
|
+ int Nr, // IMAGE nbr of rows
|
|
|
|
+ int Nc, // IMAGE nbr of cols
|
|
|
|
+ long Ne, // IMAGE nbr of elem
|
|
|
|
+ int niter, // nbr of iterations
|
|
|
|
+ fp lambda, // update step size
|
|
|
|
+ long NeROI, // ROI nbr of elements
|
|
|
|
+ int* iN,
|
|
|
|
+ int* iS,
|
|
|
|
+ int* jE,
|
|
|
|
+ int* jW,
|
|
|
|
+ int iter, // primary loop
|
|
|
|
+ int mem_size_i,
|
|
|
|
+ int mem_size_j,
|
|
|
|
+ int platform_idx,
|
|
|
|
+ int device_idx,
|
|
|
|
+ int use_gpu)
|
|
{
|
|
{
|
|
|
|
|
|
//======================================================================================================================================================150
|
|
//======================================================================================================================================================150
|
|
@@ -89,8 +92,8 @@ kernel_gpu_opencl_wrapper( fp* image, // input image
|
|
if (error != CL_SUCCESS)
|
|
if (error != CL_SUCCESS)
|
|
fatal_CL(error, __LINE__);
|
|
fatal_CL(error, __LINE__);
|
|
|
|
|
|
- // Select the 1st platform
|
|
|
|
- cl_platform_id platform = platforms[1];
|
|
|
|
|
|
+ // Select the platform using the parameter
|
|
|
|
+ cl_platform_id platform = platforms[platform_idx];
|
|
|
|
|
|
// Get the name of the selected platform and print it (if there are multiple platforms, choose the first one)
|
|
// Get the name of the selected platform and print it (if there are multiple platforms, choose the first one)
|
|
char pbuf[100];
|
|
char pbuf[100];
|
|
@@ -112,10 +115,13 @@ kernel_gpu_opencl_wrapper( fp* image, // input image
|
|
(cl_context_properties) platform,
|
|
(cl_context_properties) platform,
|
|
0};
|
|
0};
|
|
|
|
|
|
- // Create context for selected platform being GPU
|
|
|
|
|
|
+ // Selector for the device type in accordance to what passed as parameter
|
|
|
|
+ cl_device_type device_type = use_gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU;
|
|
|
|
+
|
|
|
|
+ // Create context for selected platform being GPU/CPU
|
|
cl_context context;
|
|
cl_context context;
|
|
context = clCreateContextFromType( context_properties,
|
|
context = clCreateContextFromType( context_properties,
|
|
- CL_DEVICE_TYPE_ALL,
|
|
|
|
|
|
+ device_type,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
&error);
|
|
&error);
|
|
@@ -146,9 +152,9 @@ kernel_gpu_opencl_wrapper( fp* image, // input image
|
|
if (error != CL_SUCCESS)
|
|
if (error != CL_SUCCESS)
|
|
fatal_CL(error, __LINE__);
|
|
fatal_CL(error, __LINE__);
|
|
|
|
|
|
- // Select the first device (previousely selected for the context) (if there are multiple devices, choose the first one)
|
|
|
|
|
|
+ // Select the device in accordance to the paramter
|
|
cl_device_id device;
|
|
cl_device_id device;
|
|
- device = devices[0];
|
|
|
|
|
|
+ device = devices[device_idx];
|
|
|
|
|
|
// Get the name of the selected device (previousely selected for the context) and print it
|
|
// Get the name of the selected device (previousely selected for the context) and print it
|
|
error = clGetDeviceInfo(device,
|
|
error = clGetDeviceInfo(device,
|